US 12,353,578 B2
Method of constructing high-performance anti-tampering database based on blockchain
Xinghua Li, Xi An (CN); Yunwei Wang, Xi An (CN); Xiaoqiang Li, Xi An (CN); Yanbing Ren, Xi An (CN); Hang Wang, Xi An (CN); and Zhongyuan Hu, Xi An (CN)
Assigned to Xidian University, Xi'an (CN)
Filed by Xidian University, Xi'an (CN)
Filed on Oct. 20, 2021, as Appl. No. 17/505,994.
Application 17/505,994 is a continuation in part of application No. PCT/CN2020/107591, filed on Aug. 7, 2020.
Claims priority of application No. 202010779632.8 (CN), filed on Aug. 5, 2020.
Prior Publication US 2022/0043928 A1, Feb. 10, 2022
Int. Cl. G06F 21/62 (2013.01); G06F 16/182 (2019.01); G06F 16/22 (2019.01); G06F 21/64 (2013.01); H04L 9/00 (2022.01); H04L 9/12 (2006.01); H04L 9/32 (2006.01)
CPC G06F 21/6218 (2013.01) [G06F 16/1837 (2019.01); G06F 16/2255 (2019.01); G06F 21/645 (2013.01); H04L 9/12 (2013.01); H04L 9/3239 (2013.01); H04L 9/50 (2022.05)] 9 Claims
OG exemplary drawing
 
1. A method of constructing an anti-tampering database based on blockchain, applied for a distributed peer-to-peer network, wherein the distributed peer-to-peer network comprises a plurality of database nodes, each database node has a two-layered structure composed of a top-layer database and a bottom-layer database, and the method comprises:
acquiring change increment information corresponding to data to-be-stored through the plurality of database nodes, and storing, based on a blockchain data structure, the change increment information as bottom-layer data of all of the plurality of database nodes in bottom-layer databases;
determining resultant data information corresponding to the data to-be-stored based on the change increment information, indexing the resultant data information at top-layer databases of all of the plurality of database nodes, and storing the resultant data information as top-layer data of all of the plurality of database nodes in the top-layer databases;
performing mutual-checks on the stored top-layer data in the top-layer databases as per a predetermined mutual-checking period and performing self-checks on the stored bottom-layer data in the bottom-layer databases as per a predetermined self-checking period, by the plurality of database nodes; and
restoring the bottom-layer data and/or the top-layer data of the plurality of database nodes according to results of the mutual-checks and the self-checks, to thereby realize database construction;
wherein the top-layer databases are relational databases, and the bottom-layer databases are blockchain databases;
wherein the performing mutual-checks on the stored top-layer data in the top-layer databases as per a predetermined mutual-checking period by the plurality of database nodes comprises:
acquiring, by each database node, a new block which passes a consensus of a predetermined number of the database nodes in the entire network when each round of consensus block-generation time arrives;
acquiring a hash state value of a top-layer database recorded in the new block;
comparing the hash state value corresponding to the new block with a hash state value of the top-layer database stored locally in the database node; and
determining the top-layer data of the database node have not been tampered with when the two hash state values are identical, or determining the top-layer data of the database node have been tampered with when the two hash state values are not identical;
wherein the performing self-checks on the stored bottom-layer data in the bottom-layer databases as per a predetermined self-checking period by the plurality of database nodes comprises:
acquiring a hash chain relationship among blocks in a blockchain corresponding to the bottom-layer data, between every two mutual-checks;
checking whether the hash chain relationship is established; and
determining the bottom-layer data of a current database node of the plurality of database nodes have not been tampered with when the hash chain relationship is established, or determining the bottom-layer data of the current database node have been tampered with when the hash chain relationship is not established;
wherein each of the plurality of database nodes is deployed with a sliding window, and the sliding window comprises a preset reserved block number corresponding to the database node; and
wherein the method further comprises: performing data storing through the sliding window, comprising:
obtaining, by the database node, a latest block in the blockchain;
obtaining a magnitude relationship between a number of the latest block and the preset reserved block number; and
in response to the number of the latest block being greater than the preset reserved block number, reserving all blocks in the sliding window and a genesis block, deleting a block body in a block outside the sliding window, and reserving a block header in the block outside the sliding window.