WO2020259417A1 - Data analysis method and device for block chain - Google Patents
Data analysis method and device for block chain Download PDFInfo
- Publication number
- WO2020259417A1 WO2020259417A1 PCT/CN2020/097235 CN2020097235W WO2020259417A1 WO 2020259417 A1 WO2020259417 A1 WO 2020259417A1 CN 2020097235 W CN2020097235 W CN 2020097235W WO 2020259417 A1 WO2020259417 A1 WO 2020259417A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- transaction
- event
- data analysis
- code
- data
- 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.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/64—Protecting data integrity, e.g. using checksums, certificates or signatures
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/42—Syntactic analysis
- G06F8/427—Parsing
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q40/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/04—Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
Definitions
- the present invention relates to the field of Fintech, in particular to a data analysis method and device of a blockchain.
- Blockchain technology has made the traditional financial industry gradually transforming into Finteh.
- technology finance combined with blockchain technology, it is more important to process data in the blockchain (for example, contract account data, transaction data, and event data), such as analyzing data or synchronizing data.
- the first solution is to design a set of dedicated interfaces at the level of smart contracts.
- the dedicated interfaces in the smart contracts are intelligently invoked to analyze the data in the blockchain.
- the second solution save the address of the data to be parsed on the blockchain in advance, and then call the relevant interface according to the address to obtain the data.
- the dedicated interface since the code of the dedicated interface needs to occupy a certain amount of storage space, especially when the number of dedicated interfaces is large, the dedicated interface will cause a large storage space overhead and cause higher costs. Moreover, when the dedicated interface is complicated, it may be necessary to call different interfaces multiple times to obtain data, resulting in poor performance.
- the second solution since the address is for a specific smart contract, when there is a new business or smart contract change, it cannot be reused, and the code needs to be revised by the technical staff, and the second solution is getting For data, it is necessary to calculate the data address according to the addressing rules in the data structure definition, which increases the amount of calculation.
- the invention provides a block chain data analysis method and device, which are used to reduce the cost of analyzing data in the block chain and improve the performance of data analysis.
- the first aspect of the present invention provides a block chain data analysis method, the method includes:
- the smart contract including a construction method, an event method, and a non-constant method for creating and realizing the user service;
- a data analysis code is generated.
- the data analysis code includes event data analysis code for analyzing event data of the user service and Transaction data analysis code for analyzing transaction data of the user service;
- the data analysis code is used to analyze the data in each block in the blockchain to obtain the event data and the transaction data.
- the process of generating the event data analysis code and the transaction data analysis code has different generation methods depending on the method that it relies on.
- generating the event data parsing code according to at least one of the construction method, event method, and non-constant method includes:
- the JAVA contract file includes at least an acquisition method for acquiring an event object in the event method and an event class corresponding to the event method
- the binary code of the smart contract includes at least the construction method, the event method, and the non-constant method each of which accesses the field type of the blockchain;
- the field in the event class with the same type as the first field is converted into a JAVA object, thereby obtaining the first POJO corresponding to the event class Object, the first field type is a field type used to access the blockchain in the event method;
- the first POJO object is filled into a preset event data analysis template to generate the event data analysis code.
- the preset event data analysis function template at least includes a calling module, a first analysis module, and a first instantiation Module and a first storage module, the calling module is used to call the acquisition method, the first parsing module is used to parse the event object and obtain the parsed event data, the first instantiation module is used to The parsed event data is converted into a first POJO object instance, and the first storage module is used to insert the first POJO object instance into a database table, and the database table is used to store the event data and the transaction data.
- using the event data analysis code to analyze the data in each block in the blockchain to obtain the event data includes:
- Run the event data analysis code obtain a list of event objects in the block through the calling module in the event data analysis code, the event object list including at least one value of the event object;
- the at least one parsed event data is respectively converted into at least one first POJO object instance through the instantiation module in the event data analysis code, and the at least one first POJO object instance and the at least one parsed One-to-one correspondence of event data;
- the at least one POJO object instance is inserted into the database table through the storage module in the event data analysis code.
- generating the transaction data analysis code according to at least one of the construction method, the event method, and the non-constant method includes:
- the JAVA contract file includes at least the binary code and binary string of the smart contract, and the binary code of the smart contract includes at least the Each of the construction method and the non-constant method accesses the field type of the blockchain, and the binary string is the recursive length prefix code of the smart contract;
- the field in the transaction method with the same type as the second field is converted into a JAVA object, thereby obtaining the second POJO corresponding to the transaction method Object, the second field type is a field type used to access the blockchain in the transaction method;
- the second POJO object is filled with a preset transaction data analysis template to generate the transaction data analysis code.
- the preset transaction data analysis template includes at least a matching module, a second analysis module, a second instantiation module, and a first Two storage modules, the matching module is used to determine whether the transaction method is the construction method or the non-constant method, the second analysis module is used to parse the transaction method and obtain transaction data, the second The instantiation module is used to convert transaction data into a second POJO object instance, and the second storage module is used to insert the second POJO object instance into a database table that is used to store the event data and The transaction data.
- obtaining transaction data according to the transaction data analysis code may include but not limited to the following two situations:
- using the transaction data analysis code to analyze the data in each block in the blockchain to obtain the transaction data includes:
- Run the transaction data analysis code obtain the target field in the first transaction through the matching module in the transaction data analysis code, and determine the transaction type of the first transaction according to the target field, the transaction type including the first transaction A transaction type and a second transaction type, the first transaction type is a transaction type corresponding to the construction method, the second transaction type is a transaction type corresponding to the non-constant method, and the target field is used for Indicating the transaction partner of the first transaction;
- the transaction type of the first transaction is the first transaction type
- the first remaining character string is parsed through the second parsing module in the transaction data analysis code to obtain the first transaction data of the first transaction, and the first remaining character string is the In the recursive length prefix encoding of the first transaction, the character string after removing the same symbol as the binary character string;
- the second POJO object instance is inserted into the database table through the second storage module in the transaction data analysis code.
- the target field in the first transaction is obtained through the matching module in the transaction data analysis code, and the transaction type of the first transaction is determined according to the target field .
- the method further includes:
- the transaction type of the first transaction is the second transaction type
- the second remaining code is analyzed through the second analysis module in the transaction data analysis code to obtain the second transaction data of the first transaction, and the second remaining code is the first
- the code of the transaction removes the character string after the same symbol as the signature
- a second aspect of the present invention provides an electronic device, including:
- At least one processor and,
- a memory communicatively connected with the at least one processor; wherein,
- the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor, so that the at least one processor can execute the blockchain data analysis method.
- a third aspect of the present invention provides a non-transitory computer-readable storage medium, the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to make the computer execute the data analysis of the blockchain method.
- a computing device includes: a memory for storing a computer program; a processor for calling the computer program stored in the memory, and executing various possible designs as in the first aspect according to the obtained program The method described in.
- the code for analyzing data can be automatically generated according to the smart contract of the user's business. That is to say, for different user services, the user only needs to import the smart contract corresponding to each user's business. New interfaces or no need to pre-store the code for data analysis, which can reduce the storage space occupied by the code for data analysis, and can reduce the cost of parsing data in the blockchain. Moreover, the code generated according to the smart contract corresponds to the interface in the smart contract one-to-one. Therefore, during data analysis, there is no need to call multiple interfaces or calculate the address of the data to be parsed, which can improve data analysis. performance.
- FIG. 1 is a structural block diagram of a system architecture applicable to a data analysis method provided by an embodiment of the present invention
- FIG. 2 is a flowchart of a data analysis method of a blockchain provided by an embodiment of the present invention
- FIG. 3 is a flowchart of generating event data analysis code in an embodiment of the present invention.
- FIG. 5 is a flowchart of analyzing event data in a block in an embodiment of the present invention.
- FIG. 6 is a flowchart of analyzing transaction data of the first transaction in a block in an embodiment of the present invention.
- FIG. 7 is a structural diagram of another example of data analysis of the blockchain provided in the embodiment of the present invention.
- the invention provides a block chain data analysis method and device, which are used to reduce the cost of analyzing data in the block chain and improve the performance of data analysis.
- Blockchain A chain composed of a series of blocks. In addition to recording the data of the block, each block also records the Hash value of the previous block. In this way, a chain is formed.
- a block consists of a block header and a block body.
- the block header definition includes important fields such as the block height h, the hash value prevHash of the previous block, and the block body mainly stores transaction data.
- Smart contract It is a computer protocol designed to spread, verify or execute the contract in an information-based way.
- the execution process of the smart contract will be agreed and confirmed on the blockchain in the form of a transaction, which allows the absence of a third party Conduct trusted transactions, which are traceable and irreversible.
- web3jsdk The bridging layer for JAVA language to access the blockchain, and provides related application programming interfaces (Application Programming Interface, API) to access the blockchain.
- API Application Programming Interface
- Solidity A high-level language for smart contracts, running on the Ethernet Virtual Machine (EVM), mainly used to write smart contracts.
- EVM Ethernet Virtual Machine
- JAVA An object-oriented programming language for writing desktop applications, Web applications, distributed systems, and embedded system applications.
- opcode The operating instructions after the smart contract is compiled.
- Event A method type of smart contract that can store parameters in the transaction log to facilitate tracking of the execution of the smart contract.
- Simple Java Objects (Plain Ordinary Java Object, POJO): Actually they are ordinary JavaBeans, which can be understood as interfaces, classes and objects in JAVA.
- RLP Recursive Length Prefix
- ABSI Application Binary Interface
- first and second in the embodiment of the present invention are only used to distinguish different objects, and do not indicate the importance or priority of each object.
- FIG. 1 exemplarily shows a system architecture applicable to a data analysis method provided by an embodiment of the present invention.
- the system architecture may include a data analysis device 100 and a blockchain 200. It should be noted that in FIG. 1, the data analysis device 100 and the blockchain 200 are two independent modules. In other examples, the data analysis device 100 can also be installed in the blockchain 200, which is not used here. limit.
- the blockchain 200 may include multiple blocks.
- the blockchain 200 includes two blocks, namely block A and block B.
- multiple smart contracts can be set according to the user's business.
- smart contract 1 is set in block A
- smart contract 2 is set in block B.
- the data analysis device 100 can obtain and analyze any type of data in each block in the blockchain 200 through different interfaces. For example, it can obtain contract account data through a contract interface, and block data can be obtained through a block interface. These two kinds of data are not parsed. However, since the event data and transaction data in the blockchain rely on smart contracts and are relatively complicated, the data analysis device 100 needs to analyze these two types of data.
- the present invention provides a data analysis method for blockchain, which is applied to the data analysis device 100 shown in FIG. 1. Please refer to Figure 2 for the flow chart of the method, which is described as follows:
- the data analysis device 100 may obtain the smart contract provided by the user through a preset interface, or may also obtain the smart contract in other ways, which is not limited in the embodiment of the present invention.
- Smart contracts can be written in different programming languages. For the convenience of explanation, the following uses smart contracts as smart contracts written in the Solidity programming language as an example.
- the UserInfo smart contract obtained by the data analysis device 100 may be as follows:
- the UserInfo smart contract includes a construction method for creating an instance of the UserInfo smart contract, namely:
- event modifyUserNameEvent (bytes32userName, uint8sex, address con).
- a constant method for modifying the user's name namely:
- the smart contract only includes a composition method, an event method, and a non-constant method. It should be understood as an example of a smart contract, rather than restricting the smart contract to only include one construction method, An event method and a non-constant method. In actual use, a smart contract can also include multiple construction methods or multiple event methods or multiple non-constant methods, which will not be repeated here.
- the generated data analysis code includes event data analysis code for analyzing the event data of the user service and The transaction data analysis code for analyzing the transaction data of the user service.
- Figure 3 is a flowchart for generating event data analysis code. The flowchart is described as follows:
- the smart contract Before generating the event data analysis code according to the smart contract, the smart contract must be compiled through the compiler to obtain the compiled contract file.
- a smart contract can be compiled into a JAVA code file by a compiler.
- the code to compile the UserInfo smart contract can be as follows:
- the contract file can also be other types of files.
- the type of contract file is not limited here.
- the contract file is a JAVA file as an example.
- the JAVA contract file includes at least an acquisition method for acquiring an event object in the event method, an event class corresponding to the event method, and the binary code of the smart contract.
- the binary code in the smart contract includes at least the construction method, the event method, and the non-constant method to access the field type of the blockchain.
- JAVA file including but not limited to the following contents can be obtained:
- getModifyUserNameEventEvents is the method used to obtain the event object in the event method
- public static class ModifyUserNameEventResponse ⁇ is the event class corresponding to the event method
- String ABI is the binary code of the smart contract
- the ABI is Including the types, input parameters, output parameters of all methods in the smart contract, and the field types and field names used by each method to access the blockchain.
- the binary string is the RLP code of the smart contract and is used to The contract instance is signed.
- the JAVA file may also include other content, and no examples are given here.
- the event class is modifyUserNameEvent class.
- the first field type is the field type used to access the blockchain in the event method.
- the first field type may be a web3jsdk type.
- the modifyUserNameEvent class after obtaining the modifyUserNameEvent class in the JAVA file, first locate the field in the modifyUserNameEvent class whose field type is the web3jsdk type.
- the web3jsdk type field may include Bytes32, Uint8, and Address.
- the field is converted into a JAVA object.
- the first mapping relationship may be: Bytes32 corresponds to String, Uint8 corresponds to int, and Address corresponds to String.
- the first mapping relationship may be pre-stored in the data analysis apparatus 100.
- the first POJO object corresponding to the modifyUserNameEvent class can be generated.
- the code of the POJO object with modifyUserNameEvent class is as follows:
- the applicant has studied the event data analysis process and learned that: for all event data, the processing process is basically the same, which can be divided into the following steps: call the get function to obtain the event object, then parse the event object, and obtain the event data of the event object , And then convert the parsed event data into a JAVA object instance, thereby inserting the JAVA object instance into the database table.
- the processing flow can be preset to multiple modules to form a preset event data analysis template, which is stored in the data analysis device 100, so that when the event in the smart contract to be analyzed is obtained After the object, directly fill the event object into the preset event data analysis template according to the field type, so as to obtain the event data analysis code for analyzing the event data in the smart contract.
- the implementation method is simple, and secondary development is supported.
- the preset event data analysis function template includes at least a calling module, a first analysis module, a first instantiation module, and a first storage module.
- the calling module is used to call the obtaining method
- the first parsing module is used to parse the event object and obtain the parsed event data
- the first instantiation module is used to convert the parsed event data into the first A POJO object instance
- the first storage module is used to insert the first POJO object instance into a database table
- the database table is used to store the event data and the transaction data.
- the JAVA contract file includes at least the binary code and the binary string of the smart contract, and the binary code includes at least the construction method and each of the non-constant methods.
- the field type of the blockchain, the binary string is the recursive length prefix code of the smart contract.
- Step S41 is the same as step S31, and will not be repeated here.
- the transaction method includes the construction method and the non-constant method in step S21, which will not be repeated here.
- the transaction method can also be obtained from an operation instruction (opcode), for example, after obtaining the opcode in the JAVA file, the opcode is parsed to obtain the transaction method in the opcode.
- opcode operation instruction
- the second field type is the field type used to access the blockchain in the transaction method.
- the second field type is the field type used to access the blockchain in the transaction method.
- the second field type may be the same as the first field type, for example, web3jsdk type, or the second field type may also be another type different from the first field type, which is not limited here.
- Step S43 is similar to step S33 and will not be repeated here.
- step S34 Similar to the principle in step S34, the applicant obtains the transaction data processing process by studying the transaction data analysis process and is divided into steps: because transaction data analysis is more complicated, there is no way to directly locate it like event data (for example, different directly through get Function acquisition), the transaction can only be matched by the matching method, so as to determine whether the transaction method is a construction method or a non-constant method, and then analyze the encoding string of the transaction method (such as RLP encoding string) to obtain the transaction data of the transaction method, In this way, the parsed transaction data is converted into a POJO object instance, and the POJO object instance is inserted into the database table according to the field type.
- event data for example, different directly through get Function acquisition
- the transaction can only be matched by the matching method, so as to determine whether the transaction method is a construction method or a non-constant method, and then analyze the encoding string of the transaction method (such as RLP encoding string) to obtain the transaction data of the transaction method, In this way, the
- the processing flow can be preset to multiple modules to form a preset transaction data analysis template, which is stored in the data analysis device 100, so that when the transaction in the smart contract to be analyzed is obtained
- the POJO object corresponding to the transaction method is directly filled into the preset transaction data analysis template, so as to obtain the transaction data analysis code used to analyze the transaction data in the smart contract.
- the preset transaction data analysis template includes at least a matching module, a second analysis module, a second instantiation module, and a second storage module.
- the matching module is used to determine whether the transaction method is the construction method or the non-constant method
- the second analysis module is used to analyze the transaction method and obtain transaction data
- the second instantiation module is used to The transaction data is converted into a second POJO object instance
- the second storage module is used to insert the second POJO object instance into a database table.
- the data analysis device 100 may first generate the event data analysis code and then generate the transaction data analysis code; or it may first generate the transaction data analysis code and then regenerate The event data analysis code is generated, or the transaction data analysis code and the event data analysis code are generated in parallel, and the order of execution is not restricted here.
- the data analysis device 100 can obtain each block in the block chain in turn. For example, taking the block chain shown in FIG. 1 as an example, block A is first obtained, and after analyzing the event data in block A, Get block B. Alternatively, the data analysis device 100 can also randomly acquire one of the blocks, which is not limited here. It should be noted that, for each block, the method of obtaining the event data in the block is the same. In the following, one of the blocks in the blockchain is used as an example for description.
- the data analysis device 100 After the data analysis device 100 acquires a block, it calls the generated event data analysis code, and determines whether there is event data corresponding to the smart contract in the block by calling the module. It can be understood that if the corresponding module can be obtained by calling the module A list of event objects indicates that there is event data corresponding to the smart contract in the block, otherwise, the event data corresponding to the smart contract is not included.
- the calling module will obtain the corresponding event data list through the get function, for example, getModifyUserNameEventEvents, for example, List ⁇ ModifyUserNameEventResponse>. If the List ⁇ ModifyUserName--EventResponse> can be obtained, it indicates the block Event data exists in the block, otherwise, there is no event data in the block.
- getModifyUserNameEventEvents for example, List ⁇ ModifyUserNameEventResponse>. If the List ⁇ ModifyUserName--EventResponse> can be obtained, it indicates the block Event data exists in the block, otherwise, there is no event data in the block.
- the event object list includes at least one value of the event object. For example, for the userName in the aforementioned UserInfo smart contract, at the first moment, the user sets userName as the first value, and at the second moment, the user sets userName as the second value, then the event object list corresponding to userName , It includes the first value and the second value.
- the UserInfo smart contract includes only one event method, so that the data analysis device 100 only generates one event data analysis code, but in actual use, a smart contract may include Multiple event methods, thus, the data analysis device 100 generates multiple event data analysis codes for one smart contract.
- the data analysis device 100 analyzes event data in a block, it needs to traverse multiple event data analysis codes corresponding to the smart contract. If all event data analysis codes are run, the event data cannot be obtained. List, it means that there is no event data in the block, otherwise there is event data in the block.
- S53 Parse at least one value of the event object through the parsing module in the event data parsing code to obtain at least one parsed event data.
- the at least one value is analyzed by the parsing module, so as to obtain corresponding event data.
- the at least one POJO first object instance corresponds to the at least one parsed event data in a one-to-one correspondence. For example, if the event object includes two values, the two values are parsed to obtain two event data, and then each event data is converted into a POJO object instance to obtain two first POJO object instances.
- Figure 6 is a flow chart of using transaction data analysis code to obtain transaction data.
- the flow chart is described as follows:
- Step S601 is the same as step S51, and will not be repeated here.
- the transaction acquisition interface is similar to that in the prior art, and will not be repeated here.
- the transaction type includes a first transaction type and a second transaction type
- the first transaction type is a transaction type corresponding to the construction method
- the second transaction type is related to the extraordinary transaction type.
- the target field is used to indicate the transaction object of the first transaction.
- the target field is the To field.
- step S604 to step S606 and step S610 are executed, and when the transaction type of the first transaction is determined to be the second transaction type, execute Step S607 to step S610.
- the data analysis device 100 if the data analysis device 100 generates multiple transaction data analysis codes for a smart contract, the data analysis device 100 needs to traverse multiple transaction data analysis codes corresponding to the smart contract. In the embodiment, an example of running a transaction data analysis code is described.
- the storage format of the transaction data corresponding to the construction method is: binary+encode(data), where binary is the RLP encoded string of the smart contract, and encode is the encoding function of the transaction data. Therefore, when it is determined that the transaction type of the first transaction is the transaction type corresponding to the construction method, it is necessary to compare the binary strings of all smart contracts to determine which smart contract construction method corresponds to the transaction.
- the construction method in the aforementioned UserInfo smart contract is UserInfo(bytes32userName,uint8sex).
- the binary (length M) in the JAVA file of the UserInfo smart contract is obtained, and then the RLP code (length N) of the first transaction is obtained.
- the first M strings of the RLP code of the transaction are the same as the binary in the JAVA file, and the first transaction is obtained by executing the construction method of the UserInfo smart contract.
- the first transaction is obtained from the execution of the UserInfo smart contract construction method, and the values of the field userName and the field sex can be obtained by parsing, and then the values of these two fields are parsed, and the first transaction is obtained At least one first transaction data.
- S606 Convert the first transaction data into a second POJO object instance through the second instantiation module in the transaction data analysis code.
- Step S606 is similar to step S54 and will not be repeated here.
- the storage format of the transaction data corresponding to the non-constant method is: functionSignature+encode(data), where the functionSignature is the signature of the non-constant method. Therefore, when the transaction type of the first transaction is determined to be the transaction type corresponding to the non-constant method, it is necessary to compare the signatures of the non-constant method of all smart contracts to determine which non-constant method corresponds to the transaction.
- the non-constant method in the aforementioned UserInfo smart contract is modifyUserName(bytes32userName).
- the signature of the modifyUserName (bytes32userName) method in the JAVA file of the UserInfo smart contract (length L) is obtained, and then the RLP code (length Is N). If the first L character strings of the RLP encoding of the first transaction are the same as the signature of the modifyUserName(bytes32userName) method, then the first transaction is obtained by executing the non-constant method of the UserInfo smart contract.
- the first transaction is obtained by executing the non-constant method of the UserInfo smart contract, and the values of the fields userName, sex, and address can be obtained by parsing, and then the values of these three fields are analyzed to obtain At least one piece of first transaction data in the first transaction.
- S609 Convert the second transaction data into a second POJO object instance through the second instantiation module in the transaction data analysis code.
- Steps S609 to S610 are similar to steps S54 to S55, and will not be repeated here.
- the code for analyzing data is generated automatically according to the smart contract of the user's business. That is to say, for different user's business, only the user needs to import the smart contract corresponding to each user's business. Adding an interface or pre-storing the code for data analysis can reduce the storage space occupied by the code for data analysis, and can reduce the cost of parsing data in the blockchain. Moreover, the code generated according to the smart contract corresponds to the interface in the smart contract one-to-one. Therefore, during data analysis, there is no need to call multiple interfaces or calculate the address of the data to be parsed, which can improve data analysis. performance.
- a third aspect of the present invention provides a block chain data analysis device. Please refer to FIG. 7, which is a structural diagram of the data analysis device.
- the data analysis device includes a processor 701, a transceiver 702, and a memory 703.
- the processor 701, the memory 703, and the transceiver 702 are connected through a bus interface;
- the processor 701 controls the transceiver 702 to obtain a smart contract of a user service, and the smart contract includes a construction method, an event method, and a non-constant method for creating and realizing the user service;
- the processor 701 generates data analysis code according to at least one of the construction method, the event method, and the non-constant method.
- the data analysis code includes event data analysis code for analyzing event data of the user service and Transaction data analysis code used to analyze the transaction data of the user service; and,
- the data analysis code is used to analyze the data in each block in the blockchain to obtain the event data and the transaction data.
- the processor 701 may specifically be a central processing unit, an application specific integrated circuit (English: Application Specific Integrated Circuit, abbreviated as: ASIC), may be one or more integrated circuits used to control program execution, and may be used on-site
- ASIC Application Specific Integrated Circuit
- the hardware circuit developed by the programmable gate array (English: Field Programmable Gate Array, referred to as FPGA) can be a baseband processor.
- the processor 701 may include at least one processing core.
- the electronic device further includes a memory 703.
- the memory 703 may include a read-only memory (English: Read Only Memory, abbreviated as: ROM), a random access memory (English: Random Access Memory, abbreviated as: RAM), and a disk storage.
- the memory 703 is used to store data required by the processor 701 during operation.
- the number of memories is one or more.
- a fourth aspect of the present invention provides a computer device, which includes:
- At least one processor and,
- the memory stores instructions that can be executed by the at least one processor, and the at least one processor executes the instructions shown in FIGS. 2 to 6 through the communication interface by executing the instructions stored in the memory.
- the method in the example is the example.
- the fifth aspect of the present invention provides a computer-readable storage medium, the computer-readable storage medium stores computer instructions, and when the computer instructions run on a computer, the computer executes the steps shown in FIGS. 2-6 The method in the embodiment.
- the embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) containing computer-usable program codes.
- a computer-usable storage media including but not limited to disk storage, optical storage, etc.
- These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
- the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
- These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
- the instructions provide steps for implementing functions specified in a flow or multiple flows in the flowchart and/or a block or multiple blocks in the block diagram.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Business, Economics & Management (AREA)
- Software Systems (AREA)
- Computer Security & Cryptography (AREA)
- Finance (AREA)
- Accounting & Taxation (AREA)
- Computer Hardware Design (AREA)
- General Health & Medical Sciences (AREA)
- Bioethics (AREA)
- Health & Medical Sciences (AREA)
- Development Economics (AREA)
- Economics (AREA)
- Marketing (AREA)
- Strategic Management (AREA)
- Technology Law (AREA)
- General Business, Economics & Management (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Stored Programmes (AREA)
Abstract
Description
相关申请的交叉引用Cross references to related applications
本申请要求在2019年06月24日提交中国专利局、申请号为201910550186.0、申请名称为“一种区块链的数据解析方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on June 24, 2019, the application number is 201910550186.0, and the application name is "a data analysis method and device for blockchain", the entire content of which is incorporated by reference In this application.
本发明涉及科技金融(Fintech)领域,尤其涉及一种区块链的数据解析方法及装置。The present invention relates to the field of Fintech, in particular to a data analysis method and device of a blockchain.
区块链(Block chain)技术与金融领域的结合,使得传统金融业正在逐步向科技金融(Finteh)转变。在结合了区块链技术的科技金融中,较为重要的是对区块链中的数据(例如,合约账户数据、交易数据和事件数据)进行处理,例如,解析数据或者同步数据等。The combination of Blockchain technology and the financial field has made the traditional financial industry gradually transforming into Finteh. In technology finance combined with blockchain technology, it is more important to process data in the blockchain (for example, contract account data, transaction data, and event data), such as analyzing data or synchronizing data.
针对解析数据,目前提出了两个解决方案:For analyzing data, two solutions are currently proposed:
第一种解决方案:在智能合约(Smart contract)的层面设计一套专用接口,当业务需要时,通过智能调用智能合约中的专用接口解析区块链中的数据。The first solution is to design a set of dedicated interfaces at the level of smart contracts. When business needs, the dedicated interfaces in the smart contracts are intelligently invoked to analyze the data in the blockchain.
第二种解决方案:通过预先保存待解析的数据在区块链上的地址,然后根据该地址调用相关接口,获取该数据。The second solution: save the address of the data to be parsed on the blockchain in advance, and then call the relevant interface according to the address to obtain the data.
然而,针对上述第一种解决方案,由于专用接口的代码需要占用一定的存储空间,尤其当该专用接口的数量较多时,该专用接口将导致存储空间开销大,造成较高的成本。且,由于当该专用接口较复杂时,可能需要多次调用不同接口才能获取数据,导致性能差。而针对第二种解决方案,由于地址都是针对特定的智能合约,当有新的业务或者智能合约变更时,不能复用,则需要技术人员重新修改代码,且,第二种解决方案在获取数据时,需要根据数据结构定义中的寻址规则去计算数据地址,运算量加大。However, for the above-mentioned first solution, since the code of the dedicated interface needs to occupy a certain amount of storage space, especially when the number of dedicated interfaces is large, the dedicated interface will cause a large storage space overhead and cause higher costs. Moreover, when the dedicated interface is complicated, it may be necessary to call different interfaces multiple times to obtain data, resulting in poor performance. As for the second solution, since the address is for a specific smart contract, when there is a new business or smart contract change, it cannot be reused, and the code needs to be revised by the technical staff, and the second solution is getting For data, it is necessary to calculate the data address according to the addressing rules in the data structure definition, which increases the amount of calculation.
可见,现有技术中解析区块链中的数据存在成本高且性能差的技术问题。It can be seen that there are technical problems of high cost and poor performance in parsing data in the blockchain in the prior art.
发明内容Summary of the invention
本发明提供一种区块链的数据解析方法及装置,用以降低解析区块链中的数据的成本以及提高数据解析的性能。The invention provides a block chain data analysis method and device, which are used to reduce the cost of analyzing data in the block chain and improve the performance of data analysis.
本发明第一方面提供了一种区块链的数据解析方法,所述方法包括:The first aspect of the present invention provides a block chain data analysis method, the method includes:
获取用户业务的智能合约,所述智能合约中包括用于创建实现所述用户业务的构造方法、事件方法以及非常量方法;Acquiring a smart contract for a user service, the smart contract including a construction method, an event method, and a non-constant method for creating and realizing the user service;
根据所述构造方法、事件方法以及非常量方法中的至少一个方法,生成数据解析代码,所述数据解析代码包括用于对所述用户业务的事件数据进行解析的事件数据解析代码和用于对所述用户业务的交易数据进行解析的交易数据解析代码;According to at least one of the construction method, event method, and non-constant method, a data analysis code is generated. The data analysis code includes event data analysis code for analyzing event data of the user service and Transaction data analysis code for analyzing transaction data of the user service;
使用所述数据解析代码对区块链中的每一个区块中的数据进行解析,获取所述事件数据和所述交易数据。The data analysis code is used to analyze the data in each block in the blockchain to obtain the event data and the transaction data.
在本申请实施例中,生成事件数据解析代码和交易数据解析代码的过程根据所依赖的方法不同,具有不同的生成方式。In the embodiment of the present application, the process of generating the event data analysis code and the transaction data analysis code has different generation methods depending on the method that it relies on.
在一种可能的实施方式中,根据所述构造方法、事件方法以及非常量方法中的至少一个方法,生成所述事件数据解析代码,包括:In a possible implementation manner, generating the event data parsing code according to at least one of the construction method, event method, and non-constant method includes:
编译所述智能合约,得到与所述智能合约对应的JAVA合约文件,所述JAVA合约文件中至少包括用于获取所述事件方法中的事件对象的获取方法、与所述事件方法对应的事件类以及所述智能合约的二进制编码,所述智能合约的二进制编码中至少包括所述构造方法、所述事件方法以及所述非常量方法中每个方法访问所述区块链的字段类型;Compile the smart contract to obtain a JAVA contract file corresponding to the smart contract. The JAVA contract file includes at least an acquisition method for acquiring an event object in the event method and an event class corresponding to the event method And the binary code of the smart contract, the binary code of the smart contract includes at least the construction method, the event method, and the non-constant method each of which accesses the field type of the blockchain;
加载所述JAVA合约文件,通过反射获取所述事件类;Load the JAVA contract file, and obtain the event class through reflection;
通过JAVA对象与第一字段类型之间的第一映射关系,将所述事件类中的与所述第一字段类型相同的字段转化为JAVA对象,从而获取与所述事件类对应的第一POJO对象,所述第一字段类型为所述事件方法中用于访问所述区块链的字段类型;Through the first mapping relationship between the JAVA object and the first field type, the field in the event class with the same type as the first field is converted into a JAVA object, thereby obtaining the first POJO corresponding to the event class Object, the first field type is a field type used to access the blockchain in the event method;
将所述第一POJO对象填入预设的事件数据解析模板,生成所述事件数据解析代码,所述预设的事件数据解析函数模板中至少包括调用模块、第一解析模块、第一实例化模块以及第一存储模块,所述调用模块用于调用所述获取方法,所述第一解析模块用于解析所述事件对象并获取解析后的事件数据,所述第一实例化模块用于将解析后的事件数据转换为第一POJO对象实例,以及,所述第一存储模块用于将所述第一POJO对象实例插入数据库表,所述数据库表用于存储所述事件数据和所述交易数据。The first POJO object is filled into a preset event data analysis template to generate the event data analysis code. The preset event data analysis function template at least includes a calling module, a first analysis module, and a first instantiation Module and a first storage module, the calling module is used to call the acquisition method, the first parsing module is used to parse the event object and obtain the parsed event data, the first instantiation module is used to The parsed event data is converted into a first POJO object instance, and the first storage module is used to insert the first POJO object instance into a database table, and the database table is used to store the event data and the transaction data.
相应地,使用所述事件数据解析代码对区块链中的每一个区块中的数据进行解析,以获取所述事件数据,包括:Correspondingly, using the event data analysis code to analyze the data in each block in the blockchain to obtain the event data includes:
获取所述区块链中的其中一个区块,所述其中一个区块为所述区块链中的任意一个区块;Acquiring one of the blocks in the blockchain, where the one of the blocks is any block in the blockchain;
运行所述事件数据解析代码,通过所述事件数据解析代码中的调用模块获取所述区块中的事件对象列表,所述事件对象列表包括所述事件对象的至少一个取值;Run the event data analysis code, obtain a list of event objects in the block through the calling module in the event data analysis code, the event object list including at least one value of the event object;
通过所述事件数据解析代码中的解析模块解析所述事件对象的至少一个取值,获得至少一个解析后的事件数据;Parsing at least one value of the event object through the parsing module in the event data parsing code to obtain at least one parsed event data;
通过所述事件数据解析代码中的实例化模块将所述至少一个解析后的事件数据分别转化为至少一个第一POJO对象实例,所述至少一个POJO第一对象实例与所述至少一个解析后的事件数据一一对应;The at least one parsed event data is respectively converted into at least one first POJO object instance through the instantiation module in the event data analysis code, and the at least one first POJO object instance and the at least one parsed One-to-one correspondence of event data;
通过所述事件数据解析代码中的存储模块将所述至少一个POJO对象实例插入所述数据库表中。The at least one POJO object instance is inserted into the database table through the storage module in the event data analysis code.
在一种可能的实施方式中,根据所述构造方法、事件方法以及非常量方法中的至少一个方法,生成所述交易数据解析代码,包括:In a possible implementation manner, generating the transaction data analysis code according to at least one of the construction method, the event method, and the non-constant method includes:
编译所述智能合约,得到与所述智能合约对应的JAVA合约文件,所述JAVA合约文件中至少包括所述智能合约的二进制编码以及二进制字符串,所述智能合约的二进制编码中至少包括所述构造方法以及所述非常量方法中每个方法访问所述区块链的字段类型,所述二进制字符串为所述智能合约的递归长度前缀编码;Compile the smart contract to obtain a JAVA contract file corresponding to the smart contract. The JAVA contract file includes at least the binary code and binary string of the smart contract, and the binary code of the smart contract includes at least the Each of the construction method and the non-constant method accesses the field type of the blockchain, and the binary string is the recursive length prefix code of the smart contract;
加载所述JAVA合约文件,解析所述二进制编码,获取交易方法,所述交易方法包括所述构造方法和所述非常量方法;Load the JAVA contract file, parse the binary code, and obtain a transaction method, the transaction method including the construction method and the non-constant method;
通过JAVA对象与第二字段类型之间的第二映射关系,将所述交易方法中的与所述第二字段类型相同的字段转化为JAVA对象,从而获取与所述交易方法对应的第二POJO对象,所述第二字段类型为所述交易方法中用于访问所述区块链的字段类型;Through the second mapping relationship between the JAVA object and the second field type, the field in the transaction method with the same type as the second field is converted into a JAVA object, thereby obtaining the second POJO corresponding to the transaction method Object, the second field type is a field type used to access the blockchain in the transaction method;
将所述第二POJO对象填充预设的交易数据解析模板,生成所述交易数据解析代码,所述预设的交易数据解析模板至少包括匹配模块、第二解析模块、第二实例化模块以及第二存储模块,所述匹配模块用于确定所述交易方法为所述构造方法或为所述非常量方法,所述第二解析模块用于解析所述交易方法并获取交易数据,所述第二实例化模块用于将交易数据转换为第二POJO对象实例,以及,所述第二存储模块用于将所述第二POJO对象实例插入数据库表,所述数据库表用于存储所述事件数据和所述交易数据。The second POJO object is filled with a preset transaction data analysis template to generate the transaction data analysis code. The preset transaction data analysis template includes at least a matching module, a second analysis module, a second instantiation module, and a first Two storage modules, the matching module is used to determine whether the transaction method is the construction method or the non-constant method, the second analysis module is used to parse the transaction method and obtain transaction data, the second The instantiation module is used to convert transaction data into a second POJO object instance, and the second storage module is used to insert the second POJO object instance into a database table that is used to store the event data and The transaction data.
在本申请实施例中,根据交易数据解析代码获取交易数据,可以包括但不限于如下两种情况:In the embodiment of the present application, obtaining transaction data according to the transaction data analysis code may include but not limited to the following two situations:
第一种情况,使用所述交易数据解析代码对区块链中的每一个区块中的数据进行解析,以获取所述交易数据,包括:In the first case, using the transaction data analysis code to analyze the data in each block in the blockchain to obtain the transaction data includes:
获取所述区块链中的其中一个区块,所述其中一个区块为所述区块链中的任意一个区块;Acquiring one of the blocks in the blockchain, where the one of the blocks is any block in the blockchain;
通过预设的交易获取接口,获取所述区块中的第一交易;Obtain the first transaction in the block through a preset transaction acquisition interface;
运行所述交易数据解析代码,通过交易数据解析代码中的匹配模块获取所述第一交易中的目标字段,并根据所述目标字段确定所述第一交易的交易类型,所述交易类型包括第一交易类型和第二交易类型,所述第一交易类型为与所述构造方法对应的交易类型,所述第二交易类型为与所述非常量方法对应的交易类型,所述目标字段用于指示所述第一交易的交易对象;Run the transaction data analysis code, obtain the target field in the first transaction through the matching module in the transaction data analysis code, and determine the transaction type of the first transaction according to the target field, the transaction type including the first transaction A transaction type and a second transaction type, the first transaction type is a transaction type corresponding to the construction method, the second transaction type is a transaction type corresponding to the non-constant method, and the target field is used for Indicating the transaction partner of the first transaction;
在确定所述第一交易的交易类型为所述第一交易类型时,通过所述匹配模块获取所述第一交易的递归长度前缀编码,确定所述第一交易的递归长度前缀编码是否包括所述二进制字符串;When it is determined that the transaction type of the first transaction is the first transaction type, obtain the recursive length prefix code of the first transaction through the matching module, and determine whether the recursive length prefix code of the first transaction includes all The binary string;
在为是时,通过所述交易数据解析代码中的第二解析模块,对第一剩余字符串进行解析,获取所述第一交易的第一交易数据,所述第一剩余字符串为所述第一交易的递归长度前缀编码中去除与所述二进制字符串相同的符号之后的字符串;If yes, the first remaining character string is parsed through the second parsing module in the transaction data analysis code to obtain the first transaction data of the first transaction, and the first remaining character string is the In the recursive length prefix encoding of the first transaction, the character string after removing the same symbol as the binary character string;
通过所述交易数据解析代码中的第二实例化模块将所述第一交易数据转化为第二POJO对象实例;Convert the first transaction data into a second POJO object instance through the second instantiation module in the transaction data analysis code;
通过所述交易数据解析代码中的第二存储模块将所述第二POJO对象实例插入所述数据库表中。The second POJO object instance is inserted into the database table through the second storage module in the transaction data analysis code.
第二种情况,在运行所述交易数据解析代码,通过交易数据解析代码中的匹配模块获取所述第一交易中的目标字段,并根据所述目标字段确定所述第一交易的交易类型之后,所述方法还包括:In the second case, after running the transaction data analysis code, the target field in the first transaction is obtained through the matching module in the transaction data analysis code, and the transaction type of the first transaction is determined according to the target field , The method further includes:
在所述第一交易的交易类型为所述第二交易类型时,通过所述匹配模块获取所述第一交易的递归长度前缀编码,确定所述第一交易的递归长度前缀编码是否包括所述交易数据解析代码所对应的非常量方法的签名;When the transaction type of the first transaction is the second transaction type, obtain the recursive length prefix code of the first transaction through the matching module, and determine whether the recursive length prefix code of the first transaction includes the The signature of the non-constant method corresponding to the transaction data analysis code;
在为是时,通过所述交易数据解析代码中的第二解析模块,对第二剩余编码进行解析,获取所述第一交易的第二交易数据,所述第二剩余编码为所述第一交易的编码中去除与所述签名相同的符号之后的字符串;If yes, the second remaining code is analyzed through the second analysis module in the transaction data analysis code to obtain the second transaction data of the first transaction, and the second remaining code is the first The code of the transaction removes the character string after the same symbol as the signature;
通过所述交易数据解析代码中的第二实例化模块将所述第二交易数据转化为第二POJO对象实例;Converting the second transaction data into a second POJO object instance through the second instantiation module in the transaction data analysis code;
通过所述交易数据解析代码中的第二存储模块将所述第二POJO对象实例插入所述数 据库表中。Insert the second POJO object instance into the database table through the second storage module in the transaction data analysis code.
本发明第二方面提供一种电子设备,包括:A second aspect of the present invention provides an electronic device, including:
至少一个处理器;以及,At least one processor; and,
与所述至少一个处理器通信连接的存储器;其中,A memory communicatively connected with the at least one processor; wherein,
所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行所述区块链的数据解析方法。The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor, so that the at least one processor can execute the blockchain data analysis method.
本发明第三方面提供一种非暂态计算机可读存储介质,所述非暂态计算机可读存储介质存储计算机指令,所述计算机指令用于使所述计算机执行所述区块链的数据解析方法。A third aspect of the present invention provides a non-transitory computer-readable storage medium, the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to make the computer execute the data analysis of the blockchain method.
本发明第四方面一种计算设备,包括:存储器,用于存储计算机程序;处理器,用于调用所述存储器中存储的计算机程序,按照获得的程序执行如第一方面的各种可能的设计中所述的方法。In the fourth aspect of the present invention, a computing device includes: a memory for storing a computer program; a processor for calling the computer program stored in the memory, and executing various possible designs as in the first aspect according to the obtained program The method described in.
在本发明实施例中,可以自动根据用户业务的智能合约,生成用于解析数据的代码,也就是说,针对不同的用户业务,只需要用户导入与各个用户业务对应的智能合约即可,无需新增接口或者无需预先存储用于数据解析的代码,从而可以减小用于数据解析的代码占用的存储空间,可以降低解析区块链中的数据的成本。且,根据智能合约生成的代码是与智能合约中的接口一一对应的,因此,在进行数据解析时,不需要调用多个接口或者不需要计算待解析数据的地址,从而可以提高数据解析的性能。In the embodiment of the present invention, the code for analyzing data can be automatically generated according to the smart contract of the user's business. That is to say, for different user services, the user only needs to import the smart contract corresponding to each user's business. New interfaces or no need to pre-store the code for data analysis, which can reduce the storage space occupied by the code for data analysis, and can reduce the cost of parsing data in the blockchain. Moreover, the code generated according to the smart contract corresponds to the interface in the smart contract one-to-one. Therefore, during data analysis, there is no need to call multiple interfaces or calculate the address of the data to be parsed, which can improve data analysis. performance.
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简要介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域的普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly describe the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings needed in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative work, other drawings can be obtained from these drawings.
图1为本发明实施例提供数据解析方法所适用的系统架构的结构框图;FIG. 1 is a structural block diagram of a system architecture applicable to a data analysis method provided by an embodiment of the present invention;
图2为本发明实施例提供的区块链的数据解析方法的流程图;FIG. 2 is a flowchart of a data analysis method of a blockchain provided by an embodiment of the present invention;
图3为本发明实施例中生成事件数据解析代码的流程图;3 is a flowchart of generating event data analysis code in an embodiment of the present invention;
图4为本发明实施例中生成交易数据解析代码的流程图;4 is a flowchart of generating transaction data analysis code in an embodiment of the present invention;
图5为本发明实施例中对区块中的事件数据进行解析的流程图;5 is a flowchart of analyzing event data in a block in an embodiment of the present invention;
图6为本发明实施例中对区块中的第一交易的交易数据进行解析的流程图;FIG. 6 is a flowchart of analyzing transaction data of the first transaction in a block in an embodiment of the present invention;
图7为本发明实施例中提供的区块链的数据解析的另一种示例的结构图。FIG. 7 is a structural diagram of another example of data analysis of the blockchain provided in the embodiment of the present invention.
本发明提供一种区块链的数据解析方法及装置,用以降低解析区块链中的数据的成本以及提高数据解析的性能。The invention provides a block chain data analysis method and device, which are used to reduce the cost of analyzing data in the block chain and improve the performance of data analysis.
为了便于理解,下面对本发明实施例中可能涉及的名词进行定义和解释。For ease of understanding, the following defines and explains the terms that may be involved in the embodiments of the present invention.
区块链:是由一系列区块组成的一条链,每个块上除了记录本块的数据还会记录上一块的Hash(哈希)值,通过这种方式组成一条链。区块链的核心理念有两个,一个是密码学技术,另一个是去中心化思想,基于这两个理念做到区块链上的历史信息无法被篡改。一个区块由块头和块体组成,其中块头定义包括该区块高度h,上一个区块的Hash值prevHash等重要字段,而块体主要存储交易数据。Blockchain: A chain composed of a series of blocks. In addition to recording the data of the block, each block also records the Hash value of the previous block. In this way, a chain is formed. There are two core concepts of the blockchain, one is cryptography and the other is decentralization. Based on these two concepts, the historical information on the blockchain cannot be tampered with. A block consists of a block header and a block body. The block header definition includes important fields such as the block height h, the hash value prevHash of the previous block, and the block body mainly stores transaction data.
智能合约:是一种旨在以信息化方式传播、验证或执行合同的计算机协议,智能合约的执行过程会以交易的形式在区块链上共识、确认,其允许在没有第三方的情况下进行可信交易,这些交易可追踪且不可逆转。Smart contract: It is a computer protocol designed to spread, verify or execute the contract in an information-based way. The execution process of the smart contract will be agreed and confirmed on the blockchain in the form of a transaction, which allows the absence of a third party Conduct trusted transactions, which are traceable and irreversible.
web3jsdk:JAVA语言访问区块链的桥接层,提供相关应用程序编程接口(Application Programming Interface,API)对区块链进行访问。web3jsdk: The bridging layer for JAVA language to access the blockchain, and provides related application programming interfaces (Application Programming Interface, API) to access the blockchain.
Solidity:一种智能合约高级语言,运行在以太网虚拟机(EVM)之上,主要用于编写智能合约。Solidity: A high-level language for smart contracts, running on the Ethernet Virtual Machine (EVM), mainly used to write smart contracts.
JAVA:一门面向对象的编程语言,用以编写桌面应用程序、Web应用程序、分布式系统和嵌入式系统应用程序等。JAVA: An object-oriented programming language for writing desktop applications, Web applications, distributed systems, and embedded system applications.
opcode:智能合约编译后的操作指令。opcode: The operating instructions after the smart contract is compiled.
Event:智能合约的一种方法类型,可以将参数存储在交易的日志中,便于对智能合约执行情况进行跟踪。Event: A method type of smart contract that can store parameters in the transaction log to facilitate tracking of the execution of the smart contract.
简单的Java对象(Plain Ordinary Java Object,POJO):实际就是普通JavaBeans,可以理解为是JAVA中的接口、类和对象。Simple Java Objects (Plain Ordinary Java Object, POJO): Actually they are ordinary JavaBeans, which can be understood as interfaces, classes and objects in JAVA.
递归长度前缀(Recursive Length Prefix,RLP):是一种编码规则,可用于编码任意嵌套的二进制数组数据。RLP编码的结果也是二进制序列,主要用来序列化/反序列化数据。Recursive Length Prefix (RLP): It is an encoding rule that can be used to encode arbitrary nested binary array data. The result of RLP encoding is also a binary sequence, which is mainly used to serialize/deserialize data.
应用程序二进制接口(Application Binary Interface,ABI):描述了应用程序和操作系统之间,一个应用和它的库之间,或者应用的组成部分之间的低接口。Application Binary Interface (ABI): describes the low interface between an application and an operating system, between an application and its library, or between components of an application.
需要说明的是,本发明实施例中的第一、第二仅用于区分不同的对象,不表示各个对象的重要性或者优先级。It should be noted that the first and second in the embodiment of the present invention are only used to distinguish different objects, and do not indicate the importance or priority of each object.
下面,对本发明实施例中的应用场景进行介绍。Below, the application scenarios in the embodiments of the present invention are introduced.
图1示例性的示出了本发明实施例提供数据解析方法所适用的系统架构,该系统架构可以包括数据解析装置100和区块链200。需要说明的是,在图1中,数据解析装置100与区块链200是两个独立的模块,在其他的示例中,该数据解析装置100也可以设置在区块链200中,在此不作限制。FIG. 1 exemplarily shows a system architecture applicable to a data analysis method provided by an embodiment of the present invention. The system architecture may include a
其中,区块链200可以包括多个区块,例如,在图1所示的系统架构中,区块链200包括2个区块,分别为区块A和区块B。每个区块中可以根据用户业务设置多个智能合约,例如,在区块A中设置有智能合约1,在区块B中设置有智能合约2。Among them, the
数据解析装置100可以通过不同的接口,获取并解析区块链200中每个区块中的任意一种数据,例如,可以通过合约接口获取合约账户数据,可以通过区块接口获取区块数据,这两种数据不解析。然而,由于区块链中的事件数据和交易数据依赖智能合约,比较复杂,因此,数据解析装置100需要对这两种数据进行解析。The
在现有技术中,在解析事件数据或交易数据时,要么预先设置与每个智能合约对应的专用接口,要么通过预先保存待解析的数据的地址,具体请参考背景技术中描述的第一种解决方案和第二种解决方案,在此不再赘述。但是,采用现有技术中的方法解析事件数据或交易数据存在成本高且性能差的技术问题。In the prior art, when analyzing event data or transaction data, either a dedicated interface corresponding to each smart contract is preset, or the address of the data to be parsed is stored in advance. For details, please refer to the first type described in the background art. The solution and the second solution will not be repeated here. However, using the methods in the prior art to analyze event data or transaction data has technical problems of high cost and poor performance.
为了解决上述技术问题,本发明提供一种区块链的数据解析方法,该方法应用于图1所示的数据解析装置100中。请参考图2,为该方法流程图,该流程图的描述如下:In order to solve the above technical problems, the present invention provides a data analysis method for blockchain, which is applied to the
S21、获取用户业务的智能合约,所述智能合约中包括用于创建实现所述用户业务的构造方法、事件方法以及非常量方法。S21. Acquire a smart contract for a user service, where the smart contract includes a construction method, an event method, and a non-constant method for creating and realizing the user service.
在具体实施过程中,数据解析装置100可以通过预设的接口,获取用户提供的智能合约,或者,也可以通过其他方式获取该智能合约,在本发明实施例中不对此进行限制。智能合约可以通过不同的编程语言进行编写,为方便说明,下文中以智能合约为采用Solidity编程语言编写的智能合约为例。In the specific implementation process, the
作为一种示例,假设用户业务为保存用户信息(UserInfo),数据解析装置100获取的UserInfo智能合约可以如下所示:As an example, assuming that the user service is to save user information (UserInfo), the UserInfo smart contract obtained by the
Contract UserInfo{Contract UserInfo{
bytes32_userName;bytes32_userName;
uint8_sex;uint8_sex;
function UserInfo(bytes32userName,uint8sex)public{function UserInfo(bytes32userName,uint8sex)public{
_userName=userName;_userName=userName;
_sex=sex;_sex=sex;
}}
event modifyUserNameEvent(bytes32userName,uint8sex,address con);event modifyUserNameEvent(bytes32userName, uint8sex, address con);
function modifyUserName(bytes32userName)public returns(bytes32){function modifyUserName(bytes32userName)public returns(bytes32){
_userName=userName;_userName=userName;
modifyUserNameEvent(_userName,_sex,address(this));modifyUserNameEvent(_userName,_sex,address(this));
return_userName;return_userName;
}}
}}
在该UserInfo智能合约中,包括一个用于创建该UserInfo智能合约实例的构造方法,即:The UserInfo smart contract includes a construction method for creating an instance of the UserInfo smart contract, namely:
function UserInfo(bytes32userName,uint8sex)public{function UserInfo(bytes32userName,uint8sex)public{
_userName=userName;_userName=userName;
_sex=sex;_sex=sex;
}}
以及,一个用于记录每次修改用户名之后用户的信息的事件方法,即:event modifyUserNameEvent(bytes32userName,uint8sex,address con)。以及,一个用于修改用户的姓名的非常量(constant)方法,即:And, an event method used to record the user's information after each user name modification, namely: event modifyUserNameEvent(bytes32userName, uint8sex, address con). And, a constant method for modifying the user's name, namely:
function modifyUserName(bytes32userName)public returns(bytes32){function modifyUserName(bytes32userName)public returns(bytes32){
_userName=userName;_userName=userName;
modifyUserNameEvent(_userName,_sex,address(this));modifyUserNameEvent(_userName,_sex,address(this));
return_userName;return_userName;
}}
在上述UserInfo智能合约中,该智能合约仅包括一个构成方法、一个事件方法以及一个非常量方法,应该理解为是对智能合约的一种示例,而不是限制智能合约中只能包括一个构造方法、一个事件方法以及一个非常量方法,在实际使用过程中,一个智能合约也可以包括多个构造方法或者多个事件方法或者多个非常量方法,在此不再赘述。In the above UserInfo smart contract, the smart contract only includes a composition method, an event method, and a non-constant method. It should be understood as an example of a smart contract, rather than restricting the smart contract to only include one construction method, An event method and a non-constant method. In actual use, a smart contract can also include multiple construction methods or multiple event methods or multiple non-constant methods, which will not be repeated here.
S22、根据所述构造方法、事件方法以及非常量方法中的至少一个方法,生成数据解析代码。S22. Generate a data analysis code according to at least one of the construction method, the event method, and the non-constant method.
在本发明实施例中,主要用于解析区块中的交易数据和事件数据,因此,生成的数据解析代码包括用于对所述用户业务的事件数据进行解析的事件数据解析代码和用于对所述用户业务的交易数据进行解析的交易数据解析代码。In the embodiment of the present invention, it is mainly used to analyze transaction data and event data in a block. Therefore, the generated data analysis code includes event data analysis code for analyzing the event data of the user service and The transaction data analysis code for analyzing the transaction data of the user service.
下面,将分别介绍事件数据解析代码的生成过程和交易数据解析代码的生成过程。Below, the generation process of the event data analysis code and the generation process of the transaction data analysis code will be introduced respectively.
针对事件数据解析代码,请参考图3,为生成事件数据解析代码的流程图,该流程图描述如下:For the event data analysis code, please refer to Figure 3, which is a flowchart for generating event data analysis code. The flowchart is described as follows:
S31、编译所述智能合约,得到与所述智能合约对应的JAVA合约文件。S31. Compile the smart contract to obtain a JAVA contract file corresponding to the smart contract.
在根据智能合约生成事件数据解析代码之前,首先要通过编译器,编译该智能合约,从而得到编译后的合约文件。Before generating the event data analysis code according to the smart contract, the smart contract must be compiled through the compiler to obtain the compiled contract file.
作为一种示例,可以通过编译器将智能合约编译为JAVA代码文件。继续以智能合约为UserInfo智能合约为例,对该UserInfo智能合约进行编译的代码可以如下所示:As an example, a smart contract can be compiled into a JAVA code file by a compiler. Continuing to take the smart contract as the UserInfo smart contract as an example, the code to compile the UserInfo smart contract can be as follows:
pragma solidity^0.4.7;pragma solidity^0.4.7;
Contract UserInfo{Contract UserInfo{
bytes32_userName;bytes32_userName;
uint8_sex;uint8_sex;
function UserInfo(bytes32userName,uint8sex)public{function UserInfo(bytes32userName,uint8sex)public{
_userName=userName;_userName=userName;
_sex=sex;_sex=sex;
}}
event modifyUserNameEvent(bytes32userName,uint8sex,address con);event modifyUserNameEvent(bytes32userName, uint8sex, address con);
function modifyUserName(bytes32userName)public returns(bytes32){function modifyUserName(bytes32userName)public returns(bytes32){
_userName=userName;_userName=userName;
modifyUserNameEvent(_userName,_sex,address(this));modifyUserNameEvent(_userName,_sex,address(this));
return_userName;return_userName;
}}
}}
在使用上述代码对该UserInfo智能合约进行编译后,则得到对应的JAVA文件,该JAVA文件即JAVA合约文件。当然,根据编译所使用的编程语言不同,合约文件也可以是其他类型的文件,例如,若采用PHP编程语言进行编译,则得到了编译后的PHP文件,在此不对合约文件的类型进行限制。为方便说明,在下文中以该合约文件为JAVA文件为例。After compiling the UserInfo smart contract with the above code, the corresponding JAVA file is obtained, and the JAVA file is the JAVA contract file. Of course, depending on the programming language used for compilation, the contract file can also be other types of files. For example, if the PHP programming language is used to compile, a compiled PHP file is obtained, and the type of contract file is not limited here. For the convenience of explanation, in the following, the contract file is a JAVA file as an example.
在本发明实施例中,所述JAVA合约文件中至少包括用于获取所述事件方法中的事件对象的获取方法、与所述事件方法对应的事件类以及所述智能合约的二进制编码,所述智能合约中的二进制编码中至少包括所述构造方法、所述事件方法以及所述非常量方法中每个方法访问所述区块链的字段类型。In the embodiment of the present invention, the JAVA contract file includes at least an acquisition method for acquiring an event object in the event method, an event class corresponding to the event method, and the binary code of the smart contract. The binary code in the smart contract includes at least the construction method, the event method, and the non-constant method to access the field type of the blockchain.
具体来讲,当该UserInfo智能合约采用JAVA编译器进行编译后,可以得到包括但不限于如下内容的JAVA文件:Specifically, when the UserInfo smart contract is compiled with a JAVA compiler, a JAVA file including but not limited to the following contents can be obtained:
在上述JAVA文件中,getModifyUserNameEventEvents即用于获取事件方法中的事件对象的获取方法,public static class ModifyUserNameEventResponse{}即与事件方法对应的事件类,String ABI即所述智能合约的二进制编码,该ABI中包括该智能合约中所有方法的类型、输入参数、输出参数以及每个方法用于访问区块链的字段类型以及字段名称等,二进制(binary)字符串为该智能合约的RLP编码,用于对合约实例进行签名。当然,该JAVA文件也可以包括其他内容,在此不一一举例。In the above JAVA file, getModifyUserNameEventEvents is the method used to obtain the event object in the event method, public static class ModifyUserNameEventResponse{} is the event class corresponding to the event method, String ABI is the binary code of the smart contract, and the ABI is Including the types, input parameters, output parameters of all methods in the smart contract, and the field types and field names used by each method to access the blockchain. The binary string is the RLP code of the smart contract and is used to The contract instance is signed. Of course, the JAVA file may also include other content, and no examples are given here.
S32、加载所述JAVA合约文件,通过反射获取所述事件类。S32. Load the JAVA contract file, and obtain the event class through reflection.
在上述JAVA文件中,该事件类为modifyUserNameEvent类。In the above JAVA file, the event class is modifyUserNameEvent class.
S33、通过JAVA对象与第一字段类型之间的第一映射关系,将所述事件类中的与所述第一字段类型相同的字段转化为JAVA对象,从而获取与所述事件类对应的第一POJO对象。S33. Through the first mapping relationship between the JAVA object and the first field type, the field in the event class with the same type as the first field is converted into a JAVA object, so as to obtain the first field corresponding to the event class. A POJO object.
在本发明实施例中,该第一字段类型为所述事件方法中用于访问所述区块链的字段类型。作为一种示例,该第一字段类型可以为web3jsdk类型。In the embodiment of the present invention, the first field type is the field type used to access the blockchain in the event method. As an example, the first field type may be a web3jsdk type.
沿用上述例子,当获取该JAVA文件中的modifyUserNameEvent类后,首先定位modifyUserNameEvent类中字段类型为web3jsdk类型的字段,例如,该web3jsdk类型的字段可以包括Bytes32、Uint8、Address。然后,根据第一映射关系,将该字段转化为JAVA对象。该第一映射关系可以为:Bytes32对应为String、Uint8对应为int、Address对应为String,该第一映射关系可以是预先存储在数据解析装置100中的。当将该JAVA文件中的web3jsdk类型的字段转化为JAVA对象之后,则可以生成与modifyUserNameEvent类对应的第一POJO对象。例如,与modifyUserNameEvent类的POJO对象的代码如下所示:Following the above example, after obtaining the modifyUserNameEvent class in the JAVA file, first locate the field in the modifyUserNameEvent class whose field type is the web3jsdk type. For example, the web3jsdk type field may include Bytes32, Uint8, and Address. Then, according to the first mapping relationship, the field is converted into a JAVA object. The first mapping relationship may be: Bytes32 corresponds to String, Uint8 corresponds to int, and Address corresponds to String. The first mapping relationship may be pre-stored in the data analysis apparatus 100. After converting the web3jsdk type field in the JAVA file into a JAVA object, the first POJO object corresponding to the modifyUserNameEvent class can be generated. For example, the code of the POJO object with modifyUserNameEvent class is as follows:
S34、将所述第一POJO对象填入预设的事件数据解析模板,生成所述事件数据解析代码。S34. Fill the first POJO object into a preset event data analysis template, and generate the event data analysis code.
申请人通过研究事件数据解析流程,得知:针对所有的事件数据,其处理流程基本相同,可以分为如下步骤:调用get函数获取事件对象,然后解析该事件对象,获取该事件对象的事件数据,然后将解析得到的事件数据转换为JAVA对象实例,从而将该JAVA对象实例插入数据库表。因此,在本发明实施例中,可以将该处理流程预先设置为多个模块,形成预设的事件数据解析模板,存储在数据解析装置100中,从而,当获取待解析的智能合约中的事件对象后,则直接根据字段类型,将该事件对象填充至该预设的事件数据解析模板,从而得到用于解析该智能合约中的事件数据的事件数据解析代码。这样,当解析不 同的智能合约中事件数据时,只需要获取对应的智能合约即可,无需新增接口或者重新修改代码,实现方式简单,且支持二次开发。The applicant has studied the event data analysis process and learned that: for all event data, the processing process is basically the same, which can be divided into the following steps: call the get function to obtain the event object, then parse the event object, and obtain the event data of the event object , And then convert the parsed event data into a JAVA object instance, thereby inserting the JAVA object instance into the database table. Therefore, in the embodiment of the present invention, the processing flow can be preset to multiple modules to form a preset event data analysis template, which is stored in the
作为一种示例,该预设的事件数据解析函数模板中至少包括调用模块、第一解析模块、第一实例化模块以及第一存储模块。其中,该调用模块用于调用所述获取方法,该第一解析模块用于解析所述事件对象并获取解析后的事件数据,该第一实例化模块用于将解析后的事件数据转换为第一POJO对象实例,以及,该第一存储模块用于将所述第一POJO对象实例插入数据库表,所述数据库表用于存储所述事件数据和所述交易数据。As an example, the preset event data analysis function template includes at least a calling module, a first analysis module, a first instantiation module, and a first storage module. Wherein, the calling module is used to call the obtaining method, the first parsing module is used to parse the event object and obtain the parsed event data, and the first instantiation module is used to convert the parsed event data into the first A POJO object instance, and the first storage module is used to insert the first POJO object instance into a database table, and the database table is used to store the event data and the transaction data.
针对交易数据解析代码,请参考图4,为生成交易数据解析代码的流程图,该流程图描述如下:For the transaction data analysis code, please refer to Figure 4, which is a flowchart of generating transaction data analysis code, which is described as follows:
S41、编译所述智能合约,得到与所述智能合约对应的JAVA合约文件。S41. Compile the smart contract to obtain a JAVA contract file corresponding to the smart contract.
在本发明实施例中,所述JAVA合约文件中至少包括所述智能合约的二进制编码以及二进制字符串,所述二进制编码中至少包括所述构造方法以及所述非常量方法中每个方法访问所述区块链的字段类型,所述二进制字符串为所述智能合约的递归长度前缀编码。In the embodiment of the present invention, the JAVA contract file includes at least the binary code and the binary string of the smart contract, and the binary code includes at least the construction method and each of the non-constant methods. The field type of the blockchain, the binary string is the recursive length prefix code of the smart contract.
步骤S41与步骤S31相同,在此不再赘述。Step S41 is the same as step S31, and will not be repeated here.
S42、加载所述JAVA合约文件,解析所述二进制编码,获取交易方法。S42. Load the JAVA contract file, parse the binary code, and obtain a transaction method.
加载该JAVA文件后,获取该JAVA文件中的ABI字符串,解析该ABI字符串,获取该JAVA文件中的交易方法。例如,可以获取交易方法的名称以及参数字段等。该交易方法包括步骤S21中的构造方法和非常量方法,在此不再赘述。After loading the JAVA file, obtain the ABI character string in the JAVA file, parse the ABI character string, and obtain the transaction method in the JAVA file. For example, you can get the name of the transaction method and parameter fields. The transaction method includes the construction method and the non-constant method in step S21, which will not be repeated here.
作为另一种示例,该交易方法也可以从操作指令(opcode)中获取,例如,在获取该JAVA文件中的opcode后,解析opcode,从而获取opcode中的交易方法。As another example, the transaction method can also be obtained from an operation instruction (opcode), for example, after obtaining the opcode in the JAVA file, the opcode is parsed to obtain the transaction method in the opcode.
为了保证获取的交易方法的准确性,在获取交易方法后,可以根据获取的交易方法的名称和/或参数字段,确定该交易方法是否是构造方法或者非常量方法,若不是,则退出该流程,若是,则继续后续流程。In order to ensure the accuracy of the acquired transaction method, after acquiring the transaction method, you can determine whether the transaction method is a construction method or a non-constant method according to the name and/or parameter field of the acquired transaction method. If not, exit the process If yes, continue with the subsequent process.
S43、通过JAVA对象与第二字段类型之间的第二映射关系,将所述交易方法中的与所述第二字段类型相同的字段转化为JAVA对象,从而获取与所述交易方法对应的第二POJO对象,所述第二字段类型为所述交易方法中用于访问所述区块链的字段类型。S43. Through the second mapping relationship between the JAVA object and the second field type, the field in the transaction method with the same type as the second field is converted into a JAVA object, so as to obtain the second field corresponding to the transaction method. Two POJO objects, the second field type is the field type used to access the blockchain in the transaction method.
在本发明实施例中,该第二字段类型为所述交易方法中用于访问所述区块链的字段类型。作为一种示例,该第二字段类型可以与第一字段类型相同,例如为web3jsdk类型,或者,该第二字段类型也可以是与第一字段类型不同的其他类型,在此不作限制。In the embodiment of the present invention, the second field type is the field type used to access the blockchain in the transaction method. As an example, the second field type may be the same as the first field type, for example, web3jsdk type, or the second field type may also be another type different from the first field type, which is not limited here.
步骤S43与步骤S33相似,在此不再赘述。Step S43 is similar to step S33 and will not be repeated here.
S44、将所述第二POJO对象填充预设的交易数据解析模板,生成所述交易数据解析代码。S44. Fill the second POJO object with a preset transaction data analysis template, and generate the transaction data analysis code.
与步骤S34中相似的原理,申请人通过研究交易数据解析流程,得到针对交易数据的处理过程分为步骤:由于交易数据解析比较复杂,没有办法像事件数据一样直接定位(例如,不同直接通过get函数获取),只能通过匹配方式进行交易匹配,从而确定该交易方法是构造方法还是非常量方法,然后解析交易方法的编码字符串(例如RLP编码字符串),获取该交易方法的交易数据,从而将解析得到的交易数据转换为POJO对象实例,从而根据字段类型,将该POJO对象实例插入数据库表。因此,在本发明实施例中,可以将该处理流程预先设置为多个模块,形成预设的交易数据解析模板,存储在数据解析装置100中,从而,当获取待解析的智能合约中的交易方法后,则直接将该交易方法对应的POJO对象 填充至该预设的交易数据解析模板,从而得到用于解析该智能合约中的交易数据的交易数据解析代码。Similar to the principle in step S34, the applicant obtains the transaction data processing process by studying the transaction data analysis process and is divided into steps: because transaction data analysis is more complicated, there is no way to directly locate it like event data (for example, different directly through get Function acquisition), the transaction can only be matched by the matching method, so as to determine whether the transaction method is a construction method or a non-constant method, and then analyze the encoding string of the transaction method (such as RLP encoding string) to obtain the transaction data of the transaction method, In this way, the parsed transaction data is converted into a POJO object instance, and the POJO object instance is inserted into the database table according to the field type. Therefore, in the embodiment of the present invention, the processing flow can be preset to multiple modules to form a preset transaction data analysis template, which is stored in the
作为一种示例,该预设的交易数据解析模板至少包括匹配模块、第二解析模块、第二实例化模块以及第二存储模块。其中,该匹配模块用于确定所述交易方法为所述构造方法或为所述非常量方法,该第二解析模块用于解析所述交易方法并获取交易数据,该第二实例化模块用于将交易数据转换为第二POJO对象实例,以及,该第二存储模块用于将所述第二POJO对象实例插入数据库表。As an example, the preset transaction data analysis template includes at least a matching module, a second analysis module, a second instantiation module, and a second storage module. Wherein, the matching module is used to determine whether the transaction method is the construction method or the non-constant method, the second analysis module is used to analyze the transaction method and obtain transaction data, and the second instantiation module is used to The transaction data is converted into a second POJO object instance, and the second storage module is used to insert the second POJO object instance into a database table.
需要说明的是,当智能合约中既包括事件方法,也包括交易方法,数据解析装置100可以先生成事件数据解析代码,然后再生成交易数据解析代码;也可以先生成交易数据解析代码,然后再生成事件数据解析代码,或者并行生成交易数据解析代码和事件数据解析代码,在此不对其执行的先后顺序进行限制。It should be noted that when the smart contract includes both event methods and transaction methods, the
S23、使用所述数据解析代码对区块链中的每一个区块中的数据进行解析,获取数据。S23. Use the data analysis code to analyze the data in each block in the blockchain to obtain the data.
当获取与智能合约对应的交易数据解析代码和事件数据解析代码后,则可以运行该交易数据解析代码和事件数据解析代码,来获取每个区块中与该智能合约对应的交易数据和事件数据。After obtaining the transaction data analysis code and event data analysis code corresponding to the smart contract, you can run the transaction data analysis code and event data analysis code to obtain the transaction data and event data corresponding to the smart contract in each block .
下面分别对事件数据的获取方法和交易数据的获取方法进行说明。The method for obtaining event data and the method for obtaining transaction data are respectively described below.
针对事件数据,请参考图5,为使用事件数据解析代码获取事件数据的流程图,该流程图描述如下:For event data, please refer to Figure 5, which is a flowchart of using event data parsing code to obtain event data. The flowchart is described as follows:
S51、获取所述区块链中的其中一个区块,所述其中一个区块为所述区块链中的任意一个区块。S51. Obtain one of the blocks in the block chain, where the one block is any block in the block chain.
数据解析装置100可以依次获取区块链中的每一个区块,例如,以图1所示的区块链为例,先获取区块A,对区块A中的事件数据解析完成后,在获取区块B。或者,数据解析装置100也可以随机获取其中一个区块,在此不作限制。需要说明的是,针对每个区块,获取该区块中的事件数据的方式相同,在下文中以区块链中的其中一个区块为例进行说明。The
S52、运行所述事件数据解析代码,通过所述事件数据解析代码中的调用模块获取所述区块中的事件对象列表。S52. Run the event data analysis code, and obtain the event object list in the block through the calling module in the event data analysis code.
当数据解析装置100获取一个区块后,则调用生成的事件数据解析代码,通过调用模块确定该区块中是否存在与该智能合约对应的事件数据,可以理解为,若通过调用模块能够获取对应的事件对象列表,则表示该区块中存在与该智能合约对应的事件数据,否则,则不包括与该智能合约对应的事件数据。After the
针对前述的UserInfo智能合约,该调用模块会通过get函数,例如,getModifyUserNameEventEvents,获取对应的事件数据列表,例如,List<ModifyUserNameEventResponse>,如果能够获取该List<ModifyUserName--EventResponse>,则表明该区块中存在事件数据,否则,该区块中不存在事件数据。For the aforementioned UserInfo smart contract, the calling module will obtain the corresponding event data list through the get function, for example, getModifyUserNameEventEvents, for example, List<ModifyUserNameEventResponse>. If the List<ModifyUserName--EventResponse> can be obtained, it indicates the block Event data exists in the block, otherwise, there is no event data in the block.
在本发明实施例中,所述事件对象列表包括所述事件对象的至少一个取值。例如,针对前述的UserInfo智能合约中的userName,在第一时刻,用户设置了userName为第一取值,在第二时刻,用户设置userName为第二取值,则与userName对应的事件对象列表中,则包括该第一取值和该第二取值。In the embodiment of the present invention, the event object list includes at least one value of the event object. For example, for the userName in the aforementioned UserInfo smart contract, at the first moment, the user sets userName as the first value, and at the second moment, the user sets userName as the second value, then the event object list corresponding to userName , It includes the first value and the second value.
另外需要说明的是,在本发明实施例中,UserInfo智能合约中仅包括一个事件方法,从而数据解析装置100只生成了一个事件数据解析代码,但是在实际使用过程中,一个智 能合约中可能包括多个事件方法,从而,数据解析装置100针对一个智能合约会生成多个事件数据解析代码。在这种情况下,当数据解析装置100解析一个区块中的事件数据时,则需要遍历与该智能合约对应的多个事件数据解析代码,如果运行所有的事件数据解析代码都无法获取事件数据列表,则表示该区块中不存在事件数据,否则该区块中存在事件数据。In addition, it should be noted that, in the embodiment of the present invention, the UserInfo smart contract includes only one event method, so that the
S53、通过所述事件数据解析代码中的解析模块解析所述事件对象的至少一个取值,获得至少一个解析后的事件数据。S53: Parse at least one value of the event object through the parsing module in the event data parsing code to obtain at least one parsed event data.
当获取事件对象的至少一个取值后,则通过解析模块对该至少一个取值进行解析,从而获取对应的事件数据。After obtaining at least one value of the event object, the at least one value is analyzed by the parsing module, so as to obtain corresponding event data.
S54、通过所述事件数据解析代码中的实例化模块将所述至少一个解析后的事件数据分别转化为至少一个第一POJO对象实例。S54. Convert the at least one parsed event data into at least one first POJO object instance through the instantiation module in the event data analysis code.
具体来讲,该至少一个POJO第一对象实例与该至少一个解析后的事件数据一一对应。例如,该事件对象包括2个取值,则解析该2个取值得到2个事件数据,然后,将每个事件数据转化为POJO对象实例,从而得到2个第一POJO对象实例。Specifically, the at least one POJO first object instance corresponds to the at least one parsed event data in a one-to-one correspondence. For example, if the event object includes two values, the two values are parsed to obtain two event data, and then each event data is converted into a POJO object instance to obtain two first POJO object instances.
S55、通过所述事件数据解析代码中的存储模块将所述至少一个POJO对象实例插入所述数据库表中。S55. Insert the at least one POJO object instance into the database table through the storage module in the event data analysis code.
当获取与每个事件数据对应的第一POJO对象实例后,则将该获取的第一POJO对象实例插入数据库表中,完成对事件数据解析以及同步的过程。After obtaining the first POJO object instance corresponding to each event data, insert the obtained first POJO object instance into the database table to complete the process of analyzing and synchronizing the event data.
针对交易数据,请参考图6,为使用交易数据解析代码获取交易数据的流程图,该流程图描述如下:For transaction data, please refer to Figure 6, which is a flow chart of using transaction data analysis code to obtain transaction data. The flow chart is described as follows:
S601、获取所述区块链中的其中一个区块,所述其中一个区块为所述区块链中的任意一个区块。S601. Obtain one of the blocks in the blockchain, where the one block is any block in the blockchain.
步骤S601与步骤S51相同,在此不再赘述。Step S601 is the same as step S51, and will not be repeated here.
S602、通过预设的交易获取接口,获取所述区块中的第一交易。S602. Obtain the first transaction in the block through a preset transaction acquisition interface.
该交易获取接口与现有技术中相似,在此不再赘述。The transaction acquisition interface is similar to that in the prior art, and will not be repeated here.
S603、运行所述交易数据解析代码,通过交易数据解析代码中的匹配模块获取所述第一交易中的目标字段,并根据所述目标字段确定所述第一交易的交易类型。S603. Run the transaction data analysis code, obtain the target field in the first transaction through the matching module in the transaction data analysis code, and determine the transaction type of the first transaction according to the target field.
在本发明实施例中,所述交易类型包括第一交易类型和第二交易类型,所述第一交易类型为与所述构造方法对应的交易类型,所述第二交易类型为与所述非常量方法对应的交易类型。该目标字段用于指示该第一交易的交易对象,作为一种示例,该目标字段为To字段。当获取第一交易后,则运行交易数据解析代码,获取该交易中的To字段,确定其是否为空(null),如果为null,则确定第一交易是第一交易类型,否则,确定该第一交易为第二交易类型。In the embodiment of the present invention, the transaction type includes a first transaction type and a second transaction type, the first transaction type is a transaction type corresponding to the construction method, and the second transaction type is related to the extraordinary transaction type. The transaction type corresponding to the volume method. The target field is used to indicate the transaction object of the first transaction. As an example, the target field is the To field. After obtaining the first transaction, run the transaction data analysis code to obtain the To field in the transaction, and determine whether it is null. If it is null, determine that the first transaction is the first transaction type, otherwise, determine the The first transaction is the second transaction type.
在本申请实施例中,当确定第一交易的交易类型为第一交易类型后,则执行步骤S604~步骤S606以及步骤S610,当确定第一交易的交易类型为第二交易类型后,则执行步骤S607~步骤S610。In the embodiment of the present application, when the transaction type of the first transaction is determined to be the first transaction type, step S604 to step S606 and step S610 are executed, and when the transaction type of the first transaction is determined to be the second transaction type, execute Step S607 to step S610.
另外,与事件数据解析过程相似,若数据解析装置100针对一个智能合约生成了多个交易数据解析代码,则数据解析装置100需要遍历与该智能合约对应的多个交易数据解析代码,在本发明实施例中,以运行一个交易数据解析代码为例进行说明。In addition, similar to the event data analysis process, if the
S604、在所述第一交易的交易类型为所述第一交易类型时,通过所述匹配模块获取所 述第一交易的递归长度前缀编码,确定所述第一交易的递归长度前缀编码是否包括所述二进制字符串。S604. When the transaction type of the first transaction is the first transaction type, obtain the recursive length prefix code of the first transaction through the matching module, and determine whether the recursive length prefix code of the first transaction includes The binary string.
在本发明实施例中,与构造方法对应的交易数据的存储格式为:binary+encode(data),其中,binary为智能合约的RLP编码字符串,encode为交易数据的编码函数。因此,当确定该第一交易的交易类型为与构造方法对应的交易类型后,则需要比较所有的智能合约的binary字符串,从而确定是与哪一个智能合约的构造方法对应的交易。In the embodiment of the present invention, the storage format of the transaction data corresponding to the construction method is: binary+encode(data), where binary is the RLP encoded string of the smart contract, and encode is the encoding function of the transaction data. Therefore, when it is determined that the transaction type of the first transaction is the transaction type corresponding to the construction method, it is necessary to compare the binary strings of all smart contracts to determine which smart contract construction method corresponds to the transaction.
具体来讲,前述UserInfo智能合约中的构造方法为UserInfo(bytes32userName,uint8sex)。当确定该第一交易是与构造方法对应的交易后,则获取UserInfo智能合约的JAVA文件中的binary(长度为M),然后获取该第一交易的RLP编码(长度为N),如果第一交易的RLP编码的前M个字符串和JAVA文件中的binary一样,则该第一交易为执行UserInfo智能合约的构造方法所得。Specifically, the construction method in the aforementioned UserInfo smart contract is UserInfo(bytes32userName,uint8sex). When it is determined that the first transaction is the transaction corresponding to the construction method, the binary (length M) in the JAVA file of the UserInfo smart contract is obtained, and then the RLP code (length N) of the first transaction is obtained. The first M strings of the RLP code of the transaction are the same as the binary in the JAVA file, and the first transaction is obtained by executing the construction method of the UserInfo smart contract.
S605、在为是时,通过所述交易数据解析代码中的第二解析模块,对第一剩余字符串进行解析,获取所述第一交易的第一交易数据,所述第一剩余字符串为所述第一交易的递归长度前缀编码中去除与所述二进制字符串相同的符号之后的字符串。S605. When it is yes, parse the first remaining character string through the second parsing module in the transaction data analysis code to obtain the first transaction data of the first transaction, where the first remaining character string is In the recursive length prefix encoding of the first transaction, the character string after the same symbol as the binary character string is removed.
在确定该第一交易的RLP编码的前M个字符串和JAVA文件中的binary一样后,则去掉该第一交易的RLP编码的前M个字符,即去掉第一交易的binary头,得到长度为(N-M)的第一剩余字符串,然后对该第一剩余字符串进行decode(data)操作,decode()操作是根据每个字段的类型偏移量计算的,从而获取第一交易中各个字段的取值,该各个字段的取值即为至少一个第一交易数据。After determining that the first M character strings of the RLP code of the first transaction are the same as the binary in the JAVA file, remove the first M characters of the RLP code of the first transaction, that is, remove the binary header of the first transaction to obtain the length Is the first remaining string of (NM), and then decode(data) is performed on the first remaining string. The decode() operation is calculated according to the type offset of each field to obtain each of the first transaction The value of the field, the value of each field is at least one piece of first transaction data.
具体来讲,第一交易为执行UserInfo智能合约的构造方法所得,则通过解析可以得到字段userName和字段sex的取值,然后,对这两个字段的取值进行解析,则得到第一交易中的至少一个第一交易数据。Specifically, the first transaction is obtained from the execution of the UserInfo smart contract construction method, and the values of the field userName and the field sex can be obtained by parsing, and then the values of these two fields are parsed, and the first transaction is obtained At least one first transaction data.
S606、通过所述交易数据解析代码中的第二实例化模块将所述第一交易数据转化为第二POJO对象实例。S606: Convert the first transaction data into a second POJO object instance through the second instantiation module in the transaction data analysis code.
步骤S606与步骤S54相似,在此不再赘述。Step S606 is similar to step S54 and will not be repeated here.
S607、在所述第一交易的交易类型为所述第二交易类型时,通过所述匹配模块获取所述第一交易的递归长度前缀编码,确定所述第一交易的递归长度前缀编码是否包括所述交易数据解析代码所对应的非常量方法的签名。S607. When the transaction type of the first transaction is the second transaction type, obtain the recursive length prefix code of the first transaction through the matching module, and determine whether the recursive length prefix code of the first transaction includes The signature of the non-constant method corresponding to the transaction data analysis code.
在本发明实施例中,与非常量方法对应的交易数据的存储格式为:functionSignature+encode(data),其中functionSignature为该非常量方法的签名。因此,当确定该第一交易的交易类型为与非常量方法对应的交易类型后,则需要比较所有的智能合约的非常量方法的签名,从而确定是哪一个非常量方法对应的交易。In the embodiment of the present invention, the storage format of the transaction data corresponding to the non-constant method is: functionSignature+encode(data), where the functionSignature is the signature of the non-constant method. Therefore, when the transaction type of the first transaction is determined to be the transaction type corresponding to the non-constant method, it is necessary to compare the signatures of the non-constant method of all smart contracts to determine which non-constant method corresponds to the transaction.
具体来讲,前述UserInfo智能合约中的非常量方法为modifyUserName(bytes32userName)。当确定该第一交易是与非常量方法对应的交易后,则获取UserInfo智能合约的JAVA文件中的modifyUserName(bytes32userName)方法的签名(长度为L),然后获取该第一交易的RLP编码(长度为N),如果第一交易的RLP编码的前L个字符串和modifyUserName(bytes32userName)方法的签名一样,则该第一交易为执行UserInfo智能合约的非常量方法所得。Specifically, the non-constant method in the aforementioned UserInfo smart contract is modifyUserName(bytes32userName). When it is determined that the first transaction is a transaction corresponding to a non-constant method, the signature of the modifyUserName (bytes32userName) method in the JAVA file of the UserInfo smart contract (length L) is obtained, and then the RLP code (length Is N). If the first L character strings of the RLP encoding of the first transaction are the same as the signature of the modifyUserName(bytes32userName) method, then the first transaction is obtained by executing the non-constant method of the UserInfo smart contract.
S608、在为是时,通过所述交易数据解析代码中的第二解析模块,对第二剩余编码进行解析,获取所述第一交易的第二交易数据,所述第二剩余编码为所述第一交易的编码中 去除与所述签名相同的符号之后的字符串。S608. If yes, analyze the second remaining code through the second analysis module in the transaction data analysis code to obtain the second transaction data of the first transaction, where the second remaining code is the In the encoding of the first transaction, the character string after the same symbol as the signature is removed.
在确定该第一交易的RLP编码的前L个字符串和modifyUserName(bytes32userName)方法的签名一样后,则去掉该第一交易的RLP编码的前L个字符,即去掉第一交易的签名头,得到长度为(N-L)的第二剩余字符串,然后对该第二剩余字符串进行decode(data)操作,从而获取第一交易中各个字段的取值,该各个字段的取值即为至少一个第一交易数据。After determining that the first L character strings of the RLP code of the first transaction are the same as the signature of the modifyUserName(bytes32userName) method, remove the first L characters of the RLP code of the first transaction, that is, remove the signature header of the first transaction, Obtain the second remaining string of length (NL), and then perform a decode(data) operation on the second remaining string to obtain the value of each field in the first transaction. The value of each field is at least one The first transaction data.
具体来讲,第一交易为执行UserInfo智能合约的非常量方法所得,则通过解析可以得到字段userName、字段sex以及字段address的取值,然后,对这三个字段的取值进行解析,则得到第一交易中的至少一个第一交易数据。Specifically, the first transaction is obtained by executing the non-constant method of the UserInfo smart contract, and the values of the fields userName, sex, and address can be obtained by parsing, and then the values of these three fields are analyzed to obtain At least one piece of first transaction data in the first transaction.
S609、通过所述交易数据解析代码中的第二实例化模块将所述第二交易数据转化为第二POJO对象实例。S609: Convert the second transaction data into a second POJO object instance through the second instantiation module in the transaction data analysis code.
S610、通过所述交易数据解析代码中的第二存储模块将所述第二POJO对象实例插入所述数据库表中。S610: Insert the second POJO object instance into the database table through the second storage module in the transaction data analysis code.
步骤S609~步骤S610与步骤S54~步骤S55相似,在此不再赘述。Steps S609 to S610 are similar to steps S54 to S55, and will not be repeated here.
在上述技术方案中,通过自动根据用户业务的智能合约,生成用于解析数据的代码,也就是说,针对不同的用户业务,只需要用户导入与各个用户业务对应的智能合约即可,无需新增接口或者无需预先存储用于数据解析的代码,从而可以减小用于数据解析的代码占用的存储空间,可以降低解析区块链中的数据的成本。且,根据智能合约生成的代码是与智能合约中的接口一一对应的,因此,在进行数据解析时,不需要调用多个接口或者不需要计算待解析数据的地址,从而可以提高数据解析的性能。In the above technical solution, the code for analyzing data is generated automatically according to the smart contract of the user's business. That is to say, for different user's business, only the user needs to import the smart contract corresponding to each user's business. Adding an interface or pre-storing the code for data analysis can reduce the storage space occupied by the code for data analysis, and can reduce the cost of parsing data in the blockchain. Moreover, the code generated according to the smart contract corresponds to the interface in the smart contract one-to-one. Therefore, during data analysis, there is no need to call multiple interfaces or calculate the address of the data to be parsed, which can improve data analysis. performance.
本发明第三方面提供一种区块链的数据解析装置,请参考图7所示,为该数据解析装置的结构图,该数据解析装置包括处理器701、收发器702、存储器703,其中,处理器701、存储器703与收发器702之间通过总线接口连接;A third aspect of the present invention provides a block chain data analysis device. Please refer to FIG. 7, which is a structural diagram of the data analysis device. The data analysis device includes a
处理器701控制收发器702获取用户业务的智能合约,所述智能合约中包括用于创建实现所述用户业务的构造方法、事件方法以及非常量方法;The
处理器701根据所述构造方法、事件方法以及非常量方法中的至少一个方法,生成数据解析代码,所述数据解析代码包括用于对所述用户业务的事件数据进行解析的事件数据解析代码和用于对所述用户业务的交易数据进行解析的交易数据解析代码;以及,The
使用所述数据解析代码对区块链中的每一个区块中的数据进行解析,获取所述事件数据和所述交易数据。The data analysis code is used to analyze the data in each block in the blockchain to obtain the event data and the transaction data.
可选的,处理器701具体可以是中央处理器、特定应用集成电路(英文:Application Specific Integrated Circuit,简称:ASIC),可以是一个或多个用于控制程序执行的集成电路,可以是使用现场可编程门阵列(英文:Field Programmable Gate Array,简称:FPGA)开发的硬件电路,可以是基带处理器。Optionally, the
可选的,处理器701可以包括至少一个处理核心。Optionally, the
可选的,电子设备还包括存储器703,存储器703可以包括只读存储器(英文:Read Only Memory,简称:ROM)、随机存取存储器(英文:Random Access Memory,简称:RAM)和磁盘存储器。存储器703用于存储处理器701运行时所需的数据。存储器的数量为一个或多个。Optionally, the electronic device further includes a
由于该数据解析装置是在与本发明提供的区块链的数据解析方法的相同构思下提出的,因此前述图2-图6实施例中的区块链的数据解析方法的各种变化方式和具体实施例同 样适用于本实施例的数据解析装置,通过前述对区块链的数据解析方法的详细描述,本领域技术人员可以清楚的知道本实施例中数据解析装置的实施过程,所以为了说明书的简洁,在此不再详述。Since the data analysis device is proposed under the same concept as the data analysis method of the blockchain provided by the present invention, the various changes and methods of the data analysis method of the blockchain in the embodiments of FIGS. The specific embodiment is also applicable to the data analysis device of this embodiment. Through the foregoing detailed description of the data analysis method of the blockchain, those skilled in the art can clearly know the implementation process of the data analysis device in this embodiment, so for the sake of description The succinctness is not detailed here.
本发明第四方面提供了一种计算机装置,所述计算机装置包括:A fourth aspect of the present invention provides a computer device, which includes:
至少一个处理器,以及,At least one processor, and,
与所述至少一个处理器通信连接的存储器、通信接口;A memory and a communication interface communicatively connected with the at least one processor;
其中,所述存储器存储有可被所述至少一个处理器执行的指令,所述至少一个处理器通过执行所述存储器存储的指令,利用所述通信接口执行如图2~图6所示的实施例中的方法。Wherein, the memory stores instructions that can be executed by the at least one processor, and the at least one processor executes the instructions shown in FIGS. 2 to 6 through the communication interface by executing the instructions stored in the memory. The method in the example.
本发明第五方面提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机指令,当所述计算机指令在计算机上运行时,使得计算机执行如图2~图6所示的实施例中的方法。The fifth aspect of the present invention provides a computer-readable storage medium, the computer-readable storage medium stores computer instructions, and when the computer instructions run on a computer, the computer executes the steps shown in FIGS. 2-6 The method in the embodiment.
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) containing computer-usable program codes.
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to flowcharts and/or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and/or block in the flowchart and/or block diagram, and the combination of processes and/or blocks in the flowchart and/or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing equipment to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing equipment are generated It is a device that realizes the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device. The device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment. The instructions provide steps for implementing functions specified in a flow or multiple flows in the flowchart and/or a block or multiple blocks in the block diagram.
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. In this way, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention is also intended to include these modifications and variations.
Claims (9)
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910550186.0 | 2019-06-24 | ||
| CN201910550186.0A CN110264361B (en) | 2019-06-24 | 2019-06-24 | A data analysis method and device for blockchain |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020259417A1 true WO2020259417A1 (en) | 2020-12-30 |
Family
ID=67920915
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2020/097235 Ceased WO2020259417A1 (en) | 2019-06-24 | 2020-06-19 | Data analysis method and device for block chain |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN110264361B (en) |
| WO (1) | WO2020259417A1 (en) |
Families Citing this family (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110264361B (en) * | 2019-06-24 | 2025-02-18 | 深圳前海微众银行股份有限公司 | A data analysis method and device for blockchain |
| CN110738567B (en) * | 2019-09-25 | 2021-02-09 | 支付宝(杭州)信息技术有限公司 | Transaction processing method and device of safe intelligent contract processor based on FPGA |
| CN110827034B (en) * | 2019-10-31 | 2021-10-22 | 支付宝(杭州)信息技术有限公司 | Method and apparatus for initiating a blockchain transaction |
| CN111161059B (en) * | 2019-11-29 | 2023-10-31 | 合肥学院 | Method for generalizing transaction processing into transaction |
| CN112860712B (en) * | 2021-04-13 | 2024-02-09 | 深圳前海移联科技有限公司 | Block chain-based transaction database construction method, system and electronic equipment |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107038242A (en) * | 2017-04-24 | 2017-08-11 | 杭州趣链科技有限公司 | It is a kind of towards the global intelligent contract business datum analytic method of block chain |
| CN107274186A (en) * | 2017-05-11 | 2017-10-20 | 上海点融信息科技有限责任公司 | The method and apparatus that intelligent contract-defined interface is obtained in block chain |
| CN107918666A (en) * | 2017-11-24 | 2018-04-17 | 中钞信用卡产业发展有限公司杭州区块链技术研究院 | Method of data synchronization and system on a kind of block chain |
| US20180268152A1 (en) * | 2017-03-19 | 2018-09-20 | International Business Machines Corporation | Cognitive blockchain automation and management |
| CN110264361A (en) * | 2019-06-24 | 2019-09-20 | 深圳前海微众银行股份有限公司 | A kind of data analysis method and device of block chain |
Family Cites Families (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107239479B (en) * | 2017-03-28 | 2020-03-13 | 创新先进技术有限公司 | Block chain based data storage and query method and device |
| US10963400B2 (en) * | 2017-10-11 | 2021-03-30 | International Business Machines Corporation | Smart contract creation and monitoring for event identification in a blockchain |
| CN109857807A (en) * | 2019-01-10 | 2019-06-07 | 中钞信用卡产业发展有限公司杭州区块链技术研究院 | Transaction data synchronization method, apparatus, equipment and medium based on block chain |
-
2019
- 2019-06-24 CN CN201910550186.0A patent/CN110264361B/en active Active
-
2020
- 2020-06-19 WO PCT/CN2020/097235 patent/WO2020259417A1/en not_active Ceased
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20180268152A1 (en) * | 2017-03-19 | 2018-09-20 | International Business Machines Corporation | Cognitive blockchain automation and management |
| CN107038242A (en) * | 2017-04-24 | 2017-08-11 | 杭州趣链科技有限公司 | It is a kind of towards the global intelligent contract business datum analytic method of block chain |
| CN107274186A (en) * | 2017-05-11 | 2017-10-20 | 上海点融信息科技有限责任公司 | The method and apparatus that intelligent contract-defined interface is obtained in block chain |
| CN107918666A (en) * | 2017-11-24 | 2018-04-17 | 中钞信用卡产业发展有限公司杭州区块链技术研究院 | Method of data synchronization and system on a kind of block chain |
| CN110264361A (en) * | 2019-06-24 | 2019-09-20 | 深圳前海微众银行股份有限公司 | A kind of data analysis method and device of block chain |
Also Published As
| Publication number | Publication date |
|---|---|
| CN110264361B (en) | 2025-02-18 |
| CN110264361A (en) | 2019-09-20 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2020259417A1 (en) | Data analysis method and device for block chain | |
| CN110096338B (en) | Intelligent contract execution method, device, equipment and medium | |
| TWI536263B (en) | Projecting native application programming interfaces of an operating system into other programming languages | |
| CN110704064B (en) | Method and device for compiling and executing intelligent contract | |
| CN110704063B (en) | Method and device for compiling and executing intelligent contract | |
| WO2019233293A1 (en) | Method and apparatus for developing application program | |
| US8464232B2 (en) | Compiler compiler system with syntax-controlled runtime and binary application programming interfaces | |
| US11366704B2 (en) | Configurable analytics for microservices performance analysis | |
| CN110941655B (en) | A data format conversion method and device | |
| US20180018163A1 (en) | Overriding a migrated method in an updated type | |
| CN112926008B (en) | Method, device, electronic equipment and storage medium for generating form page | |
| CN110688122A (en) | Method and device for compiling and executing intelligent contract | |
| US11029924B2 (en) | Program optimization by converting code portions to directly reference internal data representations | |
| CN113434147B (en) | Method and device for analyzing message based on ProtoBuf protocol | |
| CN115599359A (en) | Code generation method, device, equipment and medium | |
| CN117519691B (en) | Application processing method, device, computer equipment and storage medium | |
| US9836305B1 (en) | Systems and methods for task parallelization | |
| CN117519848A (en) | Function calling method, device, equipment and storage medium | |
| CN114998038A (en) | Abnormal policy processing method and system | |
| CN114416215A (en) | Function calling method and device | |
| US7917893B2 (en) | Using a system of annotations to generate views and adapters | |
| CN112947938B (en) | File conversion method and device, electronic equipment and storage medium | |
| CN117075912B (en) | Method for program language conversion, compiling method and related equipment | |
| US11188316B2 (en) | Performance optimization of class instance comparisons | |
| CN115145627A (en) | Method, device, equipment and storage medium for building local operation environment of plug-in |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 20832113 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 20832113 Country of ref document: EP Kind code of ref document: A1 |