CN110399373B - Block chain account book storage system, storage query method and deletion method - Google Patents

Block chain account book storage system, storage query method and deletion method Download PDF

Info

Publication number
CN110399373B
CN110399373B CN201910559718.7A CN201910559718A CN110399373B CN 110399373 B CN110399373 B CN 110399373B CN 201910559718 A CN201910559718 A CN 201910559718A CN 110399373 B CN110399373 B CN 110399373B
Authority
CN
China
Prior art keywords
block
node
deletion
transaction
file
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
CN201910559718.7A
Other languages
Chinese (zh)
Other versions
CN110399373A (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.)
Hangzhou Huimv Technology Co ltd
Original Assignee
Hangzhou Huimv Technology 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 Hangzhou Huimv Technology Co ltd filed Critical Hangzhou Huimv Technology Co ltd
Priority to CN201910559718.7A priority Critical patent/CN110399373B/en
Publication of CN110399373A publication Critical patent/CN110399373A/en
Application granted granted Critical
Publication of CN110399373B publication Critical patent/CN110399373B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/2219Large Object storage; Management thereof
    • 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/23Updating
    • 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
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Abstract

The invention discloses a block chain account book storage system, a storage query method and a deletion method. And when the client initiates a query request, querying the block account book according to the block file number. The client initiates deletion of the historical account book block, deletes the block file of the historical account book block to be deleted, distributes the deleted transaction to each node, realizes synchronous deletion of each node, and updates the world state to the state database. The invention changes the block storage mode to improve the block inquiry efficiency, delete the block file and release the block storage space.

Description

Block chain account book storage system, storage query method and deletion method
Technical Field
The invention belongs to the technical field of blockchains, and particularly relates to a blockchain ledger memory system, a memory query method and a deletion method.
Background
The alliance blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like, and has the technical advantages of data non-falsification, disclosure transparency, distributed storage, traceability and the like.
The account book data is not tamperable, so that the account book data becomes the biggest bottleneck of the development of the alliance blockchain technology, and as the transaction is continuously carried out, the account book block data is continuously increased, so that the storage space of the account book is insufficient, and the accounting and inquiring performances of the blockchain account book are greatly reduced. The system platform of each big software, especially the bank app application, has periodicity to the user transaction accounting history record, and the user operation record in the short period can be revealed to the user, so as to avoid overlong period and insufficient database storage space. Second, the advantage of the blockchain data being non-tamperable also results in erroneous input information that cannot be altered or deleted once it is uploaded. Besides, the method for removing the positioning blocks according to the block indexes and the offset is troublesome, and the direct positioning of the block file can improve the block query efficiency.
Therefore, aiming at the storage defect, a technical scheme is needed to be provided to solve the technical problems existing in the prior art.
Disclosure of Invention
In order to solve the above problems, the present invention provides a blockchain ledger memory system, which changes the block storage mode to improve the block query efficiency, delete the block file, and release the block storage space.
The technical scheme of the invention is as follows: a block chain account book storage system comprises a plurality of account book blocks, wherein each account book block comprises block data and a block index, wherein one block data is stored in one block file, and the size of the block file is equal to that of the block data.
Preferably, the file name of the block file is "block file_xxxxx", the "block file_" is used as a prefix, and the "xxxxx" 6-bit number is used as a suffix.
Preferably, the tile index is stored in the form of a level db.
The invention also provides a blockchain ledger storing method, wherein the blockchain comprises a plurality of ledger blocks, the ledger blocks comprise block data and block indexes, and the blockchain ledger storing method comprises the following steps: after each transaction accounting generates an account book block, a block file with the same size as the block data is newly created, the block data is added into the block file, and the block index is updated.
Preferably, the blockchain ledger storing method includes:
the client initiates a transaction calling request;
endorsing by the endorsing node, and returning an endorsing result to the client;
the client collects endorsement results, and if the endorsement results meet the endorsement policy, the client sends the orderer nodes to sort, generates blocks, and distributes the blocks to each peer node for verification;
the peer node verifies that the verification is passed, and submits the block;
generating a block file with the size of the block data;
the block data is added into the block file and the block index is updated.
The invention also provides a query method based on the blockchain ledger storage system, which comprises the following steps:
the client initiates a query request;
and inquiring the block account book according to the block file number.
The invention also provides a deleting method based on the block chain ledger storage system, which comprises the following steps:
the client initiates deletion of the historical account book block, deletes the block file of the historical account book block to be deleted, distributes the deleted transaction to each node, realizes synchronous deletion of each node, and updates the world state to the state database.
Preferably, the method comprises:
writing an intelligent contract covering a method for deleting the block file;
the client initiates a deletion transaction;
endorsing and signing the transaction proposal by the endorsing node;
the Orderer node orders and distributes transaction information to each computer node;
verifying and executing the deleted block file by the computer node;
the status database is updated.
Preferably, the method comprises:
the client packages the deleted transaction information into a transaction proposal, and the transaction proposal sends the information to be called in the transaction to an endorsement node;
the endorsement node verifies and simulates the deleted transaction proposal, and returns a simulation execution result, a read-write set and a signature to the client;
the Orderer node performs consensus sequencing on the deletion transaction proposal and generates a deletion block, the Gossip protocol performs command distribution to the coordinator node, the coordinator node verifies the deletion block, and the verification performs block file deletion according to the content of the deletion block by adding the deletion block to the blockchain;
and deleting the corresponding block index in the state database and updating the corresponding block index to the latest world state.
Preferably, the transaction proposal sends contract identification, contract method and parameter information to be called by the transaction to an endorsement node.
Compared with the prior art, the invention has the beneficial effects that:
(1) The invention fully utilizes the programmability and expandability of the intelligent contract to achieve the aim of optimizing the performance of the block chain platform.
(2) The invention changes the block data storage mode, changes the block storage mode, changes the original one-to-one or one-to-many storage mode into one-to-one (one block file stores one block data), and increases the block inquiry speed because the size of the block file depends on the size of the block.
(3) According to the invention, through the optimized management of the blockchain ledger storage, the deletion history ledger block is the deletion history block file, and the deletion transaction is distributed to each node through the gossip protocol, so that the synchronous deletion of each node is realized, and the world state is updated to the level Db. According to the invention, the historical account book block file is deleted, the block storage space is greatly reduced, and the block chain platform is pushed to the early sunset.
Drawings
FIG. 1 is a diagram of a blockchain ledger transaction storage architecture in accordance with the present invention.
FIG. 2 is a flow chart of a blockchain ledger transaction query in accordance with the present invention.
FIG. 3 is a schematic diagram of a block logic analysis of a historical ledger of a blockchain according to the block file number.
Detailed Description
The block ledger structure of the blockchain in the present invention is shown in fig. 1, and the ledger blocks include block data and block indexes. The mychannel under/mechanism is the channel name, also the account name, the block data of the whole account with the block file_as the prefix and the 6-bit number as the suffix is stored under the directory, and the block index is stored under/mechanism/index and is stored in the form of level db. The block data is the main content of the whole block, and contains all transaction information in the whole block, and each time transaction accounting is completed, a block system file (block file_xxxxx) is newly added under the mychannel directory, and the level db under the index directory is updated.
According to the invention, the account book block storage mode is changed, and one block file is used for storing a plurality of blocks or one block is changed into one block file which is used for storing only one block.
And storing the newly added block into a block file, adding the newly added block through a file manager, and in the block file_mgr.go, not comparing the size of the storage block with the size of the storage space remained by the current block file, assigning the size of the block to the size maxBlock file size of the block file, directly executing moveToNextFile (), creating a block file and adding the block into the block file to realize one block file, wherein the size of the block is the size of the block file. The modification code is as follows:
the checkpoinfo information is updated and saved to the database.
And creating a block index, such as a block file number and an account id, through a block index, storing the block index into a state database, and updating the world state.
The inquiry block is searched according to the block file number, and the execution method sequentially comprises the following steps:
locating to the ledger by ledger id (channel name or ledger name);
positioning to a block system file according to the blockfileNum;
the tile contents are returned.
Billing for the newly added block and querying for the history block are shown in the flow chart of fig. 2.
The specific logic principle of the block-by-block file number deleting method is shown in fig. 3, and the client initiates a deleting transaction proposal and sends the deleting transaction proposal to the endorsement node.
The endorsement node uses the deleted transaction scheme as an input parameter, and invokes a function in a chaincode, and the chaincode calculates a transaction result according to the current account book state, wherein the result comprises a return value and a read-write set. At this time, the blockchain ledger is not updated, and the endorsement node returns the endorsement result to the client.
After receiving the information returned by the endorsement (endocorder) node, the client determines whether the proposal results are consistent, and whether the results returned by enough endorsement nodes (executed with reference to a designated endorsement policy) are received, if not, the transaction is aborted and discarded. Otherwise, the transaction proposal, the simulation transaction result and the endorsement information are packed into a transaction and signed to the Orderer node (a sequencing service).
The Orderer node performs consensus ordering on deleted transaction information from clients, sorts the transaction information by time by channels, packages the deleted transactions into blocks by channels, and distributes the blocks to a verification (Committer) node through a gossip protocol.
And the Committer node verifies the transaction block, adds the transaction block to the account book block file after the verification is passed, and updates the check point information.
And judging the transaction block type, wherein Isdelete= =true is the deletion transaction, and executing corresponding historical ledger block file deletion according to the content of the deletion transaction block.
The specific implementation steps of executing the corresponding historical ledger-board block file deletion according to the transaction block deletion content are as follows
And calling a method for inquiring the system file of the block in the chain code according to the key value in the block.
The historic ledger block file locations are obtained and the location values are placed into a filelist [ ] array.
The [ iterative file trieng [ ] array performs the history block deletion method deleteBlockfile (), the code is as follows:
and calling deleteState () in the chain code to delete the block index in the state database and update the historical ledger database. Here, the block index deletion is to set the value corresponding to the key to nil.
[ Isdelete= =false ] is an update transaction, call putState () in the chain code to update the block index in the state database, and update the history ledger database.

Claims (9)

1. The system is characterized by comprising a plurality of account book blocks, wherein each account book block comprises block data and a block index, wherein one block data is stored in one block file, and the size of the block file is equal to that of the block data; wherein,
the client initiates a transaction calling request;
endorsing by the endorsing node, and returning an endorsing result to the client;
the client collects endorsement results, and if the endorsement results meet the endorsement policy, the client sends the orderer nodes to sort, generates blocks, and distributes the blocks to each peer node for verification;
the peer node submits the block if the peer node passes the verification;
generating a block file with the size of the block data;
the block data is added into the block file and the block index is updated.
2. The blockchain ledger storage system of claim 1, wherein the file name of the blockfile is "blockfile_xxxxx," with "blockfile_" as a prefix and "xxxxx" 6-bit digits as a suffix.
3. The blockchain ledger storage system of claim 1 or 2, wherein the blockindex is stored in a level db.
4. A blockchain ledger storage method, wherein the blockchain includes a plurality of ledger blocks, the ledger blocks including block data and a block index, the blockchain ledger storage method comprising: creating a block file with the same size as the block data after each transaction accounting generates an account block, adding the block data into the block file, and updating a block index; the method specifically comprises the following steps:
the client initiates a transaction calling request;
endorsing by the endorsing node, and returning an endorsing result to the client;
the client collects endorsement results, and if the endorsement results meet the endorsement policy, the client sends the orderer nodes to sort, generates blocks, and distributes the blocks to each peer node for verification;
the peer node submits the block if the peer node passes the verification;
generating a block file with the size of the block data;
the block data is added into the block file and the block index is updated.
5. A method of querying a blockchain ledger storage system as claimed in any of claims 1 to 3, comprising:
the client initiates a query request;
and inquiring the block account book according to the block file number.
6. A method of deleting a blockchain ledger storage system as claimed in any one of claims 1 to 3, comprising:
the client initiates deletion of the historical account book block, deletes the block file of the historical account book block to be deleted, distributes the deleted transaction to each node, realizes synchronous deletion of each node, and updates the world state to the state database.
7. The deletion method as claimed in claim 6, comprising:
writing an intelligent contract covering a method for deleting the block file;
the client initiates a deletion transaction;
endorsing and signing the transaction proposal by the endorsing node;
the Orderer node orders and distributes transaction information to each computer node;
verifying and executing the deleted block file by the computer node;
the status database is updated.
8. The deletion method as claimed in claim 7, wherein it comprises:
the client packages the deleted transaction information into a transaction proposal, and the transaction proposal sends the information to be called in the transaction to an endorsement node;
the endorsement node verifies and simulates the deleted transaction proposal, and returns a simulation execution result, a read-write set and a signature to the client;
the Orderer node performs consensus sequencing on the deletion transaction proposal and generates a deletion block, the Gossip protocol performs command distribution to the coordinator node, the coordinator node verifies the deletion block, and the verification performs block file deletion according to the content of the deletion block by adding the deletion block to the blockchain;
and deleting the corresponding block index in the state database and updating the corresponding block index to the latest world state.
9. The deletion method of claim 8, wherein the transaction proposal sends contract identification, contract method and parameter information with a call to the transaction and client signature information to an endorsement node.
CN201910559718.7A 2019-06-26 2019-06-26 Block chain account book storage system, storage query method and deletion method Active CN110399373B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910559718.7A CN110399373B (en) 2019-06-26 2019-06-26 Block chain account book storage system, storage query method and deletion method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910559718.7A CN110399373B (en) 2019-06-26 2019-06-26 Block chain account book storage system, storage query method and deletion method

Publications (2)

Publication Number Publication Date
CN110399373A CN110399373A (en) 2019-11-01
CN110399373B true CN110399373B (en) 2024-02-02

Family

ID=68322624

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910559718.7A Active CN110399373B (en) 2019-06-26 2019-06-26 Block chain account book storage system, storage query method and deletion method

Country Status (1)

Country Link
CN (1) CN110399373B (en)

Families Citing this family (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111026711A (en) * 2019-12-13 2020-04-17 深圳前海环融联易信息科技服务有限公司 Block chain based data storage method and device, computer equipment and storage medium
CN111488345A (en) * 2020-04-08 2020-08-04 北京瑞策科技有限公司 Storage optimization method and device for service data block chain
CN111506549B (en) * 2020-04-16 2023-07-14 深圳市迅雷网络技术有限公司 File processing system, method, equipment and storage medium based on block chain
CN111597190A (en) * 2020-05-15 2020-08-28 中国人民大学 Block chain data storage and retrieval method, device, equipment and storage medium
CN111444195B (en) * 2020-06-12 2020-10-30 支付宝(杭州)信息技术有限公司 Method, device and equipment for clearing indexes in block chain type account book
CN111475501B (en) * 2020-06-24 2020-10-30 支付宝(杭州)信息技术有限公司 Data cleaning method and device for block chain network
CN111797086A (en) * 2020-07-03 2020-10-20 杭州复杂美科技有限公司 Data clipping method, device and storage medium
CN112148379B (en) * 2020-08-28 2023-07-07 迅鳐成都科技有限公司 User contract unloading method, device and system of alliance chain and storage medium
US20220067028A1 (en) * 2020-08-28 2022-03-03 International Business Machines Corporation Trustless operations for blockchain networks
CN112398908B (en) * 2020-10-20 2023-04-07 杭州云象网络技术有限公司 Block chain network node deleting method, system, storage medium and device
CN112671881B (en) * 2020-12-18 2022-09-20 成都质数斯达克科技有限公司 Node organization management method and device, electronic equipment and readable storage medium
CN112767164A (en) * 2021-01-22 2021-05-07 深圳市瀚兰区块链地产有限公司 House property data deposit system, method and device based on super account book
CN112732799B (en) * 2021-03-30 2021-11-02 支付宝(杭州)信息技术有限公司 Method and device for querying Fabric Block Link book data
CN113127562A (en) * 2021-03-30 2021-07-16 河南九域腾龙信息工程有限公司 Low-redundancy block chain data storage and retrieval method and system
CN112732801B (en) * 2021-03-30 2021-08-20 支付宝(杭州)信息技术有限公司 Method and device for querying Fabric Block Link book data
CN113379542B (en) * 2021-05-28 2024-01-09 中邮信息科技(北京)有限公司 Block chain transaction query method, device, medium and electronic equipment
CN113220789A (en) * 2021-05-31 2021-08-06 青岛网信信息科技有限公司 Distributed storage method and system for block chain account book

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109325855A (en) * 2018-08-16 2019-02-12 北京京东尚科信息技术有限公司 Block chain network, dispositions method and storage medium
CN109325854A (en) * 2018-08-16 2019-02-12 北京京东尚科信息技术有限公司 Block chain network, dispositions method and storage medium
CN109729093A (en) * 2019-01-17 2019-05-07 重庆邮电大学 A kind of digital publishing rights register technique based on block chain
KR20190059491A (en) * 2017-11-23 2019-05-31 박동화 System and method for e-commerce with shared and distributed ledger coupled with outer storage devices
CN109871366A (en) * 2019-01-17 2019-06-11 华东师范大学 A kind of storage of block chain fragment and querying method based on correcting and eleting codes

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2010045262A1 (en) * 2008-10-14 2010-04-22 Wanova Technologies, Ltd. Storage-network de-duplication
US10565192B2 (en) * 2017-08-01 2020-02-18 International Business Machines Corporation Optimizing queries and other retrieve operations in a blockchain

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20190059491A (en) * 2017-11-23 2019-05-31 박동화 System and method for e-commerce with shared and distributed ledger coupled with outer storage devices
CN109325855A (en) * 2018-08-16 2019-02-12 北京京东尚科信息技术有限公司 Block chain network, dispositions method and storage medium
CN109325854A (en) * 2018-08-16 2019-02-12 北京京东尚科信息技术有限公司 Block chain network, dispositions method and storage medium
CN109729093A (en) * 2019-01-17 2019-05-07 重庆邮电大学 A kind of digital publishing rights register technique based on block chain
CN109871366A (en) * 2019-01-17 2019-06-11 华东师范大学 A kind of storage of block chain fragment and querying method based on correcting and eleting codes

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
区块链全局账本数据的拆分技术研究;于雷等;《高技术通讯》;20171231;全文 *

Also Published As

Publication number Publication date
CN110399373A (en) 2019-11-01

Similar Documents

Publication Publication Date Title
CN110399373B (en) Block chain account book storage system, storage query method and deletion method
CN103150394B (en) Distributed file system metadata management method facing to high-performance calculation
CN108427684B (en) Data query method and device and computing equipment
CN101770515B (en) Data block comparison based data updating method
CN109391645B (en) Block chain lightweight processing method, block chain node and storage medium
EP2924594B1 (en) Data encoding and corresponding data structure in a column-store database
CN101217571B (en) Write/read document operation method applied in multi-copy data grid system
CN108846133B (en) Block chain storage structure based on B-M tree, B-M tree establishment algorithm and search algorithm
CN109597853B (en) Business scene element serial number generation method, device, medium and computer equipment
CN104412266A (en) Method and apparatus for multidimensional data storage and file system with a dynamic ordered tree structure
CN102915382A (en) Method and device for carrying out data query on database based on indexes
CN104426955A (en) Processing method of shared file, and cloud storage server
CN106156070A (en) A kind of querying method, Piece file mergence method and relevant apparatus
CN108090125A (en) A kind of data de-duplication method and device of non-query formulation
CN108563697B (en) Data processing method, device and storage medium
CN110597922A (en) Data processing method, device, terminal and storage medium
CN106331160A (en) Data migration method and system
CN112148680A (en) File system metadata management method based on distributed graph database
CN105975614A (en) Cluster configuration device and data updating method and device
CN113468571A (en) Tracing method based on block chain
CN113111125A (en) Business evidence storage method based on block chain
CN112131228A (en) FABRIC-based alliance chain system convenient for data retrieval
CN111291002A (en) File account checking method and device, computer equipment and storage medium
CN104574188A (en) Transaction service system and transaction processing method
CN105550347A (en) Data processing method and device

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