CA3147339A1 - Method and device for writing blockchain data in parallel, computer equipment and storage medium thereof - Google Patents
Method and device for writing blockchain data in parallel, computer equipment and storage medium thereof Download PDFInfo
- Publication number
- CA3147339A1 CA3147339A1 CA3147339A CA3147339A CA3147339A1 CA 3147339 A1 CA3147339 A1 CA 3147339A1 CA 3147339 A CA3147339 A CA 3147339A CA 3147339 A CA3147339 A CA 3147339A CA 3147339 A1 CA3147339 A1 CA 3147339A1
- Authority
- CA
- Canada
- Prior art keywords
- thread
- current block
- blockchain
- employing
- transaction
- 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.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 65
- 238000012795 verification Methods 0.000 claims abstract description 114
- 238000012544 monitoring process Methods 0.000 claims description 55
- 238000004590 computer program Methods 0.000 claims description 27
- 230000008569 process Effects 0.000 claims description 18
- 230000008859 change Effects 0.000 claims description 16
- 230000009471 action Effects 0.000 claims description 6
- 239000002699 waste material Substances 0.000 abstract description 3
- 230000002708 enhancing effect Effects 0.000 abstract 1
- 230000005540 biological transmission Effects 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 238000013523 data management Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000007726 management method Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000005457 optimization Methods 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 238000004088 simulation Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
- G06F16/2308—Concurrency control
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION 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/00—Payment architectures, schemes or protocols
- G06Q20/38—Payment protocols; Details thereof
- G06Q20/382—Payment protocols; Details thereof insuring higher security of transaction
- G06Q20/3825—Use of electronic signatures
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- General Physics & Mathematics (AREA)
- Business, Economics & Management (AREA)
- General Engineering & Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Accounting & Taxation (AREA)
- Computing Systems (AREA)
- Computer Security & Cryptography (AREA)
- Finance (AREA)
- Strategic Management (AREA)
- General Business, Economics & Management (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The present invention makes public a method of writing blockchain data in parallel, corresponding device and computer equipment. The method comprises: employing a first thread to write received current block into structure file of blockchain, employing a second thread to verify transaction endorsement of current block, and obtaining verification result; employing, if verification of transaction endorsement is passed, second thread to write verification result into structure file, and employing a third thread to update status database of blockchain according to current block; if execution results of threads all exhibit successful, employing third thread to update history database of blockchain according to current block. Through coordination of threads, one correct ledger writing-in achieved only when all threads have successfully executed, so ledgers of various nodes are maintained consistent, while enhancing overall transaction performance of blockchain network, reducing transaction delay, flexibly allocating computational tasks, and avoiding waste of computational resources.
Description
METHOD AND DEVICE FOR WRITING BLOCKCHAIN DATA IN PARALLEL, COMPUTER EQUIPMENT AND STORAGE MEDIUM THEREOF
BACKGROUND OF THE INVENTION
Technical Field [0001] The present invention relates to the field of data processing technology, and more particularly to a method and a device for writing blockchain data in parallel, and corresponding computer equipment and storage medium.
Description of Related Art
BACKGROUND OF THE INVENTION
Technical Field [0001] The present invention relates to the field of data processing technology, and more particularly to a method and a device for writing blockchain data in parallel, and corresponding computer equipment and storage medium.
Description of Related Art
[0002] Blockchain is a decentralized, distributed ledger technology system, based on linked data structure. A blockchain ledger consists of a string of blocks associated by cryptography, each block contains certain information data and data fingerprints thereof, and the data fingerprints are usable to verify the validity of the current block and to link with the next block. Through a consensus algorithm, ledger data on each node in the blockchain system can be maintained consistent with data on other nodes. The following problems are mainly pending in the state of the art when the various nodes of the blockchain write received new blocks into the ledger.
[0003] The bottom frame of the mainstream blockchain is low in transaction throughput and high in block out delay. Such operations as transaction verification, file writing-in and database update in the process for the nodes of the blockchain to execute ledger writing-in in series engender serious bottlenecks to the overall transaction performance of the blockchain network, great quantities of block data are accumulated at the node cache and cannot be timely written into the ledger, it is required for the user to take very long time to ascertain whether a certain transaction has been successfully executed, and even such problems as severe timeout and repeated transmissions of requests are caused thereby.
Date Recue/Date Received 2022-02-01
Date Recue/Date Received 2022-02-01
[0004] The blockchain technology is somehow restricted both in terms of the fields of application and the ranges of utilization. Since the blockchain system has not achieved the transaction performance that is matched with the currently available database management system, it is usually impossible for the blockchain system to directly access to the real-time data management system already possessed by enterprises, so the current blockchain applications are mostly restricted to non-real-time transaction fields.
[0005] The server is relatively low in computational resource utilization.
Currently the entire flow for writing blockchain ledgers in node ledgers is essentially executed in full series, the computational resource of the multi-core CPU or GPU server cannot be fully utilized, and it is impossible for the user to achieve marked enhancement of the transaction performance by upgrading the server.
Currently the entire flow for writing blockchain ledgers in node ledgers is essentially executed in full series, the computational resource of the multi-core CPU or GPU server cannot be fully utilized, and it is impossible for the user to achieve marked enhancement of the transaction performance by upgrading the server.
[0006] With respect to the above problems, although methods have been proposed so far to attempt to optimize the transaction performance at the bottom framework of the blockchain by the parallel mode, for instance, to employ multiple threads to execute blockchain operations, these methods mostly focus on the single link in the update of the blockchain status database in the process of writing into the blockchain ledger, while pay no attention to the overall optimization of all links in writing into the ledger, so the transaction performance has been enhanced in a limited degree.
[0007] In short, it is a technical conundrum to be urgently dealt with as how to further optimize the execution efficiency in the link of writing in the blockchain ledger.
SUMMARY OF THE INVENTION
SUMMARY OF THE INVENTION
[0008] In order to overcome the problems prevalent in prior-art technology, embodiments of the present invention provide a method and a device for writing blockchain data in parallel, Date Recue/Date Received 2022-02-01 and corresponding computer equipment and storage medium, so as to address the problems pending in the state of the art in which the blockchain ledger writing-in flow is unduly complicated, it takes too long time to write into blockchain structure files, verify transactions and update data statuses, and there is a bottleneck in the overall transaction performance of the blockchain network.
[0009] To solve one or more of the aforementioned technical problem(s), the present invention employs the following technical solutions.
[0010] According to the first aspect, there is provided a method of writing blockchain data in parallel, and the method comprises the following steps:
[0011] receiving a current block to be processed, employing a first thread to write the current block into a structure file of a blockchain, simultaneously employing a second thread to verify transaction endorsement of the current block, and obtaining a verification result;
[0012] employing, if verification of the transaction endorsement is passed, the second thread to write the verification result into the structure file, and simultaneously employing a third thread to update a status database of the blockchain according to the current block; and
[0013] obtaining execution results of the first thread, the second thread and the third thread, and, if the execution results all exhibit successful executions, employing the third thread to update a history database of the blockchain according to the current block.
[0014] Further, the step of obtaining execution results of the first thread, the second thread and the third thread includes:
[0015] employing a preset monitoring thread to monitor the first thread, the second thread and the third thread, and obtaining execution results of the first thread, the second thread and the third thread.
[0016] Moreover, the method further comprises:
Date Recue/Date Received 2022-02-01
Date Recue/Date Received 2022-02-01
[0017] notifying, if the preset monitoring thread monitors that anyone of the first thread, the second thread and the third thread has failed to execute, the other successfully executed threads to perform data rollback.
[0018] Further, while employing a first thread to write the current block into a structure file of a blockchain, simultaneously employing a second thread to verify transaction endorsement of the current block, and obtaining a verification result, the method further comprises:
[0019] employing the third thread to update the history database of the blockchain according to a block previous to the current block.
[0020] Further, the step of employing a third thread to update a status database of the blockchain according to the current block includes:
[0021] judging whether the operation to update the history database of the blockchain according to a block previous to the current block has been executed to completion, if yes, employing the third thread to update the status database of the blockchain according to the current block.
[0022] Further, the step of employing a second thread to verify transaction endorsement of the current block includes:
[0023] verifying whether version numbers of all key values in a read/write set of all transactions in the current block are consistent with a version number of the current block.
[0024] Further, the step of employing the second thread to write the verification result into the structure file includes:
[0025] employing the second thread to compile transactions that have passed verification into a preset array, and writing the preset array into the structure file.
[0026] According to the second aspect, there is provided a device for writing blockchain data in parallel, and the device comprises:
Date Recue/Date Received 2022-02-01
Date Recue/Date Received 2022-02-01
[0027] a block receiving module, for receiving a current block to be processed;
[0028] a first processing module, for employing a first thread to write the current block into a structure file of a blockchain;
[0029] a second processing module, for simultaneously employing a second thread to verify transaction endorsement of the current block, and obtaining a verification result; and employing, if verification of the transaction endorsement is passed, the second thread to write the verification result into the structure file;
[0030] a third processing module, for employing a third thread to update a status database of the blockchain according to the current block; and
[0031] a thread monitoring module, for obtaining execution results of the first thread, the second thread and the third thread;
[0032] wherein the third processing module is further used for, if the execution results all exhibit successful executions, employing the third thread to update a history database of the blockchain according to the current block.
[0033] According to the third aspect, there is provided a computer equipment that comprises a memory, a processor and a computer program stored on the memory and operable on the processor, and the following steps are realized when the processor executes the computer program:
[0034] receiving a current block to be processed, employing a first thread to write the current block into a structure file of a blockchain, simultaneously employing a second thread to verify transaction endorsement of the current block, and obtaining a verification result;
[0035] employing, if verification of the transaction endorsement is passed, the second thread to write the verification result into the structure file, and simultaneously employing a third thread to update a status database of the blockchain according to the current block; and
[0036] obtaining execution results of the first thread, the second thread and the third thread, and, if the execution results all exhibit successful executions, employing the third thread to update a history database of the blockchain according to the current block.
Date Recue/Date Received 2022-02-01
Date Recue/Date Received 2022-02-01
[0037] According to the fourth aspect, there is provided a computer-readable storage medium storing a computer program thereon, and the following steps are realized when the computer program is executed by a processor:
[0038] receiving a current block to be processed, employing a first thread to write the current block into a structure file of a blockchain, simultaneously employing a second thread to verify transaction endorsement of the current block, and obtaining a verification result;
[0039] employing, if verification of the transaction endorsement is passed, the second thread to write the verification result into the structure file, and simultaneously employing a third thread to update a status database of the blockchain according to the current block; and
[0040] obtaining execution results of the first thread, the second thread and the third thread, and, if the execution results all exhibit successful executions, employing the third thread to update a history database of the blockchain according to the current block.
[0041] The technical solutions provided by the embodiments of the present invention bring about the following advantageous effects.
[0042] In the method and device for writing blockchain data in parallel, and corresponding computer equipment and storage medium provided by the embodiments of the present invention, by receiving a current block to be processed, employing a first thread to write the current block into a structure file of a blockchain, simultaneously employing a second thread to verify transaction endorsement of the current block, obtaining a verification result, employing, if verification of the transaction endorsement is passed, the second thread to write the verification result into the structure file, simultaneously employing a third thread to update a status database of the blockchain according to the current block, obtaining execution results of the first thread, the second thread and the third thread, and, if the execution results all exhibit successful executions, employing the third thread to update a history database of the blockchain according to the current block, namely, through coordinated operations of a plurality of threads, the present invention counts it as one correct ledger writing-in only when all threads have successfully executed, so that Date Recue/Date Received 2022-02-01 ledgers of various nodes are maintained consistent, while the overall transaction performance of the blockchain network is enhanced, transaction delay is reduced, computational tasks of the blockchain are flexibly allocated, plural CPUs are allowed to simultaneously process received plural pieces of transaction data, and waste of computational resources of the server is avoided.
[0043] Moreover, in the method and device for writing blockchain data in parallel, and corresponding computer equipment and storage medium provided by the embodiments of the present invention, by employing a first thread to write the current block into a structure file of a blockchain, simultaneously employing a second thread to verify transaction endorsement of the current block, obtaining a verification result, and employing the third thread to update the history database of the blockchain according to a block previous to the current block, writing-in operations of two adjacent blocks can as well be partially concurrently executed, whereby transaction processing speed of blockchain nodes is enhanced, so that the blockchain technology can be applied to such highly concurrent and quasi real-time transaction fields as the traditional retail payment, and application scenarios of the blockchain technology are broadened.
BRIEF DESCRIPTION OF THE DRAWINGS
BRIEF DESCRIPTION OF THE DRAWINGS
[0044] To more clearly describe the technical solutions in the embodiments of the present invention, drawings required to illustrate the embodiments will be briefly introduced below. Apparently, the drawings introduced below are merely directed to some embodiments of the present invention, while persons ordinarily skilled in the art may further acquire other drawings on the basis of these drawings without spending creative effort in the process.
[0045] Fig. 1 is a view schematically illustrating the transaction flow of the currently available blockchain network according to an exemplary embodiment;
Date Recue/Date Received 2022-02-01
Date Recue/Date Received 2022-02-01
[0046] Fig. 2 is a flowchart illustrating the ledger writing-in link in the transaction flow of the currently available blockchain network according to an exemplary embodiment;
[0047] Fig. 3 is a flowchart illustrating threads interaction in the method of writing blockchain data in parallel according to an exemplary embodiment;
[0048] Fig. 4 is a flowchart illustrating the method of writing blockchain data in parallel according to an exemplary embodiment;
[0049] Fig. 5 is a flowchart illustrating the method of writing blockchain data in parallel according to another exemplary embodiment;
[0050] Fig. 6 is a view schematically illustrating the structure of the device for writing blockchain data in parallel according to an exemplary embodiment; and
[0051] Fig. 7 is a view schematically illustrating the internal structure of the computer equipment according to an exemplary embodiment.
DETAILED DESCRIPTION OF THE INVENTION
DETAILED DESCRIPTION OF THE INVENTION
[0052] To make more lucid and clear the objectives, technical solutions and advantages of the present invention, the technical solutions in the embodiments of the present invention will be clearly and comprehensively described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the embodiments as described are merely partial, rather than the entire, embodiments of the present invention.
Any other embodiments makeable by persons ordinarily skilled in the art on the basis of the embodiments in the present invention without creative effort shall all fall within the protection scope of the present invention.
Date Recue/Date Received 2022-02-01
Any other embodiments makeable by persons ordinarily skilled in the art on the basis of the embodiments in the present invention without creative effort shall all fall within the protection scope of the present invention.
Date Recue/Date Received 2022-02-01
[0053] Fig. 1 is a view schematically illustrating the transaction flow of the currently available blockchain network according to an exemplary embodiment. With reference to Fig. 1, the currently available blockchain network mainly includes the four roles, i.e. a client end, an endorsing node, a sorting node, and a bookkeeping node, of which the client end includes an application program and an SDK, through which client end the user can initiate a transaction and submit a transaction proposal; the endorsing node is mainly responsible for verifying and endorsing the transaction proposal, calculating a simulated result of transaction execution and returning a response result of the transaction proposal to the client end; the sorting node is mainly responsible for receiving the transaction proposal from the client end, sorting and arranging the transaction proposal as blocks, and thereafter broadcasting the blocks to the bookkeeping node for processing;
and the bookkeeping node is responsible for rechecking transaction legitimacy after having received the blocks, and writing the blocks into the blockchain structure.
and the bookkeeping node is responsible for rechecking transaction legitimacy after having received the blocks, and writing the blocks into the blockchain structure.
[0054] Fig. 2 is a flowchart illustrating the ledger writing-in link in the transaction flow of the currently available blockchain network according to an exemplary embodiment.
With reference to Fig. 2, the conventional blockchain ledger writing-in process mainly includes five steps, i.e., verifying the transaction endorsement, updating the verification result to the local blockchain structure file, writing blocks into the local blockchain structure file, updating the blockchain status database and updating the blockchain history database.
With further reference to Fig. 2, the current blockchain ledger writing-in mode is writing in series, thereby on the one hand, the process proceeds with the writing-in operation of the next block only when all steps of the previous block have been executed to completion;
on the other hand, the five steps in the ledger writing-in process must also be sequentially executed, and this causes a severe bottleneck in the transaction performance of the blockchain network, whereby block data cannot be timely written into the ledger, lots of client ends wait for feedback from the bookkeeping node, and even such problems as severe timeout and repeated transmissions are caused thereby.
Date Recue/Date Received 2022-02-01
With reference to Fig. 2, the conventional blockchain ledger writing-in process mainly includes five steps, i.e., verifying the transaction endorsement, updating the verification result to the local blockchain structure file, writing blocks into the local blockchain structure file, updating the blockchain status database and updating the blockchain history database.
With further reference to Fig. 2, the current blockchain ledger writing-in mode is writing in series, thereby on the one hand, the process proceeds with the writing-in operation of the next block only when all steps of the previous block have been executed to completion;
on the other hand, the five steps in the ledger writing-in process must also be sequentially executed, and this causes a severe bottleneck in the transaction performance of the blockchain network, whereby block data cannot be timely written into the ledger, lots of client ends wait for feedback from the bookkeeping node, and even such problems as severe timeout and repeated transmissions are caused thereby.
Date Recue/Date Received 2022-02-01
[0055] In order to solve the above problems, a method of writing blockchain data in parallel is creatively proposed in the embodiments of the present invention, the method mainly focuses on the process in which the aforementioned blockchain bookkeeping node detects transaction legitimacy and writes the legitimate transactions into the blockchain structure file after having received the blocks from the sorting node and having completed preliminary block format verification, the received blocks are written into the local blockchain structure file, verification of transaction endorsement is executed in parallel as the blocks are being written into the structure file, the verification result is written into the local blockchain structure file after verification of the transaction endorsement has ended, the blockchain status database is updated after the verification of the transaction endorsement has ended, and the blockchain history database is updated after the aforementioned four steps have all been completed.
[0056] Fig. 3 is a flowchart illustrating threads interaction in the method of writing blockchain data in parallel according to an exemplary embodiment. With reference to Fig.
3, suppose the current block to be processed is block X, during specific implementation, the operation of writing into the local blockchain structure file is executed through a first thread, the operation of verifying the transaction endorsement and the operation of writing the verification result are executed through a second thread, and the operations of updating the status database and the history database of the blockchain are executed through a third thread; it is considered that the new block is successfully written into the blockchain ledger only when the three threads have all successfully executed their operations, otherwise data rollback is performed, thereby ledgers of various nodes are maintained consistent, while transaction delay of the blockchain network is reduced, and transaction throughput of the blockchain system is enhanced. The first thread, the second thread and the third thread execute their operations all in parallel, the three threads can either be pre-existent or newly created, and can be managed by way of a thread pool.
Date Recue/Date Received 2022-02-01
3, suppose the current block to be processed is block X, during specific implementation, the operation of writing into the local blockchain structure file is executed through a first thread, the operation of verifying the transaction endorsement and the operation of writing the verification result are executed through a second thread, and the operations of updating the status database and the history database of the blockchain are executed through a third thread; it is considered that the new block is successfully written into the blockchain ledger only when the three threads have all successfully executed their operations, otherwise data rollback is performed, thereby ledgers of various nodes are maintained consistent, while transaction delay of the blockchain network is reduced, and transaction throughput of the blockchain system is enhanced. The first thread, the second thread and the third thread execute their operations all in parallel, the three threads can either be pre-existent or newly created, and can be managed by way of a thread pool.
Date Recue/Date Received 2022-02-01
[0057] Fig. 4 is a flowchart illustrating the method of writing blockchain data in parallel according to an exemplary embodiment. With reference to Fig. 4, the process of writing data in parallel comprises the following steps.
[0058] Step A ¨ writing a received block into a local blockchain structure file.
[0059] Specifically, the received current block is written into a local structure file of a blockchain through a first thread, in which the structure file includes, but is not limited to, a Chunk file, etc. During specific implementation, the first thread adds the current block to a preconfigured index database, in which such block data as the block number, Hash value, file pointer and transaction offset of the current block are imported.
[0060] Since such operations as update of the blockchain structure file, verification of the transaction endorsement, update of the status database and update of the history database in the blockchain ledger writing-in process are respectively executed by different threads in the embodiments of the present invention, and since a correct ledger writing-in is counted only when the aforementioned operations have all been completed, a monitoring thread is further disposed in the embodiments of the present invention to monitor the circumstances of execution by the first thread, the second thread and the third thread.
After the first thread has executed the operation of writing the current block into the structure file of the local blockchain, it feeds back the execution result to the monitoring thread and waits for the later to assign the next task. If the first thread has successfully written the received block into the local blockchain structure file, the monitoring thread will wait for and summarize the execution results of other threads before notifying the first thread; if the execution has failed, the monitoring thread will immediately notify the first thread to perform a rollback operation on the local blockchain structure file and the index database, return to the status of the previous block and wait for the renewed operation of writing the current block.
Date Recue/Date Received 2022-02-01
After the first thread has executed the operation of writing the current block into the structure file of the local blockchain, it feeds back the execution result to the monitoring thread and waits for the later to assign the next task. If the first thread has successfully written the received block into the local blockchain structure file, the monitoring thread will wait for and summarize the execution results of other threads before notifying the first thread; if the execution has failed, the monitoring thread will immediately notify the first thread to perform a rollback operation on the local blockchain structure file and the index database, return to the status of the previous block and wait for the renewed operation of writing the current block.
Date Recue/Date Received 2022-02-01
[0061] Step B ¨ executing verification of transaction endorsements in parallel at the same time of writing into the structure file.
[0062] Specifically, at the same time as the first thread writes the received current block into the local structure file of the blockchain, the second thread verifies one-by-one transaction endorsements in the received current block, in which there are two main verification items of a transaction read/write set: whether version numbers of all key values read in the read/write set are consistent with the current version number, and whether the results of range query are consistent with the current execution result. The results of range query indicate range query results contained in all transactions in the received current block (this item is checked if there is the item of executing range query in the transactions, while there is no need to check if there is no item of executing range query in the transactions), and are specifically simulated results obtained after the node that generates the current block has executed the range query operation. The current execution result indicates a simulated execution result obtained after the node that executes the ledger writing-in operation has executed again the range query operation by simulation. After verifications of all transactions in the current block have been completed, the second thread writes the verification result into the local blockchain structure file, simultaneously forwards the verification result to the third thread, and notifies it to update the blockchain status database.
[0063] Specifically, as should be noted here, in the embodiments of the present invention, each transaction in the block contains a read/write dataset, in which the read set includes a key-value pair array that should be read from the ledger during execution of the transaction, and the write set includes a key-value pair array that should be written to the ledger during execution of the transaction.
[0064] Step C ¨ writing a verification result into the local blockchain structure file after verifications of the transaction endorsements have ended.
Date Recue/Date Received 2022-02-01
Date Recue/Date Received 2022-02-01
[0065] Specifically, the second thread compiles the transactions that have passed verification into a transaction valid tag array according to the verification result of the transaction endorsements of the current block, and subsequently writes the array into the local blockchain structure file. Finally, the second thread feeds back the execution result to the monitoring thread and waits for the later to assign the next task.
[0066] Specifically, if the second thread has successfully written the verification result into the local blockchain structure file, the monitoring thread will wait for and summarize the execution results of other threads before notifying the second thread. If the execution has failed, the monitoring thread will immediately notify the second thread to perform a rollback operation on the local block file, return to the status of the previous block, and wait for the renewed operation of writing the current block.
[0067] Step D ¨ updating the blockchain status database after verifications of the transaction endorsements have ended.
[0068] Specifically, in the embodiments of the present invention, it is required for the third thread to execute the read/write set of all valid transactions in the current block according to the verification result provided by the second thread in Step B and to update the blockchain status database after waiting for the complete execution of the operation of updating the blockchain history database of the previous block. After the execution has been completed, the third thread feeds back the execution result to the monitoring thread and waits for the later to assign the next task.
[0069] If the third thread has successfully updated the blockchain status database, the monitoring thread will wait for and summarize the execution results of other threads before notifying the third thread. If the execution has failed, the monitoring thread will immediately notify Date Recue/Date Received 2022-02-01 the third thread to perform a rollback operation on the status database, return to the status of the previous block, and wait for the renewed operation of writing in the current block.
[0070] Step E - updating the blockchain history database after the above Steps A to D have all been completed.
[0071] Specifically, the monitoring thread waits for the first thread, the second thread and the third thread to have completed the above Steps A to D, and thereafter summarizes the execution results of the various threads. If all threads have successfully executed their operations, the third thread is notified to continue to update the blockchain history database according to the current block, and the ledger writing-in flow of the next block is started; if anyone of the threads has failed its execution task, the other threads that have succeeded their executions are notified to perform data rollback.
[0072] Fig. 5 is a flowchart illustrating the method of writing blockchain data in parallel according to another exemplary embodiment. As shown in Fig. 5, the method comprises the following steps.
[0073] 51 - receiving a current block to be processed, employing a first thread to write the current block into a structure file of a blockchain, simultaneously employing a second thread to verify transaction endorsement of the current block, and obtaining a verification result.
[0074] Specifically, it is possible in the embodiments of the present invention to preconfigure, based on practical requirements, a plurality of threads, such as a first thread, a second thread, and a third thread, etc., and to configure each thread to execute different operations in the ledger writing-in process. As a preferred mode of execution in the embodiments of the present invention, the first thread executes the local blockchain structure file writing-in operation, the second thread executes the operation of verifying the transaction endorsement and the operation of writing the verification result, and the third thread Date Recue/Date Received 2022-02-01 executes the operations of updating the status database and the history database of the blockchain.
[0075] S2 - employing, if verification of the transaction endorsement is passed, the second thread to write the verification result into the structure file, and simultaneously employing a third thread to update a status database of the blockchain according to the current block.
[0076] Specifically, after the second thread has verified that the transaction endorsement of the current block has passed verification, on the one hand, the second thread is continuously employed to write the verification result into the structure file, on the other hand, the third thread is notified to update the status database of the blockchain according to the current block. As should be noted here, since the first thread and the second thread both involve the writing-in of the local blockchain structure file, in order to prevent the same and single file from being simultaneously written in to cause system error, it is so set up in the embodiments of the present invention that the block itself and the verification result of the transaction endorsement are respectively stored, that is to say, writing-in is directed to different blockchain structure files, whereby the overall writing-in efficiency of the blockchain structure is enhanced. As should be noted here, in the embodiments of the present invention, data stored in the status database includes, but is not limited to, the newest values of all keys after all transactions contained in the current ledger have been executed to completion. Taking the newest value of a certain key at the current time point as an example, when the transaction is executed, only the change itself is executed, while the action changed is not recorded.
[0077] S3 - obtaining execution results of the first thread, the second thread and the third thread, and, if the execution results all exhibit successful executions, employing the third thread to update a history database of the blockchain according to the current block.
Date Recue/Date Received 2022-02-01
Date Recue/Date Received 2022-02-01
[0078] Specifically, in order to prevent block writing sequence error in the blockchain ledger from making it impossible for the blockchain network to reach consensus, the bookkeeping node performs the ledger writing-in operation on the next block only after the four operations, i.e. writing into the structure file of the current block, verifying the transaction endorsement, writing the verification result, and updating the status database, have been executed to completion. In the embodiments of the present invention, only the operation of updating the history database can be executed in the cycle of execution of the next block, this is so because the history database is for query by users only, while it is not allowed for users to write, and there would be no system collapse due to its writing sequence error. In addition, the operation of updating the blockchain history database can also be executed by a fourth thread set up according to actual business requirements, so as to further enhance the overall transaction performance of the blockchain network. As should be noted here, in the embodiments of the present invention, data stored in the history database includes, but is not limited to, change in the versions of keys. For instance, a certain key is changed in a certain transaction of a certain block, only the change action is recorded, while the change itself is not executed.
[0079] As a preferred mode of execution in the embodiments of the present invention, the step of obtaining execution results of the first thread, the second thread and the third thread includes:
[0080] employing a preset monitoring thread to monitor the first thread, the second thread and the third thread, and obtaining execution results of the first thread, the second thread and the third thread.
[0081] Specifically, it is monitored through the preset monitoring thread whether the first thread has completed the local blockchain structure file writing-in operation, whether the second thread has completed the operation of verifying the transaction endorsement and the operation of writing the verification result, and whether the third thread has completed the operation of updating the blockchain status database. After the monitoring thread has Date Recue/Date Received 2022-02-01 detected that the aforementioned four tasks of the current block have all been successfully executed, the first thread is again enabled to start executing the structure file writing-in operation of the next block, and the second thread to start executing the operation of verifying the transaction endorsement of the next block, and so on. As should be noted here, in the embodiments of the present invention, the preset monitoring thread can be embodied as a separate thread to execute the monitoring operation, and can also be embodied as a first thread to undertake the monitoring operation among other operations ¨ this is freely selectable by users as practically required, and no restriction is made thereto in this context.
[0082] As a preferred mode of execution in the embodiments of the present invention, the method further comprises:
[0083] notifying, if the preset monitoring thread monitors that anyone of the first thread, the second thread and the third thread has failed to execute, the other successfully executed threads to perform data rollback.
[0084] Specifically, the monitoring thread waits for the first thread, the second thread and the third thread to have completed their respective operations, and thereafter summarizes the execution results of the various threads. In order to guarantee correct writing-in of the block, it is so set in the embodiments of the present invention that one correct block writing-in is counted in the case all threads have successfully executed their operations;
when the monitoring thread monitors that anyone of the first thread, the second thread and the third thread has failed execution, the other threads that have succeeded executions are notified to perform data rollback.
when the monitoring thread monitors that anyone of the first thread, the second thread and the third thread has failed execution, the other threads that have succeeded executions are notified to perform data rollback.
[0085] As a preferred mode of execution in the embodiments of the present invention, while employing a first thread to write the current block into a structure file of a blockchain, simultaneously employing a second thread to verify transaction endorsement of the current block, and obtaining a verification result, the method further comprises:
Date Recue/Date Received 2022-02-01
Date Recue/Date Received 2022-02-01
[0086] employing the third thread to update the history database of the blockchain according to a block previous to the current block.
[0087] Specifically, in order to further enhance the overall transaction performance of the blockchain network, in the embodiments of the present invention, while employing a first thread to write the current block into a structure file of a blockchain, simultaneously employing a second thread to verify transaction endorsement of the current block, and obtaining a verification result, the third thread is further employed to update the history database of the blockchain according to a block previous to the current block.
That is to say, in the current block writing-in process, for the operation of updating the history database of the blockchain by the third thread, the valid transaction read/write set in the block previous to the current block is used and imported into the history database.
That is to say, in the current block writing-in process, for the operation of updating the history database of the blockchain by the third thread, the valid transaction read/write set in the block previous to the current block is used and imported into the history database.
[0088] As a preferred mode of execution in the embodiments of the present invention, the step of employing a third thread to update a status database of the blockchain according to the current block includes:
[0089] judging whether the operation to update the history database of the blockchain according to a block previous to the current block has been executed to completion, if yes, employing the third thread to update the status database of the blockchain according to the current block.
[0090] Specifically, it is required for the third thread to wait for the operation of updating the blockchain history database according to the block previous to the current block to have been executed to completion, and thereafter execute the operation of updating the status database of the blockchain according to the current block, so as to prevent block writing sequence error in the blockchain ledger from making it impossible for the blockchain network to reach consensus.
Date Recue/Date Received 2022-02-01
Date Recue/Date Received 2022-02-01
[0091] Specifically, it is so set in another mode of execution that the operation of updating the blockchain history database is executed by a fourth thread, so as to further enhance the overall transaction performance of the blockchain network. Since the operations of updating the blockchain status database and updating the blockchain history database are respectively executed by two different threads, it is possible for the third thread to immediately execute the task of updating the status database for the next block of the current block after receiving the task, without having to wait for the completion of updating the history database of the current block.
[0092] As a preferred mode of execution in the embodiments of the present invention, the step of employing a second thread to verify transaction endorsement of the current block includes:
[0093] verifying whether version numbers of all key values in a read/write set of all transactions in the current block are consistent with a version number of the current block.
[0094] As a preferred mode of execution in the embodiments of the present invention, the step of employing the second thread to write the verification result into the structure file includes:
[0095] employing the second thread to compile transactions that have passed verification into a preset array, and writing the preset array into the structure file.
[0096] Fig. 6 is a view schematically illustrating the structure of the device for writing blockchain data in parallel according to an exemplary embodiment. The device comprises:
[0097] a block receiving module, for receiving a current block to be processed;
[0098] a first processing module, for employing a first thread to write the current block into a structure file of a blockchain;
[0099] a second processing module, for simultaneously employing a second thread to verify transaction endorsement of the current block, and obtaining a verification result; and employing, if verification of the transaction endorsement is passed, the second thread to Date Recue/Date Received 2022-02-01 write the verification result into the structure file;
[0100] a third processing module, for employing a third thread to update a status database of the blockchain according to the current block; and
[0101] a thread monitoring module, for obtaining execution results of the first thread, the second thread and the third thread;
[0102] wherein the third processing module is further used for, if the execution results all exhibit successful executions, employing the third thread to update a history database of the blockchain according to the current block.
[0103] As a preferred mode of execution in the embodiments of the present invention, the thread monitoring module is specifically employed for:
[0104] employing a preset monitoring thread to monitor the first thread, the second thread and the third thread, and obtaining execution results of the first thread, the second thread and the third thread.
[0105] As a preferred mode of execution in the embodiments of the present invention, the thread monitoring module is further employed for:
[0106] notifying, if the preset monitoring thread monitors that anyone of the first thread, the second thread and the third thread has failed to execute, the other successfully executed threads to perform data rollback.
[0107] As a preferred mode of execution in the embodiments of the present invention, the third processing module is further employed for:
[0108] employing the third thread to update the history database of the blockchain according to a block previous to the current block.
[0109] As a preferred mode of execution in the embodiments of the present invention, the third processing module is specifically employed for:
Date Recue/Date Received 2022-02-01
Date Recue/Date Received 2022-02-01
[0110] judging whether the operation to update the history database of the blockchain according to a block previous to the current block has been executed to completion, if yes, employing the third thread to update the status database of the blockchain according to the current block.
[0111] As a preferred mode of execution in the embodiments of the present invention, the second processing module is specifically employed for:
[0112] verifying whether version numbers of all key values in a read/write set of all transactions in the current block are consistent with a version number of the current block.
[0113] As a preferred mode of execution in the embodiments of the present invention, the second processing module is specifically employed for:
[0114] employing the second thread to compile transactions that have passed verification into a preset array, and writing the preset array into the structure file.
[0115] Fig. 7 is a view schematically illustrating the internal structure of the computer equipment according to an exemplary embodiment. With reference to Fig. 7, the computer equipment comprises a processor, a memory, and a network interface connected to each other via a system bus. The processor of the computer equipment is employed to provide computing and controlling capabilities. The memory of the computer equipment includes a nonvolatile storage medium, and an internal memory. The nonvolatile storage medium stores therein an operating system, a computer program and a database. The internal memory provides environment for the running of the operating system and the computer program in the nonvolatile storage medium. The network interface of the computer equipment is employed to communicate with an external terminal via network connection.
The computer program realizes a method of optimizing an execution plan when it is executed by a processor.
Date Recue/Date Received 2022-02-01
The computer program realizes a method of optimizing an execution plan when it is executed by a processor.
Date Recue/Date Received 2022-02-01
[0116] As understandable to persons skilled in the art, the structure illustrated in Fig. 7 is merely a block diagram of partial structure relevant to the solution of the present invention, and does not constitute any restriction to the computer equipment on which the solution of the present invention is applied, as the specific computer equipment may comprise component parts that are more than or less than those illustrated in Fig. 7, or may combine certain component parts, or may have different layout of component parts.
[0117] As a preferred mode of execution in the embodiments of the present invention, the computer equipment comprises a memory, a processor and a computer program stored on the memory and operable on the processor, and the following steps are realized when the processor executes the computer program:
[0118] receiving a current block to be processed, employing a first thread to write the current block into a structure file of a blockchain, simultaneously employing a second thread to verify transaction endorsement of the current block, and obtaining a verification result;
[0119] employing, if verification of the transaction endorsement is passed, the second thread to write the verification result into the structure file, and simultaneously employing a third thread to update a status database of the blockchain according to the current block; and
[0120] obtaining execution results of the first thread, the second thread and the third thread, and, if the execution results all exhibit successful executions, employing the third thread to update a history database of the blockchain according to the current block.
[0121] As a preferred mode of execution in the embodiments of the present invention, when the processor executes the computer program, the following steps are further realized:
[0122] employing a preset monitoring thread to monitor the first thread, the second thread and the third thread, and obtaining execution results of the first thread, the second thread and the third thread.
[0123] As a preferred mode of execution in the embodiments of the present invention, when the processor executes the computer program, the following step is further realized:
Date Recue/Date Received 2022-02-01
Date Recue/Date Received 2022-02-01
[0124] notifying, if the preset monitoring thread monitors that anyone of the first thread, the second thread and the third thread has failed to execute, the other successfully executed threads to perform data rollback.
[0125] As a preferred mode of execution in the embodiments of the present invention, when the processor executes the computer program, the following step is further realized:
[0126] employing the third thread to update the history database of the blockchain according to a block previous to the current block.
[0127] As a preferred mode of execution in the embodiments of the present invention, when the processor executes the computer program, the following steps are further realized:
[0128] judging whether the operation to update the history database of the blockchain according to a block previous to the current block has been executed to completion, if yes, employing the third thread to update the status database of the blockchain according to the current block.
[0129] As a preferred mode of execution in the embodiments of the present invention, when the processor executes the computer program, the following step is further realized:
[0130] verifying whether version numbers of all key values in a read/write set of all transactions in the current block are consistent with a version number of the current block.
[0131] As a preferred mode of execution in the embodiments of the present invention, when the processor executes the computer program, the following steps are further realized:
[0132] employing the second thread to compile transactions that have passed verification into a preset array, and writing the preset array into the structure file.
[0133] In the embodiments of the present invention, there is further provided a computer-readable storage medium storing thereon a computer program, and the following steps are realized when the computer program is executed by a processor:
Date Recue/Date Received 2022-02-01
Date Recue/Date Received 2022-02-01
[0134] receiving a current block to be processed, employing a first thread to write the current block into a structure file of a blockchain, simultaneously employing a second thread to verify transaction endorsement of the current block, and obtaining a verification result;
[0135] employing, if verification of the transaction endorsement is passed, the second thread to write the verification result into the structure file, and simultaneously employing a third thread to update a status database of the blockchain according to the current block; and
[0136] obtaining execution results of the first thread, the second thread and the third thread, and, if the execution results all exhibit successful executions, employing the third thread to update a history database of the blockchain according to the current block.
[0137] As a preferred mode of execution in the embodiments of the present invention, when the computer program is executed by a processor, the following steps are further realized:
[0138] employing a preset monitoring thread to monitor the first thread, the second thread and the third thread, and obtaining execution results of the first thread, the second thread and the third thread.
[0139] As a preferred mode of execution in the embodiments of the present invention, when the computer program is executed by a processor, the following step is further realized:
[0140] notifying, if the preset monitoring thread monitors that anyone of the first thread, the second thread and the third thread has failed to execute, the other successfully executed threads to perform data rollback.
[0141] As a preferred mode of execution in the embodiments of the present invention, when the computer program is executed by a processor, the following step is further realized:
[0142] employing the third thread to update the history database of the blockchain according to a block previous to the current block.
[0143] As a preferred mode of execution in the embodiments of the present invention, when the computer program is executed by a processor, the following steps are further realized:
Date Recue/Date Received 2022-02-01
Date Recue/Date Received 2022-02-01
[0144] judging whether the operation to update the history database of the blockchain according to a block previous to the current block has been executed to completion, if yes, employing the third thread to update the status database of the blockchain according to the current block.
[0145] As a preferred mode of execution in the embodiments of the present invention, when the computer program is executed by a processor, the following step is further realized:
[0146] verifying whether version numbers of all key values in a read/write set of all transactions in the current block are consistent with a version number of the current block.
[0147] As a preferred mode of execution in the embodiments of the present invention, when the computer program is executed by a processor, the following steps are further realized:
[0148] employing the second thread to compile transactions that have passed verification into a preset array, and writing the preset array into the structure file.
[0149] To sum it up, the technical solutions provided by the embodiments of the present invention bring about the following advantageous effects.
[0150] In the method and device for writing blockchain data in parallel, and corresponding computer equipment and storage medium provided by the embodiments of the present invention, by receiving a current block to be processed, employing a first thread to write the current block into a structure file of a blockchain, simultaneously employing a second thread to verify transaction endorsement of the current block, obtaining a verification result, employing, if verification of the transaction endorsement is passed, the second thread to write the verification result into the structure file, simultaneously employing a third thread to update a status database of the blockchain according to the current block, obtaining execution results of the first thread, the second thread and the third thread, and, if the execution results all exhibit successful executions, employing the third thread to update a history database of the blockchain according to the current block, namely, Date Recue/Date Received 2022-02-01 through coordinated operations of a plurality of threads, the present invention counts it as one correct ledger writing-in only when all threads have successfully executed, thereby ledgers of various nodes are maintained consistent, while the overall transaction performance of the blockchain network is enhanced, transaction delay is reduced, computational tasks of the blockchain are flexibly allocated, plural CPUs are allowed to simultaneously process received plural pieces of transaction data, and waste of computational resources of the server is avoided.
[0151] Moreover, in the method and device for writing blockchain data in parallel, and corresponding computer equipment and storage medium provided by the embodiments of the present invention, by employing a first thread to write the current block into a structure file of a blockchain, simultaneously employing a second thread to verify transaction endorsement of the current block, obtaining a verification result, and employing the third thread to update the history database of the blockchain according to a block previous to the current block, writing-in operations of two adjacent blocks can as well be partially concurrently executed, whereby transaction processing speed of blockchain nodes is enhanced, so that the blockchain technology can be applied to such highly concurrent and quasi real-time transaction fields as the traditional retail payment, and application scenarios of the blockchain technology are broadened.
[0152] As should be noted, when the device for writing blockchain data in parallel provided by the aforementioned embodiment triggers a writing-in business, it is merely exemplarily described with its division into the aforementioned various functional modules, whereas in actual application it is possible to base on requirements to assign the aforementioned functions to different functional modules for completion, that is to say, the internal structure of the device is divided into different functional modules to complete the entire or partial functions as described above. In addition, the device for writing blockchain data in parallel provided by the aforementioned embodiment pertains to the same inventive conception as the method of writing blockchain data in parallel, in other words, the device Date Recue/Date Received 2022-02-01 is based on the method of writing blockchain data in parallel ¨ see the method embodiment for its specific implementation process, while no repetition will be made in this context.
[0153] As comprehensible to persons ordinarily skilled in the art, the entire or partial steps in the aforementioned embodiments can be completed via hardware, or via a program instructing relevant hardware, the program can be stored in a computer-readable storage medium, and the storage medium can be a read-only memory, a magnetic disk or an optical disk, etc.
[0154] The foregoing embodiments are merely preferred embodiments of the present invention, and they are not to be construed as restrictive to the present invention. Any amendment, equivalent substitution, and improvement makeable within the spirit and principle of the present invention shall all fall within the protection scope of the present invention.
Date Recue/Date Received 2022-02-01
Date Recue/Date Received 2022-02-01
Claims (64)
1. A method comprising:
receiving a current block to be processed;
employing a first thread to write the current block into a structure file of a blockchain, simultaneously employing a second thread to verify transaction endorsement of the current block;
obtaining a verification result;
employing, if the verification of the transaction endorsement is passed, the second thread to write a verification result into the structure file, and simultaneously employing a third thread to update a status database of a blockchain according to the current block; and obtaining execution results of the first thread, the second thread and the third thread, and, if all the execution results exhibit successful executions, employing the third thread to update a history database of the blockchain according to the current block.
receiving a current block to be processed;
employing a first thread to write the current block into a structure file of a blockchain, simultaneously employing a second thread to verify transaction endorsement of the current block;
obtaining a verification result;
employing, if the verification of the transaction endorsement is passed, the second thread to write a verification result into the structure file, and simultaneously employing a third thread to update a status database of a blockchain according to the current block; and obtaining execution results of the first thread, the second thread and the third thread, and, if all the execution results exhibit successful executions, employing the third thread to update a history database of the blockchain according to the current block.
2. The method of claim 1, wherein the step of obtaining execution results of the first thread, the second thread and the third thread comprises:
employing a preset monitoring thread to monitor the first thread, the second thread and the third thread; and obtaining execution results of the first thread, the second thread and the third thread.
employing a preset monitoring thread to monitor the first thread, the second thread and the third thread; and obtaining execution results of the first thread, the second thread and the third thread.
3. The method of claim 2, further comprises:
notifying, if the preset monitoring thread monitors that any one of the first thread, the second thread and the third thread has failed to execute, the other successfully executed threads to perform data rollback.
Date Recue/Date Received 2022-04-05
notifying, if the preset monitoring thread monitors that any one of the first thread, the second thread and the third thread has failed to execute, the other successfully executed threads to perform data rollback.
Date Recue/Date Received 2022-04-05
4. The method of any one of claims 1 to 3, wherein employing the first thread to write the current block into the structure file of the blockchain, simultaneously employing the second thread to verify the transaction endorsement of the current block, and obtaining the verification result, further comprises:
employing the third thread to update the history database of the blockchain according to a block previous to the current block.
employing the third thread to update the history database of the blockchain according to a block previous to the current block.
5. The method of claim 4, wherein employing the third thread to update the status database of the blockchain according to the current block comprises:
judging whether the operation to update the history database of the blockchain according to the block previous to the current block has been executed to completion, if yes, employing the third thread to update the status database of the blockchain according to the current block.
judging whether the operation to update the history database of the blockchain according to the block previous to the current block has been executed to completion, if yes, employing the third thread to update the status database of the blockchain according to the current block.
6. The method of any one of claims 1 to 3, wherein employing the second thread to verify transaction endorsement of the current block comprises:
verifying whether version numbers of all key values in a read/write set of all transactions in the current block are consistent with a version number of the current block.
verifying whether version numbers of all key values in a read/write set of all transactions in the current block are consistent with a version number of the current block.
7. The method of any one of claims 1 to 3, wherein employing the second thread to write the verification result into the structure file comprises:
employing the second thread to compile transactions that have passed verification into a preset array; and writing the preset array into the structure file.
employing the second thread to compile transactions that have passed verification into a preset array; and writing the preset array into the structure file.
8. The method of any one of claims 1 to 7, wherein the verification items of the read/write set includes whether results of range query are consistent with the execution result wherein the results of range query indicate range query results contained in all transactions in the received current block.
Date Recue/Date Received 2022-04-05
Date Recue/Date Received 2022-04-05
9. The method of any one of claims 1 to 8, wherein each transaction in the block contains a read/write dataset, wherein the read set includes a key-value pair array that is read from the ledger during execution of the transaction, and the write set includes a key-value pair array that is written to the ledger during execution of the transaction.
10. The method of any one of claims 1 to 9, wherein the second thread compiles the transactions that have passed verification into a transaction valid tag array according to the verification result of the transaction endorsements of the current block, and subsequently writes the array into the local blockchain structure file.
11. The method of any one of claims 1 to 10, wherein a plurality of threads, including one or more of the first thread, the second thread, and the third thread, is preconfigured, to configure each thread to execute different operations in the ledger writing-in process, wherein the first thread executes the local blockchain structure file writing-in operation, the second thread executes the operation of verifying the transaction endorsement and the operation of writing the verification result, and the third thread executes the operations of updating the status database and the history database of the blockchain.
12. The method of any one of claims 1 to 11, wherein the first thread and the second thread both involve the writing-in of the local blockchain structure file, wherein the block itself and the verification result of the transaction endorsement are respectively stored, wherein writing-in is directed to different blockchain structure files.
13. The method of any one of claims 1 to 12, wherein data stored in the status database includes, one or more of, the newest values of all keys after all transactions contained in the current ledger have been executed to completion.
14. The method of any one of claims 1 to 13, wherein the history database is for query by users only, wherein it is not allowed for users to write, wherein the operation of updating the blockchain history database is executed by a fourth thread set up according to actual business requirements.
Date Recue/Date Received 2022-04-05
Date Recue/Date Received 2022-04-05
15. The method of any one of claims 1 to 14, wherein data stored in the history database includes, one or more of, change in the versions of keys, wherein a certain key is changed in a certain transaction of a certain block, only the change action is recorded, while the change itself is not executed.
16. The method of any one of claims 1 to 15, wherein the preset monitoring thread is embodied as a separate thread to execute the monitoring operation, and is embodied as a first thread to undertake the monitoring operation among other operation, wherein it is freely selectable by users as practically required.
17. A device comprising:
a block receiving module, for receiving a current block to be processed;
a first processing module, for employing a first thread to write the current block into a structure file of a blockchain;
a second processing module, for:
simultaneously employing a second thread to verify transaction endorsement of the current block;
obtaining a verification result; and employing, if the verification of the transaction endorsement is passed, the second thread to write the verification result into the structure file;
a third processing module, for employing a third thread to update a status database of the blockchain according to the current block; and a thread monitoring module, for obtaining execution results of the first thread, the second thread and the third thread;
Date Recue/Date Received 2022-04-05 wherein the third processing module is further configured for, if all the execution results exhibit successful executions, employing the third thread to update a history database of the blockchain according to the current block.
a block receiving module, for receiving a current block to be processed;
a first processing module, for employing a first thread to write the current block into a structure file of a blockchain;
a second processing module, for:
simultaneously employing a second thread to verify transaction endorsement of the current block;
obtaining a verification result; and employing, if the verification of the transaction endorsement is passed, the second thread to write the verification result into the structure file;
a third processing module, for employing a third thread to update a status database of the blockchain according to the current block; and a thread monitoring module, for obtaining execution results of the first thread, the second thread and the third thread;
Date Recue/Date Received 2022-04-05 wherein the third processing module is further configured for, if all the execution results exhibit successful executions, employing the third thread to update a history database of the blockchain according to the current block.
18. The device of claim 17, further comprises a thread monitoring module configured to:
employ a preset monitoring thread to monitor the first thread, the second thread and the third thread; and obtain execution results of the first thread, the second thread and the third thread.
employ a preset monitoring thread to monitor the first thread, the second thread and the third thread; and obtain execution results of the first thread, the second thread and the third thread.
19. The device of claim 18, wherein the thread monitoring module is further configured to notify, if the preset monitoring thread monitors that any one of the first thread, the second thread and the third thread has failed to execute, the other successfully executed threads to perform data rollback.
20. The device of any one of claims 17 to 19, wherein the third processing module is further configured to employ the third thread to update the history database of the blockchain according to a block previous to the current block.
21. The device of claim 20, wherein the third processing module is further configured to judge whether the operation to update the history database of the blockchain according to a block previous to the current block has been executed to completion, if yes, employing the third thread to update the status database of the blockchain according to the current block.
22. The device of any one of claims 17 to 19, wherein the second processing module is configured to verify whether version numbers of all key values in a read/write set of all transactions in the current block are consistent with a version number of the current block.
23. The device of any one of claims 17 to 19, wherein the second processing module is configured to employ the second thread to compile transactions that have passed verification into a preset array, and writing the preset array into the structure file.
Date Recue/Date Received 2022-04-05
Date Recue/Date Received 2022-04-05
24. The device of any one of claims 17 to 23, wherein the verification items of the read/write set includes whether results of range query are consistent with the execution result wherein the results of range query indicate range query results contained in all transactions in the received current block.
25. The device of any one of claims 17 to 24, wherein each transaction in the block contains a read/write dataset, wherein the read set includes a key-value pair array that is read from the ledger during execution of the transaction, and the write set includes a key-value pair array that is written to the ledger during execution of the transaction.
26. The device of any one of claims 17 to 25, wherein the second thread compiles the transactions that have passed verification into a transaction valid tag array according to the verification result of the transaction endorsements of the current block, and subsequently writes the array into the local blockchain structure file.
27. The device of any one of claims 17 to 26, wherein a plurality of threads, including one or more of the first thread, the second thread, and the third thread, is preconfigured, to configure each thread to execute different operations in the ledger writing-in process, wherein the first thread executes the local blockchain structure file writing-in operation, the second thread executes the operation of verifying the transaction endorsement and the operation of writing the verification result, and the third thread executes the operations of updating the status database and the history database of the blockchain.
28. The device of any one of claims 17 to 27, wherein the first thread and the second thread both involve the writing-in of the local blockchain structure file, wherein the block itself and the verification result of the transaction endorsement are respectively stored, wherein writing-in is directed to different blockchain structure files.
29. The device of any one of claims 17 to 28, wherein data stored in the status database includes, one or more of, the newest values of all keys after all transactions contained in the current ledger have been executed to completion.
Date Recue/Date Received 2022-04-05
Date Recue/Date Received 2022-04-05
30. The device of any one of claims 17 to 29, wherein the history database is for query by users only, wherein it is not allowed for users to write, wherein the operation of updating the blockchain history database is executed by a fourth thread set up according to actual business requirements.
31. The device of any one of claims 17 to 30, wherein data stored in the history database includes, one or more of, change in the versions of keys, wherein a certain key is changed in a certain transaction of a certain block, only the change action is recorded, while the change itself is not executed.
32. The device of any one of claims 17 to 31, wherein the preset monitoring thread is embodied as a separate thread to execute the monitoring operation, and is embodied as a first thread to undertake the monitoring operation among other operation, wherein it is freely selectable by users as practically required.
33. A computer equipment comprising:
a memory, wherein the memory includes a nonvolatile storage medium, and an internal memory, wherein the nonvolatile storage medium stores therein an operating system, a computer program and a database, wherein the internal memory provides environment for the running of the operating system and the computer program in the nonvolatile storage medium;
a processor, wherein the processor is configured to provide computing and controlling capabilities;
a network interface connected to each other via a system bus, wherein the network interface is configured to communicate with an external terminal via network connection;
the computer program stored on the memory and executed by the processor configured to:
receive a current block to be processed;
Date Recue/Date Received 2022-04-05 employ a first thread to write the current block into a structure file of a blockchain, simultaneously employing a second thread to verify transaction endorsement of the current block;
obtain a verification result;
employ, if the verification of the transaction endorsement is passed, the second thread to write a verification result into the structure file, and simultaneously employing a third thread to update a status database of a blockchain according to the current block; and obtain execution results of the first thread, the second thread and the third thread, and, if all the execution results exhibit successful executions, employing the third thread to update a history database of the blockchain according to the current block.
a memory, wherein the memory includes a nonvolatile storage medium, and an internal memory, wherein the nonvolatile storage medium stores therein an operating system, a computer program and a database, wherein the internal memory provides environment for the running of the operating system and the computer program in the nonvolatile storage medium;
a processor, wherein the processor is configured to provide computing and controlling capabilities;
a network interface connected to each other via a system bus, wherein the network interface is configured to communicate with an external terminal via network connection;
the computer program stored on the memory and executed by the processor configured to:
receive a current block to be processed;
Date Recue/Date Received 2022-04-05 employ a first thread to write the current block into a structure file of a blockchain, simultaneously employing a second thread to verify transaction endorsement of the current block;
obtain a verification result;
employ, if the verification of the transaction endorsement is passed, the second thread to write a verification result into the structure file, and simultaneously employing a third thread to update a status database of a blockchain according to the current block; and obtain execution results of the first thread, the second thread and the third thread, and, if all the execution results exhibit successful executions, employing the third thread to update a history database of the blockchain according to the current block.
34. The equipment of claim 33, wherein the step of obtaining execution results of the first thread, the second thread and the third thread comprises:
employing a preset monitoring thread to monitor the first thread, the second thread and the third thread; and obtaining execution results of the first thread, the second thread and the third thread.
employing a preset monitoring thread to monitor the first thread, the second thread and the third thread; and obtaining execution results of the first thread, the second thread and the third thread.
35. The equipment of claim 34, further comprises:
notifying, if the preset monitoring thread monitors that any one of the first thread, the second thread and the third thread has failed to execute, the other successfully executed threads to perform data rollback.
notifying, if the preset monitoring thread monitors that any one of the first thread, the second thread and the third thread has failed to execute, the other successfully executed threads to perform data rollback.
36. The equipment of any one of claims 33 to 35, wherein employing the first thread to write the current block into the structure file of the blockchain, simultaneously employing the second thread to verify the transaction endorsement of the current block, and obtaining the verification result, further comprises:
Date Recue/Date Received 2022-04-05 employing the third thread to update the history database of the blockchain according to a block previous to the current block.
Date Recue/Date Received 2022-04-05 employing the third thread to update the history database of the blockchain according to a block previous to the current block.
37. The equipment of claim 36, wherein employing the third thread to update the status database of the blockchain according to the current block comprises:
judging whether the operation to update the history database of the blockchain according to the block previous to the current block has been executed to completion, if yes, employing the third thread to update the status database of the blockchain according to the current block.
judging whether the operation to update the history database of the blockchain according to the block previous to the current block has been executed to completion, if yes, employing the third thread to update the status database of the blockchain according to the current block.
38. The equipment of any one of claims 33 to 35, wherein employing the second thread to verify transaction endorsement of the current block comprises:
verifying whether version numbers of all key values in a read/write set of all transactions in the current block are consistent with a version number of the current block.
verifying whether version numbers of all key values in a read/write set of all transactions in the current block are consistent with a version number of the current block.
39. The equipment of any one of claims 33 to 35, wherein employing the second thread to write the verification result into the structure file comprises:
employing the second thread to compile transactions that have passed verification into a preset array; and writing the preset array into the structure file.
employing the second thread to compile transactions that have passed verification into a preset array; and writing the preset array into the structure file.
40. The equipment of any one of claims 33 to 39, wherein the verification items of the read/write set includes whether results of range query are consistent with the execution result wherein the results of range query indicate range query results contained in all transactions in the received current block.
41. The equipment of any one of claims 33 to 40, wherein each transaction in the block contains a read/write dataset, wherein the read set includes a key-value pair array that is read from the ledger during execution of the transaction, and the write set includes a key-value pair array that is written to the ledger during execution of the transaction.
Date Recue/Date Received 2022-04-05
Date Recue/Date Received 2022-04-05
42. The equipment of any one of claims 33 to 41, wherein the second thread compiles the transactions that have passed verification into a transaction valid tag array according to the verification result of the transaction endorsements of the current block, and subsequently writes the array into the local blockchain structure file.
43. The equipment of any one of claims 33 to 42, wherein a plurality of threads, including one or more of the first thread, the second thread, and the third thread, is preconfigured, to configure each thread to execute different operations in the ledger writing-in process, wherein the first thread executes the local blockchain structure file writing-in operation, the second thread executes the operation of verifying the transaction endorsement and the operation of writing the verification result, and the third thread executes the operations of updating the status database and the history database of the blockchain.
44. The equipment of any one of claims 33 to 43, wherein the first thread and the second thread both involve the writing-in of the local blockchain structure file, wherein the block itself and the verification result of the transaction endorsement are respectively stored, wherein writing-in is directed to different blockchain structure files.
45. The equipment of any one of claims 33 to 44, wherein data stored in the status database includes, one or more of, the newest values of all keys after all transactions contained in the current ledger have been executed to completion.
46. The equipment of any one of claims 33 to 45, wherein the history database is for query by users only, wherein it is not allowed for users to write, wherein the operation of updating the blockchain history database is executed by a fourth thread set up according to actual business requirements.
47. The equipment of any one of claims 33 to 46, wherein data stored in the history database includes, one or more of, change in the versions of keys, wherein a certain key is changed in a certain transaction of a certain block, only the change action is recorded, while the change itself is not executed.
Date Recue/Date Received 2022-04-05
Date Recue/Date Received 2022-04-05
48. The equipment of any one of claims 33 to 47, wherein the preset monitoring thread is embodied as a separate thread to execute the monitoring operation, and is embodied as a first thread to undertake the monitoring operation among other operation, wherein it is freely selectable by users as practically required.
49. A readable computer storage medium with computer programs stored thereon configured to:
receive a current block to be processed;
employ a first thread to write the current block into a structure file of a blockchain, simultaneously employing a second thread to verify transaction endorsement of the current block;
obtain a verification result;
employ, if the verification of the transaction endorsement is passed, the second thread to write a verification result into the structure file, and simultaneously employing a third thread to update a status database of a blockchain according to the current block; and obtain execution results of the first thread, the second thread and the third thread, and, if all the execution results exhibit successful executions, employing the third thread to update a history database of the blockchain according to the current block.
receive a current block to be processed;
employ a first thread to write the current block into a structure file of a blockchain, simultaneously employing a second thread to verify transaction endorsement of the current block;
obtain a verification result;
employ, if the verification of the transaction endorsement is passed, the second thread to write a verification result into the structure file, and simultaneously employing a third thread to update a status database of a blockchain according to the current block; and obtain execution results of the first thread, the second thread and the third thread, and, if all the execution results exhibit successful executions, employing the third thread to update a history database of the blockchain according to the current block.
50. The storage medium of claim 49, wherein the step of obtaining execution results of the first thread, the second thread and the third thread comprises:
employing a preset monitoring thread to monitor the first thread, the second thread and the third thread; and obtaining execution results of the first thread, the second thread and the third thread.
employing a preset monitoring thread to monitor the first thread, the second thread and the third thread; and obtaining execution results of the first thread, the second thread and the third thread.
51. The storage medium of claim 50, further comprises:
Date Recue/Date Received 2022-04-05 notifying, if the preset monitoring thread monitors that any one of the first thread, the second thread and the third thread has failed to execute, the other successfully executed threads to perform data rollback.
Date Recue/Date Received 2022-04-05 notifying, if the preset monitoring thread monitors that any one of the first thread, the second thread and the third thread has failed to execute, the other successfully executed threads to perform data rollback.
52. The storage medium of any one of claims 49 to 51, wherein employing the first thread to write the current block into the structure file of the blockchain, simultaneously employing the second thread to verify the transaction endorsement of the current block, and obtaining the verification result, further comprises:
employing the third thread to update the history database of the blockchain according to a block previous to the current block.
employing the third thread to update the history database of the blockchain according to a block previous to the current block.
53. The storage medium of claim 52, wherein employing the third thread to update the status database of the blockchain according to the current block comprises:
judging whether the operation to update the history database of the blockchain according to the block previous to the current block has been executed to completion, if yes, employing the third thread to update the status database of the blockchain according to the current block.
judging whether the operation to update the history database of the blockchain according to the block previous to the current block has been executed to completion, if yes, employing the third thread to update the status database of the blockchain according to the current block.
54. The storage medium of any one of claims 33 to 53, wherein employing the second thread to verify transaction endorsement of the current block comprises:
verifying whether version numbers of all key values in a read/write set of all transactions in the current block are consistent with a version number of the current block.
verifying whether version numbers of all key values in a read/write set of all transactions in the current block are consistent with a version number of the current block.
55. The storage medium of any one of claims 33 to 54, wherein employing the second thread to write the verification result into the structure file comprises:
employing the second thread to compile transactions that have passed verification into a preset array; and writing the preset array into the structure file.
Date Recue/Date Received 2022-04-05
employing the second thread to compile transactions that have passed verification into a preset array; and writing the preset array into the structure file.
Date Recue/Date Received 2022-04-05
56. The storage medium of any one of claims 33 to 55, wherein the verification items of the read/write set includes whether results of range query are consistent with the execution result wherein the results of range query indicate range query results contained in all transactions in the received current block.
57. The storage medium of any one of claims 33 to 56, wherein each transaction in the block contains a read/write dataset, wherein the read set includes a key-value pair array that is read from the ledger during execution of the transaction, and the write set includes a key-value pair array that is written to the ledger during execution of the transaction.
58. The storage medium of any one of claims 33 to 57, wherein the second thread compiles the transactions that have passed verification into a transaction valid tag array according to the verification result of the transaction endorsements of the current block, and subsequently writes the array into the local blockchain structure file.
59. The storage medium of any one of claims 33 to 58, wherein a plurality of threads, including one or more of the first thread, the second thread, and the third thread, is preconfigured, to configure each thread to execute different operations in the ledger writing-in process, wherein the first thread executes the local blockchain structure file writing-in operation, the second thread executes the operation of verifying the transaction endorsement and the operation of writing the verification result, and the third thread executes the operations of updating the status database and the history database of the blockchain.
60. The storage medium of any one of claims 33 to 59, wherein the first thread and the second thread both involve the writing-in of the local blockchain structure file, wherein the block itself and the verification result of the transaction endorsement are respectively stored, wherein writing-in is directed to different blockchain structure files.
61. The storage medium of any one of claims 33 to 60, wherein data stored in the status database includes, one or more of, the newest values of all keys after all transactions contained in the current ledger have been executed to completion.
Date Recue/Date Received 2022-04-05
Date Recue/Date Received 2022-04-05
62. The storage medium of any one of claims 33 to 61, wherein the history database is for query by users only, wherein it is not allowed for users to write, wherein the operation of updating the blockchain history database is executed by a fourth thread set up according to actual business requirements.
63. The storage medium of any one of claims 33 to 62, wherein data stored in the history database includes, one or more of, change in the versions of keys, wherein a certain key is changed in a certain transaction of a certain block, only the change action is recorded, while the change itself is not executed.
64. The storage medium of any one of claims 33 to 63, wherein the preset monitoring thread is embodied as a separate thread to execute the monitoring operation, and is embodied as a first thread to undertake the monitoring operation among other operation, wherein it is freely selectable by users as practically required.
Date Recue/Date Received 2022-04-05
Date Recue/Date Received 2022-04-05
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110140335.3 | 2021-02-01 | ||
CN202110140335.3A CN113157710B (en) | 2021-02-01 | 2021-02-01 | Block chain data parallel writing method and device, computer equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CA3147339A1 true CA3147339A1 (en) | 2022-08-01 |
CA3147339C CA3147339C (en) | 2023-03-14 |
Family
ID=76879176
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CA3147339A Active CA3147339C (en) | 2021-02-01 | 2022-02-01 | Method and device for writing blockchain data in parallel, computer equipment and storage medium thereof |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN113157710B (en) |
CA (1) | CA3147339C (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117294757A (en) * | 2023-11-27 | 2023-12-26 | 山东省计算中心(国家超级计算济南中心) | Complex service splitting execution method, system, equipment and medium based on block chain |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113505000B (en) * | 2021-09-08 | 2021-12-21 | 广东卓启云链科技有限公司 | Multithreading processing method, device, system and storage medium in block chain |
CN116662276B (en) * | 2023-06-06 | 2024-03-05 | 中科三清科技有限公司 | Data processing method, device, electronic equipment and storage medium |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110457123B (en) * | 2018-09-13 | 2021-06-15 | 腾讯科技(深圳)有限公司 | Control method and device for block processing task |
CN109285006A (en) * | 2018-09-20 | 2019-01-29 | 中链科技有限公司 | A kind of parallel proof processing method and processing device of block chain data |
CN110765193B (en) * | 2019-10-22 | 2024-03-15 | 深圳前海微众银行股份有限公司 | Block chain data export method and device |
CN112231105B (en) * | 2020-10-26 | 2023-10-27 | 中国工商银行股份有限公司 | Block writing method and system based on block chain |
-
2021
- 2021-02-01 CN CN202110140335.3A patent/CN113157710B/en active Active
-
2022
- 2022-02-01 CA CA3147339A patent/CA3147339C/en active Active
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117294757A (en) * | 2023-11-27 | 2023-12-26 | 山东省计算中心(国家超级计算济南中心) | Complex service splitting execution method, system, equipment and medium based on block chain |
CN117294757B (en) * | 2023-11-27 | 2024-02-20 | 山东省计算中心(国家超级计算济南中心) | Complex service splitting execution method, system, equipment and medium based on block chain |
Also Published As
Publication number | Publication date |
---|---|
CN113157710A (en) | 2021-07-23 |
CA3147339C (en) | 2023-03-14 |
CN113157710B (en) | 2022-08-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CA3147339C (en) | Method and device for writing blockchain data in parallel, computer equipment and storage medium thereof | |
US20200177373A1 (en) | System and method for storing contract data structures on permissioned distributed ledgers | |
KR102013004B1 (en) | Dynamic load balancing in a scalable environment | |
US8417991B2 (en) | Mitigating reduction in availability level during maintenance of nodes in a cluster | |
KR102013005B1 (en) | Managing partitions in a scalable environment | |
US12007866B2 (en) | System and method for database replication benchmark testing using a pipeline-based microservices model | |
US9256460B2 (en) | Selective checkpointing of links in a data flow based on a set of predefined criteria | |
Thakkar et al. | Scaling hyperledger fabric using pipelined execution and sparse peers | |
US9189355B1 (en) | Method and system for processing a service request | |
AU2021203955B2 (en) | Dynamic component performance monitoring | |
US20140280441A1 (en) | Data integration on retargetable engines in a networked environment | |
AU2013344538B2 (en) | Dynamic graph performance monitoring | |
WO2021066948A1 (en) | Real time multi-tenant workload tracking and auto throttling | |
CN113157411B (en) | Celery-based reliable configurable task system and device | |
Wang | Stream processing systems benchmark: Streambench | |
Chung et al. | Performance tuning and scaling enterprise blockchain applications | |
Thakkar et al. | Scaling blockchains using pipelined execution and sparse peers | |
Kleiminger | Stream processing in the cloud | |
US11698914B1 (en) | Serverless managed bulk import on a global NoSQL database with selective back pressure | |
Litchfield et al. | Distributed relational database performance in cloud computing: An investigative study | |
Dam et al. | SQL server 2008 query performance tuning distilled | |
US20240176651A1 (en) | Auto time optimization for migration of applications | |
Blöcher et al. | ROME: All Overlays Lead to Aggregation, but Some Are Faster than Others | |
Ma et al. | Key-Based Transaction Reordering: An Optimized Approach for Concurrency Control in Hyperledger Fabric | |
Kayode et al. | Performance Evaluation and Tuning Strategies for High Availability Messaging Infrastructures: A Case Study with Zookeeper and Kafka |