A chain can only be a wrapper around the GDB storage, without using consensus algorithms. This is the fastest way to store the ledger, it is designed to storing private ledgers where there is no need to protect the system from spam data but it is necessary to ensure maximum performance.
Every datum stored in Chain GDB is laying in special GDB section, specfied for the chain. Different backends can be used for different chains, for example SQL or No-SQL databases - to have compatibility with classic non-chain software that's important for Enterprise.
The synchronization initiator sends a request DAP_STREAM_CH_CHAIN_PKT_TYPE_SYNC_GLOBAL_DB
with parameters net_id
, chain_id
, cell_id
and its address node_addr
.
The response side receives this request and determines how much data is left to transfer for this node at the address of the first side node.
DAP_STREAM_CH_CHAIN_PKT_TYPE_FIRST_GLOBAL_DB
with the parameters net_id
, chain_id
and cell_id
is sent in response.DAP_STREAM_CH_CHAIN_PKT_TYPE_GLOBAL_DB
with transactions are transmitted. Each packet contains one transaction.If there is nothing to send, then DAP_STREAM_CH_CHAIN_PKT_TYPE_SYNCED_GLOBAL_DB
packet is sent.
When the first party receives a transaction, we search for it in the current global_db by key.
DAP_STREAM_CH_CHAIN_PKT_TYPE_SYNCED_GLOBAL_DB
packet, completing the data transfer.All in all, here is a short diagram of the interaction of two nodes during synchronization:
-> DAP_STREAM_CH_CHAIN_PKT_TYPE_SYNC_GLOBAL_DB (1 packet)
If there is data:
<- DAP_STREAM_CH_CHAIN_PKT_TYPE_FIRST_GLOBAL_DB (1 packet)
<- DAP_STREAM_CH_CHAIN_PKT_TYPE_GLOBAL_DB (N packets)
-> DAP_STREAM_CH_CHAIN_PKT_TYPE_SYNCED_GLOBAL_DB (1 packet)
And then - according to the same scheme.