Method and system for generating block chain modified in expansionTechnical Field
The embodiment of the invention belongs to the technical field of block chains, and particularly relates to a block chain generation method and system for modification in expansion.
Background
With the continuous development of the internet, a block chain technology is produced, and the block chain technology is an internet database technology and has the characteristics of decentralization, openness and transparency. In particular, the essence of blockchain technology is a decentralized and distributed approach to data storage, transmission and certification, replacing the current internet dependency on a central server with data blocks, such that all data changes or transaction items are recorded on a cloud system. Since there is no distributed peer-to-peer network of central control points and a distributed method of collective operation is used, it can be said that the blockchain is a "public big ledger" on the network. The system has a plurality of nodes, each node can observe the whole ledger and participate in maintenance together, the income is the right of obtaining accounting, a complete database can be copied, and a single node cannot modify the database, so that the safety and reliability of ledger data are ensured.
At present, the block chain technology is widely applied to various business fields for organizing and managing data.
In the process of implementing the invention, the inventor finds that the prior art has the following defects:
the existing block chain only generates new blocks in sequence along the extension direction of the block chain, the generation mode of the chain is single, and the overall form of the block chain cannot be embodied until a certain historical time, and especially when a certain block in the block chain needs to be modified or even deleted, a user cannot know the form of the whole block chain before modification operation.
Disclosure of Invention
The embodiment of the invention provides a method and a system for generating a block chain modified in expansion, and aims to store the historical forms of the block chain in each stage in the form of the block chain on the whole by combining a data snapshot technology on the basis of the extension process of the existing block chain, and particularly to keep the historical forms of the block chain before modification operation is carried out on blocks in the block chain.
In order to achieve the above object, an embodiment of the present invention provides a method for generating a block chain modified in an extension, where the block chain is composed of an extended block chain, or is composed of an extended block chain and one or more non-extended block chains, and in an extension process of the block chain, when a new block is generated for newly generated data, the new block is linked to the extended block chain; the generation method comprises the following steps: performing data snapshot on a currently formed extension block chain, and generating a snapshot result block chain corresponding to the extension block chain, wherein the extension block chain is originally recorded as a snapshot object block chain, a first link relation between the snapshot result block chain and each block in the snapshot object block chain is the same as the correspondence of the contents of block data in the blocks; modifying block volume data of blocks in the snapshot result block chain and/or link relations among the blocks; taking each block in the snapshot object block chain as a parent block, taking each block corresponding to each parent block in the modified snapshot result block chain as a child block, and performing combined linking on the snapshot object block chain and the modified snapshot result block chain to form a second linking relation; and according to the first link relation and the second link relation, sequentially generating the hash value of each block in the modified snapshot result block chain, writing the hash value into the block head of each corresponding block to form an expanded block chain, marking the snapshot result block chain in the expanded block chain as the extended block chain, and marking the snapshot object block chain as a non-extended block chain.
The embodiment of the invention provides a system for generating a block chain modified in expansion, wherein the block chain consists of an extension block chain or consists of an extension block chain and one or more non-extension block chains, and when a new block is generated for newly generated data in the extension process of the block chain, the new block is linked to the extension block chain; the generation system includes: the data snapshot module is configured to perform data snapshot on a currently formed extension block chain, generate a snapshot result block chain corresponding to the extension block chain, mark the extension block chain as a snapshot object block chain, and correspond to the same block data in the block in a first link relationship between the snapshot result block chain and each block in the snapshot object block chain; the data modification module is used for modifying block body data of blocks in the snapshot result block chain and/or the link relation among the blocks; a combined link module, configured to take each block in the snapshot object block chain as a parent block, take each block in the modified snapshot result block chain corresponding to each parent block as a child block, and perform combined link on the snapshot object block chain and the modified snapshot result block chain to form a second link relationship; and the block chain generating module is configured to sequentially generate a hash value of each block in the modified snapshot result block chain according to the first link relationship and the second link relationship, write the hash value into a block header of each corresponding block to form an expanded block chain, mark the snapshot result block chain in the expanded block chain as the extended block chain, and mark the snapshot object block chain as a non-extended block chain.
The method and the system for generating the block chain modified in the expansion of the embodiment of the invention take a data snapshot on the extended block chain which is formed currently, generate a snapshot result block chain corresponding to the block chain, mark the original extended block chain as a snapshot object block chain, and then modify the block body data of the blocks in the snapshot result block chain and/or the link relation among the blocks; then, taking each block in the snapshot object block chain as a parent block, taking each block corresponding to each parent block in the modified snapshot result block chain as a child block, and performing combined linking on the snapshot object block chain and the modified snapshot result block chain to form a second linking relation; and according to the first link relation and the second link relation, generating the hash value of each block in the modified snapshot result block chain in sequence, writing the hash value into the block head of each corresponding block to form an expanded block chain, marking the snapshot result block chain in the expanded block chain as an extended block chain, and marking the snapshot object block chain as a non-extended block chain. The expanded block chain can clearly reserve the trace of the modification operation of the block chain in the expanding process.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Fig. 1 is a first block chain configuration diagram according to an embodiment of the present invention;
FIG. 2 is a block chain configuration diagram II according to an embodiment of the present invention;
fig. 3 is a third diagram illustrating a block chain according to an embodiment of the present invention;
fig. 4 is a flowchart of a first method for generating a block chain modified in an extension according to an embodiment of the present invention;
FIG. 5 is a block chain configuration diagram of the present invention;
FIG. 6 is a schematic diagram of a method for modifying block data according to an embodiment of the present invention;
FIG. 7 is a first diagram illustrating a method for modifying inter-block linking relationships according to an embodiment of the present invention;
FIG. 8 is a diagram illustrating a second method for modifying inter-block linking relationships according to an embodiment of the present invention;
FIG. 9 is a block chain diagram according to a fifth embodiment of the present invention;
FIG. 10 is a block chain diagram six according to an embodiment of the present invention;
fig. 11 is a flowchart of a second method for generating a block chain modified in an extension according to the embodiment of the present invention;
FIG. 12 is a flow chart of a data snapshot method provided by an embodiment of the present invention;
fig. 13 is a seventh block chain configuration diagram according to an embodiment of the present invention;
FIG. 14 is a diagram of a comprehensive morphology of data snapshots and block extensions for extended block chains provided by an embodiment of the present invention;
FIG. 15 is a first schematic diagram of a system for generating a blockchain modified in an expansion according to an embodiment of the present invention;
FIG. 16 is a block diagram of a data snapshot module according to an embodiment of the present invention;
fig. 17 is a second schematic diagram of a system for generating a blockchain modified in an extension according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Before describing the contents of the embodiments of the present invention, the following terms are explained:
data snapshot: the data replication is not completely the same, and a result after the data snapshot is the same as partial data existing between the original data of the executed snapshot, which may specifically be: the data after snapshot is completely the same as the original data, all the data after snapshot is the same as partial data of the original data, and partial data in the data after snapshot is the same as all or partial data in the original data;
extending the block chain: when a new block is generated for newly generated data, a part of a block chain linked by the new block in the whole block chain is called as an extended block chain; a complete blockchain, which may be composed of an extended blockchain or composed of an extended blockchain and one or more non-extended blockchains, wherein the defined range of the extended blockchain in the complete blockchain is newly specified after the blockchain is subjected to operations such as data snapshot, block modification, and the like; when the blockchain initially includes only one created block, the created block constitutes the extended blockchain in the initial state. It is noted that the new block generated by the newly generated data does not include the new block generated by performing the operations such as data snapshot, block modification, and the like on the block chain.
Snapshot object blockchain: the block chain of the data snapshot operation is recorded as a snapshot object block chain corresponding to the current snapshot;
snapshot result block chaining: and after the block chain is subjected to snapshot operation, generating a result block chain relative to the snapshot object block chain.
It should be noted that, in the embodiments of the present invention, a method for generating a modified blockchain in an extension is provided, so as to retain a shape of a blockchain before modification in an extended blockchain. Performing data snapshot on a currently formed block chain before modifying the block chain each time to generate a snapshot result block chain, recording an original block chain as a snapshot object block chain, wherein a first link relation between the snapshot result block chain and each block in the snapshot object block chain is the same as the corresponding content of block data in the block; modifying the snapshot result block chain, and combining and linking the modified snapshot result block chain and the snapshot object block chain to form an expanded block chain and a second link relation; and according to the first link relation and the second link relation, sequentially generating the hash value of each block in the modified snapshot result block chain, and writing the hash value into the block head of each corresponding block to form the expanded block chain. The expanded blockchain retains the shape of the modified preceding blockchain. The block volume data described herein is understood to be information as actual transaction data, and the block header data includes a hash value, which is a fixed-length character string generated by an irreversible algorithm on all data of a parent block of the current block, and control information related to the current block, and the block volume data and the block header data constitute complete data of one block.
Next, the transaction information described in the block volume data of each block in the block chain in the embodiment of the present invention is not limited to the information of "account book" or "financial transaction" in the business, and may be broadly understood as diversified object data that needs to be managed by such a data organization form as the block chain, such as enterprise management data for managing an enterprise, project progress management data for tracking a project, and the like. In the embodiment of the invention, the form and the extension direction of the block chain are not limited, and the overall dimension of the current block chain is expanded through the data snapshot only in the normal extension process of the block chain, and the block data is modified in the expansion process. For example, the extended form of the block chain may be a conventional single-chain block chain as shown in fig. 1, or may be a block chain in an overall tree structure as shown in fig. 2 (each block in the block chain has only one parent block and one or more child blocks), or may be a block chain having a directed acyclic pattern structure as shown in fig. 3 (at least one block in the block chain has one or more parent blocks).
The following describes in detail a method for generating a block chain modified in development according to an embodiment of the present invention.
Example one
Fig. 4 is a flowchart of a first method for generating a blockchain modified in an extension according to an embodiment of the present invention, where the blockchain is formed by an extended blockchain, or formed by an extended blockchain and one or more non-extended blockchains, and in an extension process of the blockchain, when a new block is generated for newly generated data, the new block is linked to the extended blockchain. As shown in fig. 4, the block chain generating method includes the following steps:
s410, performing data snapshot on the currently formed extended block chain to generate a snapshot result block chain corresponding to the extended block chain, marking the original extended block chain as a snapshot object block chain, and making the first link relation between the snapshot result block chain and each block in the snapshot object block chain and the content of the block data in the blocks correspondingly identical;
the extended block chain formed currently refers to a block chain shape which is shown by the formed extended block chain as a whole when the current time is reached.
Specifically, when the extension block chain currently formed needs to be modified, a data snapshot may be performed on the extension block chain currently formed first, so as to generate a snapshot result block chain corresponding to the extension block chain currently formed.
It should be noted that the process of the data snapshot in this embodiment is an operation of partially copying and/or entirely copying and/or modifying the content of the snapshot object. The operation is only used for making the block volume data of each block in the snapshot result block chain generated after the data snapshot and the snapshot object block chain correspond to the same, and the link relation between the blocks corresponds to the same. Here, the link relationship among the blocks in the snapshot object block chain is defined as the first link relationship as a whole, and since the link relationship between the generated snapshot result block chain and the corresponding snapshot object block chain is the same after the data snapshot, the link relationship among the blocks in the snapshot result block chain can also be defined as the first link relationship as a whole. The link relation between the blocks refers to the parent-child relation existing between the blocks, and the parent-child relation does not require that the consistency verification is carried out through the hash value in the block header data in the blocks. In other words, the linking relationship in this embodiment is only to express a linking frame between blocks, and is not used as a definition scope for specifying consistency verification between blocks.
In a specific application, the purpose of the data snapshot is to make the snapshot result block chain and the snapshot object block chain be the same in the overall architecture of the block chain, and the block volume data in each block is also the same correspondingly, and the data in the block header may be the same or different, even in the snapshot result block chain, there is no substantial data in the block header of each block, which needs to be determined according to specific requirements.
In the subsequent step, the snapshot result block chain is also modified, and in order to reduce the complexity of subsequently calculating the hash value of each block, the block header data of each block in the snapshot result block chain obtained through the data snapshot is default to be null. From this, it can be considered that the snapshot result block chain obtained after the data snapshot is an "incomplete" block chain, and the block header of each block in the block chain does not include a hash value that can verify the consistency of the block chain. A "complete" chain of blocks is considered only if hash values are added to the block headers of the blocks of the snapshot result chain of blocks and the hash values satisfy the consistency verification requirements of the chain of blocks.
For example, fig. 5 shows a morphological sample of the corresponding snapshot object block chain and snapshot result block chain after the data snapshot. As can be seen from the figure, the snapshot object block chain and the snapshot result block chain are identical in the overall configuration, the linking relationships (first linking relationships) between the blocks in the two block chains are correspondingly identical, the block data in the block are correspondingly identical, the block header data are not necessarily identical, and even the block header data of each block in the snapshot result block chain may be empty.
S420, modifying block body data of blocks in the snapshot result block chain and/or the link relation among the blocks;
in order to meet the modification requirement of block volume data of blocks in a snapshot result block chain and the requirement of adjusting the link organization form of each block in the block chain in practical application, the block volume data of the blocks in the generated snapshot result block chain and/or the link relation between the blocks can be modified after the data snapshot.
Specifically, modifying block volume data of blocks in the snapshot result block chain includes: at least one of adding, deleting and replacing the contents of the block volume data.
For example, fig. 6 shows a schematic diagram of operations for modifying the block volume data, such as a delete operation of data 1 in the block volume data, an add operation of data 3 to the block volume data, and a replace operation of replacing data 2 with data 2'.
Specifically, modifying the link relationship between blocks in the snapshot result block chain includes:
the link relationship between the blocks is exchanged,
and/or the presence of a gas in the gas,
after one or more blocks are deleted and/or added, the link relation between the blocks is newly formed.
The swapping of the link relationship between the blocks means that the link relationship between the existing blocks is adjusted without adding or deleting the blocks in the block chain. For example, as shown in fig. 7, the tree-link relationship formed by block a as a parent block and blocks B and C as children blocks is adjusted to a single-chain link relationship formed by block a as a parent block of block B and block B as a parent block of block C.
The step of deleting and/or adding one or more blocks and then newly forming the link relationship between the blocks refers to deleting and/or adding one or more blocks in a currently formed snapshot result block chain and then newly forming the link relationship between the blocks as required. For example, in the block chain of the tree-link relationship shown in fig. 8, which is configured with block a as a parent block and block B and block C as children blocks, block D is added and block B is deleted, and then block D is linked after block a as required, thereby forming a new block chain of the tree-link relationship.
Specifically, after modifying the block volume data of the blocks and/or the link relationship between the blocks in the snapshot result block chain formed by the data snapshot, the following definitions are provided for each block in the snapshot result block chain:
the block after modifying the block volume data of the block still maintains the corresponding relation with the original corresponding block in the snapshot object block chain;
after the link relation among the blocks is exchanged, the corresponding blocks still keep the corresponding relation with the original corresponding blocks in the snapshot object block chain;
the added block does not have a corresponding block in the snapshot object block chain.
S430, taking each block in the snapshot object block chain as a parent block, taking each block corresponding to each parent block in the modified snapshot result block chain as a child block, and performing combined linking on the snapshot object block chain and the modified snapshot result block chain to form a second linking relation;
for example, in fig. 5, block a and block B in the snapshot object block chain are used as parent blocks, and block a1 (the block volume data of a1 is modified) corresponding to the parent block a in the snapshot result block chain is used as a child block of block a; the block B1 corresponding to the parent block B (the block volume data of a1 has been modified) serves as a child block of the block B, thereby compositely linking the snapshot object block chain and the snapshot result block chain and forming a second linking relationship. The second link relationship is a general term of all link relationships between the snapshot object block chain and the modified snapshot result block chain. The block chain state diagram shown in fig. 9 is a block chain state diagram obtained by combining and linking the snapshot object block chain and the modified snapshot result block chain. It should be noted that, by combining and linking the snapshot object block chain and the snapshot result block chain, only the link relationship between the two block chains is determined, and consistency verification after block chain linking is not involved, so that in the block chain formed after combining and linking, the block header data of each block in the snapshot result block chain is still undefined.
In the block chain configuration diagrams shown in fig. 5 and 9, the block header data of each block in the snapshot result block chain is not limited, and therefore "block header data? "show.
And S440, according to the first link relation and the second link relation, generating the hash value of each block in the modified snapshot result block chain in sequence, writing the hash value into the block head of each corresponding block to form an expanded block chain, marking the snapshot result block chain in the expanded block chain as an extended block chain, and marking the snapshot object block chain as a non-extended block chain.
For example, taking the block chain form shown in fig. 9 as an example, the parent-child relationship between the corresponding blocks is determined according to the first link relationship of each block in the snapshot result block chain and the second link relationship between the modified snapshot result block chain and the snapshot object block chain, and then according to the parent-child relationship, the hash values of each block in the modified snapshot result block chain are sequentially generated and written into the block headers of the corresponding blocks, so as to form the expanded block chain in the form shown in fig. 10.
As shown in fig. 10, "sequentially generating" here means that a hash value of the block a1 is generated first, the hash value being a fixed-length character string generated by an irreversible algorithm on all data in the parent block a of the block a1, and the hash value providing a guarantee of the existence and non-falsification of the plaintext into the block chain. After the hash value of the tile a1 is obtained, the hash value is added to the tile header of the tile a1, the tile header data A3 of the tile a1 is formed, and the modified tile volume data a2 and the tile header data A3 together form the complete data of the tile a 1; then, the hash value of the tile B1 is calculated according to the parent-child relationship between the tiles (determined by the first linking relationship and the second linking relationship), the hash value includes two character strings of fixed length generated by the irreversible algorithm for all data in the parent tile a1 of the tile B1 and a character string of fixed length generated by the irreversible algorithm for all data in the parent tile B of the tile B1, the two hash values are added to the tile header of the tile B1 to form the tile header data B3 of the tile B1, and the modified tile body data B2 and the tile header data B3 together form the complete data of the tile B1. After the block header data of each block in all the modified snapshot result block chains are calculated in sequence according to the method, the formed whole block chain is marked as an expanded block chain. In the expanded block chain, the modified snapshot result block chain is used as a subsequent extension block chain, and the snapshot object block chain is used as a non-extension block chain.
The irreversible algorithm may be a fixed-length computation (Hash) algorithm, and correspondingly, the character string obtained by the irreversible algorithm may be a Hash value.
When the block body data of each block in the snapshot result block chain is formed, other control data possibly existing in the block head data is ignored, and if the control data exists in the block head of the block, the control data and the calculated hash value can be used as the block head data of the current block.
The method for generating a block chain modified in an extension provided by the embodiment of the invention includes the steps of performing data snapshot on a currently formed extended block chain, generating a snapshot result block chain corresponding to the block chain, marking an original extended block chain as a snapshot object block chain, and then modifying block body data of blocks in the snapshot result block chain and/or link relations among the blocks; then, taking each block in the snapshot object block chain as a parent block, taking each block corresponding to each parent block in the modified snapshot result block chain as a child block, and performing combined linking on the snapshot object block chain and the modified snapshot result block chain to form a second linking relation; and according to the first link relation and the second link relation, sequentially generating the hash value of each block in the modified snapshot result block chain, writing the hash value into the block head of each corresponding block to form an expanded block chain, marking the snapshot result block chain in the expanded block chain as an extended block chain, and taking the snapshot object block chain as a non-extended block chain. The expanded block chain can clearly reserve the trace of the modification operation of the block chain in the expanding process.
Example two
Fig. 11 is a flowchart of a second method for generating a blockchain modified in an extension according to an embodiment of the present invention, where the embodiment of the method can be regarded as a refinement method of the embodiment of the method shown in fig. 4. As shown in fig. 11, the block chain generating method includes the following steps:
s111, performing data snapshot on the currently formed extended block chain to generate a snapshot result block chain corresponding to the extended block chain, marking the original extended block chain as a snapshot object block chain, and making the first link relation between the snapshot result block chain and each block in the snapshot object block chain and the content of the block data in the blocks correspondingly identical; step S111 is similar to step S410.
Specifically, fig. 12 shows a specific method for data snapshot, in which the block header data of each block of the snapshot result block chain generated according to the method is empty. As shown in fig. 12, the method for data snapshot includes the following steps:
s121, copying block body data of each block in the snapshot object block chain and a first link relation between the blocks, and building a block chain architecture according to copy contents;
for example, taking the snapshot object block chain shown in fig. 5 as an example, block body data in a block a and a block B and a first link relation are copied, and blocks without block head data are constructed by the copied block body data, and then the blocks are constructed into a block chain architecture according to the first link relation.
And S122, adding label information aiming at the current data snapshot into the block head of each block in the built block chain structure to form a snapshot result block chain.
The tag information may include time information for the current data snapshot, storage location information of the block, and the like.
As shown in fig. 13, a block chain architecture constructed according to the above steps is shown, where block volume data of each block in the block chain architecture is the same as block volume data of each block in a snapshot object block chain, and tag information for the current data snapshot is added to block header data, and the tag information in the block header of each block may be the same or different.
S112, modifying block body data of blocks in the snapshot result block chain and/or the link relation among the blocks;
s113, taking each block in the snapshot object block chain as a parent block, taking each block in the modified snapshot result block chain corresponding to each parent block as a child block, and performing combined linking on the snapshot object block chain and the modified snapshot result block chain to form a second linking relationship;
and S114, according to the first link relation and the second link relation, sequentially generating hash values of all blocks in the modified snapshot result block chain, writing the hash values into block headers of all corresponding blocks to form an expanded block chain, marking the snapshot result block chain in the expanded block chain as an extended block chain, and taking the snapshot object block chain as a non-extended block chain.
The contents of steps S112 to S114 correspond to the same contents of steps S420 to S440.
After step S114, step S115 may be further performed to extend the block chain as an extended block chain in the expanded block chain.
It should be noted that in this embodiment, the operations of performing the data snapshot operation and performing the block extension both use the extension block chain as the operation target.
For example, fig. 14 shows a comprehensive change pattern diagram of data snapshot and block extension for an extended block chain. As shown in the figure, the morphology of the block chain in 4 states is shown:
state at time T1: the state is the initial state of the block chain, and the figure only comprises an extended block chain consisting of one block A;
state at time T2: in this state, the original extended block chain has completed the first data snapshot, and a snapshot result block chain composed of block a1 is generated, the snapshot result block chain is linked and combined with the corresponding snapshot object block chain to form an extended block chain, and in the extended block chain, the snapshot result block chain is used as the extended block chain, and block B is generated by extension;
state at time T3: in this state, the extended blockchain completes the second data snapshot, and generates a snapshot result blockchain composed of a blocka 2 and a blockb 1, the snapshot result blockchain is linked and combined with the corresponding snapshot object blockchain to form an extended blockchain, and in the extended blockchain, the snapshot result blockchain is used as an extended blockchain, and a blockc and a blockd are generated by extension;
state at time T4: in this state, the extended blockchain completes the third data snapshot, generates a snapshot result blockchain composed of a block a3, a block B2, a block C1, and a block D1, modifies the snapshot result blockchain, deletes the block D1 (in the actual data snapshot, the data snapshot operation may not be performed on the block D), combines the modified snapshot result blockchain with the corresponding snapshot object blockchain to form an extended blockchain, and extends and generates a block E in the extended blockchain by using the snapshot result blockchain as an extended blockchain.
After the first and second data snapshots, block data of each block in the generated snapshot result block chain can be modified, and the modified snapshot result block chain and the corresponding snapshot object block chain are combined and linked.
The method for generating the block chain modified in the expansion in the embodiment of the invention is described in detail in the process of performing data snapshot on the extended block chain on the basis of the first embodiment; after the data snapshot is completed, modifying the block body data and/or the link relation among the blocks of the obtained snapshot result block chain, and performing block extension by using the data snapshot block chain in each expanded block chain as an extension block chain, so that the extension form of the real block chain is maintained.
EXAMPLE III
Fig. 15 is a schematic diagram of a system for generating a blockchain modified in an extension according to an embodiment of the present invention, where the blockchain is formed by an extended blockchain, or formed by an extended blockchain and one or more non-extended blockchains, and in an extension process of the blockchain, when a new block is generated for newly generated data, the new block is linked to the extended blockchain. The generation system may be used to perform the method steps as shown in fig. 4. As shown in fig. 15, the system for generating the block chain includes: adata snapshot module 151, adata modification module 152, a combinedlinking module 153, and a blockchain generation module 154, wherein:
a data snapshot module 151, configured to perform data snapshot on a currently formed extension block chain, and generate a snapshot result block chain corresponding to the extension block chain, where the extension block chain is originally marked as a snapshot object block chain, and a first link relationship between the snapshot result block chain and each block in the snapshot object block chain is the same as a correspondence between contents of block data in the blocks; a data modification module 152, configured to modify block volume data of blocks in the snapshot result block chain and/or a link relationship between the blocks; the combined link module 153 is configured to take each block in the snapshot object block chain as a parent block, take each block in the modified snapshot result block chain corresponding to each parent block as a child block, and combine and link the snapshot object block chain and the modified snapshot result block chain to form a second link relationship; the block chain generating module 154 is configured to sequentially generate hash values of blocks in the modified snapshot result block chain according to the first link relationship and the second link relationship, write the hash values into block headers of the corresponding blocks to form an expanded block chain, mark the snapshot result block chain in the expanded block chain as an extended block chain, and mark the snapshot object block chain as a non-extended block chain.
The system for generating a block chain modified in an expansion provided by the embodiment of the invention performs data snapshot on a currently formed extended block chain to generate a snapshot result block chain corresponding to the block chain, marks an original extended block chain as a snapshot object block chain, and then modifies block body data of blocks in the snapshot result block chain and/or link relations among the blocks; then, taking each block in the snapshot object block chain as a parent block, taking each block corresponding to each parent block in the modified snapshot result block chain as a child block, and performing combined linking on the snapshot object block chain and the modified snapshot result block chain to form a second linking relation; and according to the first link relation and the second link relation, generating the hash value of each block in the modified snapshot result block chain in sequence, writing the hash value into the block head of each corresponding block to form an expanded block chain, marking the snapshot result block chain in the expanded block chain as an extended block chain, and marking the snapshot object block chain as a non-extended block chain. The expanded block chain can clearly reserve the trace of the modification operation of the block chain in the expanding process.
Example four
The embodiment of the present invention performs structural and functional refinement on the system embodiment shown in fig. 15, and the refined structure can be used to execute the method steps shown in fig. 11. Specifically, on the basis of the structure shown in fig. 15:
as shown in fig. 16, thedata snapshot module 151 may specifically include:
thearchitecture building unit 161 is configured to copy block body data of each block in the snapshot object block chain and the first link relationship between each block, and build a block chain architecture according to copy contents; theinformation adding unit 162 is configured to add tag information for the current data snapshot to a block header of each block in the built block chain architecture to form a snapshot result block chain.
Thedata snapshot module 151 may be specifically configured to perform the method steps shown in fig. 12.
Further, thedata modification module 152 may specifically include a data modification unit, configured to perform at least one of adding, deleting and replacing on the content of the block volume data.
Further, the data modification module 154 may further include a link relationship modification unit for exchanging the link relationship between the blocks,
and/or the presence of a gas in the gas,
after one or more blocks are deleted and/or added, the link relation between the blocks is newly formed.
Further, as shown in fig. 17, the system shown in fig. 15 may further include: theblock extending module 155 is configured to extend the block chain by using the snapshot result block chain in the expanded block chain as an extended block chain.
The system for generating the block chain modified in the expansion of the embodiment of the invention performs a data snapshot process of extending the block chain on the data snapshot module on the basis of the system shown in the third embodiment, and the detailed description is given; after the data snapshot is completed, modifying the block body data and/or the link relation among the blocks of the obtained snapshot result block chain, and performing block extension by using the data snapshot block chain in each expanded block chain as an extension block chain, so that the extension form of the real block chain is maintained.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.