The protocol check that Events have properly broadcasted through the
network before adding Events to the Model.
The read_confirms inside each Event indicate how many times the Event has
been read from other nodes in the network.
The protocol classify the Events by their state:
Unread: read_confirms < `MAX_CONFIMRS`
Read: read_confirms >= `MAX_CONFIMRS`
Inventory vectors are used for notifying other nodes about objects they have or data which is being requested.
| Description | Data Type | Comments |
|---|---|---|
| invs | Vec<[u8; 32]> |
Inventory items |
Inv messageAllows a node to advertise its knowledge of one or more objects. It can be received unsolicited,
or in reply to getevents.
An Inv message is a confirmation from a node in the network that the Event
has been read.
Confirmation for an Event not exist in the UnreadEvents list,
The protocol send a GetData message to request the missing Event.
The protocol update the Event in the UnreadEvents list by increasing the
read_confirms by one.
The state for updated Event change to read when the read_confirms exceed
MAX_CONFIMRS, Then the Event remove from theUnreadEventslist and add to theModel`.
The protocol rebroadcast the received Inv to the network.
Inv messageOn receiving an Event with unread status from the network, The protocol send back
an Inv message to confirm that the Event has been read.
| Description | Data Type | Comments |
|---|---|---|
| events | Vec<EventId> |
A list of EventId |
GetData messageThe protocol search in both Model and UnreadEvents for requested Events
in GetData message.
| Description | Data Type | Comments |
|---|---|---|
| Messages | HashMap<EventId, Event> |
Hold all the Events that have broadcasted to other nodes but haven't confirmed yet |
Event to UnreadEventsTo add an Event to UnreadEvents, the protocol first must check the validity of
Event.
The Event is not valid in the network if it's too far in the future from now,
or too far in the past from now.
UnreadEvents listThe protocol continually broadcast unread Event to the network
after a certain period of time(SEND_UNREAD_EVENTS_INTERVAL),
Until the state of Event updated to read.
| Description | Data Type | Comments |
|---|---|---|
| Leaves | Vec<EventId> |
hash of Events |
To achieve complete synchronization between nodes, the protocol send a
SyncEvent message every 2 seconds to other nodes in the network.
The SyncEvent contains the hashes of Events set in the leaves of Model's tree.
On receiving SyncEvent message, The leaves in SyncEvent should match the
leaves in the Model's tree, Otherwise the protocol send Events which are the childern of
Events in SyncEvent
This used to prevent receiving duplicate Objects. The list will contains only 2^16 ids.
| Description | Data Type | Comments |
|---|---|---|
| Ids | Vec | Contains objects ids |