CN110851448B - Local data storage optimization method based on block chain intelligent contract - Google Patents

Local data storage optimization method based on block chain intelligent contract Download PDF

Info

Publication number
CN110851448B
CN110851448B CN201911087252.1A CN201911087252A CN110851448B CN 110851448 B CN110851448 B CN 110851448B CN 201911087252 A CN201911087252 A CN 201911087252A CN 110851448 B CN110851448 B CN 110851448B
Authority
CN
China
Prior art keywords
node
block
block chain
information
mobile terminal
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911087252.1A
Other languages
Chinese (zh)
Other versions
CN110851448A (en
Inventor
李逸萧
常清雪
张攀
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sichuan Changhong Electric Co Ltd
Original Assignee
Sichuan Changhong Electric Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sichuan Changhong Electric Co Ltd filed Critical Sichuan Changhong Electric Co Ltd
Priority to CN201911087252.1A priority Critical patent/CN110851448B/en
Publication of CN110851448A publication Critical patent/CN110851448A/en
Application granted granted Critical
Publication of CN110851448B publication Critical patent/CN110851448B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2246Trees, e.g. B+trees
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2255Hash tables
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3827Use of message hashing

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Software Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Finance (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a local data storage optimization method based on a block chain intelligent contract, which comprises the following steps of 1: setting a fixed node in a block chain network, and storing all block data; step 2: each mobile terminal node only stores block specific information related to the mobile terminal node, acquires related account information of a block through an interface provided by a block chain platform when the block information is stored, allocates a node address to the mobile terminal node when the mobile terminal node is added into a block chain, and skips if the address of the mobile terminal node is not matched with the address in the account information in the block data; if the matching is carried out, acquiring and storing specific block information; and step 3: and calculating the hash value of the block by taking the block information as input, and assembling the hash value into a Merckel tree data structure. The pressure of the mobile terminal user node on saving the block chain information is greatly reduced, meanwhile, the loss of the account book of a few nodes can not lead to the collapse of the block chain, and the problems in the prior art are well solved.

Description

Local data storage optimization method based on block chain intelligent contract
Technical Field
The invention relates to the field of block chains, in particular to a local data storage optimization method based on a block chain intelligent contract.
Background
In recent years, the technology of blockchain intelligent contracts is continuously developed, and a plurality of APP applications based on the blockchain intelligent contracts are promoted. However, in the existing block chain APP, because each node in the block chain needs to be mutually equal and credible, the whole block chain account is stored in each node, and the account data is the original data set of the block, and includes a timestamp, a random number, a hash of the previous block and specific transaction data, and there is no operation for processing (compressing and simplifying) the data; however, the storage capacity of most mobile phones is only dozens of GB at present, the bit currency account book capacity in 2017 reaches the size of dozens of GB, which is the storage capacity hard to bear by mobile end users; the main reason is that most block chains APP do not perform any processing on stored data and all nodes store consistent data, new blocks are generated continuously along with the accumulation of time, the storage capacity in the local area will increase unlimitedly, and obviously, the storage capacity of a user cannot reach the unbounded size; therefore, a technique is needed to solve the problem of insufficient storage of the block chain APP at the mobile end.
Disclosure of Invention
The invention aims to provide a local data storage optimization method based on a block chain intelligent contract, which is used for solving the problems that in the prior art, a block chain APP does not perform any processing on stored data, all nodes store consistent data, new blocks are generated continuously along with the accumulation of time, and the storage capacity in the local area can be increased unlimitedly.
The invention solves the problems through the following technical scheme:
a local data storage optimization method based on a blockchain intelligent contract, the method comprises the following steps:
step 1: setting a fixed node in a block chain network, and storing all block data;
step 2: each mobile terminal node only stores block specific information related to the mobile terminal node, acquires related account information of a block through an interface provided by a block chain platform when the block information is stored, allocates a node address to the mobile terminal node when the mobile terminal node is added into a block chain, and skips if the address of the mobile terminal node is not matched with the address in the account information in the block data; if the matching is carried out, acquiring and storing specific block information;
and step 3: and calculating the hash value of the block by taking the block information as input, and assembling the hash value into a Merckel tree data structure.
Preferably, the merkel tree data structure is comprised of a set of leaf nodes, a set of intermediate nodes, and a root node; the leaf node stores specific block information including a block head and a block body, the intermediate node stores a hash value of the block head, and the root node stores a hash value of the whole block chain information.
Preferably, the block header contains a timestamp, a random number, a hash value of the last block, and a root hash value of the merkel tree where all block transactions are stored.
Preferably, the assembling process of the merkel tree data structure includes:
step 3.1: traversing and finding out a node with a first child node as empty, and setting the node as a pointer pointing to the newly added node; if the node with the empty first child node is not found, generating a node in the middle of supplement according to a preset depth value;
step 3.2: traversing again, then adding nodes, after the addition is completed, sequentially calculating the hash value of the data addition stored by each node child node from bottom to top, and storing the hash value in the node until the hash value of the root node is calculated.
Preferably, in the step 3.2, a SHA-256hash algorithm is adopted to calculate a hash value added to the stored data of each node child node.
Preferably, step 3.1 adds a new branch node from the root node downwards when generating the supplemental intermediate node, and stops when the depth is equal to the preset depth value of-2.
Compared with the prior art, the invention has the following advantages and beneficial effects:
the method of the invention greatly reduces the pressure of the mobile terminal user node on saving the block chain information, and simultaneously, the loss of the account book of a few nodes can not cause the collapse of the block chain, thereby well solving the problems that the block chain APP does not carry out any processing on the stored data, all the nodes save the consistent data, new blocks are generated continuously along with the accumulation of time, and the storage capacity in the local can be increased without limit.
Drawings
Fig. 1 is a data flow diagram of the local data storage optimization method based on a block chain intelligent contract according to the present invention.
Fig. 2 is a schematic diagram of a data structure used in the local data storage optimization method based on the blockchain intelligent contract according to the present invention.
Detailed Description
The present invention will be described in further detail with reference to examples, but the embodiments of the present invention are not limited thereto.
Example 1:
referring to fig. 1 and 2, a local data storage optimization method based on a block chain intelligent contract, first, the method needs to create a data structure of a merkel tree and an array for storing fixed node addresses; the merkel tree is not greatly different from a general binary tree, and mainly comprises character-type storage data and pointers pointing to left and right child nodes, and the different places mainly lie in that the merkel tree needs to be fixed with a depth, and the general depth is about 100-: struct treenenode { string data; struct treeenode, rchild; int depth }; the fixed node address array is saved and added by a developer during development, and the address is a 32-bit node address of the fixed node in the block chain, and the specific declaration is as follows: const fixddress [ ] { … }.
Due to the characteristics of the block chain, a user can send out broadcast to all nodes when joining the block chain; after receiving the broadcast, the fixed node firstly acquires the block specific information BlockInfo according to an eth, getLock method, and then judges whether the address of the current node is in the array of the fixed node addresses, namely whether the current node is the fixed node; if the node is a fixed node, calculating a hash value of the BlockInfo, and creating two Mercker tree nodes, wherein one SHA-256hash value for storing the BlockInfo and the other for storing the BlockInfo are stored in data in a treenode structure; wherein the left child of the hash node, i.e., the lchild pointer, points to the node holding the BlockInfo. Determining that the parent node of the hash node needs to traverse the Merckel tree, finding a node with a first child pointer being null and depth being equal to a preset depth-1 by adopting a depth traversal method, and setting the pointer as a pointer pointing to the hash node; if the traversal does not find such a node, a supplementary intermediate node is generated according to the previously set depth, the intermediate node is added until depth is equal to the preset depth-2, and then the previous traversal and node adding operations are performed. After the nodes are added, as shown in fig. 2, the hash value of the stored data of each node child node is calculated one step from bottom to top by using the SHA-256hash algorithm, and the hash value is stored in the node until the hash value of the root node is calculated.
After receiving the broadcast, the mobile end node firstly acquires the account information of the block according to an eth.getAccount method, and firstly judges whether the account information of the mobile end node is matched with the account information, namely whether the 32-bit node address is consistent; if the protocol for storing other data is matched or selected, the specific information of the block is stored, and the specific method is the same as that of the fixed node (the mobile end node is equivalent to a fixed node at the moment); if not, and refuses to save other data, except generating a node with data equal to the block hash, other operations are consistent with the fixed node.
Although the present invention has been described herein with reference to the illustrated embodiments thereof, which are intended to be preferred embodiments of the present invention, it is to be understood that the invention is not limited thereto, and that numerous other modifications and embodiments can be devised by those skilled in the art that will fall within the spirit and scope of the principles of this disclosure.

Claims (4)

1. A local data storage optimization method based on a block chain intelligent contract is characterized by comprising the following steps:
step 1: setting a fixed node in a block chain network, and storing all block data;
step 2: each mobile terminal node only stores block specific information related to the mobile terminal node, acquires related account information of a block through an interface provided by a block chain platform when the block information is stored, allocates a node address to the mobile terminal node when the mobile terminal node is added into a block chain, and skips if the address of the mobile terminal node is not matched with the address in the account information in the block data; if the matching is carried out, acquiring and storing specific block information;
and step 3: calculating the hash value of the block by taking the block information as input, and assembling the hash value into a Merckel tree data structure; the merkel tree data structure is composed of a set of leaf nodes, a set of intermediate nodes and a root node; leaf nodes store specific block information comprising block heads and block bodies, intermediate nodes store hash values of the block heads, and root nodes store hash values of the whole block chain information; the block header contains the timestamp, the random number, the hash value of the last block, and the root hash value of the merkel tree where all block transactions are stored.
2. The method for optimizing local data storage based on a block chain intelligent contract, according to claim 1, wherein the assembling process of the merkel tree data structure comprises:
step 3.1: traversing and finding out a node with a first child node as empty, and setting the node as a pointer pointing to the newly added node; if the node with the empty first child node is not found, generating a node in the middle of supplement according to a preset depth value;
step 3.2: traversing again, then adding nodes, after the addition is completed, sequentially calculating the hash value of the data addition stored by each node child node from bottom to top, and storing the hash value in the node until the hash value of the root node is calculated.
3. The method for optimizing local data storage based on the intelligent block chain contract as claimed in claim 2, wherein in the step 3.2, a hash value added to the storage data of each node child node is calculated by using a SHA-256hash algorithm.
4. A method for local data storage optimization based on blockchain intelligent contracts according to claim 2, wherein step 3.1 adds a new branch node from the root node downwards when generating the node in the middle of the supplement, and stops when the depth is-2, which is the preset depth value.
CN201911087252.1A 2019-11-08 2019-11-08 Local data storage optimization method based on block chain intelligent contract Active CN110851448B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911087252.1A CN110851448B (en) 2019-11-08 2019-11-08 Local data storage optimization method based on block chain intelligent contract

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911087252.1A CN110851448B (en) 2019-11-08 2019-11-08 Local data storage optimization method based on block chain intelligent contract

Publications (2)

Publication Number Publication Date
CN110851448A CN110851448A (en) 2020-02-28
CN110851448B true CN110851448B (en) 2022-05-03

Family

ID=69599844

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911087252.1A Active CN110851448B (en) 2019-11-08 2019-11-08 Local data storage optimization method based on block chain intelligent contract

Country Status (1)

Country Link
CN (1) CN110851448B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112750514A (en) * 2021-01-30 2021-05-04 云知声智能科技股份有限公司 Medical record management method and system based on block chain technology

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107800795A (en) * 2017-10-30 2018-03-13 中国联合网络通信集团有限公司 The processing method and processing device of block information
CN107809484A (en) * 2017-10-30 2018-03-16 中国联合网络通信集团有限公司 Block chain exchange information processing method and block chain node
CN108711052A (en) * 2018-05-18 2018-10-26 电子科技大学 A kind of information authentication system based on block chain
CN108876361A (en) * 2017-05-12 2018-11-23 李平 Block catenary system, block generation method and computer readable storage medium
CN108924252A (en) * 2018-07-31 2018-11-30 泰链(厦门)科技有限公司 Mitigate method, medium and the block catenary system of node storage load in block catenary system
CN108990002A (en) * 2018-06-27 2018-12-11 柳州市蓝海数链科技有限公司 A kind of block chain data processing method, device, terminal and storage medium
CN109213730A (en) * 2018-09-14 2019-01-15 莆田市烛火信息技术有限公司 A kind of file storage service address changing method and system being associated with block chain main chain
CN109684287A (en) * 2018-12-29 2019-04-26 厦门链平方科技有限公司 Gateway information sharing query method and system based on block chain
CN109711192A (en) * 2018-12-24 2019-05-03 众安信息技术服务有限公司 Method of commerce and system between block catenary system construction method, node
CN110175188A (en) * 2019-05-31 2019-08-27 杭州复杂美科技有限公司 A kind of block chain state data buffer storage and querying method, equipment and storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10121019B2 (en) * 2015-06-02 2018-11-06 ALTR Solutions, Inc. Storing differentials of files in a distributed blockchain
US10749668B2 (en) * 2017-05-03 2020-08-18 International Business Machines Corporation Reduction in storage usage in blockchain
CN109840769B (en) * 2019-01-21 2022-01-25 中国联合网络通信集团有限公司 Block chain based evidence storing method, device, system and storage medium
CN110163607A (en) * 2019-05-10 2019-08-23 南京邮电大学 The personal reference method of college student number based on block chain intelligence contract
CN110300173A (en) * 2019-06-28 2019-10-01 杭州复杂美科技有限公司 Decentralization date storage method, verification method, equipment and storage medium

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108876361A (en) * 2017-05-12 2018-11-23 李平 Block catenary system, block generation method and computer readable storage medium
CN107800795A (en) * 2017-10-30 2018-03-13 中国联合网络通信集团有限公司 The processing method and processing device of block information
CN107809484A (en) * 2017-10-30 2018-03-16 中国联合网络通信集团有限公司 Block chain exchange information processing method and block chain node
CN108711052A (en) * 2018-05-18 2018-10-26 电子科技大学 A kind of information authentication system based on block chain
CN108990002A (en) * 2018-06-27 2018-12-11 柳州市蓝海数链科技有限公司 A kind of block chain data processing method, device, terminal and storage medium
CN108924252A (en) * 2018-07-31 2018-11-30 泰链(厦门)科技有限公司 Mitigate method, medium and the block catenary system of node storage load in block catenary system
CN109213730A (en) * 2018-09-14 2019-01-15 莆田市烛火信息技术有限公司 A kind of file storage service address changing method and system being associated with block chain main chain
CN109711192A (en) * 2018-12-24 2019-05-03 众安信息技术服务有限公司 Method of commerce and system between block catenary system construction method, node
CN109684287A (en) * 2018-12-29 2019-04-26 厦门链平方科技有限公司 Gateway information sharing query method and system based on block chain
CN110175188A (en) * 2019-05-31 2019-08-27 杭州复杂美科技有限公司 A kind of block chain state data buffer storage and querying method, equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
区块链关键技术中的安全性研究;朱岩等;《信息安全研究》;20161205(第12期);第40-47页 *

Also Published As

Publication number Publication date
CN110851448A (en) 2020-02-28

Similar Documents

Publication Publication Date Title
CN108846133B (en) Block chain storage structure based on B-M tree, B-M tree establishment algorithm and search algorithm
CN101009516B (en) A method, system and device for data synchronization
US20180239800A1 (en) Data query method and apparatus
CN110599169B (en) Data processing method, device, terminal and medium
CN104462141B (en) Method, system and the storage engines device of a kind of data storage and inquiry
CN111190904B (en) Method and device for hybrid storage of graph-relational database
CN103561133A (en) IP address ownership information indexing and fast querying method
KR20050065642A (en) Data update system, differential data creating device and program for data update system, updated file restoring device and program
CN103051543A (en) Route prefix processing, lookup, adding and deleting method
CN110147204A (en) A kind of metadata rule method, apparatus, system and computer readable storage medium
CN108134739B (en) Route searching method and device based on index trie
CN101286935A (en) Route searching method based on IP address scope
CN104636349A (en) Method and equipment for compression and searching of index data
CN110851448B (en) Local data storage optimization method based on block chain intelligent contract
CN109408682A (en) A kind of method of regular expression matching, system and equipment
CN101277252A (en) Method for traversing multi-branch Trie tree
CN114676135A (en) Data storage method, readable medium and electronic device
CN113468080B (en) Caching method, system and related device for full-flash metadata
JP2014520318A (en) Compression match enumeration
CN103780263B (en) Device and method of data compression and recording medium
CN110825706A (en) Data compression method and related equipment
CN110266834B (en) Area searching method and device based on internet protocol address
CN111597139A (en) Communication method, system, equipment and medium of GPU
CN112988911B (en) Block chain data storage method and device and electronic equipment
CN112988908B (en) Block chain data storage method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant