Blockchain ledger data processing method, device, storage medium and electronic device
By archiving ledger data on blockchain network nodes, the problem of blockchain ledger data expansion is solved, and efficient management and traceability of ledger data is achieved.
Patent Information
- Application Number
- CN202111532118.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-14
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2041-12-14
AI Technical Summary
Blockchain ledger data is bloated due to its non-deletion, which may in turn cause ledger data overflow.
By determining the boundary file pointer of the ledger file to be archived on the nodes in the blockchain network, extracting the block header information, determining the storage address corresponding to the ledger ID, saving the archived ledger information and deleting the ledger file to be archived, thus realizing the archived ledger data.
It effectively solves the problem of inflation of ledger data, avoids overflow of ledger data, and ensures the chain storage structure and traceability of blockchain ledger data.
Smart Images

Figure CN114185897B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of blockchain technology, and in particular, to a blockchain ledger data processing method, device, storage medium and electronic device. Background Art
[0002] Blockchain has been applied in more and more business fields due to its features such as decentralization, collective maintenance, high credibility, traceability, non-tamperability, consensus mechanism, and smart contracts. Blockchain stores ledger data in a chain structure, and uses consensus mechanism and cryptography to ensure that ledger data cannot be tampered with. Any tampering operation will make the entire ledger unavailable. In short, blockchain ledgers only support ledger data query operations and ledger data write operations, and do not support ledger data modification operations and ledger data deletion operations. Since blockchain ledger data cannot be deleted, the continuous addition of blockchain ledger data over time will lead to the hidden danger of blockchain ledger data "expansion". Summary of the invention
[0003] The purpose of the present invention is to provide a blockchain ledger data processing method, device, storage medium and electronic device, which can avoid the problem of ledger data expansion by archiving blockchain ledger data.
[0004] In order to achieve the above-mentioned purpose, the first part of the embodiment of the present disclosure provides a blockchain ledger data processing method, which is applied to any node in the blockchain network, and the method includes:
[0005] Determine a boundary file pointer of the ledger file to be archived based on the storage capacity occupied by the ledger data in the node and the write rate of the ledger data, and determine at least one ledger file to be archived according to the boundary file pointer;
[0006] Determine block header information from the to-be-archived ledger file, where the block header information includes a ledger ID;
[0007] Determine the storage address of the ledger data corresponding to the ledger ID on other nodes in the blockchain network, and associate the storage address with the block header information to obtain archived ledger information;
[0008] The archived ledger information is saved, and the ledger file to be archived is deleted to complete the blockchain ledger data archiving.
[0009] Optionally, determining a boundary file pointer of the to-be-archived ledger file based on the storage capacity occupied by the ledger data in the node and the write rate of the ledger data includes:
[0010] Calculate a data volume range of the ledger data to be archived according to the storage capacity occupied by the ledger data and the write rate of the ledger data;
[0011] Determine the pointer value range of the boundary file pointer according to the historical boundary file pointer, the data volume value interval, and the data capacity of a single account book file;
[0012] The boundary file pointer is determined from the pointer value range.
[0013] Optionally, determining the boundary file pointer from the pointer value range includes:
[0014] A pointer in the pointer value range that points to the hotspot account file and has the smallest pointer value is determined as the boundary file pointer.
[0015] Optionally, determining at least one account book file to be archived according to the boundary file pointer includes:
[0016] Determine the target account file pointed to by the boundary file pointer;
[0017] Determine the last data writing time of the target ledger file;
[0018] Each account book file whose last data writing time is less than or equal to the last data writing time of the target account book file is determined as the account book file to be archived.
[0019] Optionally, the block header information also includes a hash value of the ledger data, and the method further includes:
[0020] Upon receiving a request to access archived ledger data in an archived ledger file, determining a target ledger ID corresponding to the archived ledger data from the request;
[0021] Determine, from the archived account information according to the target account ID, a target storage address associated with the target account ID;
[0022] Obtain target ledger data from the target storage address;
[0023] When it is determined that the hash value calculated according to the target ledger data is consistent with the hash value of the archived ledger data, the target ledger data is determined as the archived ledger data.
[0024] Optionally, before deleting the ledger file to be archived, the method further includes:
[0025] Calculate the unique hash value of the ledger file to be archived;
[0026] A Merkle root value is calculated according to the unique hash value of the ledger file to be archived to obtain an archiving credential, and the archiving credential is saved. The archiving credential is used to verify the ledger file obtained from other nodes when the archived ledger file is restored according to the ledger file obtained from other nodes.
[0027] Optionally, the calculating a data volume value range of the to-be-archived ledger data according to the storage capacity occupied by the ledger data and the write rate of the ledger data includes:
[0028] The data volume value interval θ is determined by the following method:
[0029]
[0030] Among them, β represents the storage capacity occupied by the ledger data, and γ represents the write rate of the ledger data.
[0031] The second part of the embodiment of the present disclosure provides a blockchain ledger data processing device, which is applied to any node in a blockchain network, and the device includes:
[0032] A first determining module, configured to determine a boundary file pointer of a to-be-archived ledger file based on the storage capacity occupied by the ledger data in the node and a write rate of the ledger data, and to determine at least one to-be-archived ledger file according to the boundary file pointer;
[0033] A second determination module is used to determine block header information from the to-be-archived ledger file, where the block header information includes a ledger ID;
[0034] An association module, used to determine the storage address of the ledger data corresponding to the ledger ID on other nodes in the blockchain network, and associate the storage address with the block header information to obtain archived ledger information;
[0035] The archiving module is used to save the archived ledger information and delete the ledger file to be archived to complete the blockchain ledger data archiving.
[0036] Optionally, the first determining module includes:
[0037] A first calculation submodule, configured to calculate a data volume value range of the ledger data to be archived according to the storage capacity occupied by the ledger data and the write rate of the ledger data;
[0038] A first determination submodule is used to determine a pointer value range of the boundary file pointer according to the historical boundary file pointer, the data volume value interval, and the data capacity of a single account file;
[0039] The second determining submodule is used to determine the boundary file pointer from the pointer value range.
[0040] Optionally, the second determination submodule is specifically used to determine a pointer in the pointer value range that points to the hotspot account file and has the smallest pointer value as the boundary file pointer.
[0041] Optionally, the first determining module further includes:
[0042] A third determination submodule is used to determine the target account file pointed to by the boundary file pointer;
[0043] A fourth determination submodule is used to determine the last data writing time of the target account file;
[0044] The fifth determining submodule is used to determine each account book file whose last data writing time is less than or equal to the last data writing time of the target account book file as the account book file to be archived.
[0045] The block header information also includes a hash value of the ledger data, and the device also includes:
[0046] An execution module, configured to, upon receiving a request to access archived ledger data in an archived ledger file, determine a target ledger ID corresponding to the archived ledger data from the request;
[0047] A third determination module, configured to determine a target storage address associated with the target account book ID from the archived account book information according to the target account book ID;
[0048] An acquisition module, used to acquire target account book data from the target storage address;
[0049] The fourth determining module is configured to determine the target ledger data as the archived ledger data if it is determined that the hash value calculated based on the target ledger data is consistent with the hash value of the archived ledger data.
[0050] Optionally, the device further comprises:
[0051] A second calculation submodule, used for calculating a unique hash value of the to-be-archived account book file before deleting the to-be-archived account book file;
[0052] The third calculation submodule is used to calculate the Merkle root value according to the unique hash value of the ledger file to be archived to obtain an archiving certificate, and save the archiving certificate. The archiving certificate is used to verify the ledger file obtained from other nodes when the archived ledger file is restored according to the ledger file obtained from other nodes.
[0053] Optionally, the first calculation submodule is specifically configured to determine the data volume value interval θ in the following manner:
[0054]
[0055] Among them, β represents the storage capacity occupied by the ledger data, and γ represents the write rate of the ledger data.
[0056] The third part of the embodiment of the present disclosure provides a non-temporary computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of any one of the methods described in the first part are implemented.
[0057] The fourth part of the embodiment of the present disclosure provides an electronic device, including:
[0058] a memory having a computer program stored thereon;
[0059] A processor, configured to execute the computer program in the memory to implement the steps of any one of the methods described in the first part.
[0060] By adopting the above technical solution, at least the following beneficial technical effects can be achieved:
[0061] Based on the storage capacity occupied by the ledger data in the node and the write rate of the ledger data, the boundary file pointer of the ledger file to be archived is determined, and at least one ledger file to be archived is determined according to the boundary file pointer. The block header information is determined from the ledger file to be archived, and the block header information includes the ledger ID. The storage address of the ledger data corresponding to the ledger ID on other nodes in the blockchain network is determined, and the storage address is associated with the block header information to obtain the archived ledger information. The archived ledger information is saved, and the ledger file to be archived is deleted to complete the archiving of the blockchain ledger data. In this way, since the amount of data of the deleted ledger file to be archived is greater than the amount of data of the archived ledger information to be saved, this way can effectively solve the problem of ledger data expansion on the node and avoid the overflow of the node ledger data. Moreover, by saving the archived ledger information including the block header information, since the block header information can be used to ensure the chain structure of the blocks and blocks of the blockchain, the chain storage structure of the blockchain ledger data can be ensured not to be changed, thereby ensuring the traceability of the blockchain ledger data on the node. At the same time, since the saved archived ledger information also includes the association between the ledger ID and the storage address of the ledger data corresponding to the ledger ID on other nodes in the blockchain network, after the ledger data in the to-be-archived ledger file on the node is archived, the archived ledger data can be obtained from other nodes through the association, thereby ensuring that the archived ledger data on the node can still be accessed.
[0062] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings:
[0064] Figure 1 The present invention is a flowchart of a method for processing blockchain ledger data according to an exemplary embodiment of the present invention.
[0065] Figure 2 The present invention is a flowchart of a method for querying archived account data according to an exemplary embodiment of the present disclosure.
[0066] Figure 3 It is a block diagram of a blockchain ledger data processing device according to an exemplary embodiment of the present disclosure.
[0067] Figure 4 It is a block diagram of an electronic device according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0068] The specific implementation of the present disclosure is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described herein is only used to illustrate and explain the present disclosure, and is not used to limit the present disclosure.
[0069] Figure 1 The flowchart of a method for processing blockchain ledger data according to an exemplary embodiment of the present disclosure is shown. The method for processing blockchain ledger data is applied to any node in a blockchain network. The blockchain network includes multiple nodes, and each node stores blockchain ledger data. Figure 1 As shown, the blockchain ledger data processing method may include the following steps:
[0070] S11. Determine a boundary file pointer of a to-be-archived ledger file based on the storage capacity occupied by the ledger data in the node and a write rate of the ledger data, and determine at least one to-be-archived ledger file according to the boundary file pointer.
[0071] The storage capacity occupied by ledger data refers to the storage capacity on the node that has been used to store blockchain ledger data. The ledger data write rate can be determined by monitoring the growth of the amount of ledger data in the physical storage space of the node.
[0072] It should be noted that data is usually stored on the disk in the form of files, and files are the most basic storage unit of the disk. Writing data to the disk is actually writing data to a file. When the amount of data in a file exceeds the data capacity of the file, the next file will be generated and data will continue to be written to the next file. Each file has a file pointer, the value of which is a memory address, and the file pointer is used to point to the corresponding file. By calling the file pointer, various operations can be performed on the file pointed to by the file pointer, such as writing data, reading data, modifying data, deleting data, etc. In this disclosure, the ledger file refers to the most basic storage unit of the disk, which is used to store blockchain ledger data.
[0073] In some implementations, the total storage capacity of the ledger, the storage capacity occupied by the ledger data, and the rate at which the ledger data is written can be used to determine how much time (referred to as the remaining time) it will take for the total storage capacity of the ledger to be reduced to 0. Since after the total storage capacity of the ledger is reduced to 0, if new ledger data continues to be generated and written to the disk, it will cause disk data overflow, i.e., the problem of ledger data expansion. Therefore, before the total storage capacity of the ledger is reduced to 0, for example, when the total storage capacity of the ledger is less than a preset threshold, the ledger data can be archived. Alternatively, when the remaining time is less than a preset threshold, the ledger data can be archived. Among them, the total storage capacity of the ledger refers to the size of the storage space allocated by the node for storing the ledger data.
[0074] When it is determined that a node needs to perform ledger data archiving processing, a boundary file pointer of the ledger file to be archived can be determined based on the storage capacity occupied by the ledger data of the node and the write rate of the ledger data, and then at least one ledger file to be archived can be determined according to the boundary file pointer.
[0075] S12. Determine block header information from the ledger file to be archived, where the block header information includes a ledger ID.
[0076] The ledger file is used to store blockchain ledger data, which includes block header information and block body information. The block header information is the ledger meta-information of the block, including the ledger ID, block hash, previous block hash, etc. It should be noted that the block header information can be used to ensure the chain structure between each block of the blockchain on the node. It should be known to those skilled in the art that since the block body information includes specific ledger transaction data, the amount of block body information is very large.
[0077] S13. Determine the storage address of the ledger data corresponding to the ledger ID on other nodes in the blockchain network, and associate the storage address with the block header information to obtain archived ledger information.
[0078] It should be noted that the blockchain network includes multiple nodes. When the multiple nodes correspond to one ledger file channel, the multiple nodes are peer nodes to each other, and the same ledger data is stored between the peer nodes.
[0079] In detail, the storage address of the ledger data corresponding to the ledger ID on other nodes in the blockchain network is determined, and the storage address is associated with the block header information to obtain the archived ledger information. Among them, the other nodes refer to the peer nodes of the current node that executes the blockchain ledger data processing method disclosed in the present invention, and the ledger data corresponding to the ledger ID on each peer node has not been archived. It should be noted that if there is no such peer node in the blockchain network, it means that the ledger data corresponding to the ledger ID on the current node cannot be archived, because if the ledger data corresponding to the ledger ID on the current node is archived, the ledger data corresponding to the ledger ID cannot be found from the blockchain network.
[0080] S14: Save the archived ledger information and delete the ledger file to be archived to complete the blockchain ledger data archiving.
[0081] Based on the storage capacity occupied by the ledger data in the node and the write rate of the ledger data, the boundary file pointer of the ledger file to be archived is determined, and at least one ledger file to be archived is determined according to the boundary file pointer. The block header information is determined from the ledger file to be archived, and the block header information includes the ledger ID. The storage address of the ledger data corresponding to the ledger ID on other nodes in the blockchain network is determined, and the storage address is associated with the block header information to obtain the archived ledger information. The archived ledger information is saved, and the ledger file to be archived is deleted to complete the archiving of the blockchain ledger data. In this way, since the amount of data of the deleted ledger file to be archived is greater than the amount of data of the archived ledger information to be saved, this way can effectively solve the problem of ledger data expansion on the node and avoid the overflow of the node ledger data. Moreover, by saving the archived ledger information including the block header information, since the block header information can be used to ensure the chain structure of the blocks and blocks of the blockchain, the chain storage structure of the blockchain ledger data can be ensured not to be changed, thereby ensuring the traceability of the blockchain ledger data on the node. At the same time, since the saved archived ledger information also includes the association between the ledger ID and the storage address of the ledger data corresponding to the ledger ID on other nodes in the blockchain network, after the ledger data in the to-be-archived ledger file on the node is archived, the archived ledger data can be obtained from other nodes through the association, thereby ensuring that the archived ledger data on the node can still be accessed.
[0082] Optionally, determining a boundary file pointer of the to-be-archived ledger file based on the storage capacity occupied by the ledger data in the node and the write rate of the ledger data includes:
[0083] The method further comprises: calculating a data volume value interval of the ledger data to be archived according to the storage capacity occupied by the ledger data and the write rate of the ledger data; determining a pointer value range of the boundary file pointer according to a historical boundary file pointer, the data volume value interval, and the data capacity of a single ledger file; and determining the boundary file pointer from the pointer value range.
[0084] The historical boundary file pointer refers to the boundary file pointer used when the node last archived the ledger data. If the current ledger data archive is the first ledger data archive of the node, the historical boundary file pointer refers to the file pointer of the ledger file where the first ledger data of the blockchain on the node is located.
[0085] In some implementations, calculating the data volume value range of the ledger data to be archived according to the storage capacity occupied by the ledger data and the write rate of the ledger data includes:
[0086] The data volume value interval θ is determined by the following method:
[0087]
[0088] Among them, β represents the storage capacity occupied by the ledger data, and γ represents the write rate of the ledger data.
[0089] It should be noted that 3600 represents 3600 seconds and is used for unit conversion. In the embodiment of the present disclosure, the default unit of the account data write rate is M / h (megabytes per hour). In some other implementations, it can be determined whether to delete 3600 in the formula according to the specific unit of the account data write rate.
[0090] In the data volume value range, It represents archiving of at least half of the ledger data. [γ×3600, γ×3600×3] represents that on the basis of archiving at least half of the ledger data, it is possible to consider archiving the amount of ledger data that grows within 1 to 3 hours. In this way, the node will not have the problem of ledger data expansion or ledger data overflow within at least 1 to 3 hours after archiving the ledger data of the node. Within this 1 to 3 hours, the user has sufficient time to expand the storage space of the node.
[0091] After determining the data volume value interval θ, the pointer value range of the boundary file pointer can be further determined based on the historical boundary file pointer, the data volume value interval, and the data capacity of a single account file. For example, through the formula Calculate the pointer value range. Among them, ε represents the pointer value range, represents the historical boundary file pointer, θ represents the data value range, and μ represents the data capacity of a single ledger file. Combined with the expression of the data value range mentioned above, the expanded form of this formula is
[0092] After determining the pointer value range, the boundary file pointer can be determined therefrom.
[0093] In some implementations, the boundary file pointer is determined from the pointer value range by randomly determining a pointer from the pointer value range as the boundary file pointer.
[0094] In some other implementations, determining the boundary file pointer from the pointer value range includes:
[0095] A pointer in the pointer value range that points to the hotspot account file and has the smallest pointer value is determined as the boundary file pointer.
[0096] Specifically, all candidate account book files corresponding to the pointer value range can be determined first. Then, for each candidate account book file, the sum of the number of times each account book data in the candidate account book file has been accessed within the historical length of time is calculated. Among them, ρ i It refers to the number of times the i-th ledger data in the candidate ledger file has been accessed within the historical period, and n refers to the total number of n ledger data in the candidate ledger file. If the sum is greater than the preset threshold, the candidate ledger file is determined as a hot candidate ledger file.
[0097] Next, all the hot candidate ledger files corresponding to the pointer value range are determined, and the file pointer with the smallest pointer value is selected from the file pointers corresponding to all the hot candidate ledger files as the boundary file pointer. Since the pointer value is a memory address, the smaller the pointer value, the earlier the ledger data in the memory address pointed to by the pointer value is stored. The earlier the ledger data is stored, the earlier the corresponding logical block of the ledger data in the blockchain is. Based on this, if the file pointer with the smallest pointer value is selected from the file pointers corresponding to all the hot candidate ledger files as the boundary file pointer, the boundary file pointer can divide all the hot candidate ledger files together, and then the purpose of archiving non-hot ledger files and not archiving hot ledger files can be achieved, thereby avoiding the problem of low reading speed when accessing the hot ledger data in the hot ledger file caused by archiving the hot ledger file.
[0098] In detail, determining at least one account book file to be archived according to the boundary file pointer includes:
[0099] Determine the target account book file pointed to by the boundary file pointer; determine the last data writing time of the target account book file; and determine each account book file whose last data writing time is less than or equal to the last data writing time of the target account book file as the account book file to be archived.
[0100] In other implementations, if the ledger files are stored sequentially and continuously on the disk, each ledger file having a file pointer smaller than the boundary file pointer may be determined as the ledger file to be archived.
[0101] When accessing archived ledger data in an archived ledger file on the current node, the current node can access the archived ledger data by Figure 2 The following method is used to find the archived ledger data that has been accessed:
[0102] S21. When receiving a request to access archived ledger data in an archived ledger file, determine a target ledger ID corresponding to the archived ledger data from the request.
[0103] S22. Determine a target storage address associated with the target account book ID from the archived account book information according to the target account book ID.
[0104] The target storage address is the storage address of the target ledger data corresponding to the target ledger ID on any other node in the blockchain network. Any other node refers to any peer node of the current node.
[0105] S23. Obtain target account data from the target storage address.
[0106] S24. When it is determined that the hash value calculated according to the target ledger data is consistent with the hash value of the archived ledger data, determine the target ledger data as the archived ledger data.
[0107] Among them, the block header information in the archived ledger information also includes the hash value of the archived ledger data.
[0108] In addition, when it is determined that the hash value calculated based on the target ledger data is inconsistent with the hash value of the archived ledger data, the process returns to step S32 to determine a new target storage address to obtain the target ledger data from another peer node until the archived ledger data is determined.
[0109] After the archived ledger data is determined, the archived ledger data is fed back to the requester. If the corresponding archived ledger data is not found in all target storage addresses stored in the archived ledger information, a result indicating that the corresponding ledger data does not exist is returned to the requester.
[0110] Optionally, before deleting the ledger file to be archived, the method further includes:
[0111] Calculate the unique hash value of the ledger file to be archived; calculate the Merkle root value according to the unique hash value of the ledger file to be archived to obtain an archiving certificate, and save the archiving certificate, wherein the archiving certificate is used to verify the ledger file obtained from other nodes when restoring the archived ledger file according to the ledger file obtained from other nodes.
[0112] The algorithm for calculating the unique hash value of the account book file to be archived can be any hash algorithm / function in the relevant technology, such as the SHA-256 algorithm, the MD5 information digest algorithm, the hash algorithm, etc. This disclosure does not make any specific restrictions on this.
[0113] Among them, the unique hash value of the ledger file represents the unique ID of the ledger file. It should be noted that when the data in the two ledger files are inconsistent, the ledger file IDs (unique hash values) of the two ledger files are inconsistent. When the data in the two ledger files are consistent, the ledger file IDs (unique hash values) of the two ledger files are consistent. Therefore, the unique hash value of the ledger file to be archived can be used to verify whether the ledger file obtained from other nodes is consistent with the ledger file to be archived.
[0114] The Merkle root value is calculated based on the unique hash value of the ledger file to be archived, and the Merkle root value is used as the archiving credential. In this way, when restoring the archived ledger file based on the ledger file obtained from other nodes, the Merkle root value can be used to verify the accuracy and integrity of the ledger file obtained from other nodes.
[0115] A feasible implementation method is that after the current node archives the blockchain ledger data, if the disk memory of the current node is expanded, the archived ledger data can be restored for the current node. Specifically, the boundary file pointer of the archived ledger file is obtained, and the ledger file ID (i.e., the unique hash value) corresponding to the boundary file pointer is determined. The target ledger file corresponding to the ledger file ID is determined from any peer node in the blockchain network. Each ledger file whose last data write time in the peer node is less than or equal to the last data write time of the target ledger file is determined as the ledger file to be restored. The unique hash value of the ledger file to be restored is calculated, and the Merkle root value is calculated according to the unique hash value of the ledger file to be restored to obtain a recovery certificate. The recovery certificate is compared with the archived certificate, and if they are consistent, the archived ledger file is restored according to the ledger file to be restored. If they are inconsistent, a new target ledger file corresponding to the ledger file ID is determined from another peer node again until the archived ledger file is restored.
[0116] Figure 3is a block diagram of a blockchain ledger data processing device according to an exemplary embodiment of the present disclosure, such as Figure 3 As shown, the device 300 includes:
[0117] A first determining module 310 is configured to determine a boundary file pointer of a to-be-archived ledger file based on the storage capacity occupied by the ledger data in the node and the write rate of the ledger data, and determine at least one to-be-archived ledger file according to the boundary file pointer;
[0118] A second determination module 320 is used to determine block header information from the to-be-archived ledger file, where the block header information includes a ledger ID;
[0119] An association module 330 is used to determine the storage address of the ledger data corresponding to the ledger ID on other nodes in the blockchain network, and associate the storage address with the block header information to obtain archived ledger information;
[0120] The archiving module 340 is used to save the archived ledger information and delete the ledger file to be archived to complete the blockchain ledger data archiving.
[0121] Optionally, the first determining module 310 includes:
[0122] A first calculation submodule, configured to calculate a data volume value range of the ledger data to be archived according to the storage capacity occupied by the ledger data and the write rate of the ledger data;
[0123] A first determination submodule is used to determine a pointer value range of the boundary file pointer according to the historical boundary file pointer, the data volume value interval, and the data capacity of a single account file;
[0124] The second determining submodule is used to determine the boundary file pointer from the pointer value range.
[0125] Optionally, the second determination submodule is specifically used to determine a pointer in the pointer value range that points to the hotspot account file and has the smallest pointer value as the boundary file pointer.
[0126] Optionally, the first determining module 310 further includes:
[0127] A third determination submodule is used to determine the target account file pointed to by the boundary file pointer;
[0128] A fourth determination submodule is used to determine the last data writing time of the target account file;
[0129] The fifth determining submodule is used to determine each account book file whose last data writing time is less than or equal to the last data writing time of the target account book file as the account book file to be archived.
[0130] The block header information also includes a hash value of the ledger data, and the device 300 also includes:
[0131] An execution module, configured to, upon receiving a request to access archived ledger data in an archived ledger file, determine a target ledger ID corresponding to the archived ledger data from the request;
[0132] A third determination module, configured to determine a target storage address associated with the target account book ID from the archived account book information according to the target account book ID;
[0133] An acquisition module, used to acquire target account book data from the target storage address;
[0134] The fourth determining module is configured to determine the target ledger data as the archived ledger data if it is determined that the hash value calculated based on the target ledger data is consistent with the hash value of the archived ledger data.
[0135] Optionally, the device 300 further includes:
[0136] A second calculation submodule, used for calculating a unique hash value of the to-be-archived account book file before deleting the to-be-archived account book file;
[0137] The third calculation submodule is used to calculate the Merkle root value according to the unique hash value of the ledger file to be archived to obtain an archiving certificate, and save the archiving certificate. The archiving certificate is used to verify the ledger file obtained from other nodes when the archived ledger file is restored according to the ledger file obtained from other nodes.
[0138] Optionally, the first calculation submodule is specifically used to determine the data volume value interval in the following manner:
[0139]
[0140] Among them, β represents the storage capacity occupied by the ledger data, and γ represents the write rate of the ledger data.
[0141] The above device is used to determine the boundary file pointer of the ledger file to be archived based on the storage capacity occupied by the ledger data in the node and the write rate of the ledger data, and at least one ledger file to be archived is determined according to the boundary file pointer. Block header information is determined from the ledger file to be archived, and the block header information includes the ledger ID. The storage address of the ledger data corresponding to the ledger ID on other nodes in the blockchain network is determined, and the storage address is associated with the block header information to obtain the archived ledger information. The archived ledger information is saved, and the ledger file to be archived is deleted to complete the archiving of the blockchain ledger data. In this way, since the amount of data of the deleted ledger file to be archived is greater than the amount of data of the archived ledger information to be saved, this way can effectively solve the problem of ledger data expansion on the node and avoid the overflow of the node ledger data. Moreover, by saving the archived ledger information including the block header information, since the block header information can be used to ensure the chain structure of the blocks and blocks of the blockchain, the chain storage structure of the blockchain ledger data can be ensured not to be changed, thereby ensuring the traceability of the blockchain ledger data on the node. At the same time, since the saved archived ledger information also includes the association between the ledger ID and the storage address of the ledger data corresponding to the ledger ID on other nodes in the blockchain network, after the ledger data in the to-be-archived ledger file on the node is archived, the archived ledger data can be obtained from other nodes through the association, thereby ensuring that the archived ledger data on the node can still be accessed.
[0142] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0143] The embodiments of the present disclosure provide a non-temporary computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the aforementioned blockchain ledger data processing methods.
[0144] Figure 4 FIG. 7 is a block diagram of an electronic device 700 according to an exemplary embodiment. Figure 4 As shown, the electronic device 700 may include: a processor 701 and a memory 702. The electronic device 700 may also include one or more of a multimedia component 703, an input / output (I / O) interface 704, and a communication component 705.
[0145] The processor 701 is used to control the overall operation of the electronic device 700 to complete all or part of the steps in the above-mentioned blockchain ledger data processing method. The memory 702 is used to store various types of data to support the operation of the electronic device 700, which may include, for example, instructions for any application or method used to operate on the electronic device 700, and application-related data, such as contact data, sent and received messages, pictures, audio, video, etc. The memory 702 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, disk or optical disk. The multimedia component 703 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may be further stored in the memory 702 or sent through the communication component 705. The audio component also includes at least one speaker for outputting audio signals. The I / O interface 704 provides an interface between the processor 701 and other interface modules, and the other interface modules may be keyboards, mice, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 705 is used for wired or wireless communication between the electronic device 700 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more of them, is not limited here. Therefore, the corresponding communication component 705 may include: Wi-Fi module, Bluetooth module, NFC module, etc.
[0146] In an exemplary embodiment, the electronic device 700 can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned blockchain ledger data processing method.
[0147] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned blockchain ledger data processing method are implemented. For example, the computer-readable storage medium can be the above-mentioned memory 702 including program instructions, and the above-mentioned program instructions can be executed by the processor 701 of the electronic device 700 to complete the above-mentioned blockchain ledger data processing method.
[0148] In another exemplary embodiment, a computer program product is also provided, which includes a computer program that can be executed by a programmable device, and the computer program has a code portion for executing the above-mentioned blockchain ledger data processing method when executed by the programmable device.
[0149] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings; however, the present disclosure is not limited to the specific details in the above embodiments. Within the technical concept of the present disclosure, a variety of simple modifications can be made to the technical solution of the present disclosure, and these simple modifications all fall within the protection scope of the present disclosure.
[0150] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.
[0151] In addition, various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as the contents disclosed by the present disclosure.
Claims
1. A blockchain ledger data processing method, characterized in that: The method is applied to any node in a blockchain network, and the method includes: Determine a boundary file pointer of the ledger file to be archived based on the storage capacity occupied by the ledger data in the node and the write rate of the ledger data, and determine at least one ledger file to be archived according to the boundary file pointer; Determine block header information from the to-be-archived ledger file, where the block header information includes a ledger ID; Determine the storage address of the ledger data corresponding to the ledger ID on other nodes in the blockchain network, and associate the storage address with the block header information to obtain archived ledger information; Saving the archived ledger information and deleting the ledger file to be archived to complete the blockchain ledger data archiving; The step of determining the boundary file pointer of the ledger file to be archived based on the storage capacity occupied by the ledger data in the node and the write rate of the ledger data includes: The method further comprises: calculating a data volume value interval of the ledger data to be archived according to the storage capacity occupied by the ledger data and the write rate of the ledger data; determining a pointer value range of the boundary file pointer according to a historical boundary file pointer, the data volume value interval, and the data capacity of a single ledger file; and determining the boundary file pointer from the pointer value range.
2. The method according to claim 1, characterized in that: Determining the boundary file pointer from the pointer value range includes: A pointer in the pointer value range that points to the hotspot account file and has the smallest pointer value is determined as the boundary file pointer.
3. The method according to claim 1 or 2, characterized in that: The determining at least one account book file to be archived according to the boundary file pointer comprises: Determine the target account file pointed to by the boundary file pointer; Determine the last data writing time of the target ledger file; Each account book file whose last data writing time is less than or equal to the last data writing time of the target account book file is determined as the account book file to be archived.
4. The method according to claim 1, characterized in that The block header information also includes a hash value of the ledger data, and the method further includes: Upon receiving a request to access archived ledger data in an archived ledger file, determining a target ledger ID corresponding to the archived ledger data from the request; Determine, from the archived account information according to the target account ID, a target storage address associated with the target account ID; Obtain target ledger data from the target storage address; When it is determined that the hash value calculated according to the target ledger data is consistent with the hash value of the archived ledger data, the target ledger data is determined as the archived ledger data.
5. The method according to claim 1, characterized in that: Before deleting the account book file to be archived, it also includes: Calculate the unique hash value of the ledger file to be archived; A Merkle root value is calculated according to the unique hash value of the ledger file to be archived to obtain an archiving credential, and the archiving credential is saved. The archiving credential is used to verify the ledger file obtained from other nodes when the archived ledger file is restored according to the ledger file obtained from other nodes.
6. The method according to claim 1, characterized in that The calculating the data volume value range of the to-be-archived ledger data according to the storage capacity occupied by the ledger data and the write rate of the ledger data includes: The data volume value interval is determined by the following method : , in, Characterizes the storage capacity occupied by the account book data, Characterizes the rate at which the ledger data is written.
7. A blockchain ledger data processing device, characterized in that: The device is applied to any node in the blockchain network, and the device includes: A first determining module, configured to determine a boundary file pointer of a to-be-archived ledger file based on the storage capacity occupied by the ledger data in the node and a write rate of the ledger data, and to determine at least one to-be-archived ledger file according to the boundary file pointer; A second determination module is used to determine block header information from the to-be-archived ledger file, where the block header information includes a ledger ID; An association module, used to determine the storage address of the ledger data corresponding to the ledger ID on other nodes in the blockchain network, and associate the storage address with the block header information to obtain archived ledger information; The archiving module is used to save the archived ledger information and delete the ledger file to be archived to complete the blockchain ledger data archiving; Wherein, the first determining module includes: A first calculation submodule, configured to calculate a data volume value range of the ledger data to be archived according to the storage capacity occupied by the ledger data and the write rate of the ledger data; A first determination submodule is used to determine a pointer value range of the boundary file pointer according to the historical boundary file pointer, the data volume value interval, and the data capacity of a single account book file; The second determining submodule is used to determine the boundary file pointer from the pointer value range.
8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method described in any one of claims 1 to 6 are implemented.
9. An electronic device, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Block chain data filing method
CN107526775A
Block chain account book data processing method and device, storage medium and electronic equipment
CN112527896A