Chain could be only wrap around part of GDB storage, without consistent guarantee and ever without consensus at all. Its the fastest way to store ledger and designed for private ledgers store where there is no needs to protect the system from spam data but there is needing to provide top performance.
Every datum stored in Chain GDB is laying in special GDB section, specfied for the chain. Could be also used different backends for different chains for example SQL or No-SQL databases to have compatibility with classic non-chain software thats important for Enterprise
The gdb synchronization process
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.
If there is something left to pass, the first packet DAP_STREAM_CH_CHAIN_PKT_TYPE_FIRST_GLOBAL_DB with the parameters net_id, chain_id and cell_id is sent in response.
And then packages DAP_STREAM_CH_CHAIN_PKT_TYPE_GLOBAL_DB with transactions. Each packet contains one transaction.
If nothing, then DAP_STREAM_CH_CHAIN_PKT_TYPE_SYNCED_GLOBAL_DB.
When the first party receives a transaction, we search for it in the current global_db by key.
If a transaction in the same group with the same key is already present in the database: If it is a delete transaction, then we delete it.
If it is an add-on transaction, we will additionally compare its contents with the content of the accepted transaction.
If the transactions are the same, then we do nothing, if they are different, then we see whose timestamp is greater, that transaction and leave it.
If the transactions are not in the database yet, then: If it is a deletion transaction, then we do nothing.
If it is an additional transaction, then we add it to the database.
As the last packet is sent packet DAP_STREAM_CH_CHAIN_PKT_TYPE_SYNCED_GLOBAL_DB, completing the data transfer. The first side is DAP_STREAM_CH_CHAIN_PKT_TYPE_FIRST_GLOBAL_DB.
All in all, a short table:
-> DAP_STREAM_CH_CHAIN_PKT_TYPE_SYNC_GLOBAL_DB (1 pcs.) if there are data <- DAP_STREAM_CH_CHAIN_PKT_TYPE_FIRST_GLOBAL_DB (1 pc.) <- DAP_STREAM_CH_CHAIN_PKT_TYPE_GLOBAL_DB (N pcs.) -> DAP_STREAM_CH_CHAIN_PKT_TYPE_SYNCED_GLOBAL_DB (1 pc.)
Then it's the same, but the other way around.