Detailed Description
In order to better understand the technical solutions in the present application, the following description will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, shall fall within the scope of the present application.
The embodiment of the application aims to provide a data migration method, device and equipment applied to a blockchain so as to migrate data in the blockchain. The data migration method can be applied to a alliance chain scene to realize block chain data migration in the alliance chain scene. The method in the embodiment of the application can be executed by a specific data migration plug-in, and the data migration plug-in can be executed on a separate computer device or can be executed in a target blockchain platform to which data is migrated.
Fig. 1 is a flowchart of a data migration method applied to a blockchain according to an embodiment of the present application, as shown in fig. 1, the method includes the following steps:
step S102, historical transaction data to be migrated of an original blockchain is obtained;
step S104, constructing a new transaction corresponding to the historical transaction data to be migrated in the target blockchain according to the transaction data structure of the target blockchain to which the historical transaction data to be migrated is to be migrated; the new transaction is used for representing historical transaction contents corresponding to the historical transaction data to be migrated;
step S106, executing new transaction in the target blockchain to migrate the historical transaction data to be migrated to the target blockchain.
In the embodiment of the application, first, historical transaction data to be migrated of an original blockchain is obtained, then, according to a transaction data structure of a target blockchain to which the historical transaction data to be migrated is to be migrated, a new transaction corresponding to the historical transaction data to be migrated is constructed in the target blockchain, wherein the new transaction is used for representing historical transaction content corresponding to the historical transaction data to be migrated, and finally, the new transaction is executed in the target blockchain so as to migrate the historical transaction data to the target blockchain. Therefore, according to the embodiment of the application, the historical transaction data to be migrated can be migrated from the original blockchain to the target blockchain, so that the purpose of migrating the data in the blockchain is achieved.
In the step S102, each block in the original blockchain is traversed in sequence to obtain the historical transaction data in the original blockchain, and the historical transaction data is used as the historical transaction data to be migrated. Historical transaction data to be migrated includes, but is not limited to, transfer data between accounts, creation data for accounts, and the like.
In the step S104, according to the transaction data structure of the target blockchain to which the historical transaction data to be migrated is to be migrated, a new transaction corresponding to the historical transaction data to be migrated is constructed in the target blockchain, specifically:
(a1) Analyzing the transaction data structure of the target blockchain to obtain each transaction field name included in the transaction data structure of the target blockchain;
(a2) Extracting field values corresponding to each transaction field name from historical transaction data to be migrated;
(a3) And splicing field values corresponding to the transaction field names in the target blockchain according to the transaction data structure of the target blockchain to obtain a new transaction.
In a specific example, the historical transaction data to be migrated is: "3.1.2019, transfer of money to plum four, transfer amount is 10 yuan". The transaction data structure of the target blockchain is "transfer person-receiver-transfer time-transfer amount". In this example, first, the transaction data structure of the target blockchain is parsed to obtain each transaction field name included in the transaction data structure of the target blockchain, where each transaction field name includes: transfer person, payee, transfer time, transfer amount. Then, extracting the field value corresponding to each transaction field name from the historical transaction data to be migrated to obtain the field value corresponding to the ' transfer person ' as ' Zhang Sanj ', the field value corresponding to the ' payee ' as ' Liqu ', the field value corresponding to the ' transfer time ' as ' 2019 as ' 3 month 1 day ', and the field value corresponding to the ' transfer amount ' as ' 10 yuan '. Finally, according to the transaction data structure of the target blockchain, splicing field values corresponding to the transaction field names in the target blockchain to obtain a new transaction, wherein the new transaction is 'Zhang San-Lisi-2019, 3 months, 1 day-10 yuan'.
In this embodiment, the new transaction is used to represent the historical transaction content corresponding to the historical transaction data to be migrated, that is, the new transaction is identical to the historical transaction content corresponding to the historical transaction data to be migrated, and the difference between the new transaction and the historical transaction data to be migrated is that the new transaction is matched with the transaction data structure of the target blockchain, and the historical transaction data to be migrated is matched with the transaction data structure of the original blockchain.
Therefore, in this embodiment, considering that the transaction data structure of the original blockchain is different from the data transaction structure of the target blockchain, a new transaction corresponding to the historical transaction data to be migrated may be constructed in the target blockchain according to the transaction data structure of the target blockchain, and the historical transaction content corresponding to the historical transaction data to be migrated may be represented by the new transaction.
In step S106, a new transaction is executed in the target blockchain to migrate the historical transaction data to be migrated to the target blockchain. Because the new transaction is used for representing the historical transaction content corresponding to the historical transaction data to be migrated, executing the new transaction in the target blockchain is equivalent to re-executing all the historical transactions to be migrated in the target blockchain, thereby achieving the purpose of migrating the historical transaction data to be migrated to the target blockchain.
It can be seen that, according to the embodiment of the application, the historical transaction data to be migrated can be migrated to the target blockchain in a transaction replay mode. Where transaction replay may be understood as meaning transaction re-execution.
In this embodiment, after the target blockchain executes the new transaction, it may also be verified whether the historical transaction data to be migrated is successful, and if so, it is determined that the data migration is completed.
Further, considering that the hash values of the historical transaction and the new transaction are different, fig. 2 is a flow chart of a data migration method applied to a blockchain according to another embodiment of the present application, as shown in fig. 2, the method further includes the following steps based on fig. 1:
step S108, obtaining a first hash value of historical transaction data to be migrated and a second hash value of the new transaction;
step S110, constructing an association contract for associating the first hash value and the second hash value, and constructing a contract calling transaction for calling the association contract;
step S112, executing the contract invoking transaction at the target blockchain to save the first hash value and the second hash value association at the target blockchain.
Specifically, first, a first hash value of historical transaction data to be migrated and a second hash value of the new transaction are acquired. And then constructing an association contract for associating the first hash value and the second hash value, wherein the association contract stores the first hash value, the second hash value and the corresponding relation between the first hash value and the second hash value. If the new transaction corresponding to a certain second hash value is constructed based on the historical transaction data to be migrated corresponding to a certain first hash value, the second hash value and the first hash value correspond to each other, that is, in the first hash value and the second hash value corresponding to each other, the new transaction corresponding to the second hash value is constructed based on the historical transaction data to be migrated corresponding to the first hash value.
Further, a contract invocation transaction is also constructed for invoking the associated contract. Finally, executing the contract calling transaction in the target blockchain, calling the associated contract, and storing the first hash value and the second hash value in the target blockchain in an associated manner through calling the associated contract. Storing the first hash value and the second hash value in association with the target blockchain specifically includes storing the first hash value, the second hash value and a correspondence between the first hash value and the second hash value in the target blockchain.
Further, considering the problem that the hash value according to the new transaction is unfavorable for searching the historical transaction content, fig. 3 is a flow chart of a data migration method applied to the blockchain according to another embodiment of the present application, as shown in fig. 3, the method further includes the following steps based on fig. 2:
step S114, obtaining a first hash value of historical transaction data to be migrated corresponding to historical transaction content to be queried;
step S116, calling an association contract to determine a second hash value associated with the acquired first hash value;
step S118, searching a new transaction corresponding to the associated second hash value in the target blockchain;
Step S120, obtaining the historical transaction content to be queried from the corresponding new transaction.
Specifically, firstly, determining historical transaction content to be queried, determining historical transaction data to be migrated corresponding to the historical transaction content, namely determining the historical transaction data to be migrated for recording the historical transaction content, and acquiring a first hash value of the historical transaction data to be migrated.
Next, the association contract described above is invoked to determine a second hash value associated with the obtained first hash value. In this process, the second hash value corresponding to the obtained first hash value may be searched in the correspondence between the first hash value and the second hash value stored in the association contract, and the searched second hash value is used as the second hash value associated with the obtained first hash value.
Then, a new transaction corresponding to the associated second hash value is searched in the target blockchain, namely, the new transaction with the hash value being the associated second hash value is searched. Since the new transaction is used for representing the historical transaction content of the historical transaction data to be migrated, the historical transaction content to be queried can be obtained from the searched corresponding new transaction.
It can be seen that, with the present embodiment, it is possible to store hash values of new and old transactions based on a manner of constructing an association contract, and to implement inquiry of historical transaction contents based on the association contract.
In a specific embodiment, for the certificate transaction, each historical certificate transaction is traversed firstly, a corresponding new transaction is constructed for each historical certificate transaction according to a transaction data structure of a target blockchain, a contract for associating historical transaction hash and new transaction hash is written, a contract calling transaction for calling the contract is constructed, and finally the new transaction and the contract calling transaction are executed, so that transaction data migration is completed. When the business side inquires the evidence-storing data through the historical transaction hash, a new transaction hash can be acquired in a contract calling mode, and then the evidence-storing data is inquired through the new transaction hash.
In summary, embodiments of the present application have at least the following advantages:
1. the migration of the historical transaction data is realized by constructing a new transaction to execute the new transaction, and the integrity of the migration of the historical transaction data is ensured;
2. the storage of the new and old transaction hash values is realized based on the mode of constructing the association contract, and the searching of the historical transaction contents is realized based on the association contract.
Further, the embodiment of the application also provides a data migration method applied to the blockchain, wherein the data migration method can be applied to the alliance chain scene so as to realize the blockchain data migration in the alliance chain scene. The method in the embodiment of the application can be executed by a specific data migration plug-in, and the data migration plug-in can be executed on a separate computer device or can be executed in a target blockchain platform to which data is migrated.
FIG. 4 is a flowchart of a data migration method applied to a blockchain according to another embodiment of the present application, as shown in FIG. 4, the method includes the following steps:
step S402, obtaining state data to be migrated of an original blockchain, and determining whether a target blockchain to which the state data to be migrated is to be migrated and the original blockchain are isomorphic blockchains;
step S404, if yes, writing the state data to be migrated into the target blockchain, if not, converting the data storage structure of the state data to be migrated into the data storage structure of the target blockchain, and writing the converted state data to be migrated into the target blockchain.
In the embodiment of the application, the state data to be migrated of the original blockchain is obtained, whether the target blockchain to which the state data to be migrated is to and the original blockchain are isomorphic blockchains or not is determined, if the target blockchain is isomorphic blockchain, the state data to be migrated is written into the target blockchain, if the target blockchain is not isomorphic blockchain, the data storage structure of the state data to be migrated is converted into the data storage structure of the target blockchain, and the converted state data to be migrated is written into the target blockchain. Therefore, according to the embodiment of the application, the state data to be migrated can be migrated from the original blockchain to the target blockchain, so that the purpose of migrating the data in the blockchain is achieved.
In the step S402, the state data to be migrated of the original blockchain is obtained, and for the common account, the state data to be migrated includes account balance, and for the contract account, the state data to be migrated includes data such as account balance and contract variable.
In step S402, it is determined whether the target blockchain to which the state data to be migrated is to be migrated and the original blockchain are isomorphic blockchains. Isomorphic chains are blockchains that are consistent in design, e.g., data structures, stores, etc., and different isomorphic chains (also referred to as heterogeneous chains) are blockchains that are inconsistent in design, e.g., data structures, stores, etc.
If the target blockchain and the original blockchain are isomorphic blockchains, it is indicated that the designs of the data structures, storage, etc. of the target blockchain and the original blockchain are identical, so in step S406, the state data to be migrated can be directly written into the target blockchain. If the target blockchain is different from the original blockchain, it is indicated that the designs of the data structures, storage, etc. of the target blockchain and the original blockchain are inconsistent, so in step S406, it is necessary to convert the data storage structure of the state data to be migrated into the data storage structure of the target blockchain first, and then write the state data to be migrated after conversion into the target blockchain.
In this embodiment, the data storage structure of the state data to be migrated is a key structure, and the data storage structure of the target blockchain is a table structure; or the data storage structure of the state data to be migrated is a table structure, and the data storage structure of the target blockchain is a key value structure.
In this embodiment, the conversion of the data storage structure of the state data to be migrated into the data storage structure of the target blockchain may be: the data storage structure of the state data to be migrated is converted into a core data structure of a block chain bottom layer, and the data storage structure of the state data to be migrated is converted into a data storage structure of a target block chain based on the core data storage structure. The core data structure of the blockchain bottom layer may be a tree structure.
In one embodiment, the data storage structure of the state data to be migrated is a key value structure, the data storage structure of the target blockchain is a table structure, the core data structure of the bottom layer of the blockchain is a tree structure, and the data storage structure of the state data to be migrated is converted into the data storage structure of the target blockchain, specifically: traversing state data to be migrated according to the key value structure, and determining values of all nodes and child node indexes of all nodes in the tree structure according to the traversed data indexes and data values of all data indexes; combining the values of each node and the child node indexes of each node to convert the data storage structure of the state data to be migrated into a tree structure; traversing the converted state data to be migrated according to the tree structure, and determining each field and the field value of each field in the table structure according to the traversed values of each node and the child node indexes of each node; the fields and field values of the fields are combined to translate the data storage structure of the state data to be migrated into a table structure.
In another embodiment, the data storage structure of the state data to be migrated is a table structure, the data storage structure of the target blockchain is a key value structure, the core data structure of the bottom layer of the blockchain is a tree structure, and the data storage structure of the state data to be migrated is converted into the data storage structure of the target blockchain, specifically: traversing state data to be migrated according to a table structure, and determining values of all nodes and child node indexes of all nodes in a tree structure according to the traversed fields and field values of all fields; combining the values of each node and the child node indexes of each node to convert the data storage structure of the state data to be migrated into a tree structure; traversing the converted state data to be migrated according to the tree structure, and determining each data index and the data value of each data index in the key value structure according to the traversed values of each node and the child node indexes of each node; the respective data indexes and the data values of the respective data indexes are combined to transform the data storage structure of the state data to be migrated into a key-value structure.
In a specific embodiment, when migrating state data, each account in the original blockchain is traversed firstly, if traversing to a common account, the balance value in the account is read, the common account is created in the target blockchain, the balance value is migrated, if traversing to a contract account, the balance value and the contract variable in the account are read, the contract account is created in the target blockchain, and the balance value and the contract variable are migrated.
Therefore, by the method in the embodiment, data migration between isomorphic chains can be realized, and data migration between different isomorphic chains can be realized. In a specific implementation, migration status data (also called world status) or transaction data may be determined first, and if the transaction data is migrated, the method in fig. 1 to 3 is implemented, and if the migration status data is migrated, the method in fig. 4 is implemented. It will be appreciated that if transaction data is migrated by the method of figures 1 to 3 described above, world state will also migrate synchronously.
Corresponding to the data migration method in fig. 1 to 3, the embodiment of the application also provides a data migration device applied to the blockchain, which is used for implementing the data migration method in fig. 1 to 3. Fig. 5 is a schematic block diagram of a data migration apparatus according to an embodiment of the present application, and as shown in fig. 5, the apparatus includes:
the transaction acquisition module 51 is configured to acquire historical transaction data to be migrated of the original blockchain;
the transaction construction module 52 is configured to construct a new transaction corresponding to the historical transaction data to be migrated at the target blockchain according to the transaction data structure of the target blockchain to which the historical transaction data to be migrated is to be migrated; the new transaction is used for representing historical transaction contents corresponding to the historical transaction data to be migrated;
And a transaction execution module 53, configured to execute the new transaction in the target blockchain, so as to migrate the historical transaction data to be migrated to the target blockchain.
Optionally, the transaction construction module 52 is specifically configured to: analyzing the transaction data structure of the target blockchain to obtain each transaction field name included in the transaction data structure of the target blockchain; extracting field values corresponding to the transaction field names from the historical transaction data to be migrated; and splicing field values corresponding to the transaction field names in the target blockchain according to the transaction data structure of the target blockchain to obtain the new transaction.
Optionally, the method further comprises a hash association module for: acquiring a first hash value of the historical transaction data to be migrated and a second hash value of the new transaction; constructing an association contract for associating the first hash value and the second hash value, and constructing a contract call transaction for calling the association contract; and executing the contract invoking transaction on the target blockchain to store the first hash value and the second hash value association in the target blockchain.
Optionally, the transaction searching module is further included for: acquiring a first hash value of historical transaction data to be migrated corresponding to historical transaction content to be queried; invoking the association contract to determine a second hash value associated with the acquired first hash value; searching a new transaction corresponding to the associated second hash value in the target blockchain; and acquiring the historical transaction content to be queried from the corresponding new transaction.
In the embodiment of the application, first, historical transaction data to be migrated of an original blockchain is obtained, then, according to a transaction data structure of a target blockchain to which the historical transaction data to be migrated is to be migrated, a new transaction corresponding to the historical transaction data to be migrated is constructed in the target blockchain, wherein the new transaction is used for representing historical transaction content corresponding to the historical transaction data to be migrated, and finally, the new transaction is executed in the target blockchain so as to migrate the historical transaction data to the target blockchain. Therefore, according to the embodiment of the application, the historical transaction data to be migrated can be migrated from the original blockchain to the target blockchain, so that the purpose of migrating the data in the blockchain is achieved.
It should be noted that, the data migration apparatus in this embodiment can implement the foregoing respective processes of the data migration methods in fig. 1 to 3, and achieve the same functions and effects, which are not repeated here.
Corresponding to the data migration method in fig. 4, the embodiment of the application also provides a data migration device applied to the blockchain, which is used for implementing the data migration method in fig. 4. Fig. 6 is a schematic block diagram of a data migration apparatus according to another embodiment of the present application, and as shown in fig. 6, the apparatus includes:
the state acquisition module 61 is configured to acquire state data to be migrated of an original blockchain, and determine whether a target blockchain to which the state data to be migrated is to and the original blockchain are isomorphic blockchains;
and the state migration module 62 is configured to, if yes, write the state data to be migrated into the target blockchain, if not, convert a data storage structure of the state data to be migrated into a data storage structure of the target blockchain, and write the converted state data to be migrated into the target blockchain.
Optionally, the data storage structure of the state data to be migrated is a key value structure, and the data storage structure of the target blockchain is a table structure; or the data storage structure of the state data to be migrated is a table structure, and the data storage structure of the target blockchain is a key value structure.
Optionally, the state migration module 62 is specifically configured to: converting the data storage structure of the state data to be migrated into a core data structure of a block chain bottom layer; and converting the data storage structure of the state data to be migrated into the data storage structure of the target blockchain based on the core data storage structure.
In the embodiment of the application, the state data to be migrated of the original blockchain is obtained, whether the target blockchain to which the state data to be migrated is to and the original blockchain are isomorphic blockchains or not is determined, if the target blockchain is isomorphic blockchain, the state data to be migrated is written into the target blockchain, if the target blockchain is not isomorphic blockchain, the data storage structure of the state data to be migrated is converted into the data storage structure of the target blockchain, and the converted state data to be migrated is written into the target blockchain. Therefore, according to the embodiment of the application, the state data to be migrated can be migrated from the original blockchain to the target blockchain, so that the purpose of migrating the data in the blockchain is achieved.
It should be noted that, the data migration apparatus in this embodiment can implement the foregoing respective processes of the data migration method in fig. 4, and achieve the same functions and effects, which are not repeated here.
Further, the embodiment of the present application further provides a data migration device applied to a blockchain, and fig. 7 is a schematic structural diagram of the data migration device applied to the blockchain according to an embodiment of the present application, as shown in fig. 7, the data migration device applied to the blockchain may have relatively large differences due to different configurations or performances, and may include one or more processors 901 and a memory 902, where one or more storage applications or data may be stored in the memory 902. Wherein the memory 902 may be transient storage or persistent storage. The application programs stored in the memory 902 may include one or more modules (not shown in the figures), each of which may include a series of computer-executable instructions for use in a data migration apparatus for a blockchain. Still further, the processor 901 may be configured to communicate with the memory 902 to execute a series of computer executable instructions in the memory 902 on a data migration device applied to a blockchain. The data migration device applied to the blockchain may also include one or more power supplies 903, one or more wired or wireless network interfaces 904, one or more input output interfaces 905, one or more keyboards 906, and the like.
In one particular embodiment, a data migration apparatus for use with a blockchain includes a memory, and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for use in the data migration apparatus for a blockchain, and the execution of the one or more programs by one or more processors comprises computer-executable instructions for:
acquiring historical transaction data to be migrated of an original blockchain;
constructing a new transaction corresponding to the historical transaction data to be migrated in the target blockchain according to the transaction data structure of the target blockchain to which the historical transaction data to be migrated is to be migrated; the new transaction is used for representing historical transaction contents corresponding to the historical transaction data to be migrated;
and executing the new transaction in the target blockchain so as to migrate the historical transaction data to be migrated to the target blockchain.
Optionally, the computer executable instructions, when executed, construct a new transaction corresponding to the historical transaction data to be migrated at the target blockchain according to a transaction data structure of the target blockchain to which the historical transaction data to be migrated is to be migrated, including: analyzing the transaction data structure of the target blockchain to obtain each transaction field name included in the transaction data structure of the target blockchain; extracting field values corresponding to the transaction field names from the historical transaction data to be migrated; and splicing field values corresponding to the transaction field names in the target blockchain according to the transaction data structure of the target blockchain to obtain the new transaction.
Optionally, the computer executable instructions, when executed, further comprise: acquiring a first hash value of the historical transaction data to be migrated and a second hash value of the new transaction; constructing an association contract for associating the first hash value and the second hash value, and constructing a contract call transaction for calling the association contract; and executing the contract invoking transaction on the target blockchain to store the first hash value and the second hash value association in the target blockchain.
Optionally, the computer executable instructions, when executed, further comprise: acquiring a first hash value of historical transaction data to be migrated corresponding to historical transaction content to be queried; invoking the association contract to determine a second hash value associated with the acquired first hash value; searching a new transaction corresponding to the associated second hash value in the target blockchain; and acquiring the historical transaction content to be queried from the corresponding new transaction.
In the embodiment of the application, first, historical transaction data to be migrated of an original blockchain is obtained, then, according to a transaction data structure of a target blockchain to which the historical transaction data to be migrated is to be migrated, a new transaction corresponding to the historical transaction data to be migrated is constructed in the target blockchain, wherein the new transaction is used for representing historical transaction content corresponding to the historical transaction data to be migrated, and finally, the new transaction is executed in the target blockchain so as to migrate the historical transaction data to the target blockchain. Therefore, according to the embodiment of the application, the historical transaction data to be migrated can be migrated from the original blockchain to the target blockchain, so that the purpose of migrating the data in the blockchain is achieved.
It should be noted that, the data migration apparatus in this embodiment can implement the foregoing respective processes of the data migration methods in fig. 1 to 3, and achieve the same functions and effects, which are not repeated here.
In another particular embodiment, a data migration apparatus for use with a blockchain includes a memory, and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for use in the data migration apparatus for a blockchain, and the execution of the one or more programs by one or more processors comprises computer-executable instructions for:
acquiring state data to be migrated of an original blockchain, and determining whether a target blockchain to which the state data to be migrated is to be migrated and the original blockchain are isomorphic blockchains;
if yes, the state data to be migrated is written into the target block chain, if not, the data storage structure of the state data to be migrated is converted into the data storage structure of the target block chain, and the converted state data to be migrated is written into the target block chain.
Optionally, when the computer executable instructions are executed, the data storage structure of the state data to be migrated is a key value structure, and the data storage structure of the target blockchain is a table structure; or the data storage structure of the state data to be migrated is a table structure, and the data storage structure of the target blockchain is a key value structure.
Optionally, the computer executable instructions, when executed, transform the data storage structure of the state data to be migrated into the data storage structure of the target blockchain, comprising: converting the data storage structure of the state data to be migrated into a core data structure of a block chain bottom layer; and converting the data storage structure of the state data to be migrated into the data storage structure of the target blockchain based on the core data storage structure.
In the embodiment of the application, the state data to be migrated of the original blockchain is obtained, whether the target blockchain to which the state data to be migrated is to and the original blockchain are isomorphic blockchains or not is determined, if the target blockchain is isomorphic blockchain, the state data to be migrated is written into the target blockchain, if the target blockchain is not isomorphic blockchain, the data storage structure of the state data to be migrated is converted into the data storage structure of the target blockchain, and the converted state data to be migrated is written into the target blockchain. Therefore, according to the embodiment of the application, the state data to be migrated can be migrated from the original blockchain to the target blockchain, so that the purpose of migrating the data in the blockchain is achieved.
It should be noted that, the data migration apparatus in this embodiment can implement the foregoing respective processes of the data migration method in fig. 4, and achieve the same functions and effects, which are not repeated here.
Further, the embodiment of the present application further provides a storage medium, which is configured to store computer executable instructions, and in a specific embodiment, the storage medium may be a usb disk, an optical disc, a hard disk, etc., where the computer executable instructions stored in the storage medium can implement the following flow when executed by a processor:
acquiring historical transaction data to be migrated of an original blockchain;
constructing a new transaction corresponding to the historical transaction data to be migrated in the target blockchain according to the transaction data structure of the target blockchain to which the historical transaction data to be migrated is to be migrated; the new transaction is used for representing historical transaction contents corresponding to the historical transaction data to be migrated;
and executing the new transaction in the target blockchain so as to migrate the historical transaction data to be migrated to the target blockchain.
Optionally, the computer executable instructions stored on the storage medium, when executed by the processor, construct a new transaction corresponding to the historical transaction data to be migrated at the target blockchain according to a transaction data structure of the target blockchain to which the historical transaction data to be migrated is to be migrated, including: analyzing the transaction data structure of the target blockchain to obtain each transaction field name included in the transaction data structure of the target blockchain; extracting field values corresponding to the transaction field names from the historical transaction data to be migrated; and splicing field values corresponding to the transaction field names in the target blockchain according to the transaction data structure of the target blockchain to obtain the new transaction.
Optionally, the storage medium stores computer executable instructions that when executed by the processor further comprise: acquiring a first hash value of the historical transaction data to be migrated and a second hash value of the new transaction; constructing an association contract for associating the first hash value and the second hash value, and constructing a contract call transaction for calling the association contract; and executing the contract invoking transaction on the target blockchain to store the first hash value and the second hash value association in the target blockchain.
Optionally, the storage medium stores computer executable instructions that when executed by the processor further comprise: acquiring a first hash value of historical transaction data to be migrated corresponding to historical transaction content to be queried; invoking the association contract to determine a second hash value associated with the acquired first hash value; searching a new transaction corresponding to the associated second hash value in the target blockchain; and acquiring the historical transaction content to be queried from the corresponding new transaction.
In the embodiment of the application, first, historical transaction data to be migrated of an original blockchain is obtained, then, according to a transaction data structure of a target blockchain to which the historical transaction data to be migrated is to be migrated, a new transaction corresponding to the historical transaction data to be migrated is constructed in the target blockchain, wherein the new transaction is used for representing historical transaction content corresponding to the historical transaction data to be migrated, and finally, the new transaction is executed in the target blockchain so as to migrate the historical transaction data to the target blockchain. Therefore, according to the embodiment of the application, the historical transaction data to be migrated can be migrated from the original blockchain to the target blockchain, so that the purpose of migrating the data in the blockchain is achieved.
It should be noted that the storage medium in this embodiment can implement the foregoing respective processes of the data migration method in fig. 1 to 3, and achieve the same functions and effects, and are not repeated here.
In another particular embodiment, a data migration apparatus for use with a blockchain includes a memory, and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for use in the data migration apparatus for a blockchain, and the execution of the one or more programs by one or more processors comprises computer-executable instructions for:
acquiring state data to be migrated of an original blockchain, and determining whether a target blockchain to which the state data to be migrated is to be migrated and the original blockchain are isomorphic blockchains;
if yes, the state data to be migrated is written into the target block chain, if not, the data storage structure of the state data to be migrated is converted into the data storage structure of the target block chain, and the converted state data to be migrated is written into the target block chain.
Optionally, the computer executable instructions stored by the storage medium, when executed by the processor, the data storage structure of the state data to be migrated is a key structure, and the data storage structure of the target blockchain is a table structure; or the data storage structure of the state data to be migrated is a table structure, and the data storage structure of the target blockchain is a key value structure.
Optionally, the computer executable instructions stored on the storage medium, when executed by the processor, transform the data storage structure of the state data to be migrated into the data storage structure of the target blockchain, comprising: converting the data storage structure of the state data to be migrated into a core data structure of a block chain bottom layer; and converting the data storage structure of the state data to be migrated into the data storage structure of the target blockchain based on the core data storage structure.
In the embodiment of the application, the state data to be migrated of the original blockchain is obtained, whether the target blockchain to which the state data to be migrated is to and the original blockchain are isomorphic blockchains or not is determined, if the target blockchain is isomorphic blockchain, the state data to be migrated is written into the target blockchain, if the target blockchain is not isomorphic blockchain, the data storage structure of the state data to be migrated is converted into the data storage structure of the target blockchain, and the converted state data to be migrated is written into the target blockchain. Therefore, according to the embodiment of the application, the state data to be migrated can be migrated from the original blockchain to the target blockchain, so that the purpose of migrating the data in the blockchain is achieved.
It should be noted that, the storage medium in this embodiment can implement the foregoing respective processes of the data migration method in fig. 4, and achieve the same functions and effects, which are not repeated here.
In the 90 s of the 20 th century, improvements to one technology could clearly be distinguished as improvements in hardware (e.g., improvements to circuit structures such as diodes, transistors, switches, etc.) or software (improvements to the process flow). However, with the development of technology, many improvements of the current method flows can be regarded as direct improvements of hardware circuit structures. Designers almost always obtain corresponding hardware circuit structures by programming improved method flows into hardware circuits. Therefore, an improvement of a method flow cannot be said to be realized by a hardware entity module. For example, a programmable logic device (Programmable Logic Device, PLD) (e.g., field programmable gate array (Field Programmable Gate Array, FPGA)) is an integrated circuit whose logic function is determined by the programming of the device by a user. A designer programs to "integrate" a digital system onto a PLD without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Moreover, nowadays, instead of manually manufacturing integrated circuit chips, such programming is mostly implemented by using "logic compiler" software, which is similar to the software compiler used in program development and writing, and the original code before the compiling is also written in a specific programming language, which is called hardware description language (Hardware Description Language, HDL), but not just one of the hdds, but a plurality of kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), lava, lola, myHDL, PALASM, RHDL (Ruby Hardware Description Language), etc., VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog are currently most commonly used. It will also be apparent to those skilled in the art that a hardware circuit implementing the logic method flow can be readily obtained by merely slightly programming the method flow into an integrated circuit using several of the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer readable medium storing computer readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable logic controllers, and embedded microcontrollers, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, atmel AT91SAM, microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic of the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller in a pure computer readable program code, it is well possible to implement the same functionality by logically programming the method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers, etc. Such a controller may thus be regarded as a kind of hardware component, and means for performing various functions included therein may also be regarded as structures within the hardware component. Or even means for achieving the various functions may be regarded as either software modules implementing the methods or structures within hardware components.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. One typical implementation is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being functionally divided into various units, respectively. Of course, the functions of each element may be implemented in one or more software and/or hardware elements when implemented in the present application.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may 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, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may 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, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may 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, and the like) having computer-usable program code embodied therein.
The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and changes may be made to the present application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. which are within the spirit and principles of the present application are intended to be included within the scope of the claims of the present application.