Deferred update of database hashcode in blockchain
Gespeichert in:
| Titel: | Deferred update of database hashcode in blockchain |
|---|---|
| Patent Number: | 10877,962 |
| Publikationsdatum: | December 29, 2020 |
| Appl. No: | 15/674629 |
| Application Filed: | August 11, 2017 |
| Abstract: | A computer-implemented method for updating a database in a blockchain system to add a block to a blockchain may include: adding an update query to the database as a data item upon receiving the update query to update the database; calculating a hash value based on data items stored in the database, the stored data items including the added data item of the update query; and adding a new block to the blockchain using the hash value. |
| Inventors: | International Business Machines Corporation (Armonk, NY, US) |
| Assignees: | International Business Machines Corporation (Armonk, NY, US) |
| Claim: | 1. A computer-implemented method for updating a first database in a blockchain system to add a block to a blockchain, comprising: adding a first update query to the first database as a data item upon receiving the first update query to update the first database; calculating a first hash value based on data items stored in the first database, the stored data items including the added data item of the first update query; adding, using a first thread, a new block to the blockchain using the first hash value; generating a second database by copying the first database using copy-on-write techniques; updating, using a second thread, the second database according to the added data item of the first update query; calculating a second hash value based on data items stored in the updated second database; adding a second new block to the blockchain using the second hash value; determining, in response to the second new block addition, a threshold number of added new blocks has been met, wherein the threshold is determined according to one or more properties of the first update query; and replacing, in response to the determination, the first database with the second database. |
| Claim: | 2. The method according to claim 1 , further comprising: replacing the first database with the second database at a predetermined timing. |
| Claim: | 3. The method according to claim 1 , further comprising: replacing the first database with the second database when a predetermined number of blocks are added to the block chain. |
| Claim: | 4. The method according to claim 1 , wherein the blockchain system comprises a plurality of nodes connected to each other via a network, each of the nodes comprises the first database and second database, the second database being a copy of the first database, and the first database is replaced with the second database when a predetermined number of blocks are added to the block chain. |
| Claim: | 5. The method according to claim 1 , further comprising: determining not to add a second update query to the database as the data item according to an attribute of the second update query; updating the first database according to the second update query; calculating a non-added hash value based on the updated first database according to the second update query; and adding a third new block to the blockchain using the non-added hash value. |
| Claim: | 6. A computer program product for updating a first database in a blockchain system to add a block to a blockchain, the computer program product comprising a computer readable storage medium having program instructions embodied therewith, the program instructions executable by a computer to cause the computer to: add a first update query to the first database as a data item upon receiving the first update query to update the first database; calculate a first hash value based on data items stored in the first database, the stored data items including the added data item of the first update query; add, using a first thread, a new block to the blockchain using the first hash value; generate a second database by copying the first database using copy-on-write techniques; update, using a second thread, the second database according to the added data item of the first update query; calculate a second hash value based on data items stored in the updated second database; add a second new block to the blockchain using the second hash value; determine, in response to the second new block addition, a threshold number of added new blocks has been met, wherein the threshold is determined according to one or more properties of the first update query; and replace, in response to the determination, the first database with the second database. |
| Claim: | 7. The computer program product according to claim 6 , the program instructions executable by a computer to further cause the computer to: replace the first database with the second database at a predetermined timing. |
| Claim: | 8. The computer program product according to claim 6 , the program instructions executable by a computer to further cause the computer to: replace the first database with the second database when a predetermined number of blocks are added to the blockchain. |
| Claim: | 9. The computer program product according to claim 6 , wherein the blockchain system comprises a plurality of nodes connected to each other via a network, each of the nodes comprises the first database and second database, the second database being a copy of the first database, and the first database is replaced with the second database when a predetermined number of blocks are added to the block chain. |
| Claim: | 10. The computer program product according to claim 6 , the program instructions executable by a computer to further cause the computer to: determine not to add a second update query to the database as the data item according to an attribute of the second update query; update the first database according to the second update query; calculate a non-added hash value based on the updated first database according to the second update query; and add a third new block to the blockchain using the non-added hash value. |
| Claim: | 11. A system for a blockchain system to add a block to a blockchain, the system comprising: a memory with program instructions stored thereon; and a processor in communication with the memory, wherein the system is configured to perform a method, the method comprising: adding a first update query to the first database as a data item upon receiving the first update query to update the first database; calculating a first hash value based on data items stored in the first database, the stored data items including the added data item of the first update query; adding, using a first thread, a new block to the blockchain using the first hash value; generating a second database by copying the first database using copy-on-write techniques; updating, using a second thread, the second database according to the added data item of the first update query; calculating a second hash value based on data items stored in the updated second database; adding a second new block to the blockchain using the second hash value; determining, in response to the second new block addition, a threshold number of added new blocks has been met, wherein the threshold is determined according to one or more properties of the first update query; and replacing, in response to the determination, the first database with the second database. |
| Claim: | 12. The system according to claim 11 , wherein the method further comprises: replacing the first database with the second database at a predetermined timing. |
| Claim: | 13. The system according to claim 11 , wherein the method further comprises: replacing the first database with the second database when a predetermined number of blocks are added to the block chain. |
| Claim: | 14. The system according to claim 11 , wherein the method further comprises: determining not to add a second update query to the database as the data item according to an attribute of the second update query; updating the first database according to the second update query; calculating a non-added hash value based on the updated first database according to the second update query; and adding a third new block to the blockchain using the non-added hash value. |
| Claim: | 15. A computer program product for updating a first database in a blockchain, wherein the blockchain is shared by a plurality of nodes included in a blockchain system, the nodes being connected to each other via a network, the nodes generating a block to be added to the blockchain according to a first update of the first database, each of the nodes determines whether to apply a first update query to the first database using a regular update, or to apply the first update query to the first database using a deferred update, upon receiving the first update query to updated the first database, the computer program product comprising a computer readable storage medium having program instructions embodied therewith, the program instructions executable by a computer to cause the computer to: if each node determines to apply the first update query to the database using the regular update: update, using a first thread, the first database according to the first update query, calculate a regular hash value based on the updated database, and add a new block to the blockchain using the regular hash value; and if each node determines to apply the first update query to the first database using the deferred update: generate a second database by copying the first database using copy-on-write techniques; add the first update query to the database as a data item of the first database, calculate a deferred has value based on the database to which the first update query is added as the data item, add a new block to the blockchain using the deferred hash value, update, using a second thread, the second database according to the data item of the first update query added to the first database, replace, in response to a determination that a threshold number of added new block has been met, the first database with the second, wherein the threshold is determined according to one or more properties of the first update query, calculate a replaced hash value based on the replaced database, and add a second new block to the blockchain using the replaced hash value. |
| Claim: | 16. The computer program product of claim 15 , wherein each node receives a second update query and determines to apply the second update query to the first database using the regular update, wherein the program instructions further cause the computer to: prior to updating the second database according to the first update query, update the first database by applying the first update query and the second update query to the first database; calculate an updated hash value based on the first database updated with the first update query and the second update query; and update the second database by applying the first update query and the second update query to the second database. |
| Claim: | 17. The method of claim 1 , wherein the first update query calls a heavy-update. |
| Claim: | 18. The method of claim 4 , wherein each node replaces the first database with the second database in parallel. |
| Claim: | 19. The method of claim 1 , wherein the one or more properties of the first update query includes a determination of the number of blocks between the block and a second block, wherein the second block calls for a heavy-update. |
| Claim: | 20. The method of claim 19 , wherein the first database includes a data tree structure, and wherein the data item is stored in a modified leaf node, and wherein the hash value is calculated based on a subset of nodes of the data tree structure and a set of edges connecting the subset, the subset including a chain of nodes from the modified leaf node to the root node. |
| Patent References Cited: | 9418094 August 2016 Wong 2010/0114832 May 2010 Lillibridge 2015/0161182 June 2015 Baeuerle et al. 2016/0086441 March 2016 Cohen et al. 2016/0147797 May 2016 Dolph et al. 2017/0148016 May 2017 Davis 2017/0228371 August 2017 Seger, II 2017/0364699 December 2017 Goldfarb 2018/0089041 March 2018 Smith 2018/0101560 April 2018 Christidis 2018/0260324 September 2018 Marathe |
| Other References: | Google Search (Year: 2016). cited by examiner |
| Assistant Examiner: | Halm, Kweku William |
| Primary Examiner: | Featherstone, Mark D |
| Attorney, Agent or Firm: | Housley, Daniel C. |
| Dokumentencode: | edspgr.10877962 |
| Datenbank: | USPTO Patent Grants |
| Abstract: | A computer-implemented method for updating a database in a blockchain system to add a block to a blockchain may include: adding an update query to the database as a data item upon receiving the update query to update the database; calculating a hash value based on data items stored in the database, the stored data items including the added data item of the update query; and adding a new block to the blockchain using the hash value. |
|---|