4.7 MPT + LevelDB
DxChain uses the Merkle Patricia Trie (MPT) as the data structure. MPT is an encrypted and authenticated data structure that combines the advantages of Merkle tree and Prefix Tree, can not only organize and manage important data such as user account status, transaction information, and block information, but also achieve high-performance storage and imtamability of data.
MTP Tree is a data structure made up of multiple key-value pairs. The value usually contains information of a child node, and the key contains path information from the root node to the child node that the value represents. The key is generated based on the data of the node, which is then encoded by recursive length prefix encoding algorithm (RLP) and SHA3 Hash Function. The value is generated based on the RLP encoded node's data. All data from the MPT tree are stored in the LevelDB. By using the SHA3 Hash value of the node (key), RLP encoded node data can be acquired from the LevelDB. Then, by using the RLP decoding mechanism, the actual node data can be revealed.
According to the advantages of the Merkle Tree, the MPT allows segmented transmission of block data that avoids the low efficiency caused by fixed sequence transmission and allows nodes to synchronize block data from different P2P nodes that ensure the accuracy of synchronized data from other sources. Since the MPT is a bottom-up diffusion structure, if the node data has been maliciously tampered, all the node data in the MPT tree will be changed. When the DxChain block verification mechanism cannot verify the block data, transactions will not be recorded to prevent the generation of malicious blocks.
Figure 9: MPT