CN107918666B - Data synchronization method and system on block chain - Google Patents

Data synchronization method and system on block chain Download PDF

Info

Publication number
CN107918666B
CN107918666B CN201711193947.9A CN201711193947A CN107918666B CN 107918666 B CN107918666 B CN 107918666B CN 201711193947 A CN201711193947 A CN 201711193947A CN 107918666 B CN107918666 B CN 107918666B
Authority
CN
China
Prior art keywords
data
synchronized
structure definition
address
block chain
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201711193947.9A
Other languages
Chinese (zh)
Other versions
CN107918666A (en
Inventor
王加楠
张一锋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhongchao Creditcard Industry Development Co Ltd Hangzhou Blockchain Technology Research Institute
Original Assignee
Zhongchao Creditcard Industry Development Co Ltd Hangzhou Blockchain Technology Research Institute
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhongchao Creditcard Industry Development Co Ltd Hangzhou Blockchain Technology Research Institute filed Critical Zhongchao Creditcard Industry Development Co Ltd Hangzhou Blockchain Technology Research Institute
Priority to CN201711193947.9A priority Critical patent/CN107918666B/en
Publication of CN107918666A publication Critical patent/CN107918666A/en
Application granted granted Critical
Publication of CN107918666B publication Critical patent/CN107918666B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Abstract

The application discloses a data synchronization method on a block chain, which comprises the following steps: the middleware acquires a data structure definition corresponding to the intelligent contract; calculating the address of the data to be synchronized in the block chain database according to the addressing rule in the data structure definition; calling a block chain storage area data acquisition interface to acquire the data to be synchronized by using the address; and writing the data to be synchronized into a service database. And calculating the address of the data to be synchronized through the data structure definition corresponding to the intelligent contract, directly calling an interface provided by the block chain to acquire the data, and storing the data in a service database. The method avoids writing and calling a large number of intelligent contract interfaces only used for data synchronization, and improves the performance of the block chain. The application also provides a data synchronization system on the block chain, which has the beneficial effects.

Description

Data synchronization method and system on block chain
Technical Field
The present invention relates to the field of a block chain, and in particular, to a method and a system for synchronizing data on a block chain.
Background
The data on the blockchain is bound with intelligent contracts, and each intelligent contract is a program running on the blockchain and is provided with an independent storage area. The intelligent contract can read and write data in the storage area of the intelligent contract, but cannot operate data in other intelligent contract storage areas.
Blockchain-based applications often require extensive, complex query operations on data that are difficult to implement via smart contracts. To address this problem, middleware may be introduced between the service application layer and the blockchain. The middleware maintains a conventional relational (or non-relational) database for query operations by the upper-level business applications. Meanwhile, the middleware continuously synchronizes the data on the block chain into the database, so that the data in the database is consistent with the data on the block chain.
The general idea of the existing data synchronization scheme is as follows:
firstly, a set of interfaces for acquiring data is designed in the intelligent contract. Data with simple structure can be obtained in batch through the interface. For complex data types, multiple interfaces are required to be used together.
Then, the synchronous process calls an interface in the intelligent contract according to a certain rule to acquire data. For data with complex structure, multiple times of calling are needed. For example, when acquiring data of a structure array type, it is necessary to acquire the length of the data first and then acquire the contents of the array one by one.
And finally, writing the acquired data into a service database.
The above scheme has the following disadvantages:
a large number of data synchronization interfaces need to be included in the intelligent contract. These interfaces are used for data synchronization only and have no relation to the actual business logic. The presence of these interfaces increases the amount of code for the intelligent contract, thereby increasing the storage overhead of the blockchain.
The intelligent contracts cannot contain data with an excessively complex structure. The increase of the complexity of the data structure can complicate the design of the corresponding data synchronization interface; the intelligent contract limits the number and the type of return values of the interface, which causes that the interface needs to be called repeatedly for many times in the data synchronization process; each call to the interface, the blockchain starts a virtual machine for executing logic in the interface. This incurs a certain performance overhead.
Disclosure of Invention
The application aims to provide a data synchronization method and a data synchronization system on a block chain, and the method and the system can be used for solving the problems of high dependence on interfaces in an intelligent contract and storage overhead and performance overhead caused by the interfaces when data are synchronized from a block chain database to a service database in the prior art.
In order to solve the above technical problem, the present application provides a data synchronization method on a block chain, and the technical scheme is as follows:
the middleware acquires a data structure definition corresponding to the intelligent contract;
calculating the address of the data to be synchronized in the block chain database according to the addressing rule in the data structure definition;
calling a block chain storage area data acquisition interface to acquire the data to be synchronized by using the address;
and writing the data to be synchronized into a service database.
Optionally, the generating manner of the data structure definition includes:
generating the data structure definition according to basic information and addressing logic rules in the intelligent contract; wherein the data structure definition comprises basic information of the data and addressing rules.
Optionally, the using the address, invoking a block chain storage area data acquisition interface to acquire the data to be synchronized includes:
judging whether the address of the data to be synchronized in the block chain database is calculated by a field of a specified skip keyword or not by using the address;
if not, calling a block chain storage area data acquisition interface to acquire the data to be synchronized;
and if so, not acquiring the data to be synchronized corresponding to the address obtained by the field calculation of the specified skip keyword.
Optionally, the method further includes:
the data structure definition is saved on a blockchain.
Optionally, writing the data to be synchronized into the service database includes:
analyzing the acquired data to be synchronized into a correct data type according to the basic information in the data structure definition;
and writing the data to be synchronized which is analyzed into the correct data type into the service database.
The present application further provides a system for data synchronization on a blockchain, the system comprising:
the acquisition definition module is used for acquiring the data structure definition corresponding to the intelligent contract by the middleware;
the address calculation module is used for calculating the address of the data to be synchronized in the block chain database according to the addressing rule in the data structure definition;
the data acquisition module is used for calling a block chain storage area data acquisition interface to acquire the data to be synchronized by using the address;
and the data synchronization module is used for writing the data to be synchronized into a service database.
Optionally, the system further comprises:
the data structure definition generating module is used for generating the data structure definition according to the basic information and the addressing logic rule in the intelligent contract; wherein the data structure definition comprises basic information of the data and addressing rules.
Optionally, the data obtaining module includes:
the judging submodule is used for judging whether the address of the data to be synchronized in the block chain database is obtained by calculating the field of the specified skip keyword or not by utilizing the address;
the data acquisition submodule is used for calling a data acquisition interface of a block chain storage area to acquire the data to be synchronized when the address of the data to be synchronized in the block chain database is not calculated by a field of a specified skip keyword;
and the data shielding submodule is used for not acquiring the data to be synchronized corresponding to the address calculated by the field of the specified skip key word when the address of the data to be synchronized in the block chain database is calculated by the field of the specified skip key word.
Optionally, the system further comprises:
and the storage module is used for storing the data structure definition on the block chain.
Optionally, the data synchronization module includes:
the data processing submodule is used for analyzing the acquired data to be synchronized into a correct data type according to the basic information in the data structure definition;
and the data writing sub-module is used for writing the data to be synchronized which is analyzed into the correct data type into the service database.
The application provides a data synchronization method on a block chain, which comprises the steps of acquiring a data structure definition corresponding to an intelligent contract through a middleware, and calculating the address of data to be synchronized in a block chain database according to an addressing rule in the data structure definition; and calling a data acquisition interface provided by the block chain to acquire data to be synchronized, converting the acquired data to be synchronized into a correct format, and storing the converted data to be synchronized into a service database.
Obviously, the method and the device avoid calling and compiling a large number of intelligent contract interfaces only used for data synchronization in the intelligent contract, are more convenient for synchronizing the data with the complex structure, and improve the performance of the block chain. The application also comprises a data synchronization system on the block chain, and the beneficial effects are achieved.
Drawings
In order to more clearly illustrate the embodiments of the present application, the drawings needed for the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings can be obtained by those skilled in the art without inventive effort.
Fig. 1 is a flowchart of a method for synchronizing data on a block chain according to an embodiment of the present invention;
fig. 2 is a flowchart of another method for synchronizing data on a blockchain according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating a working relationship between a blockchain and middleware according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a system for synchronizing data on a block chain according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, fig. 1 is a flowchart of a method for data synchronization on a block chain according to an embodiment of the present invention, and the technical solution is as follows:
s101: the middleware acquires a data structure definition corresponding to the intelligent contract;
each intelligent contract that needs to be data synchronized has a corresponding data structure definition. The present embodiment does not limit the generation manner and process of the data structure definition, and may have a plurality of generation methods or generation processes. The data structure definition may be generated according to basic information and addressing logic rules in the intelligent contract. For example, in a smart contract, a series of state variables are defined. The values in the state variables are written to the blockchain database after each call of the smart contract is completed. Part of the state variables have complex custom types, such as structures and the like. These custom types of structural information may also be included in the data structure definition. Specifically, the corresponding generation manner may be as follows:
analyzing a source code of the intelligent contract according to a reference relation among the intelligent contracts; extracting all custom types and state variables in the intelligent contract source code; and associating and organizing the information obtained in the last step, and outputting the data structure definition.
The data structure definition includes addressing information and may also include basic information of each data item, such as name, type, data size, etc. The basic information has the function of performing type conversion on the acquired data to be synchronized according to the content of the basic information in subsequent operations. Therefore, the basic information may include content related to genre conversion, or may include some basic content unrelated to genre conversion. For the convenience of the data synchronization process, the basic information of the data item may be placed in the data structure definition, and of course, other locations may also be stored, or the basic information of the corresponding data may be obtained again directly after the data to be synchronized is preliminarily obtained, so as to be used for data type conversion. The present application does not limit the existence form and the storage location of the basic information.
The addressing rules are related to the language of the smart contract. Each intelligent contract language complies with certain addressing logic specifications when reading and writing storage. The addressing rules for different intelligent contract languages are not identical. For example, in the solid language, data of basic types (e.g., uint, pool, address, etc.) are arranged compactly in a database, and the offset of the address is sequentially increased. For mapping and other complex structures, the addresses are subjected to hash calculation according to keys, and the hashes are in the database.
The data structure definition may be generated by a compiler when the smart contract is compiled, or may be edited manually, for example, to mask fields or add additional information. The preliminarily obtained data structure definition contains all data in the intelligent contract, and may also contain non-critical data which is not concerned by the business application. Non-critical data may be masked from being synchronized by customizing the contents of the data structure definition.
The data structure definition may be generated by a compiler or other tool at the time of compiling the smart contract, and then the underlying data structure definition may be edited manually, for example, to delete useless information or add additional information. This manner of generation requires the provision of a compilable source code for the intelligent contract. The data structure definition may also be written directly by a human being when a compilable source code of the intelligent contract cannot be provided.
If dynamic or extensible data structures are employed in the intelligent contracts, their corresponding data structure definitions may be manually maintained at a later time. For example, when a data structure in a smart contract changes or needs to be extended, the corresponding data structure definition needs to be regenerated. Typically edited on the basis of an old version and then saved with updates of the definition of the completed data structure. Of course, there may be other ways to update the definition of the data structure, and the update way is not limited in this application.
Preferably, in order to facilitate the acquisition of the middleware, the data structure definition can be used as auxiliary data of the intelligent contract and stored on the blockchain; but may be stored separately in other centralized servers, etc.
S102: calculating the address of the data to be synchronized in the block chain database according to the addressing rule in the data structure definition;
the middleware can calculate the address of the data to be synchronized in the blockchain database according to the addressing rule, namely the storage position of the data to be synchronized in the blockchain database.
S103: calling a block chain storage area data acquisition interface to acquire the data to be synchronized by using the address;
the data acquisition interface of the block chain storage area is an interface provided by the block chain, so that the block chain can be directly called without starting a virtual machine.
The middleware will analyze field by field according to the content in the data structure definition. There may be data that is not useful to the service user in the data to be synchronized. The garbage can be masked by setting a key in the data structure definition. For example, if the field does not specify a skip keyword, the step of acquiring the data to be synchronized by the calling block chain storage area data acquisition interface is normally executed; if the skip key word is appointed in the field, the middleware still calculates the address of the field, but does not perform subsequent synchronization operation, namely does not acquire the data to be synchronized corresponding to the address calculated by the field of the appointed skip key word. The address needs to be calculated because the address of the subsequent field needs to be calculated based on the address of the field. There are other ways to implement the masking of useless data or the filtering of useful data, and the present application is not limited to the implementation thereof.
S104: and writing the data to be synchronized into a service database.
Because the blockchain provides binary data, the same piece of data, which is converted according to different data types, will have different results. The middleware needs to submit the correct results to the traffic database. Therefore, before writing into the service database, the middleware needs to convert the acquired data to be synchronized into correct data according to the basic information of the data. After the conversion is completed, the middleware writes the data to be synchronized into the service database, namely mapping the data to each field in the service database.
If the data with the complex structure needs to be acquired for multiple times, the steps S102 to S104 are repeated until all the data are synchronized.
Based on the technical scheme, the data synchronization method on the block chain is provided, writing and calling of a large number of intelligent contract interfaces only used for data synchronization are avoided, synchronization of data with complex structures is more convenient, and performance of the block chain is improved.
Example two
The following is a second embodiment of the present application, and referring to fig. 2, fig. 2 is a flowchart of another block chain data synchronization method provided by the embodiment of the present invention, and the technical solution is as follows:
s201: and generating a data structure definition corresponding to the intelligent contract.
The editor generates the basic data structure definition according to the following method;
analyzing the source code of the contract according to the reference relation between the contracts; extracting all custom types and state variables in the contract source code; and associating and organizing the information obtained in the last step, and outputting the data structure definition serving as the basis.
The data structure definition acquired at this time includes basic information of the data item, such as name, type, data length, and the like, and an addressing rule of the data. At this time, the basic data structure definition needs to be compiled manually, and the complete code is as follows:
Figure BDA0001481595280000071
Figure BDA0001481595280000081
Figure BDA0001481595280000091
the compiler generates the base data structure definition that includes the name, but no skip. Therefore, the name is removed by manual editing, and skip is added, namely useless information is removed and additional information is added. "field _2_ name" in the program is also additional information manually added by a human, and keys can also be automatically generated by a compiler according to a specific rule.
S202: and the middleware acquires the data structure definition and calculates the address of the data to be synchronized in the block chain database according to the addressing rule in the data structure definition.
S203: the middleware analyzes the content in the data structure definition field by field and acquires the unmasked data to be synchronized according to the address.
The middleware will analyze field by field according to the content in the data structure definition. If the field does not specify a skip keyword, normally synchronizing the data to be synchronized on the address corresponding to the field; if the skip key is specified, i.e. 'skip' in the code: true', then the address corresponding to the field is calculated again and no subsequent data synchronization operation is performed.
The middleware calls an interface provided by the blockchain and acquires the unmasked data to be synchronized according to the address.
S204: and analyzing the acquired data to be synchronized into a correct data type according to the basic information in the data structure definition.
The preliminarily acquired data to be synchronized is of a binary type, and the type of the data to be synchronized needs to be converted according to a required type.
S205: and writing the analyzed data to be synchronized of the correct type into a service database to complete data synchronization.
And the middleware maps the analyzed data to be synchronized to each field of the service database.
If the data with the complex structure exists, the steps S203 to S205 are repeated until all the data are synchronized.
Referring to fig. 3, fig. 3 is a schematic diagram of information and data interaction between a chunk chain and middleware in a data synchronization process according to this embodiment.
The middleware is responsible for acquiring the data structure definition, calculating the address of the block chain database of the data, reading the data from the block chain database, analyzing the data and storing the data in the service database.
Wherein, reading data from the block chain database is realized through the information and data interaction of the middleware and the block chain. The middleware sends a request for obtaining the specified address data to the blockchain, and the blockchain returns the specified address data after receiving the request, so that the operation of reading the data from the blockchain database is completed.
Based on the technical scheme, the data to be synchronized is acquired by using the data structure definition, so that a large number of interfaces only used for data synchronization are prevented from being written in the intelligent contract, and the code amount of the intelligent contract is reduced; the shielding of useless data of a service user is realized; the data of complex structures can be conveniently synchronized; and a large number of intelligent contract interfaces are not required to be called, so that the performance of the block chain is improved.
EXAMPLE III
Referring to fig. 4, fig. 4 is a schematic diagram of a system for synchronizing data on a blockchain according to an embodiment of the present invention, the system including:
an obtaining definition module 100, configured to obtain, by the middleware, a data structure definition corresponding to the intelligent contract;
the address calculation module 200 is configured to calculate an address of the data to be synchronized in the blockchain database according to an addressing rule in the data structure definition;
a data obtaining module 300, configured to call a block chain storage area data obtaining interface to obtain the data to be synchronized, using the address;
and a data synchronization module 400, configured to write the data to be synchronized into a service database.
Wherein the system further comprises:
the data structure definition generating module is used for analyzing a source code corresponding to the intelligent contracts according to the reference relation among the intelligent contracts; extracting all custom types and state variables in the source code; and associating and organizing the custom type and the state variable to obtain the data structure definition.
Based on the foregoing embodiment, the present application further provides an embodiment of a data synchronization system on a blockchain, where in this embodiment, the data obtaining module further includes:
the judgment submodule is used for judging whether the address of the data to be synchronized in the block chain database is obtained by calculating the field of the specified skip keyword;
the data acquisition submodule is used for calling a data acquisition interface of a block chain storage area to acquire the data to be synchronized when the address of the data to be synchronized in the block chain database is not calculated by a field of a specified skip keyword;
and the data shielding submodule is used for not acquiring the data to be synchronized corresponding to the address calculated by the field of the specified skip key word when the address of the data to be synchronized in the block chain database is calculated by the field of the specified skip key word.
The system further comprises:
the storage module is used for storing the data structure definition on a block chain;
the data synchronization module includes:
the data processing submodule is used for analyzing the acquired data to be synchronized into a correct data type according to the basic data information in the data structure definition;
and the data writing sub-module is used for writing the data to be synchronized which is analyzed into the correct data type into the service database.
The corresponding workflow is:
s301: the obtaining definition module 100 obtains the data structure definition generated by the data structure definition generating sub-module;
the process of generating the data structure definition by the data structure definition generating submodule may be to generate the data structure definition according to the basic information and the addressing logic rule in the intelligent contract, and specifically, the generating manner may be as follows:
analyzing the source code of the contract according to the reference relation between the contracts; extracting all custom types and state variables in the contract source code; and associating and organizing the information obtained in the last step, and outputting the data structure definition serving as the basis.
The data structure definition includes basic information of each data item, such as name, type, and the like, and an addressing rule of each data item. Wherein the addressing rules are related to the language of the smart contract. Each intelligent contract language complies with certain addressing logic specifications when reading and writing storage. The addressing rules for different intelligent contract languages are not identical. For example, in the solid language, data of basic types (e.g., uint, pool, address, etc.) are arranged compactly in a database, and the offset of the address is sequentially increased. For mapping and other complex structures, the addresses are subjected to hash calculation according to keys, and the hashes are in the database.
The data structure definition generation submodule typically includes a compiler, and may be generated by the compiler when the smart contract is compiled, or may not manually edit the basic data structure definition through the compiler, for example, may perform operations such as masking fields, or add additional information. The preliminary data structure definition includes all data in the intelligent contract, which may include non-critical data that is not of interest to the business application. Some data to be synchronized may be masked from being synchronized by customizing the contents of the data structure definition. For example, if the field does not specify a skip key, the field is synchronized according to the normal flow. If the skip key is specified in this field, the middleware will still calculate the address of this field, but will not perform subsequent synchronization operations. The address needs to be calculated because the address of the subsequent field needs to be calculated based on the address of the field. There may be other ways to customize the content of the data structure definition, and the application is not limited herein.
If dynamic or extensible data structures are employed in the intelligent contracts, their corresponding data structure definitions need to be manually maintained at a later stage. For example, when a data structure in a smart contract changes or needs to be extended, the corresponding data structure definition needs to be regenerated. Typically edited on the basis of an old version and then saved with a replacement of the finished data structure definition. This process may be performed by the storage module. Of course, there may be other ways to update the definition of the data structure, and the update way is not limited in this application.
After the generation of the data structure definition is finished, the storage module stores the data structure definition. In order to facilitate the acquisition of the middleware, the data structure definition can be used as auxiliary data of an intelligent contract and is directly stored on a block chain by a storage module; but may be stored separately in other centralized servers, etc.
S302: the address calculation module 200 calculates the address of the data to be synchronized in the block chain database according to the addressing rule defined by the data structure;
s303: the data obtaining module 300 calls a block chain storage area data obtaining interface to obtain the data to be synchronized by using the address;
the data to be synchronized acquired here is binary raw data. In addition, the data acquisition module comprises a judgment submodule for judging whether the address of the data to be synchronized in the block chain database is calculated by a field of a specified skip keyword; if not, calling a data acquisition submodule, and executing a step of acquiring the to-be-synchronized data by using a calling block chain storage area data acquisition interface; and if so, calling a data shielding submodule, and not acquiring the data to be synchronized corresponding to the address obtained by calculating the field of the specified skip keyword.
S304: and a data synchronization module 400, configured to write the data to be synchronized into a service database.
The data synchronization module 400 includes a data processing sub-module, configured to analyze the acquired data to be synchronized into a correct data type according to the basic information in the data structure definition;
and the data writing sub-module is used for writing the data to be synchronized which is analyzed into the correct data type into the service database.
Because the data to be synchronized which is just acquired is binary data, the data to be synchronized is required to be converted into a correct data type through the data processing submodule according to the basic information in the data structure definition, and then the data to be synchronized of the correct type is written into the service database by the data writing submodule.
If the data with the complex structure exists, the steps S302 to S304 are repeated until all the data are synchronized to the service database.
The method and system for data synchronization on a blockchain provided by the present application are described in detail above. The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. For the system disclosed by the embodiment, the description is relatively simple because the system corresponds to the method disclosed by the embodiment, and the relevant points can be referred to the method part for description. It should be noted that, for those skilled in the art, it is possible to make several improvements and modifications to the present application without departing from the principle of the present application, and such improvements and modifications also fall within the scope of the claims of the present application.
It is further noted that, in the present specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, 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 an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

Claims (8)

1. A method for data synchronization over a blockchain, the method comprising:
the middleware acquires a data structure definition corresponding to the intelligent contract; specifically, according to the reference relation among the intelligent contracts, analyzing the source code of the intelligent contract; extracting all custom types and state variables in the source code, associating and organizing the obtained information, and outputting the data structure definition; wherein the data structure definition comprises addressing rules;
calculating the address of the data to be synchronized in a block chain database according to the addressing rule in the data structure definition;
calling a block chain storage area data acquisition interface to acquire the data to be synchronized by using the address;
writing the data to be synchronized into a service database; wherein the writing the data to be synchronized into a traffic database comprises: analyzing the acquired data to be synchronized into a correct data type according to the basic information in the data structure definition; and writing the data to be synchronized which is analyzed into the correct data type into the service database.
2. The method of claim 1, wherein the data structure definition is generated in a manner that includes:
generating the data structure definition according to basic information and addressing logic rules in the intelligent contract; wherein the data structure definition comprises basic information of the data and addressing rules.
3. The method according to claim 1 or 2, wherein the using the address, calling a blockchain storage area data acquisition interface to acquire the data to be synchronized comprises:
judging whether the address of the data to be synchronized in the block chain database is calculated by a field of a specified skip keyword or not by using the address;
if not, calling a block chain storage area data acquisition interface to acquire the data to be synchronized;
and if so, not acquiring the data to be synchronized corresponding to the address obtained by the field calculation of the specified skip keyword.
4. The method of claim 3, further comprising:
the data structure definition is saved on a blockchain.
5. A system for data synchronization over a blockchain, the system comprising:
the acquisition definition module is used for acquiring the data structure definition corresponding to the intelligent contract by the middleware; specifically, according to the reference relation among the intelligent contracts, analyzing the source code of the intelligent contract; extracting all custom types and state variables in the source code, associating and organizing the obtained information, and outputting the data structure definition; wherein the data structure definition comprises addressing rules;
the address calculation module is used for calculating the address of the data to be synchronized in the block chain database according to the addressing rule in the data structure definition;
the data acquisition module is used for calling a block chain storage area data acquisition interface to acquire the data to be synchronized by using the address;
the data synchronization module is used for writing the data to be synchronized into a service database;
wherein the data synchronization module comprises:
the data processing submodule is used for analyzing the acquired data to be synchronized into a correct data type according to the basic information in the data structure definition;
and the data writing sub-module is used for writing the data to be synchronized which is analyzed into the correct data type into the service database.
6. The system of claim 5, further comprising:
the data structure definition generating module is used for generating the data structure definition according to the basic information and the addressing logic rule in the intelligent contract; wherein the data structure definition comprises basic information of the data and addressing rules.
7. The system of claim 5 or 6, wherein the data acquisition module comprises:
the judging submodule is used for judging whether the address of the data to be synchronized in the block chain database is obtained by calculating the field of the specified skip keyword or not by utilizing the address;
the data acquisition submodule is used for calling a data acquisition interface of a block chain storage area to acquire the data to be synchronized when the address of the data to be synchronized in the block chain database is not calculated by a field of a specified skip keyword;
and the data shielding submodule is used for not acquiring the data to be synchronized corresponding to the address calculated by the field of the specified skip key word when the address of the data to be synchronized in the block chain database is calculated by the field of the specified skip key word.
8. The system of claim 7, further comprising:
and the storage module is used for storing the data structure definition on the block chain.
CN201711193947.9A 2017-11-24 2017-11-24 Data synchronization method and system on block chain Active CN107918666B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711193947.9A CN107918666B (en) 2017-11-24 2017-11-24 Data synchronization method and system on block chain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711193947.9A CN107918666B (en) 2017-11-24 2017-11-24 Data synchronization method and system on block chain

Publications (2)

Publication Number Publication Date
CN107918666A CN107918666A (en) 2018-04-17
CN107918666B true CN107918666B (en) 2020-05-12

Family

ID=61897741

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711193947.9A Active CN107918666B (en) 2017-11-24 2017-11-24 Data synchronization method and system on block chain

Country Status (1)

Country Link
CN (1) CN107918666B (en)

Families Citing this family (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109086325A (en) 2018-06-29 2018-12-25 阿里巴巴集团控股有限公司 Data processing method and device based on block chain
CN110011800B (en) 2018-11-07 2020-04-14 阿里巴巴集团控股有限公司 Block chain data reading method and device
CN109508334B (en) * 2018-11-23 2019-10-11 中科驭数(北京)科技有限公司 For the data compression method of block chain database, access method and system
CN110622149A (en) * 2018-11-30 2019-12-27 阿里巴巴集团控股有限公司 Block chain data relation structure scheme based on binary log replication
CN109446273B (en) * 2018-12-04 2022-07-22 深圳前海环融联易信息科技服务有限公司 Data synchronization method and device of block chain, computer equipment and storage medium
CN109885612B (en) * 2018-12-26 2021-04-20 联动优势科技有限公司 Synchronous validation method and device for intelligent contracts of block chains
CN109754251B (en) * 2018-12-27 2022-02-01 石更箭数据科技(上海)有限公司 Data processing method and device, medium and terminal thereof
CN109857807A (en) * 2019-01-10 2019-06-07 中钞信用卡产业发展有限公司杭州区块链技术研究院 Transaction data synchronization method, apparatus, equipment and medium based on block chain
CN109766722B (en) * 2019-01-22 2020-11-10 苏州同济区块链研究院有限公司 Method for constructing intelligent contract in block chain
CN110223069A (en) * 2019-06-17 2019-09-10 北京艾摩瑞策科技有限公司 Packaging method and device based on block chain meshed network
CN110245950B (en) * 2019-06-17 2020-08-04 北京瑞策科技有限公司 Block discharging method and device related to block chain
CN110264361A (en) * 2019-06-24 2019-09-20 深圳前海微众银行股份有限公司 A kind of data analysis method and device of block chain
CN111164586B (en) * 2019-06-28 2023-07-04 创新先进技术有限公司 System and method for updating data in a blockchain
CN110784517B (en) * 2019-09-20 2021-05-04 北京海益同展信息科技有限公司 Service application integration method, system, terminal and storage medium based on block chain
CN111143476B (en) * 2019-12-31 2023-06-27 杭州趣链科技有限公司 Intelligent contract data rapid query method based on database
CN111581181B (en) * 2020-04-07 2021-06-29 浙商银行股份有限公司 Method for automatically generating intelligent contract of block chain based on database data table
CN114239039A (en) * 2021-09-30 2022-03-25 西南电子技术研究所(中国电子科技集团公司第十研究所) Method for dynamically adapting data structure on user-defined block chain

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2540977A (en) * 2015-07-31 2017-02-08 British Telecomm Expendable access control
CN106651346A (en) * 2016-11-28 2017-05-10 上海凯岸信息科技有限公司 Block chain-based credit investigation data sharing and trading system
CN106681739A (en) * 2017-01-11 2017-05-17 杭州云象网络技术有限公司 Method for automatically generating intelligent contract
WO2017098519A1 (en) * 2015-12-08 2017-06-15 Tallysticks Limited A system and method for automated financial transaction validation, processing and settlement using blockchain smart contracts
CN106874393A (en) * 2017-01-13 2017-06-20 北京众享比特科技有限公司 Synchronizing traffic data method and system, Database Systems based on block chain
WO2017109140A1 (en) * 2015-12-22 2017-06-29 Bigchaindb Gmbh Decentralized, tamper-resistant, asset-oriented database system and method of recording a transaction
CN107147704A (en) * 2017-04-21 2017-09-08 杭州趣链科技有限公司 A kind of generic service middleware system towards block chain
CN107171794A (en) * 2017-06-27 2017-09-15 葛峰 A kind of electronic document based on block chain and intelligent contract signs method

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170228371A1 (en) * 2016-02-05 2017-08-10 Manifold Technology, Inc. Blockchain-enhanced database

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2540977A (en) * 2015-07-31 2017-02-08 British Telecomm Expendable access control
WO2017098519A1 (en) * 2015-12-08 2017-06-15 Tallysticks Limited A system and method for automated financial transaction validation, processing and settlement using blockchain smart contracts
WO2017109140A1 (en) * 2015-12-22 2017-06-29 Bigchaindb Gmbh Decentralized, tamper-resistant, asset-oriented database system and method of recording a transaction
CN106651346A (en) * 2016-11-28 2017-05-10 上海凯岸信息科技有限公司 Block chain-based credit investigation data sharing and trading system
CN106681739A (en) * 2017-01-11 2017-05-17 杭州云象网络技术有限公司 Method for automatically generating intelligent contract
CN106874393A (en) * 2017-01-13 2017-06-20 北京众享比特科技有限公司 Synchronizing traffic data method and system, Database Systems based on block chain
CN107147704A (en) * 2017-04-21 2017-09-08 杭州趣链科技有限公司 A kind of generic service middleware system towards block chain
CN107171794A (en) * 2017-06-27 2017-09-15 葛峰 A kind of electronic document based on block chain and intelligent contract signs method

Non-Patent Citations (9)

* Cited by examiner, † Cited by third party
Title
"Blockchain Standards for Compliance and Trust";Ashiq Anjum et al.;《 IEEE Cloud Computing》;20171012;全文 *
"EtherQL: A Query Layer for Blockchain System";Li, Y et al.;《 22nd International Conference on Database Systems for Advanced Applications》;20170330;全文 *
"The Blockchain as a Software Connector";Xiwei Xu et al.;《2016 13th Working IEEE/IFIP Conference on Software Architecture》;20160721;全文 *
"区块链_金融_未来更多向智能合约领域发展";顾彦;《中国战略新兴产业》;20161001;全文 *
"区块链技术与应用前瞻综述";何蒲 等;《计算机科学》;20170430;第44卷(第4期);全文 *
"区块链智能合约技术在金融领域的研发应用现状、问题及建议";刘德林;《海南金融》;20161215;全文 *
"基于模式的远监督关系抽取算法";王加楠 等;《中文信息学报》;20170731;第31卷(第4期);全文 *
"智能合约与金融合约";王春宇 等;《商》;20160508;全文 *
"融合区块链技术和智能合约的能源互联网需求侧响应分析";孙涵洁;《机电信息》;20170423;全文 *

Also Published As

Publication number Publication date
CN107918666A (en) 2018-04-17

Similar Documents

Publication Publication Date Title
CN107918666B (en) Data synchronization method and system on block chain
CN109582909B (en) Webpage automatic generation method and device, electronic equipment and storage medium
US7904488B2 (en) Time stamp methods for unified plant model
CN104035754A (en) XML (Extensible Markup Language)-based custom code generation method and generator
CN105528418B (en) A kind of design documentation generation method and device
CN101430714B (en) Content structuring process method and system based on model
CN106991100B (en) Data import method and device
CN103631601A (en) Code generation method and code generation device
CN110737594B (en) Database standard conformance testing method and device for automatically generating test cases
CN101604241A (en) A kind of code generating method of embedded system
CN106557307B (en) Service data processing method and system
CN109241184B (en) Data synchronization method, device, computer equipment and storage medium
JP2018527611A (en) Method and device for recognizing time information from audio information
CN107609302B (en) Method and system for generating product process structure
CN102110102A (en) Data processing method and device, and file identifying method and tool
CN102236544A (en) Method and device for designing skins
CN112528619A (en) Page template file generation method and device, electronic equipment and storage medium
CN113283216A (en) Webpage content display method, device, equipment and storage medium
CN112016283A (en) Form generation method and device
WO2018233673A1 (en) Method and apparatus for configuring model code in controller, and storage medium
CN112988123B (en) DDD-oriented software design method and system
CN111125216B (en) Method and device for importing data into Phoenix
CN110502735B (en) Method and system for quickly manufacturing universal process file of electronic equipment
CN108090034B (en) Cluster-based uniform document code coding generation method and system
CN113722337B (en) Service data determination method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant