03.05.21
===
## name jam
- hash
- keypair (w. author inside)
message
- message
- message_encoded
entry
- seq_num
- entry_signed
- entry
- log_id
- encode, decode, verify ..
schema
- persona
- ...
wasm
- ...
## materialize jam
```
struct Message {
fields: MessageFields,
}
message:
fields: {
message: Text
date: Text (ISO date string)
}
struct Schema "chat" {
fields: ... name, type
}
```
- aquadoggo:
registratoring schema
1. schema -> CDDL (create_cddl)
CDDL in memory
CDDL validates message payload -> yes / no
2. create tables
create sql for tables (create_sql)
```
CREATE TABLE IF NOT EXISTS cat(actually the entry hash, and not a cat but a chat) (
message VARCHAR(64) NOT NULL,
date DATETIME NOT NULL,
);
```
- incoming new entry using the chat schema
- check bamboo integrity
- check message schema via CDDL
& check "chat" schema via CDDL
- create row in "entries" table
- create task for background materializer
- tell sender it's alright go to bed, and send next entry arguments in case you can't sleep
- materializer background job handles task
- receives notification about new incoming entry (coming from replication or creation)
- add incoming entry to worker queue
- create or update row in cat table
```
The raw data
==================
entries
-
- author: "andreas"
- log_id: 1
- seq_num: 1
- message: {
hash: "ABC"
action: create
schema: "Chat"
fields:
message: "Hello"
date: ...
}
logs
-
- author: "andreas"
- log_id: 1
- schema: "Chat"
- seq_num_head: 120
- materialized_seq_num_head: 20
```
```
The (materialized) DB
=====================
chat
-
- id: "ABC"
- message: "Hello"
- date: "..."
```
RPC: panda_query "Give me the first 10 chat messages sorted by date
---
### Relations?
**First scenario (same schema)**
```
NODE 1
hash author message reply_to
1 alice hi -
2 bob hi back! 1
NODE 2 (didn't receive alice message yet)
materializing this:
2 bob hi back! 1
```
**Second scenario (two different schemas)**
One schema depends on another schema - node should understand that the second one should be materialized as well
```
schema chat messages
hash message profile_name
1 hi 2
2 hi back! 1
schema profile names
hash name
1 bob
2 alice
```
**Third scenario (writing to the same data instance by multiple authors)**
Two different key pairs ("devices"):
Persona:
- panda
- shirokuma
```
entries w. messages
hash author action fields id seq_num
1 panda CREATE { profile: "Cat" } % 1
2 panda UPDATE { profile: "Dog" } 1 2
3 shirokuma UPDATE { profile: "Kuro" } 1 1
4 grizzly UPDATE { profile: "I HATE CATS" } 1 1
😾 > boo, grizzly! You are not allowed to do that update!
materializing this:
hash profile
1 Dog
```
Do we need a `Permission` or `Collaboration` system schema?
---
> Automerge dealing w. conflicts: https://github.com/automerge/automerge#conflicting-changes
> SSBs approach to "Personas": https://gitlab.com/tangle-js