CN112818014A - Block chain data analysis method and device and electronic equipment - Google Patents

Block chain data analysis method and device and electronic equipment Download PDF

Info

Publication number
CN112818014A
CN112818014A CN202011626903.2A CN202011626903A CN112818014A CN 112818014 A CN112818014 A CN 112818014A CN 202011626903 A CN202011626903 A CN 202011626903A CN 112818014 A CN112818014 A CN 112818014A
Authority
CN
China
Prior art keywords
transaction
target
block
header information
information
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.)
Granted
Application number
CN202011626903.2A
Other languages
Chinese (zh)
Other versions
CN112818014B (en
Inventor
李伟
邱炜伟
匡立中
谭锦志
鲁琦韦华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Qulian Technology Co Ltd
Original Assignee
Hangzhou Qulian Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Qulian Technology Co Ltd filed Critical Hangzhou Qulian Technology Co Ltd
Priority to CN202011626903.2A priority Critical patent/CN112818014B/en
Publication of CN112818014A publication Critical patent/CN112818014A/en
Application granted granted Critical
Publication of CN112818014B publication Critical patent/CN112818014B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2471Distributed queries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management

Abstract

The application relates to a block chain data analysis method, a block chain data analysis device and electronic equipment, wherein the method comprises the following steps: acquiring block header information of a target block corresponding to a target transaction, wherein the target transaction is generated when an intelligent contract variable is updated; determining target block transaction information based on the block header information; performing context tracing on the target transaction according to the block header information and the transaction information to obtain the context transaction of the target transaction; caching the target transaction and the context transaction. When the user views the blockchain data, the target transaction and the context information can be acquired, so that the viewed data are more aggregated and have an association relationship with each other, further data analysis can be performed, and the effectiveness of blockchain data analysis is improved.

Description

Block chain data analysis method and device and electronic equipment
Technical Field
The present application relates to the field of block chain technologies, and in particular, to a method and an apparatus for analyzing block chain data, and an electronic device.
Background
The data on the block chain is safe and can not be tampered, and anyone can simply inquire the block transaction information through some access means so as to obtain the data content on the chain. However, the technical query method has a threshold, the operation process may be complex although the logic is simple, the data itself is scattered, and there is no way to analyze and utilize the data.
Therefore, the conventional technique has a problem that the availability of data obtained when performing block data search or analysis is poor.
Disclosure of Invention
The application provides a block chain data analysis method and device and electronic equipment, and aims to solve the problem that in the prior art, the availability of data obtained during block data query or analysis is poor.
In a first aspect, the present application provides a method for analyzing block chain data, including: acquiring block header information of a target block corresponding to a target transaction, wherein the target transaction is generated when an intelligent contract variable is updated; determining target block transaction information based on the block header information; performing context tracing on the target transaction according to the block header information and the transaction information to obtain the context transaction of the target transaction; caching the target transaction and the context transaction.
Optionally, the chunk header information includes a target chunk hash value and a last chunk hash value, and the transaction information includes a transaction number in the target chunk, target transaction information, and location information of the target transaction; the context tracing of the target transaction according to the block header information and the transaction information comprises: judging whether the transaction quantity is 1; and when the transaction quantity is 1, inquiring a first transaction in a next block as a next transaction of the target transaction based on the target block hash value, and inquiring last transaction information in a last block as a last transaction of the target transaction based on the last block hash value.
Optionally, when the transaction quantity is greater than 1, acquiring a transaction position of the target transaction; judging whether the target transaction is the first transaction or the last transaction of the target block; when the target transaction is the first transaction of the target block, inquiring the last transaction in the last block as the last transaction of the target transaction based on the hash value of the last block, and searching the next transaction of the target transaction in the target block; when the target transaction is the last transaction of the target block, inquiring a first transaction in a next block as a next transaction of the target transaction based on the hash value of the target block, and searching the previous transaction of the target transaction in the target block; and when not, searching the previous transaction and the next transaction of the target transaction in the target block.
Optionally, the obtaining block header information of the target block corresponding to the target transaction includes: acquiring a transaction receipt of the target transaction; acquiring the block header information to be analyzed of the target block based on the transaction receipt; and analyzing the block header information to be analyzed based on a Hash algorithm to obtain the block header information.
Optionally, the parsing the to-be-parsed block header information based on a hash algorithm includes: coding the block header information to be analyzed by using the coding rule to obtain a coding sequence; and decoding the coding sequence based on a Hash algorithm to obtain the block header information.
Optionally, the caching the target transaction and the context transaction includes: caching the target transaction and the context transaction according to a browser data structure; obtaining a persistence instruction, wherein the persistence instruction comprises a timing persistence instruction and/or a user trigger instruction; storing the cached target transactions and the context transactions in a relational database based on the persistence instructions.
Optionally, before the obtaining of the block header information of the target block corresponding to the target transaction, the method includes: monitoring a message queue of the intelligent contract variables based on a message monitoring cache pool, wherein the message monitoring cache pool monitors the intelligent contract variables based on a monitoring port and a specified intelligent contract address; and when the intelligent contract variable is monitored to be updated, acquiring a transaction receipt of the target transaction based on the updated intelligent contract variable.
In a second aspect, the present application provides a device for analyzing blockchain data, including: the acquisition module is used for acquiring block header information of a target block corresponding to a target transaction, wherein the target transaction is generated when an intelligent contract variable is updated; a determination module for determining target block transaction information based on the block header information; the tracing module is used for performing context tracing on the target transaction according to the block header information and the transaction information to obtain the context transaction of the target transaction; and the cache module is used for caching the target transaction and the context transaction.
In a third aspect, the present application provides an electronic device, comprising: the system comprises a processor, a communication component, a memory and a communication bus, wherein the processor, the communication component and the memory are communicated with each other through the communication bus; the memory for storing a computer program; the processor is configured to execute the program stored in the memory, and implement the method for analyzing block chain data according to the first aspect.
In a fourth aspect, the present application provides a computer-readable storage medium, which stores a computer program, and implements the method for parsing blockchain data according to the first aspect.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages: according to the method provided by the embodiment of the application, after the block header information of the target block corresponding to the target transaction generated when the intelligent contract variable changes is obtained, the block transaction information is determined based on the block header information, the target transaction is subjected to context tracing based on the block header information and the transaction information, the context transaction of the target transaction is obtained, the target transaction and the context transaction are subjected to associated caching, when a user checks the block chain data, the target transaction and the context information can be obtained, the checked data are more aggregated and have an association relationship with each other, so that further data analysis can be performed, and the effectiveness of block chain data analysis is improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
FIG. 1 is a block chain-based query system according to an embodiment of the present disclosure;
FIG. 2 is a block chain structure in the present application;
FIG. 3 is a block chain network functional structure diagram according to an embodiment of the present application;
FIG. 4 is a schematic flow chart illustrating a method for analyzing block chain data according to an embodiment of the present disclosure;
fig. 5 is a schematic flow chart illustrating another method for analyzing blockchain data according to an embodiment of the present disclosure;
FIG. 6 is a flowchart illustrating another method for analyzing blockchain data according to an embodiment of the present disclosure
FIG. 7 is a block chain data parsing structure in the embodiment of the present application;
fig. 8 is a schematic structural diagram of an electronic device in an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In the following description, reference is made to "one embodiment" which describes a subset of all possible embodiments, but it is understood that "one embodiment" describes the same subset or a different subset of all possible embodiments, and may be combined with each other without conflict.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used herein is for the purpose of describing embodiments of the invention only and is not intended to be limiting of the invention.
As described in the background art, there are roughly two technical approaches in the related art, one is to query variable data by repeatedly calling a query method preset by an intelligent contract by using a method of an intelligent contract deployed on a chain, and this scheme has disadvantages in that the query method needs to be preset, overhead is excessive if the query method is preset for all data, and in addition, data obtained by parsing is still scattered data, and there is a problem of poor availability of the obtained data.
The second method is to store uplink data in a relational database before uplink is performed, and the disadvantage of this method is mainly that the characteristics of the block chain are not effectively utilized to perform a secure and reliable protection on the data, and there may be inconsistency of uplink and downlink data in the chain, thereby losing the data security and validity proof using the block chain technology originally used.
Based on this, the present application provides a method for analyzing block chain data, so as to solve the problem of poor availability of the existing centralized data.
Before further detailed description of the embodiments of the present invention, terms and expressions referred to in the embodiments of the present invention are described, and the terms and expressions referred to in the embodiments of the present invention are applicable to the following explanations.
(1) Transactions (transactions), equivalent to the computer term "Transaction," include operations that need to be committed to a blockchain network for execution and do not refer solely to transactions in the context of commerce, which embodiments of the present invention follow in view of the convention in blockchain technology that colloquially uses the term "Transaction.
For example, a deployment (deployment) transaction is used to install a specified smart contract to a node in a blockchain network and is ready to be invoked; the Invoke (Invoke) transaction is used to append records of the transaction in the blockchain by invoking the smart contract and to perform operations on the state database of the blockchain, including update operations (including adding, deleting, and modifying key-value pairs in the state database) and query operations (i.e., querying key-value pairs in the state database).
(2) A Block chain (Blockchain) is a storage structure for encrypted, chained transactions formed from blocks (blocks).
(3) A Blockchain Network (Blockchain Network) incorporates new blocks into a set of nodes of a Blockchain in a consensus manner.
(4) Ledger (legger) is a general term for blockchains (also called Ledger data) and state databases synchronized with blockchains. Wherein, the blockchain records the transaction in the form of a file in a file system; the state database records the transaction in the blockchain in the form of different types of Key (Key) Value pairs for supporting quick query of the transaction in the blockchain.
(5) Intelligent Contracts (Smart Contracts), also known as chain codes (chaincodes) or application codes, are programs deployed in nodes of a blockchain network, and the nodes execute the intelligent Contracts called in received transactions to update or query key-value data of a state database.
(6) Consensus (Consensus), a process in a blockchain network, is used to agree on transactions in a block among a plurality of nodes involved, the agreed block is to be appended to the end of the blockchain, and the mechanisms for achieving Consensus include Proof of workload (PoW, Proof of Work), Proof of rights and interests (PoS, Proof of equity (DPoS), Proof of right of stock (DPoS), Proof of Elapsed Time (PoET, Proof of Elapsed Time), and so on.
An exemplary application of the blockchain network according to the embodiment of the present invention is described below, as shown in fig. 1, fig. 1 is a schematic diagram of a blockchain data analysis system according to the embodiment of the present invention, and includes a blockchain network 101, a consensus node 102, an authentication center 103, a service entity 104, a client node 104-1, a service entity 105, and a client node 105-1, which are described below:
the type of blockchain network 101 is flexible and may be any of a public chain, a private chain, or a federation chain, for example. Taking a public link as an example, electronic devices such as a user terminal and a server of any service agent can access the blockchain network 101 without authorization; taking a federation chain as an example, an electronic device (e.g., a terminal/server) under the jurisdiction of a service entity after obtaining authorization may access the blockchain network 101, and at this time, become a client node in the blockchain network 101.
In some embodiments, the client node 104 may act as a mere watcher of the blockchain network 101, i.e., provides functionality to support a business entity to initiate a transaction (e.g., for uplink storage of data or querying of data on a chain), and may be implemented by default or selectively (e.g., depending on the specific business requirements of the business entity) for the functions of the consensus node 102 of the blockchain network 101, such as a ranking function, a consensus service, and an accounting function, etc. Therefore, the data and the service processing logic of the service subject can be migrated to the blockchain network 101 to the maximum extent, and the credibility and traceability of the data and service processing process are realized through the blockchain network 101.
Consensus nodes in blockchain network 101 receive transactions submitted from different business entities, such as client node 104-1 of business entity 104 shown in fig. 1, perform the transactions to update the ledger or query the ledger, and various intermediate or final results of performing the transactions may be returned for display in client node 104-1 of business entity 104.
For example, client node 104-1 may subscribe to events of interest in blockchain network 101, such as transactions occurring in a particular organization/channel in blockchain network 101, and corresponding transaction notifications are pushed by consensus node 102 to client node 104-1, thereby triggering corresponding business logic in client node 104-1.
As an example of a block chain, as shown in fig. 2, fig. 2 is a schematic structural diagram of a block chain in a block chain network 101 according to an embodiment of the present invention, where a header of each block may include hash values of all transactions in the block and also include hash values of all transactions in a previous block, a record of a newly generated transaction is filled in the block and is added to a tail of the block chain after being identified by nodes in the block chain network, so as to form a chain growth, and a chain structure based on hash values between blocks ensures tamper resistance and forgery prevention of transactions in the block.
An exemplary functional architecture of a blockchain network provided by the embodiment of the present invention is described below, as shown in fig. 3, fig. 3 is a schematic functional architecture diagram of a blockchain network 101 provided by the embodiment of the present invention, and includes an application layer 301, a consensus layer 302, a network layer 303, a data layer 304, and a resource layer 305, which are described below:
the application layer 301 encapsulates various services that the blockchain network can implement, including tracing, crediting, and verifying transactions.
The consensus layer 302 encapsulates the functions of the mechanism by which the nodes 102 in the blockchain network 101 agree on a block (i.e., a consensus mechanism), transaction management, and ledger management. The consensus mechanism comprises consensus algorithms such as POS, POW and DPOS, and the pluggable consensus algorithm is supported. The transaction management is used for verifying the digital signature carried in the transaction received by the node 101, verifying the identity information of the service body 104, and determining whether the service body has the authority to perform the transaction (reading the relevant information from the service body identity management) according to the identity information; for the service agents authorized to access the blockchain network 101, the service agents all have digital certificates issued by the certificate authority, and the service agents sign the submitted transactions by using private keys in the digital certificates of the service agents, so that the legal identities of the service agents are declared. The ledger administration is used to maintain blockchains and state databases. For the block with the consensus, adding the block to the tail of the block chain; executing the transaction in the acquired consensus block, updating the key-value pairs in the state database when the transaction comprises an update operation, querying the key-value pairs in the state database when the transaction comprises a query operation and returning a query result to the client node of the business entity. Supporting query operations for multiple dimensions of a state database, comprising: querying the chunk based on the chunk sequence number (e.g., hash value of the transaction); inquiring the block according to the block hash value; inquiring a block according to the transaction serial number; inquiring the transaction according to the transaction serial number; inquiring account data of a business main body according to an account (serial number) of the business main body; and inquiring the block chain in the channel according to the channel name.
The network layer 303 encapsulates the functions of a point-to-point (P2P, point) network protocol, a data propagation mechanism and a data verification mechanism, an access authentication mechanism, and service agent identity management.
The P2P network protocol implements communication between nodes 102 in the blockchain network 101, the data propagation mechanism ensures propagation of transactions in the blockchain network 101, and the data verification mechanism implements reliability of data transmission between the nodes 102 based on cryptography methods (e.g., digital certificates, digital signatures, public/private key pairs); the access authentication mechanism is used for authenticating the identity of a service subject added to the block chain network 101 according to an actual service scene, and endowing the service subject with the authority of accessing the block chain network 101 when the authentication is passed; the business entity 104 identity management is used to store the identity of the business entity 104 that is allowed to access the blockchain network 101, as well as the permissions (e.g., the types of transactions that can be initiated).
Data layer 304 encapsulates various data structures that implement ledgers, including blockchains implemented in files in a file system, key-value type state databases, and presence certificates (e.g., hash trees for transactions in blocks).
The resource layer 305 encapsulates the computing, storage, and communication resources that implement each node 102 in the blockchain network 101.
Based on the above architecture, the embodiments of the present invention provide the following implementation manners.
As shown in fig. 4, the present embodiment provides a method for analyzing block chain data, which is applied to the above-mentioned block chain network 101.
In the following, for the sake of clarity of the present application, the working principle of the intelligent contract is first briefly described:
constructing an intelligent contract: the intelligent contract is made by a plurality of users in the block chain, and can be used for any transaction between any users. The agreement defines the rights and obligations of the parties to the transaction, which are programmed electronically by the developer, the code containing conditions that trigger the automatic execution of the contract.
Storing the intelligent contract: once the encoding is completed, the intelligent contract is uploaded to the blockchain network, that is, each node of the whole network can receive the intelligent contract.
Executing the intelligent contract: the intelligent contract can regularly check whether related events and trigger conditions exist or not, the events meeting the conditions are pushed to a queue to be verified, the verification nodes on the block chain firstly carry out signature verification on the events to ensure the validity of the events, most verification nodes agree with the events, the intelligent contract is successfully executed, and a user is informed of the successful execution.
Referring to fig. 4, the method for analyzing blockchain data in the present application may include the following steps:
s401, acquiring block header information of a target block corresponding to a target transaction, wherein the target transaction is generated when an intelligent contract variable is updated;
s402, determining target block transaction information based on the block header information;
s403, performing context tracing on the target transaction according to the block header information and the transaction information to obtain the context transaction of the target transaction;
s404, caching the target transaction and the context transaction.
Through the steps S401 to S404, after the block header information of the target block corresponding to the target transaction generated when the intelligent contract variable changes is obtained, the block transaction information is determined based on the block header information, the target transaction is context-traced based on the block header information and the transaction information, the context transaction of the target transaction is obtained, the target transaction and the context transaction are associated and cached, when the user views the block chain data, the target transaction and the context information can be obtained, so that the viewed data are more aggregated and have an association relationship with each other, further data analysis can be performed, and the effectiveness of block chain data analysis is improved.
Aiming at the technical scheme in the step S401, a transaction receipt of the transaction is generated when the intelligent contract variable is updated, block header information is taken out from a target block corresponding to the target transaction based on the transaction receipt, and the block header information is analyzed to obtain block header information of the target block, wherein the block header information may include a target block hash value and a previous block hash value.
For the technical solution in step S402, after obtaining the analyzed block header information, the block information of the target block may be determined through the block header information, and then the transaction information of the target block is obtained through analysis, for example, the transaction information includes the target transaction information, the transaction number in the target block, and the position information of the target transaction in the target block.
For the technical solution in step S403, the context information of the target transaction may be searched by using the timestamp of the transaction or the ordering of the transaction, and the context information of the target transaction may also be searched in the current tile and other tiles by using the position information, the transaction number, and the target tile hash value and the last tile hash value in the tile header information. For example, the context transaction may include the last transaction and the next transaction immediately adjacent to the target transaction, and may also include the last N transactions and the next M transactions, where N and M are positive integers greater than or equal to 1. Specifically, the next transaction may be determined based on the target hash value in the location information and the chunk header information of the target transaction, and the previous transaction to be performed by the target may be determined based on the previous hash value.
For the technical solution in step S403, after the previous transaction and the next transaction are obtained, the hash values of the target transaction and the context transaction are cached. The data on the block chain can be guaranteed not to be linked down and uploaded to the message queue at any time, when the data needs to be checked or downloaded, the data base can be persisted at any time, the data is cached firstly, and then the data is stored persistently according to the requirement, so that the problem that the data is stored firstly and then linked up is avoided while the query efficiency is improved.
As an exemplary embodiment, the block header information is usually encrypted, and therefore, the block header information needs to be parsed to obtain the block header information, as shown in fig. 5, the following steps may be included:
s501, acquiring a transaction receipt of the target transaction, wherein the variable data is generated when the intelligent contract variable is updated. The method comprises the steps that a user deploys an intelligent contract, a plurality of times of data chaining intelligent contract calling operations are carried out, the intelligent contract is monitored in real time, when an intelligent contract variable is updated, a transaction receipt of variable data is obtained in real time, and for example, when a transaction occurs, the transaction receipt can be obtained in real time.
S502, acquiring the block header information to be analyzed of the target block based on the transaction receipt. As an exemplary embodiment, the to-be-parsed tile header information of the target tile may be obtained based on the transaction receipt. For example, the transaction receipt includes identification information of a target block where the variable data is located, and block header information of the target block may be found based on the identification information of the target block. As an exemplary embodiment, the chunk header information may include information such as a target chunk hash value and a last chunk hash value.
S503, analyzing the block header information to be analyzed based on a Hash algorithm to obtain the block header information. As an exemplary embodiment, the to-be-analyzed block header information is analyzed based on a hash algorithm, specifically, a block header data structure may be established, the block header information to be decoded is temporarily stored, block header information in the block header data structure is serialized by using a standard serialization method, block projection information may be encoded by using an encoding rule to obtain a string sequence, for example, the block header information may be represented and encoded by using an abstract syntax flag for a 16-system string in a block header to obtain serialized data, and then the to-be-analyzed block header information is analyzed by using a hash algorithm, for example, a sha256 hash algorithm may be used to perform hash decoding of a serialized array, and a decoded string, that is, a target block hash value, is subjected to 16-system conversion and a result is returned. The block body is queried based on the target block hash value, for example, transaction information in the target block body may be used as the variable data, and in this embodiment, the variable data may further include other information in the block body, for example, target block transaction quantity information and location information of the transaction.
When the intelligent contract variable is updated, the transaction receipt is generated, the block header information is taken out from the target block based on the transaction receipt, the block information of the target block is determined through the block header information, and then the variable data is analyzed, so that the variable data can be analyzed in real time through the transaction receipt when the intelligent contract variable is updated, the data stored on the block chain is analyzed in real time, further data analysis can be carried out, and meanwhile the trust safety problem that the data under the chain is inconsistent can be avoided. Moreover, the query method preset by the intelligent contract does not need to be called repeatedly to query the variable data, and computing resources are saved.
As an exemplary embodiment, the transaction information is generally arranged in the order of transactions in the block according to the transaction time stamp. The block header information comprises a target block hash value and a last block hash value; the context tracing of the target transaction according to the block header information and the transaction information comprises:
and judging whether the transaction quantity is 1, judging whether only one transaction exists in a target block, inquiring a first transaction in a next block as a next transaction of the target transaction based on the hash value of the target block when the transaction quantity is 1, and inquiring last transaction information in a last block as a last transaction of the target transaction based on the hash value of the last block. Specifically, since the target chunk hash value is stored in the next chunk, the first transaction in the next chunk can be queried as the next transaction of the target transaction based on the target chunk hash value. Since the last chunk hash value stored in the target chunk is the hash value of the last chunk, the last transaction in the last chunk can be searched in the last chunk by the last chunk hash value as the last transaction of the target transaction.
As an exemplary embodiment, when there are multiple transactions in the target block, the location information of the target transaction may be queried first, and the search range of the context transaction is determined based on the location information, and for example, when the number of transactions is greater than 1, the transaction location of the target transaction is obtained;
judging whether the target transaction is the first transaction or the last transaction of the target block; when the target transaction is the first transaction of the target block, inquiring the last transaction in the last block as the last transaction of the target transaction based on the hash value of the last block, and searching the next transaction of the target transaction in the target block; and when the target transaction is the last transaction of the target block, inquiring a first transaction in a next block as a next transaction of the target transaction based on the hash value of the target block, and searching the previous transaction of the target transaction in the target block. Specifically, the search may be performed in a manner of searching for the last transaction in the previous block and searching for the first transaction in the next block in the above embodiment. And when the target transaction is not the first transaction or the last transaction of the target block, namely a plurality of transactions exist in the target block and the target transaction is positioned in the middle of the plurality of transactions, searching the previous transaction and the next transaction of the target transaction in the target block. In particular, the previous transaction and the next transaction may be looked up based on a timestamp of the occurrence of the transaction.
For convenience of query and presentation of a user, as an exemplary embodiment, a data variable may be cached in a data structure of a blockchain browser, and the following data caching and storing processes are all described by taking the data consumer as a blockchain browser, specifically, as shown in fig. 6, the following steps may be included:
s601, caching the target transaction and the context transaction according to a browser data structure body. For example, after the target transaction and the context transaction are obtained, the target transaction and the context transaction in the contract may be uploaded to an upper layer application by using a message queue, and the target transaction and the context transaction are cached according to a browser data structure so as to be queried and displayed by the upper layer application, such as a blockchain browser.
S602, obtaining a persistence instruction.
S603, storing the cached target transaction and the context transaction into a relational database based on the persistence instruction.
For example, after the target transaction and the context transaction are cached according to the data structure, whether persistence in the relational database is needed or not can be determined based on actual needs. When the persistence is needed, a persistence instruction can be obtained, the target transaction and the context information are persisted in the relational database based on the persistence instruction, and the target transaction and the context information are returned to the front-end page for displaying.
As an alternative embodiment, the browser data structure may adopt the following structure:
Figure BDA0002879399540000131
Figure BDA0002879399540000141
as an exemplary embodiment, for monitoring of the intelligent contract dynamic variable, a message monitoring cache pool may be adopted, and a message queue of the contract variable is monitored to obtain real-time variable analysis data update on a chain, specifically, the message queue of the intelligent contract variable is monitored based on the message monitoring cache pool, and the message monitoring cache pool monitors the intelligent contract variable based on a monitoring port and a specified intelligent contract address; and when the intelligent contract variable is monitored to be updated, acquiring the update identification based on the updated intelligent contract variable. For example, the message snoop cache pool may be pre-established, and specifically, the establishment of the message snoop cache pool may be as follows: selecting an intelligent contract needing to be monitored, designating a monitoring port, designating an intelligent contract address to be deployed on a block chain, establishing monitoring connection based on the monitoring port and the intelligent contract address, acquiring an updating identifier, such as a transaction receipt, when an intelligent contract variable is updated, for example, when a new transaction occurs, acquiring an updating identifier of variable data in a message monitoring cache pool, and executing the embodiment of the block chain data analysis method.
The embodiment of the present application further provides a device for analyzing block chain data, where specific implementation of the device may refer to the description in the method embodiment, and repeated details are not repeated, as shown in fig. 7, the device mainly includes:
an obtaining module 701, configured to obtain block header information of a target block corresponding to a target transaction, where the target transaction is generated when an intelligent contract variable is updated;
a determining module 702, configured to determine target block transaction information based on the block header information;
a tracing module 703, configured to perform context tracing on the target transaction according to the block header information and the transaction information, so as to obtain a context transaction of the target transaction;
a caching module 704, configured to cache the target transaction and the context transaction.
Based on the same concept, an embodiment of the present application further provides an electronic device, as shown in fig. 8, the electronic device mainly includes: a processor 801, a communication component 802, a memory 803, and a communication bus 804, wherein the processor 801, the communication component 802, and the memory 803 communicate with each other via the communication bus 804. Wherein, the memory 803 stores the program which can be executed by the processor 801, the processor 801 executes the program stored in the memory 803, and the following steps are realized:
s1, acquiring block header information of a target block corresponding to a target transaction, wherein the target transaction is generated when an intelligent contract variable is updated;
s2, determining target block transaction information based on the block header information;
s3, context tracing is carried out on the target transaction according to the block header information and the transaction information, and context transaction of the target transaction is obtained;
s4, caching the target transaction and the context transaction.
The communication bus 804 mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus 804 may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 8, but this is not intended to represent only one bus or type of bus.
The communication component 802 is used for communication between the electronic device and other devices described above.
The Memory 803 may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Alternatively, the memory may be at least one memory device located remotely from the processor 801.
The Processor 801 may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc., and may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic devices, discrete gates or transistor logic devices, and discrete hardware components.
In yet another embodiment of the present application, a computer-readable storage medium is further provided, in which a computer program is stored, and when the computer program runs on a computer, the computer program causes the computer to execute the block chain data parsing method described in the above embodiment.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored on a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wirelessly (e.g., infrared, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that includes one or more of the available media. The available media may be magnetic media (e.g., floppy disks, hard disks, tapes, etc.), optical media (e.g., DVDs), or semiconductor media (e.g., solid state drives), among others.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present invention, which enable those skilled in the art to understand or practice the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A method for analyzing block chain data, comprising:
acquiring block header information of a target block corresponding to a target transaction, wherein the target transaction is generated when an intelligent contract variable is updated;
determining target block transaction information based on the block header information;
performing context tracing on the target transaction according to the block header information and the transaction information to obtain the context transaction of the target transaction;
caching the target transaction and the context transaction.
2. The method for parsing data of a blockchain according to claim 1, wherein the block header information includes a target block hash value and a last block hash value, and the transaction information includes a transaction number in a target block, target transaction information, and position information of a target transaction;
the context tracing of the target transaction according to the block header information and the transaction information comprises:
judging whether the transaction quantity is 1;
and when the transaction quantity is 1, inquiring a first transaction in a next block as a next transaction of the target transaction based on the target block hash value, and inquiring last transaction information in a last block as a last transaction of the target transaction based on the last block hash value.
3. The method for parsing data in a block chain according to claim 2,
when the transaction quantity is larger than 1, acquiring the transaction position of the target transaction;
judging whether the target transaction is the first transaction or the last transaction of the target block;
when the target transaction is the first transaction of the target block, inquiring the last transaction in the last block as the last transaction of the target transaction based on the hash value of the last block, and searching the next transaction of the target transaction in the target block;
when the target transaction is the last transaction of the target block, inquiring a first transaction in a next block as a next transaction of the target transaction based on the hash value of the target block, and searching the previous transaction of the target transaction in the target block;
and when not, searching the previous transaction and the next transaction of the target transaction in the target block.
4. The method of claim 1, wherein the obtaining of the block header information of the target block corresponding to the target transaction comprises:
acquiring a transaction receipt of the target transaction;
acquiring the block header information to be analyzed of the target block based on the transaction receipt;
and analyzing the block header information to be analyzed based on a Hash algorithm to obtain the block header information.
5. The method for parsing blockchain data according to claim 4, wherein the parsing the to-be-parsed blockhead information based on the hash algorithm includes:
coding the block header information to be analyzed by using the coding rule to obtain a coding sequence;
and decoding the coding sequence based on a Hash algorithm to obtain the block header information.
6. The method for blockchain data parsing of claim 1 wherein said caching said target transaction and said context transaction comprises:
caching the target transaction and the context transaction according to a browser data structure;
obtaining a persistence instruction, wherein the persistence instruction comprises a timing persistence instruction and/or a user trigger instruction;
storing the cached target transactions and the context transactions in a relational database based on the persistence instructions.
7. The method for parsing blockchain data according to any one of claims 1 to 6, wherein before the obtaining of the block header information of the target block corresponding to the target transaction, the method comprises:
monitoring a message queue of the intelligent contract variables based on a message monitoring cache pool, wherein the message monitoring cache pool monitors the intelligent contract variables based on a monitoring port and a specified intelligent contract address;
and when the intelligent contract variable is monitored to be updated, acquiring a transaction receipt of the target transaction based on the updated intelligent contract variable.
8. An apparatus for analyzing blockchain data, comprising:
the acquisition module is used for acquiring block header information of a target block corresponding to a target transaction, wherein the target transaction is generated when an intelligent contract variable is updated;
a determination module for determining target block transaction information based on the block header information;
the tracing module is used for performing context tracing on the target transaction according to the block header information and the transaction information to obtain the context transaction of the target transaction;
and the cache module is used for caching the target transaction and the context transaction.
9. An electronic device, comprising: the system comprises a processor, a communication component, a memory and a communication bus, wherein the processor, the communication component and the memory are communicated with each other through the communication bus;
the memory for storing a computer program;
the processor is configured to execute the program stored in the memory to implement the block chain data parsing method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, wherein the computer program is configured to implement the method for block chain data parsing according to any one of claims 1-7 when executed by a processor.
CN202011626903.2A 2020-12-31 2020-12-31 Block chain data analysis method and device and electronic equipment Active CN112818014B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011626903.2A CN112818014B (en) 2020-12-31 2020-12-31 Block chain data analysis method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011626903.2A CN112818014B (en) 2020-12-31 2020-12-31 Block chain data analysis method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN112818014A true CN112818014A (en) 2021-05-18
CN112818014B CN112818014B (en) 2022-07-26

Family

ID=75856264

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011626903.2A Active CN112818014B (en) 2020-12-31 2020-12-31 Block chain data analysis method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN112818014B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113268546A (en) * 2021-06-15 2021-08-17 中国电子科技网络信息安全有限公司 Block chain account book data capture analysis method
CN113436017A (en) * 2021-07-07 2021-09-24 支付宝(杭州)信息技术有限公司 Transaction processing method, device and equipment
CN113781214A (en) * 2021-08-25 2021-12-10 安徽中科晶格技术有限公司 Packaging method, device and equipment for promoting transaction TPS (transaction transfer protocol) based on PoW (PoW)
CN117527832A (en) * 2024-01-03 2024-02-06 杭州趣链科技有限公司 Transaction ordering method and device for blockchain, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR102085997B1 (en) * 2019-01-30 2020-04-24 연대겸 Method and system for real estate transaction service based on block chain
CN111104429A (en) * 2019-12-19 2020-05-05 中思博安科技(北京)有限公司 Data access method and device
US20200169388A1 (en) * 2019-07-31 2020-05-28 Alibaba Group Holding Limited Providing data authorization based on blockchain
CN111445333A (en) * 2020-03-26 2020-07-24 腾讯科技(深圳)有限公司 Block generation method and device, computer equipment and storage medium
WO2020191935A1 (en) * 2019-03-22 2020-10-01 深圳市网心科技有限公司 Method and system for blockchain cross-chain communication, and electronic device and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR102085997B1 (en) * 2019-01-30 2020-04-24 연대겸 Method and system for real estate transaction service based on block chain
WO2020191935A1 (en) * 2019-03-22 2020-10-01 深圳市网心科技有限公司 Method and system for blockchain cross-chain communication, and electronic device and storage medium
US20200169388A1 (en) * 2019-07-31 2020-05-28 Alibaba Group Holding Limited Providing data authorization based on blockchain
CN111104429A (en) * 2019-12-19 2020-05-05 中思博安科技(北京)有限公司 Data access method and device
CN111445333A (en) * 2020-03-26 2020-07-24 腾讯科技(深圳)有限公司 Block generation method and device, computer equipment and storage medium

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113268546A (en) * 2021-06-15 2021-08-17 中国电子科技网络信息安全有限公司 Block chain account book data capture analysis method
CN113268546B (en) * 2021-06-15 2022-04-01 中国电子科技网络信息安全有限公司 Block chain account book data capture analysis method
CN113436017A (en) * 2021-07-07 2021-09-24 支付宝(杭州)信息技术有限公司 Transaction processing method, device and equipment
CN113781214A (en) * 2021-08-25 2021-12-10 安徽中科晶格技术有限公司 Packaging method, device and equipment for promoting transaction TPS (transaction transfer protocol) based on PoW (PoW)
CN117527832A (en) * 2024-01-03 2024-02-06 杭州趣链科技有限公司 Transaction ordering method and device for blockchain, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN112818014B (en) 2022-07-26

Similar Documents

Publication Publication Date Title
WO2021073452A1 (en) Blockchain network-based data processing method and device, electronic device and storage medium
CN112818014B (en) Block chain data analysis method and device and electronic equipment
US10887081B2 (en) Audit trail configuration in a blockchain
US11940971B2 (en) Blockchain implementing reliability database
US20220138212A1 (en) Blockchain implementing reliability database
CN110598434B (en) House information processing method and device based on blockchain network, electronic equipment and storage medium
CN112506987B (en) Query method, device and equipment based on block chain and storage medium
US11669532B2 (en) Blockchain implementing reliability database
CN110569674A (en) Block chain network-based authentication method and device
US11095705B2 (en) Content distributed over secure channels
US10282461B2 (en) Structure-based entity analysis
CN112800129A (en) Block state updating method, device and system and electronic equipment
US10192262B2 (en) System for periodically updating backings for resource requests
CN111177246A (en) Service data processing method and device
CN112712452A (en) Approval information processing method and device based on block chain
CN110769274A (en) Live broadcast information processing method and device based on block chain network, electronic equipment and storage medium
US11381403B2 (en) Integrating blockchain with off-chain services
CN112702419B (en) Data processing method, device, equipment and storage medium based on block chain
CN112235301A (en) Method and device for verifying access authority and electronic equipment
CN112699799A (en) Face recognition method, device, equipment and storage medium based on block chain
CN112837023A (en) Business collaboration platform, method and device of organization and electronic equipment
CN112836186A (en) Page control method and device
CN112560005A (en) Identity trusted service system, method, electronic device and computer readable medium
CN112597512B (en) Temperature data control method and device based on block chain and storage medium
CN117040929B (en) Access processing method, device, equipment, medium and program product

Legal Events

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