-
Notifications
You must be signed in to change notification settings - Fork 10
blockchain
| type | description |
|---|---|
| hash | block hash |
| header | header info |
| transactions | transactions array |
| signature | Signature of the byte stream array |
| irreversibleinfo | Irreversible information of this block |
| height | block height |
| type | description |
|---|---|
| version | version number |
| privous block hash | parent block hash |
| transaction root | transactions state root hash |
| time stamp | the number of nanoseconds elapsed since January 1, 1970 UTC |
| magic | magic number |
| periodhash | |
| candidatehash | The hash of the candidate block |
Blocks need to be securely linked to the blockchain, there are two ways to get a new block.
Due to network delay,We cannot guarantee that the received block can be linked to the chain,We cache the received block through orphan pool.
First, we need to use the transaction pool to cache transactions from the p2p network. Then, Waiting for a block to be created by a miner node.
Regardless of where the block comes from,we use the same steps to process it as following.

when a block needs to be linked to the main chain, the following operations are required.here is a diagram of apply block.

When the length of the block on the side chain exceeds the length on the main chain, we need to reorganize the chain. The following shows how the block is reorganized.here is a diagram of reorganize.

Due to network latency, some blocks may be received at a slower rate. The parent block of these blocks has not yet been added to the chain and will become an orphan block. In the end, we need to deal with these orphan blocks.here is a diagram of process Orphan

Sometimes we get a block that is much higher than the current block height. we need to sync blocks from peer nodes to catch up with them. Contentbox provides two method to sync blocks from peers: LightSync and Sync. if the height of the received block is higher than the height of the current chain 32,we'll choose Sync to get a lot of blocks,otherwise we use LightSync
Sync
Block synchronization requires three stages to complete:
locate Get the fork point from the remote node
check Check if the acquired fork point is valid by two remote nodes,The principle of inspection is based on the Merkle tree
sync Add blocks to the blockchain in turn
Blocks added to the chain of this process are not broadcast
Here is a diagram of this sync procedure:

LightSync
if the difference between the received block height and the current chain height is less than 32,we'll use LightSync to get the missing blocks one by one.
Here is a diagram of light sync procedure:
