A length-adjustable blockchain and block verification method
By employing an adjustable-length ring structure and modular LTN numbering in the blockchain, the problems of wasted blockchain storage space and hash collisions are solved, improving the performance and data access efficiency of industrial IoT systems and enhancing data security.
Patent Information
- Application Number
- CN202310812247.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-04
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2043-07-04
AI Technical Summary
Existing blockchain technology in the Industrial Internet of Things (IIoT) suffers from wasted storage space and reduced access efficiency due to the increased number of blocks, as well as an increased probability of hash collisions, which affects system performance.
Design a blockchain structure with adjustable length. By dynamically adjusting the number of blocks, adopting a ring structure and block numbering on an Abelian group with LTN, limit the overall storage size of the blockchain, and establish a closed unidirectional ring structure in the blockchain to reduce the risk of hash collisions.
It optimizes blockchain storage space, improves data access efficiency, reduces hash collisions and redundant calculation overhead, and enhances the security and availability of blockchain data.
Smart Images

Figure CN116881362B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to an adjustable-length blockchain and a block verification method, belonging to the field of data storage technology in blockchain. Background Technology
[0002] The Industrial Internet of Things (IIoT) connects nodes in a mesh network through wireless sensor network and radio frequency identification (RFID) technologies, enabling complex data acquisition and monitoring through data interaction. In recent years, blockchain technology (BC) has received increasing attention in the field of information security research. Benefiting from its immutability, blockchain is particularly suitable for storing and accessing critical data, such as IIoT communication packets.
[0003] Unlike traditional data storage models, blockchain does not support modification or deletion of data within blocks. IIoT underlying data is highly time-sensitive, typically becoming meaningless after three to five years due to the end of the device's lifecycle, making permanent storage unnecessary. As the number of blocks in the blockchain increases, access efficiency gradually decreases until it affects system availability, and the probability of collisions in hash function outputs also increases linearly. This can cause performance disasters for IIoT nodes with limited computing power.
[0004] In order to enable the recycling and reuse of blocks and their occupied space, limit the number of blocks in the blockchain, and further improve the working efficiency of IIoT nodes so that they can meet the specific needs of application scenarios such as water conservancy, environmental protection, and transportation, it is necessary to design a blockchain structure with adjustable length. Summary of the Invention
[0005] The technical problem to be solved by the present invention is to provide a blockchain and block verification method with adjustable length, which limits the overall storage scale of the blockchain by dynamically adjusting the number of blocks on the blockchain, thereby saving storage space, improving data access efficiency, reducing the overhead of repeated calculations caused by hash collisions and hash exhaustion, and limiting the total storage scale.
[0006] To solve the above-mentioned technical problems, the present invention adopts the following technical solution:
[0007] An adjustable-length blockchain, comprising LTN blocks, wherein the LTN blocks are linked end-to-end in the order of the first block to the LTN-th block to form a ring structure, where LTN is the block length threshold, i.e. the maximum number of blocks allowed to be stored in the blockchain, and LTN > 1;
[0008] Each block consists of two parts: a header (Bheader) and a body (Bbody). The header (Bheader) includes the following attributes: block number (BN), timestamp (STP), parent block header hash (Phash), block body hash (Bhash), block trust root number (TRN), and block trust root header hash (TRhash). The body (Bbody) contains the data that needs to be stored in the blockchain.
[0009] When a new block needs to be generated in the blockchain, that is, when data needs to be stored in the blockchain, the data to be stored in the blockchain is used as the body of the new block. The corresponding header is generated based on the body of the new block. The header of the new block includes the following attributes:
[0010] 1) Block number BN, represented as a long integer, is calculated using the following formula:
[0011] BN = (previous block.Bheader.BN + 1) mod LTN
[0012] Wherein, `previousblock.Bheader.BN` represents the value of the block number in the header of the previous block of the new block; `mod` represents the modulo operation.
[0013] 2) Timestamp STP, represented as a long integer, with the value of STP being the system time when the header of a new block was generated;
[0014] 3) Parent block header hash, represented as a binary string, is derived by jointly hashing all attributes of the header of the previous block of the new block;
[0015] 4) Block body hash (Bhash), represented as a binary string, is derived by jointly hashing all data attributes of the new block body. Its value is calculated according to the following formula:
[0016] Bhash = Hash(Bbody)
[0017] Where Hash represents hash operation;
[0018] 5) Block Trust Root Number (TRN), where the value of TRN is the block number of the first block in the current blockchain;
[0019] 6) The block trust root header hash (TRhash), represented as a binary string, is calculated using the following formula:
[0020] TRhash = Hash(Hash(Block with the lowest STP in the blockchain.Bheader) + BN)
[0021] Among them, the block with the smallest STP in the blockchain. Bheader represents all attributes in the header of the block with the smallest timestamp STP in the current blockchain; the block with the smallest timestamp STP in the current blockchain is the first block in the current blockchain;
[0022] When the number of existing blocks in the blockchain is less than LTN, a new block is added to the end of the blockchain; when the number of existing blocks in the blockchain is greater than or equal to LTN, the first block is removed from the blockchain and a new block is added to the end of the blockchain.
[0023] When it is necessary to increase the block length threshold from LTN to N, determine whether the block number of the first block in the blockchain is equal to 0; if so, reset the block length threshold to N; otherwise, continue to add new blocks to the blockchain until the block number of the first block is 0, at which point the block length threshold is reset to N.
[0024] When it is necessary to reduce the block length threshold from LTN to M, determine whether the block number of the first block in the blockchain is equal to M; if so, starting from the first block in the blockchain, remove (LTN-M) blocks sequentially and reset the block length threshold to M; otherwise, continue to add new blocks to the blockchain until the block number of the first block is M.
[0025] As a preferred embodiment of the present invention, the difference number BN of the first block is 0, the parent block header hash Phash value of the first block is empty, and the block trust root header hash TRhash value of the first block is empty.
[0026] As a preferred embodiment of the present invention, the hash algorithm includes, but is not limited to, Cyclic Redundancy Check (CRC), MD5 message digest algorithm, SM3 cryptographic hash algorithm, and Secure Hash Algorithm (SHA).
[0027] As a preferred embodiment of the present invention, blocks removed from the blockchain are synchronously or asynchronously transferred to an external non-volatile media storage device for offline or online backup. The external non-volatile media storage device includes high-density magnetic tape, disk array, and portable hard drive.
[0028] As a preferred embodiment of the present invention, the blockchain contains the following relationships:
[0029] Hash(first block.Bheader.Phash + (first block.Bheader.BN - 1)) = Hash(first block.Bheader.Phash + last block.Bheader.BN) = last block.Bheader.TRhash
[0030] In this context, `first block.Bheader.Phash` represents the value of the parent block header hash in the header of the first block, `first block.Bheader.BN` represents the value of the block number in the header of the first block, `last block.Bheader.BN` represents the value of the block number in the header of the last block, and `last block.Bheader.TRhash` represents the value of the block trust root header hash in the header of the last block.
[0031] As a preferred embodiment of the present invention, the specific process of increasing the block length threshold from LTN to N is as follows:
[0032] S1: Determine if the block number of the first block in the blockchain is equal to 0. If yes, proceed to S2; otherwise, proceed to S3.
[0033] S2, pause adding new blocks to the blockchain and reset the block length threshold to N;
[0034] S3 continues to add new blocks to the blockchain and returns to S1.
[0035] As a preferred embodiment of the present invention, the specific process for reducing the block length threshold from LTN to M is as follows:
[0036] S4. Determine if the block number of the first block in the blockchain is equal to M. If yes, proceed to S5; otherwise, proceed to S6.
[0037] S5, pause adding new blocks to the blockchain, remove (LTN-M) blocks sequentially from the first block in the blockchain, and reset the block length threshold to M;
[0038] S6 continues to add new blocks to the blockchain and returns to S4.
[0039] A block verification method, the block verification method comprising the following steps:
[0040] Step 1: Find the block with the smallest timestamp STP value in the blockchain, calculate the hash value of the current block body, and compare it with the block body hash Bhash value in the current block header. If they are the same, the integrity verification of the current block body is passed, and proceed to Step 2 to verify the integrity of the current block header; otherwise, the verification fails and stops.
[0041] Step 2: Determine if the current block is the last block in the blockchain. If it is not the last block, calculate the combined hash value Temp0 of all attributes in the header of the current block. The calculation formula is as follows:
[0042] Temp0 = Hash(current block.Bheader)
[0043] Here, `current_block.Bheader` represents all attributes in the header of the current block; the combined hash value of all attributes is compared with the hash value of the parent block header in the header of the next block of the current block. If they are the same, the integrity verification of the current block header passes, and the process returns to step 1 to continue verifying the next block; otherwise, the verification fails, and the verification stops.
[0044] If it is the last block, the hash of the parent block header (Phash) in the header of the first block in the blockchain is combined with the hash of the first block ([Block number BN-1) mod LTN], calculated as follows:
[0045] Temp1 = (first block.Bheader.BN - 1) mod LTN = last block.Bheader.BNT Temp2 = Hash(first block.Bheader.Phash + Temp1)
[0046] In this code, `first block.Bheader.BN` represents the block number in the header of the first block, `last block.Bheader.BN` represents the block number in the header of the last block, `first block.Bheader.Phash` represents the parent block header hash in the header of the first block, `Temp1` represents the intermediate result, and `Temp2` represents the final result. The final result is compared with the trust root header hash `TRhash` in the header of the last block. If they are the same, the integrity verification of the current block header passes, and the verification of all blocks is completed; otherwise, the verification fails, and the verification stops.
[0047] A computer device includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor executes the computer program to implement the steps of the block verification method as described above.
[0048] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the block verification method as described above.
[0049] Compared with the prior art, the present invention, employing the above technical solution, has the following technical effects:
[0050] This invention dynamically sets the blockchain length to LTN based on performance and storage redundancy requirements, using discrete integers from an Abelian group modulo LTN as block header numbers. Each block number is globally unique on the blockchain, preventing attackers from inserting blocks exceeding the LTN range. For the first block in the blockchain header, if it is not the genesis block, a hash link is established between the first block and the last block in the blockchain, forming a closed unidirectional ring structure. This design ensures that a proper subset of consecutive blocks in a traditional blockchain structure also possesses hash connections across all block nodes, reducing the security risk of unauthorized tampering with the block header and block body data. Attached Figure Description
[0051] Figure 1 This is a schematic diagram of the adjustable-length blockchain block data structure of the present invention;
[0052] Figure 2 This is a schematic diagram of the adjustable-length hash connection between blockchain blocks according to the present invention. Detailed Implementation
[0053] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0054] like Figure 1 The diagram illustrates the adjustable-length blockchain block data structure of this invention. In a blockchain, a finite number of blocks are interconnected in a linked list structure. In other words, the number of blocks in a blockchain is an integer greater than 1, and initially, at least one block exists; this block is called the genesis block. Each block consists of two parts: the block body and the block header. The block header contains the following attributes:
[0055] Block number, timestamp, parent block header hash, block body hash, block trust root number, block trust root header hash;
[0056] The block body contains the data that needs to be stored persistently in the blockchain. Once the block containing the block body is in the blockchain, it cannot be modified until it is removed from the blockchain. The blockchain provides verification of the data integrity of the block body and block header. The block body can be plaintext or encrypted data.
[0057] When a new block needs to be generated in the blockchain, perform the following operations:
[0058] The data that needs to be persistently stored in the blockchain is designated as the block body, denoted as Bbody, and its data type can be a string or a byte stream. Based on Bbody, its corresponding block header Bheader is generated. The Bheader's data structure must include at least the following attributes:
[0059] The block number BN, represented as a long integer, is calculated using the following formula:
[0060] BN = (previous block.Bheader.BN + 1) mod LTN
[0061] `Previous Block.Bheader.BN` represents the block number value in the header of the block preceding the current block; `mod` represents the modulo operation, i.e., the remainder after subtracting an integer multiple of LTN that is less than LTN. The block length threshold LTN is the maximum number of blocks allowed to be stored in the blockchain. Since there is at least one genesis block in the initial state of the blockchain, the value of LTN is obviously greater than 1. LTN can be set by the creator; this value limits the maximum number of blocks in the blockchain, and blocks exceeding this number will be removed from the blockchain. For ease of calculation, the BN value of the genesis block is set to 0.
[0062] The timestamp STP is represented as a long integer, and its value is the system time when the Bheader is generated. Its precision is set by the creator and can be accurate to seconds, milliseconds, or nanoseconds.
[0063] The parent block header hash, represented as a binary string, is derived by jointly hashing all attributes of the Bheader in the previous block of the current block. The hash algorithm includes, but is not limited to, CRC, MD5, SM3, SHA, etc.
[0064] The genesis block is the first block in the blockchain by default. There is no previous block, so the Phash value of the genesis block is empty.
[0065] The block body hash, Bhash, is represented as a binary string and is obtained by jointly hashing all data attributes of the current block body Bbody. Its value is calculated according to the following formula:
[0066] Bhash = Hash(Bbody)
[0067] The block trust root number is the block number of the first block in the current blockchain.
[0068] The block trust root header hash (TRhash), represented as a binary string, is calculated using the following formula:
[0069] TRhash = Hash(Hash(Block with the lowest STP in the blockchain.Bheader) + BN)
[0070] The Bheader represents all attributes in the header of the block with the smallest STP (Size-to-Time) in the current blockchain. Since blocks enter the blockchain in chronological order, the first block in the blockchain will always have the smallest STP when generating the Bheader. Therefore, the above formula can be replaced with:
[0071] TRhash = hash(hash(first block in the blockchain.Bheader) + BN)
[0072] Before the genesis block was added to the blockchain, there were no other blocks, so the TRhash value of the genesis block was empty.
[0073] As can be proven by the BN calculation formula, when the number of existing blocks in the blockchain is less than the block length threshold LTN, the block number BN of the new block will not collide with other blocks. Bheader and Bbody are added as new blocks to the end of the blockchain, and the block generation is completed.
[0074] When the number of existing blocks in the blockchain is greater than or equal to LTN, the next block number BN will inevitably collide with the first block in the blockchain. At this point, the first block is removed from the blockchain, and Bheader and Bbody are added as a new block to the end of the blockchain, completing the block generation process. The block with block number BN+1 then becomes the new header of the blockchain. The previous block pointed to by its parent block header hash (Phash) has been removed, but this value can still be verified during the block verification process.
[0075] The removed blocks can be synchronously or asynchronously transferred to external non-volatile media storage such as high-density tapes, disk arrays, and portable hard drives for offline or online backup.
[0076] Block length threshold increased
[0077] Suppose we need to increase the block length threshold from the current value LTN to N, then the following relationship clearly exists:
[0078] N>LTN>0
[0079] The block length threshold increment step is allowed only if the block number of the first block in the blockchain is equal to 0. If the block number of the first block in the current blockchain is not equal to 0, the block generation step is waited for to add a new block to the blockchain until the block number of the first block is 0.
[0080] First, pause the block generation process and suspend all block generation operation instructions, thereby stopping the addition of blocks to the blockchain;
[0081] Then, reset the block length threshold to N;
[0082] Finally, resume the block generation process and continue adding blocks to the blockchain.
[0083] Block length threshold reduced
[0084] Suppose we need to reduce the block length threshold from the current value LTN to M, then the following relationship clearly holds:
[0085] 0 <M<LTN
[0086] The block length threshold reduction step is allowed to be executed if and only if the block number of the first block in the current blockchain is equal to M. If the block number of the first block in the current blockchain is not equal to M, the block generation step is waited for to add a new block to the blockchain until the block number of the first block is M.
[0087] First, pause the block generation process and suspend all block generation operation instructions, thereby stopping the addition of blocks to the blockchain;
[0088] Then, starting from the first block in the blockchain, remove (LTN-M) blocks sequentially until the block number BN of the first block in the blockchain is 0, and reset the block length threshold to M.
[0089] Finally, resume the block generation process and continue adding blocks to the blockchain.
[0090] According to the above formula, it is easy to prove that after LTN+1 blocks are stored in the blockchain, the old blocks are removed from the blockchain, and only the latest LTN blocks are retained. Furthermore, the following relationship exists in the blockchain:
[0091] Hash(first block.Bheader.Phash + (first block.Bheader.BN - 1)) = Hash(first block.Bheader.Phash + last block.Bheader.BN) = last block.Bheader.TRhash
[0092] The above relationship establishes a hash connection between the first and last blocks, making it a ring structure, as shown below. Figure 2 As shown, any operation that inserts a block between elements on the ring will inevitably break the hash connection, causing the block verification step to fail, thus reducing the risk of illegal tampering with data on the blockchain. Therefore, attackers cannot insert or tamper with any block from the first block to the last block without breaking the hash connection.
[0093] Block verification
[0094] When it is necessary to verify the data integrity of each block in the blockchain, the following operations are performed:
[0095] Find the first block in the current blockchain, which must have the smallest timestamp (STP) value, and verify the integrity of its block body (Bbody). The specific steps are as follows:
[0096] First, calculate the hash value of the current block body (Bbody) and compare it with the block body hash (Bhash) in the current block header. If they are the same, the block body integrity verification passes, and the verification of its block header integrity begins. If not, the verification fails, and the verification stops.
[0097] Next, determine whether the current block is the last block in the blockchain. If the current block is the last block in the blockchain, then the block with the current block number BN+1 must be the first block in the blockchain, possessing the smallest timestamp STP value; otherwise, the block with the current block number BN+1 must not be the first block in the blockchain.
[0098] If it is not the last block, calculate the combined hash value of all attributes in the block header, using the following formula:
[0099] Temp0 = Hash(current block.Bheader)
[0100] The above value is compared with the hash of the parent block header of the next block in the current blockchain. If they are the same, the block header integrity verification passes and the verification of the next block continues; otherwise, the verification fails and the verification stops.
[0101] If it is the last block, the hash of the parent block header of the first block in the blockchain is combined with the hash of the first block [block number BN-1) mod LTN], calculated as follows:
[0102] Temp1 = (first block.Bheader.BN - 1) mod LTN = last block.Bheader.BNT Temp2 = Hash(first block.Bheader.Phash + Temp1)
[0103] The result is compared with the Trust Root Header Hash (TRhash) of the last block. If they match, the block header integrity verification passes, and all block verifications are completed successfully; otherwise, verification fails, and verification stops.
[0104] Based on the same inventive concept, embodiments of this application provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the aforementioned block verification method.
[0105] Based on the same inventive concept, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the aforementioned block verification method.
[0106] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0107] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0108] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0109] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0110] The above embodiments are merely illustrative of the technical concept of the present invention and should not be construed as limiting the scope of protection of the present invention. Any modifications made to the technical solutions based on the technical concept proposed in this invention shall fall within the scope of protection of this invention.
Claims
1. A length-adjustable blockchain, characterized by, The blockchain comprises LTN blocks, the LTN blocks are sequentially and circularly connected from a first block to an LTNth block, LTN is a block length threshold, that is, a maximum number of blocks allowed to be stored in the blockchain, and LTN>1; Each block comprises a header Bheader and a body Bbody, wherein the header Bheader comprises the following attributes: a block number BN, a timestamp STP, a parent block header hash Phash, a block body hash Bhash, a block trust root number TRN, and a block trust root header hash TRhash; and the body Bbody comprises data to be stored in the blockchain; The blockchain comprises the following relationships: Hash(first block.Bheader.Phash + (first block.Bheader.BN-1)) = Hash(first block.Bheader.Phash + last block.Bheader.BN) = last block.Bheader.TRhash, wherein first block.Bheader.Phash represents a value of the parent block header hash in the first block header, first block.Bheader.BN represents a value of the block number in the first block header, last block.Bheader.BN represents a value of the block number in the last block header, and last block.Bheader.TRhash represents a value of the block trust root header hash in the last block header; When a new block needs to be generated in the blockchain, that is, data needs to be stored in the blockchain, the data to be stored in the blockchain is taken as a new block body, a header corresponding to the new block body is generated according to the new block body, and the new block header comprises the following attributes: 1) a block number BN, represented by a long integer, the value of BN is calculated by the following formula: BN = (previous block.Bheader.BN + 1) mod LTN, wherein previous block.Bheader.BN represents a value of the block number in the header of the previous block of the new block; and mod represents a modulus operation; 2) a timestamp STP, represented by a long integer, the value of STP is a system time when the new block header is generated; 3) a parent block header hash Phash, represented by a binary string, obtained by jointly hashing all attributes of the header of the previous block of the new block; 4) a block body hash Bhash, represented by a binary string, obtained by jointly hashing all data attributes of the new block body, and the value of Bhash is calculated according to the following formula: Bhash = Hash(Bbody), wherein Hash represents a hash operation; 5) a block trust root number TRN, the value of TRN is the block number of the first block in the current blockchain; 6) a block trust root header hash TRhash, represented by a binary string, and the value of TRhash is calculated according to the following formula: TRhash = Hash(Hash(block in the blockchain with the smallest STP.Bheader) + BN). Wherein, the block header of the block with the minimum STP in the blockchain represents all attributes in the block header of the block with the minimum timestamp STP in the current blockchain; the block with the minimum timestamp STP in the current blockchain is the first block in the current blockchain; When the number of blocks in the blockchain is less than LTN, a new block is added to the tail of the blockchain; when the number of blocks in the blockchain is greater than or equal to LTN, the first block is removed from the blockchain, and then a new block is added to the tail of the blockchain; When it is necessary to increase the block length threshold from LTN to N, it is judged whether the block number of the first block in the blockchain is equal to 0; if yes, the block length threshold is reset to N; otherwise, new blocks are continuously added to the blockchain until the block number of the first block is 0, and then the block length threshold is reset to N; When it is necessary to reduce the block length threshold from LTN to M, it is judged whether the block number of the first block in the blockchain is equal to M; if yes, starting from the first block in the blockchain, (LTN-M) blocks are sequentially removed, and the block length threshold is reset to M; otherwise, new blocks are continuously added to the blockchain until the block number of the first block is M.
2. The length-adjustable blockchain of claim 1, wherein, The block number BN of the first block is 0, the parent block header hash Phash of the first block is empty, and the block trust root header hash TRhash of the first block is empty.
3. The length-adjustable blockchain of claim 1, wherein, The hash algorithm includes but is not limited to cyclic redundancy check algorithm CRC, MD5 information digest algorithm, SM3 password hash algorithm and secure hash algorithm SHA.
4. The length-adjustable blockchain of claim 1, wherein, The removed blocks in the blockchain are synchronously or asynchronously stored in an external non-volatile medium storage, and are backed up offline or online, wherein the external non-volatile medium storage includes high-density magnetic tape, disk array and mobile hard disk.
5. A block verification method for the length-adjustable blockchain of any one of claims 1-4, characterized in that, The block verification method includes the following steps: Step 1, find the block with the minimum timestamp STP in the blockchain, calculate the hash value of the current block body, and compare it with the block body hash Bhash in the current block header; if they are the same, the current block body integrity verification is passed, and step 2 is entered to verify the integrity of the current block header; otherwise, the verification is not passed, and the verification is stopped; Step 2, it is judged whether the current block is the last block in the blockchain; if not, the joint hash value Temp0 of all attributes in the current block header is calculated, and the calculation formula is as follows: Temp0 = Hash(current block.Bheader), Wherein, the current block.Bheader represents all attributes in the current block header; compare the joint hash value of all attributes with the parent block header hash Phash in the block header of the next block of the current block; if they are the same, the integrity verification of the current block header is passed, and step 1 is returned to continue verifying the next block; otherwise, the verification is not passed, and the verification is stopped; If it is the last block, the parent block header hash Phash in the first block header in the blockchain is combined with the joint hash of [(block number BN-1) mod LTN] of the first block, and the calculation formula is as follows: Temp1 = (first block.Bheader.BN - 1) mod LTN = last block.Bheader.BN, Temp2 = Hash(first block.Bheader.Phash + Temp1), wherein first block.Bheader.BN represents the block number in the first block header, last block.Bheader.BN represents the block number in the last block header, first block.Bheader.Phash represents the parent block header hash in the first block header, Temp1 represents an intermediate result, and Temp2 represents a final result, the final result is compared with the trust root header hash TRhash in the last block header, if the same, the current block header integrity verification is passed, and all block verifications are completed; otherwise, the verification is not passed, and the verification is stopped. 6.A computer device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, and the computer device is characterized in that, The processor implements the steps of the block verification method of claim 5 when executing the computer program.
7. A computer-readable storage medium storing a computer program, wherein the computer program comprises the following steps of: receiving a request for a resource from a client; determining whether the client is authorized to access the resource; and if the client is authorized to access the resource, providing the resource to the client. The computer program is executed by the processor to implement the steps of the block verification method of claim 5.
Citation Information
Patent Citations
Block chain generation method, data verification method, node and system
CN107657438A
Block chain generation method, data verification method, nodes and system
CN107807951A