CN111339130A - Data query method, related equipment and readable storage medium - Google Patents

Data query method, related equipment and readable storage medium Download PDF

Info

Publication number
CN111339130A
CN111339130A CN202010117495.1A CN202010117495A CN111339130A CN 111339130 A CN111339130 A CN 111339130A CN 202010117495 A CN202010117495 A CN 202010117495A CN 111339130 A CN111339130 A CN 111339130A
Authority
CN
China
Prior art keywords
block chain
data
block
management platform
target node
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.)
Pending
Application number
CN202010117495.1A
Other languages
Chinese (zh)
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202010117495.1A priority Critical patent/CN111339130A/en
Publication of CN111339130A publication Critical patent/CN111339130A/en
Pending legal-status Critical Current

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/2453Query optimisation
    • G06F16/24534Query rewriting; Transformation
    • G06F16/24549Run-time optimisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Abstract

The embodiment of the invention provides a data query method, related equipment and a readable storage medium, wherein the method is applied to a block chain management platform and comprises the following steps: the block chain management platform receives a data query request submitted by a user through terminal equipment, wherein the data query request comprises an identifier of a block chain; the block chain management platform determines a plurality of nodes corresponding to the block chain according to the identification of the block chain; the block chain management platform determines a target node with the latest data on a chain of a block chain from a plurality of nodes; and the block chain management platform acquires a query result corresponding to the data query request from the target node, wherein the query result comprises block data corresponding to a block with the highest height in the block chain on the target node. By implementing the method, a user can quickly and accurately inquire the latest data on the block chain.

Description

Data query method, related equipment and readable storage medium
Technical Field
The present invention relates to the field of block chains, and in particular, to a data query method, a related device, and a readable storage medium.
Background
The block chain is a distributed shared account book and a database, and has the characteristics of decentralization, no tampering, trace retaining in the whole process, traceability, collective maintenance, openness and transparency and the like. The user can access any node in the blockchain network through the terminal to inquire the data in the blockchain.
Since the terminal needs to communicate directly with the nodes on the blockchain network, the method is very challenging for the user to know and master the blockchain and the blockchain lower-layer technology. In particular, when the data queried by the user is not synchronized to all nodes on the blockchain network, it is very likely that the required data, such as the latest updated data of the blockchain, cannot be queried.
Disclosure of Invention
The embodiment of the invention provides a data query method, related equipment and a readable storage medium, which can quickly and accurately query the latest data on a block chain through a block chain management platform.
In a first aspect, an embodiment of the present invention provides a data query method, which is applied to a block chain management platform, and the method includes:
the method comprises the steps that a block chain management platform receives a data query request submitted by a user through terminal equipment, wherein the data query request comprises an identifier of a block chain;
the block chain management platform determines a plurality of nodes corresponding to the block chain according to the identification of the block chain;
the block chain management platform determines a target node with the latest data on the block chain from the plurality of nodes;
and the block chain management platform acquires a query result corresponding to the data query request from the target node, wherein the query result comprises block data corresponding to a block with the highest height in the block chain on the target node.
In a second aspect, an embodiment of the present invention provides a data query method, where the method includes:
a target node receives a block height query request sent by a block chain management platform, wherein the block height query request is sent to a plurality of nodes corresponding to the data query request including block chain identifiers when the block chain management platform receives a data query request, and the target node is a node with the latest data on the block chain of the plurality of nodes;
the target node inquires the block height of the block chain according to the identification of the block chain and sends the block height to the block chain management platform, so that the block chain management platform determines the target node with the latest data on the chain of the block chain according to the block height sent by each node in the plurality of nodes;
the target node receives a data acquisition request sent by the blockchain management platform, and acquires a query result corresponding to the data query request from a corresponding blockchain process, wherein the query result comprises blockchain data corresponding to a block with the highest height in the blockchain on the target node;
and the target node sends the query result to the block chain management platform.
In a third aspect, an embodiment of the present invention provides a block chain management platform, where the apparatus includes:
a receiving unit, configured to receive a data query request submitted by a user through a terminal device, where the data query request includes an identifier of a block chain;
a determining unit, configured to determine, according to the identifier of the blockchain, a plurality of nodes corresponding to the blockchain;
the determining unit is further configured to determine, from the plurality of nodes, a target node of the block chain, where data on the chain is the latest;
an obtaining unit, configured to obtain, from the target node, a query result corresponding to the data query request, where the query result includes block data corresponding to a block with a highest degree in the block chain on the target node.
In a fourth aspect, an embodiment of the present invention provides a node device, where the node device includes:
a receiving unit, configured to receive a block height query request sent by a block chain management platform, where the block height query request is sent by the block chain management platform to a plurality of nodes corresponding to identifiers of a block chain when the block chain management platform receives a data query request, and the target node is a node of the plurality of nodes where data on the block chain is the latest;
the query unit is used for querying the block height of the block chain according to the identification of the block chain;
a sending unit, configured to send the block height to the blockchain management platform, so that the blockchain management platform determines, according to the block height sent by each node of the multiple nodes, the target node of the blockchain with the latest data on the chain;
the receiving unit is further configured to receive a data acquisition request sent by the blockchain management platform, and acquire a query result corresponding to the data query request from a corresponding blockchain process, where the query result includes blockchain data corresponding to a highest-degree block in the blockchain on the target node;
the sending unit is further configured to send the query result to the blockchain management platform.
In a fifth aspect, an embodiment of the present invention provides a blockchain management platform, where the blockchain management platform includes a processor, a network interface, and a storage device, where the processor, the network interface, and the storage device are connected to each other, where the network interface is controlled by the processor to send and receive data, and the storage device is used to store a computer program, where the computer program includes program instructions, and the processor is configured to call the program instructions to execute the data query method according to the first aspect.
In a sixth aspect, an embodiment of the present invention provides a node device, which is applied to a blockchain network, where the blockchain network includes a plurality of nodes, and the node device includes a processor, a network interface, and a storage device, where the processor, the network interface, and the storage device are connected to each other, where the network interface is controlled by the processor to send and receive data, and the storage device is used to store a computer program, where the computer program includes program instructions, and the processor is configured to call the program instructions to execute the data query method according to the second aspect.
In a seventh aspect, an embodiment of the present invention provides a computer storage medium, where the computer storage medium stores program instructions, and the program instructions, when executed, are configured to implement the data query method according to the first aspect or the second aspect.
In the embodiment of the invention, after receiving a data query request submitted by a user through a terminal, a block chain management platform determines a block chain requested to be queried by the data query request. And then the blockchain management platform inquires the node with the latest data in all the nodes on the blockchain, and takes the node with the latest data as a target node. And finally, the block chain management platform acquires the query result corresponding to the data query request at the target node. Since the query result includes the block data of the block with the highest block height in all the block chains on the target node, the embodiment of the present invention can not only quickly query the data on the block chain, but also the finally queried data or the latest data on the block chain. In summary, the blockchain management platform in the embodiment of the invention provides a convenient and efficient method for querying data for a user.
Drawings
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, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1a is a schematic diagram of a block chain management system according to an embodiment of the present invention;
fig. 1b is a schematic structural diagram of a block chain according to an embodiment of the present invention;
FIG. 1c is a schematic diagram of a process for generating a new block according to an embodiment of the present invention;
FIG. 2 is a flow chart of a data query method provided by an embodiment of the present invention;
FIG. 3 is a flow chart of another data query method provided by the embodiment of the invention;
FIG. 4 is a block diagram of a block chain management platform according to an embodiment of the present invention;
fig. 5 is a schematic block diagram of a node device provided in an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a block chain management platform according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a node device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the 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 invention.
Aiming at the problems that the query efficiency of current block chain data is low, the latest data is difficult to obtain and the like, the embodiment of the invention provides a data query method, which can quickly and efficiently obtain the latest data on a block chain for a user through a block chain management platform.
Referring to fig. 1a, it is a schematic structural diagram of a block chain management system according to an embodiment of the present invention, the block chain management system includes a block chain network 10, a block chain management platform 102 and a terminal device 103, where:
the blockchain network 10 refers to a network for performing data sharing between nodes, and a plurality of node apparatuses 101 may be included in the blockchain network. Each node apparatus 101 may receive input information while performing normal operations and maintain shared data (i.e., blockchains) within the blockchain network based on the received input information. In order to ensure information intercommunication in the blockchain network, information connection may exist between each node device, and Peer-to-Peer (PeerTo Peer, P2P) communication may be implemented between any two node devices, and specifically, P2P communication may be performed through a wired communication link or a wireless communication link. For example, when any node device in the blockchain network receives input information, other node devices acquire the input information according to a consensus algorithm, and store the input information as data in shared data, so that the data stored in all the node devices in the blockchain network are consistent.
The blockchain management platform 102 and the terminal device 103 may access the blockchain network and may communicate with node devices in the blockchain network, for example, initiate a service request to the node devices, obtain data from the node devices, and so on. The Blockchain management platform 102 may be a BaaS (Blockchain as a Service) management platform, a TBaaS management platform, and the like, and the terminal device 103 may specifically be a smart phone, a tablet computer, a notebook computer, a desktop computer, a vehicle-mounted smart terminal, and the like, which is not limited in the embodiment of the present invention.
It should be noted that the number of nodes shown in fig. 1a is only schematic, and according to actual needs, any number of node devices may be deployed, and the blockchain management platform 102 and the terminal device 103 may communicate with the same node device in the blockchain network or communicate with different node devices in the blockchain network respectively.
Each node device in the blockchain network has a node identifier corresponding thereto, and each node device in the blockchain network can store node identifiers of other node devices in the blockchain network, so that the generated block is broadcast to other node devices in the blockchain network according to the node identifiers of the other node devices in the blockchain network. Each node device may maintain a node identifier list as shown in the following table, and store the node name and the node identifier in the node identifier list correspondingly. The node identifier may be an Internet Protocol (IP) address or any other information that can be used to identify the node, and the table is described by taking the IP address as an example.
Node name Node identification
Node 1 117.114.151.174
Node 2 117.116.189.145
Node N 119.123.789.258
Each node device in the blockchain network stores one same blockchain. The block chain is composed of a plurality of blocks, referring to fig. 1b, the block chain is composed of a plurality of blocks, the starting block comprises a block head and a block main body, the block head stores an input information characteristic value, a version number, a timestamp and a difficulty value, and the block main body stores input information; the next block of the starting block takes the starting block as a parent block, the next block also comprises a block head and a block main body, the block head stores the input information characteristic value of the current block, the block head characteristic value of the parent block, the version number, the timestamp and the difficulty value, and the like, so that the block data stored in each block in the block chain is associated with the block data stored in the parent block, and the safety of the input information in the block is ensured.
When each block in the block chain is generated, referring to fig. 1c, when a node where the block chain is located receives input information, the input information is verified, after the verification is completed, the input information is stored in a memory pool, and a hash tree used for recording the input information is updated; and then, updating the updating time stamp to the time when the input information is received, trying different random numbers, and calculating the characteristic value for multiple times, so that the calculated characteristic value can meet the following formula:
SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x))<TARGET
wherein, SHA256 is a characteristic value algorithm used for calculating a characteristic value; version is version information of the relevant block protocol in the block chain; prev _ hash is a block head characteristic value of a parent block of the current block; merkle _ root is a characteristic value of the input information; ntime is the update time of the update timestamp; nbits is the current difficulty, is a fixed value within a period of time, and is determined again after exceeding a fixed time period; x is a random number; TARGET is a feature threshold, which can be determined from nbits.
Therefore, when the random number meeting the formula is obtained through calculation, the information can be correspondingly stored, and the block head and the block main body are generated to obtain the current block. And then, the node where the block chain is located respectively sends the newly generated blocks to other nodes in the block chain network where the newly generated blocks are located according to the node identifications of the other nodes in the block chain network, the newly generated blocks are verified by the other nodes, and the newly generated blocks are added to the block chain stored in the newly generated blocks after the verification is completed.
The intelligent contract can be operated on the nodes of the block chain network, the intelligent contract is realized by codes executed when a certain condition is met, developers can define contract logic through a programming language, issue the contract logic to the block chain (intelligent contract registration), and call keys or other events to trigger execution according to the logic of contract terms to complete the contract logic and simultaneously provide the functions of upgrading and cancelling the intelligent contract.
In some possible embodiments, the blockchain management platform 102 receives a data query request submitted by a user through the terminal device 103, determines a plurality of nodes corresponding to a blockchain according to an identifier of the blockchain included in the data query request, then determines a target node with the latest data on the blockchain from the plurality of nodes, and obtains a query result corresponding to the data query request from the target node, where the query result includes block data corresponding to a block with the highest height in the blockchain on the target node, thereby ensuring that the latest data on the blockchain can be accurately and efficiently obtained.
The implementation details of the technical scheme of the embodiment of the invention are explained in detail as follows:
fig. 2 is a schematic flow chart of a data query method provided by the blockchain management system shown in fig. 1a according to an embodiment of the present invention, where the data query method of the embodiment of the present invention is mainly described from the side of the blockchain management platform. The data query method comprises the following steps:
201. and the block chain management platform receives a data query request submitted and sent by a client front-end user through terminal equipment, wherein the data query request comprises an identifier of a block chain.
In the embodiment of the present invention, a user may manage a blockchain on a blockchain management platform through a terminal device, for example, query data on the blockchain. When the block chain management platform receives a data query request sent by a user through terminal equipment, the data query request indicates that the user requests to query data on a block chain, and the data query request comprises an identifier of the block chain which is requested to be queried by the user. The identifier of the blockchain may be any combination of characters such as numbers, letters, and the like, so as to uniquely represent the blockchain. Different block chains are represented with different identities.
202. And the block chain management platform determines a plurality of nodes corresponding to the block chain according to the identification of the block chain.
In the embodiment of the present invention, the blockchain management platform finds the corresponding blockchain and the plurality of nodes storing the data of the blockchain according to the identifier of the blockchain. And storing the corresponding relation between the identification of the block chain and the node on the block chain management platform.
203. And the block chain management platform determines a target node with the latest data on the chain of the block chain from the plurality of nodes.
In the embodiment of the present invention, since the synchronization of data among the nodes is delayed, one of the nodes may contain the latest data and may not be synchronized with other nodes. And the block chain management platform determines a target node which stores the latest data from a plurality of nodes corresponding to the block chain. The target node with the latest data, namely the node with the highest block height. That is, the node storing the largest number of blocks.
In some possible embodiments, when determining a target node, the blockchain management platform first sends a blockchain height query request to each node of a plurality of nodes corresponding to a blockchain, where the blockchain height query request is used to query a blockchain height of the blockchain at each node; then receiving the block height returned by each node, and comparing the block heights returned by each node; and finally, taking the node with the highest corresponding block height as a target node with the latest data on the chain of the block chain.
In the embodiment of the present invention, the blockchain management platform may determine the target node storing the latest data by querying the block height of each node one by one and comparing the node with the largest block height. It should be noted that if there are two or more nodes with the largest block height, any one of the nodes may be selected as the target node.
204. And the block chain management platform acquires a query result corresponding to the data query request from the target node, wherein the query result comprises block data corresponding to a block with the highest height in the block chain on the target node.
In the embodiment of the present invention, the block chain management platform obtains the block data corresponding to the block with the highest height from the target node, and uses the block data as the query result corresponding to the data query request. Or acquiring block data corresponding to the block with the highest height and the preset number of blocks from the target node as a query result corresponding to the data query request. Such as data of the top ten highly ranked blocks in the target node. Therefore, the embodiment of the invention acquires the latest data on the target node, so that the method and the device can be applied to scenes in which the user needs to acquire the latest data and update the data on the terminal. If the terminal of the user directly communicates with the node, the node communicating with the user may just not update to the latest data due to the synchronization delay, so that the user cannot acquire the latest data.
In some feasible embodiments, the block chain management platform sends a data acquisition request to an agent process on a target node, wherein the data acquisition request is used for instructing the agent process to acquire a query result corresponding to the data query request from a corresponding block chain process and encrypt the query result; and the block chain management platform receives the encrypted query result returned by the agent process.
In the embodiment of the invention, the blockchain management platform instructs the agent process to acquire the query result by sending the data acquisition request to the agent process on the target node, and feeds back the query result. Wherein the data request may be a post request packet. In order to ensure the communication security between the blockchain management platform and the agent process on the target node, the agent process encrypts the query result according to the key agreed with the blockchain management platform, and then the blockchain management platform decrypts the query result to obtain the query result.
It should be noted that, when querying the block height of a node, the blockchain management platform may also determine the block height of the node by sending a block height query request to an agent process on the target node. Specifically, the block chain management platform sends a block height query request to an agent process on the target node, instructs the agent process to acquire the block height of the node from the corresponding block chain process, and encrypts the block height; and the block chain management platform receives the encrypted block height returned by the agent process.
In some possible embodiments, the block chain management platform decrypts the encrypted query result to obtain the query result; and the block chain management platform sends the query result to the terminal equipment.
In the embodiment of the invention, the block chain management platform decrypts the encrypted query result and sends the decrypted query result to the terminal equipment, so that the terminal equipment presents the query result to a user or updates a local database by using the query result.
The embodiment of the invention utilizes the block chain management platform to inquire the data on the block chain, and the inquired latest data on the block chain. Specifically, the blockchain management platform determines the blockchain requested to be queried by the data query request according to the received data query request submitted by the user. And then determining a target node with the latest data on the block chain, and acquiring a query result corresponding to the data query request on the target node. In summary, the blockchain management platform in the embodiment of the invention provides a convenient and efficient method for querying data for a user.
Please refer to fig. 3, which is a schematic flow diagram of another data query method provided by the blockchain management system shown in fig. 1a according to an embodiment of the present invention, where the data query method in the embodiment of the present invention is mainly described from a node device side, the blockchain network includes a plurality of node devices, and the data query method includes the following steps:
301. the target node receives a block height query request sent by the block chain management platform.
In the embodiment of the present invention, if the target node receives the block height query request sent by the block chain management platform, the target node indicates a request for querying the block height sent by the block chain management platform to the plurality of nodes corresponding to the identifier of the block chain included in the data query request when the block chain management platform receives the data query request. Since the target node is one of the plurality of nodes corresponding to the blockchain, when the blockchain management platform queries the blockheight of each node corresponding to the blockchain, the target node also receives a request for indicating the height of the query blockheight. The target node is a node with the latest data in the plurality of nodes.
302. And the target node inquires the block height of the block chain according to the identification of the block chain and sends the block height to the block chain management platform, so that the block chain management platform determines the target node with the latest data on the chain of the block chain according to the block height sent by each node in the plurality of nodes.
In the embodiment of the present invention, after receiving the block height query request, the target node queries the block heights of all the blocks of the block chain stored in the local node, that is, queries the number of the stored blocks of the block chain. After the target node queries the block height of the node, the block height is sent to the block chain management platform, so that the block chain management platform determines the node with the largest block height, namely the node (target node), according to the received block height of each node.
In some possible embodiments, running an agent process of the blockchain management platform on the target node, the target node querying the blockchain for the block height according to the identifier of the blockchain includes: the target node calls the agent process to determine a corresponding data read-write port of the block chain process according to the identification of the block chain; the target node calls an agent process to package the block height query request into a block height request packet according to the protocol specification of the data read-write port; the target node calls the proxy process to transmit the block height request packet to the data read-write port so as to read the block height of the block chain from the block chain process.
In the embodiment of the present invention, when determining the block height of the target node, the target node actually obtains data by calling a proxy process to a predetermined port. Specifically, the target node calls a proxy process to query a data read-write port of a blockchain process corresponding to the identifier of the blockchain in the configuration file, wherein different blockchain processes correspond to different data read-write ports, the blockchain process is a code for managing data of the blockchain, the proxy process is a code for processing communication between the blockchain management platform and the node, and the proxy process can start the blockchain process to manage the data of the blockchain only through the port corresponding to the blockchain process. After the data read-write port is determined, the target node calls the proxy process to encapsulate the block height query request into a block height request packet according to the protocol specification of the data read-write port, and transmits the block height request packet into the data read-write port so as to read the block height of the block chain from the block chain process. After receiving the height request packet through the data read-write port, the block chain process automatically fills the field requested by the block height request packet according to the protocol specification, and feeds back the filled field (namely the block height) to the proxy process through the data read-write port. The data read/write port may be a Remote Procedure Call (RPC) port, and a Protocol specification corresponding to the RPC port is a HyperText Transfer Protocol (HTTP).
303. And the target node receives a data acquisition request sent by the block chain management platform, and acquires a query result corresponding to the data query request from a corresponding block chain process, wherein the query result comprises block data corresponding to a block with the highest height in the block chain on the target node.
In the embodiment of the present invention, the target node further receives a data obtaining request sent by the blockchain management platform, where the data obtaining request is used to instruct the target node to return data requested by the data obtaining request. Specifically, the target node obtains a corresponding query result from the stored block data according to the data obtaining request, where the query result at least includes data of a block with the highest height on the target node, or includes data of a block with a preset number of blocks with the highest height on the target node, such as data of a block with a top ten height in the target node. The preset block number may be set to any value, which is not limited in the embodiment of the present invention.
In some possible embodiments, the target node runs an agent process of the blockchain management platform, and the target node receives a data acquisition request sent by the blockchain management platform and acquires a query result corresponding to the data query request from a corresponding blockchain process, including: a target node receives a data acquisition request sent by a block chain management platform; the target node calls the agent process to determine a corresponding data read-write port of the block chain process according to the identification of the block chain; the target node calls an agent process to package the data acquisition request into a data reading request packet according to the protocol specification of the data reading and writing port; and the target node calls the proxy process to transmit the data reading request packet into the data reading and writing port so as to read the query result corresponding to the data query request from the block chain process.
In the embodiment of the present invention, after receiving the data acquisition request, the target node determines the data read/write port according to the identifier of the block chain, and the process of determining the data read/write port may refer to the contents described in the foregoing embodiment, which is not described herein again. And then the target node encapsulates the data acquisition request into a data reading request packet according to the protocol specification of the data reading and writing port, and transmits the data reading request packet into the data reading and writing port so as to read the query result corresponding to the data query request from the block chain process. After receiving the height request packet through the data read-write port, the block chain process automatically fills the field requested by the data read request packet according to the protocol specification, and feeds back the filled field (namely the query result) to the proxy process through the data read-write port.
304. And the target node sends the query result to the block chain management platform.
In the embodiment of the invention, the target node sends the inquired inquiry result to the block chain management platform. The target node can also encrypt the query result and then send the encrypted query result to the block chain management platform, so that the data security is further ensured.
The embodiment of the application describes the process of querying the data of the blockchain in detail from the perspective of the target node. The target node receives a block height query request from the blockchain management platform. Then, after the target node sends the block height to the block chain management platform so that the block chain management platform determines the node, that is, the target node receives the data acquisition request sent by the block chain management platform. And finally, the target node sends the inquired inquiry result to the block chain management platform, so that the whole inquiry process is finished. And the data included in the query result is the data of the block with the highest height on the target node, so that the block chain management platform can accurately and efficiently acquire the latest data on the block chain. And because the node realizes the query process by calling the proxy process, the whole query process is automatically completed without the participation of a user, so that the query process is very efficient and quick.
Embodiments of the present invention further provide a computer storage medium, in which program instructions are stored, and when the program instructions are executed, the computer storage medium is configured to implement the corresponding method described in the above embodiments.
Referring to fig. 4, a block diagram of a block chain management platform according to an embodiment of the present invention is shown, where the block chain management platform includes:
a receiving unit 401, configured to receive a data query request submitted by a user through a terminal device, where the data query request includes an identifier of a block chain;
a determining unit 402, configured to determine, according to the identifier of the blockchain, a plurality of nodes corresponding to the blockchain;
the determining unit 402 is further configured to determine, from the plurality of nodes, a target node of the block chain, where data on the chain is the latest;
an obtaining unit 403, configured to obtain, from the target node, a query result corresponding to the data query request, where the query result includes block data corresponding to a block with a highest degree in the block chain on the target node.
In some possible embodiments, the determining unit 402 is specifically configured to:
sending a block height query request to each node in the plurality of nodes, the block height query request being used for querying the block height of the block chain on each node;
receiving the block height returned by each node, and comparing the block heights returned by each node;
and taking the node with the highest corresponding block height as a target node with the latest data on the chain of the block chain.
In some possible embodiments, the obtaining unit 403 is specifically configured to:
the block chain management platform sends a data acquisition request to an agent process of the block chain management platform on the target node, wherein the data acquisition request is used for indicating the agent process to acquire a query result corresponding to the data query request from a corresponding block chain process and encrypting the query result;
and the block chain management platform receives the encrypted query result returned by the agent process.
In some possible embodiments, the blockchain management platform further includes a decryption unit 404 and a sending unit 405, specifically:
the decryption unit 404 is configured to decrypt the encrypted query result by the blockchain management platform to obtain the query result;
the sending unit 405 is configured to send the query result to the terminal device by the blockchain management platform.
It should be noted that the functions of each functional unit of the block chain management platform according to the embodiment of the present invention may be specifically implemented according to the method in the foregoing method embodiment, and the specific implementation process may refer to the related description of the foregoing method embodiment, which is not described herein again.
Referring to fig. 5, a schematic block diagram of a node device according to an embodiment of the present invention is shown, where the node device according to the embodiment of the present invention is applied to a blockchain network, and the node device includes:
a receiving unit 501, configured to receive a block height query request sent by a block chain management platform, where the block height query request is sent by the block chain management platform to a plurality of nodes corresponding to identifiers of a block chain when the block chain management platform receives a data query request, and the target node is a node of the plurality of nodes where data on the block chain is the latest;
a querying unit 502, configured to query a block height of the block chain according to the identifier of the block chain;
a sending unit 503, configured to send the block height to the blockchain management platform, so that the blockchain management platform determines, according to the block height sent by each node of the multiple nodes, the target node of the blockchain with the latest data on the chain;
the receiving unit 501 is further configured to receive a data obtaining request sent by the blockchain management platform, and obtain a query result corresponding to the data query request from a corresponding blockchain process, where the query result includes blockchain data corresponding to a highest-degree block in the blockchain on the target node;
the sending unit 503 is further configured to send the query result to the blockchain management platform.
In some possible embodiments, the node device runs an agent process of the blockchain management platform. The querying unit 502 is specifically configured to:
calling the proxy process to determine a data read-write port of the corresponding block chain process according to the identification of the block chain;
calling the proxy process to package the block height query request into a block height request packet according to the protocol specification of the data read-write port;
and calling the proxy process to transmit the block height request packet into the data read-write port so as to read the block height of the block chain from the block chain process.
In some possible embodiments, the node device runs an agent process of the blockchain management platform. The receiving unit 501 is specifically configured to:
receiving a data acquisition request sent by the block chain management platform;
calling the proxy process to determine a data read-write port of the corresponding block chain process according to the identification of the block chain;
calling the proxy process to package the data acquisition request into a data reading request packet according to the protocol specification of the data reading and writing port;
and calling the proxy process to transmit the data reading request packet into the data reading and writing port so as to read the query result corresponding to the data query request from the block chain process.
It should be noted that the functions of each functional unit of the node device in the embodiment of the present invention may be specifically implemented according to the method in the foregoing method embodiment, and the specific implementation process may refer to the related description of the foregoing method embodiment, which is not described herein again.
Referring to fig. 6, a schematic structural diagram of a block chain management platform according to an embodiment of the present invention is shown, where the block chain management platform according to the embodiment of the present invention includes a power supply module and other structures, and includes a processor 601, a storage device 602, and a network interface 603. The processor 601, the storage device 602, and the network interface 603 may exchange data therebetween.
The storage device 602 may include a volatile memory (volatile memory), such as a random-access memory (RAM); the storage device 602 may also include a non-volatile memory (non-volatile memory), such as a flash memory (flash memory), a solid-state drive (SSD), etc.; the storage means 602 may also comprise a combination of memories of the kind described above.
The processor 601 may be a Central Processing Unit (CPU) 601. In one embodiment, the processor 601 may also be a Graphics Processing Unit (GPU) 601. The processor 601 may also be a combination of a CPU and a GPU. In one embodiment, the storage device 602 is used to store program instructions. The processor 601 may call the program instructions to perform the following operations:
receiving a data query request submitted by a user through terminal equipment, wherein the data query request comprises an identifier of a block chain;
determining a plurality of nodes corresponding to the block chain according to the identifier of the block chain;
determining a target node with the latest data on the block chain from the plurality of nodes;
and acquiring a query result corresponding to the data query request from the target node, wherein the query result comprises block data corresponding to a block with the highest height in the block chain on the target node.
In some possible embodiments, the processor 601 is further configured to:
sending a block height query request to each node in the plurality of nodes, the block height query request being used for querying the block height of the block chain on each node;
receiving the block height returned by each node, and comparing the block heights returned by each node;
and taking the node with the highest corresponding block height as a target node with the latest data on the chain of the block chain.
In some possible embodiments, the processor 601 is further configured to:
sending a data acquisition request to an agent process of the block chain management platform on the target node, wherein the data acquisition request is used for indicating the agent process to acquire a query result corresponding to the data query request from a corresponding block chain process and encrypting the query result;
and receiving the encrypted query result returned by the agent process.
In some possible embodiments, the processor 601 is further configured to:
decrypting the encrypted query result to obtain the query result;
and sending the query result to the terminal equipment.
In a specific implementation, the processor 601, the storage device 602, and the network interface 603 which are described in this embodiment of the present invention may execute the implementation described in the related embodiment of the data query method provided in fig. 2 in the embodiment of the present invention, and may also execute the implementation described in the related embodiment of the block chain management platform provided in fig. 4 in the embodiment of the present invention, which is not described herein again.
Fig. 7 is a schematic structural diagram of a node device according to an embodiment of the present invention, where the node device includes a power supply module and other structures, and includes a processor 701, a storage 702, and a network interface 703. The processor 701, the storage 702, and the network interface 703 may exchange data with each other.
The storage 702 may include a volatile memory (volatile memory), such as a random-access memory (RAM); the storage device 702 may also include a non-volatile memory (non-volatile memory), such as a flash memory (flash memory), a solid-state drive (SSD), or the like; the storage means 702 may also comprise a combination of memories of the kind described above.
The processor 701 may be a Central Processing Unit (CPU) 701. In one embodiment, the processor 701 may also be a Graphics Processing Unit (GPU) 701. The processor 701 may also be a combination of a CPU and a GPU. In one embodiment, the storage 702 is used to store program instructions. The processor 701 may call the program instructions to perform the following operations:
receiving a block height query request sent by a block chain management platform, wherein the block height query request is sent to a plurality of nodes corresponding to the data query request including block chain identifiers when the block chain management platform receives a data query request, and the target node is a node with the latest data on the block chain of the plurality of nodes;
inquiring the block height of the block chain according to the identifier of the block chain, and sending the block height to the block chain management platform, so that the block chain management platform determines the target node with the latest data on the chain of the block chain according to the block height sent by each node in the plurality of nodes;
receiving a data acquisition request sent by the blockchain management platform, and acquiring a query result corresponding to the data query request from a corresponding blockchain process, wherein the query result comprises blockdata corresponding to a block with the highest height in the blockchain on the target node;
and sending the query result to the block chain management platform.
In some possible embodiments, the target node has an agent process running thereon for the blockchain management platform. The processor 701 is further configured to:
calling the proxy process to determine a data read-write port of the corresponding block chain process according to the identification of the block chain;
calling the proxy process to package the block height query request into a block height request packet according to the protocol specification of the data read-write port;
and calling the proxy process to transmit the block height request packet into the data read-write port so as to read the block height of the block chain from the block chain process.
In some possible embodiments, the target node has an agent process running thereon for the blockchain management platform. The processor 701 is further configured to:
the target node receives a data acquisition request sent by the block chain management platform;
the target node calls the agent process to determine a data read-write port of the corresponding block chain process according to the identification of the block chain;
the target node calls the agent process to package the data acquisition request into a data reading request packet according to the protocol specification of the data reading and writing port;
and the target node calls the proxy process to transmit the data reading request packet into the data reading and writing port so as to read the query result corresponding to the data query request from the block chain process.
In a specific implementation, the processor 701, the storage device 702, and the network interface 703, which are described in this embodiment of the present invention, may execute the implementation described in the related embodiment of the data query method provided in fig. 3 in this embodiment of the present invention, and may also execute the implementation described in the related embodiment of the node device provided in fig. 5 in this embodiment of the present invention, which is not described herein again.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus may be implemented in other manners. For example, the above-described embodiments of the apparatus are merely illustrative, and for example, the above-described division of the units is only one type of division of logical functions, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of some interfaces, devices or units, and may be an electric or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit may be stored in a computer-readable storage medium if it is implemented in the form of a software functional unit and sold or used as a separate product. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, a network device, or the like, and may specifically be a processor in the computer device) to execute all or part of the steps of the above-described method according to the embodiments of the present invention. The storage medium may include: a U-disk, a removable hard disk, a magnetic disk, an optical disk, a Read-Only Memory (ROM) or a Random Access Memory (RAM), and other various media capable of storing program codes.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A data query method is applied to a block chain management platform, and comprises the following steps:
the method comprises the steps that a block chain management platform receives a data query request submitted by a user through terminal equipment, wherein the data query request comprises an identifier of a block chain;
the block chain management platform determines a plurality of nodes corresponding to the block chain according to the identification of the block chain;
the block chain management platform determines a target node with the latest data on the block chain from the plurality of nodes;
and the block chain management platform acquires a query result corresponding to the data query request from the target node, wherein the query result comprises block data corresponding to a block with the highest height in the block chain on the target node.
2. The method of claim 1, wherein the blockchain management platform determines a target node of the blockchain with the latest data on the chain from the plurality of nodes, and comprises:
the block chain management platform sends a block height query request to each node in the plurality of nodes, wherein the block height query request is used for querying the block height of the block chain on each node;
the block chain management platform receives the block height returned by each node and compares the block height returned by each node;
and the block chain management platform takes the node with the highest corresponding block height as a target node with the latest data on the chain of the block chain.
3. The method according to claim 1 or 2, wherein the obtaining, by the blockchain management platform, the query result corresponding to the data query request from the target node includes:
the block chain management platform sends a data acquisition request to an agent process of the block chain management platform on the target node, wherein the data acquisition request is used for indicating the agent process to acquire a query result corresponding to the data query request from a corresponding block chain process and encrypting the query result;
and the block chain management platform receives the encrypted query result returned by the agent process.
4. The method of claim 3, further comprising:
the block chain management platform decrypts the encrypted query result to obtain the query result;
and the block chain management platform sends the query result to the terminal equipment.
5. A method for data query, the method comprising:
a target node receives a block height query request sent by a block chain management platform, wherein the block height query request is sent to a plurality of nodes corresponding to the data query request including block chain identifiers when the block chain management platform receives a data query request, and the target node is a node with the latest data on the block chain of the plurality of nodes;
the target node inquires the block height of the block chain according to the identification of the block chain and sends the block height to the block chain management platform, so that the block chain management platform determines the target node with the latest data on the chain of the block chain according to the block height sent by each node in the plurality of nodes;
the target node receives a data acquisition request sent by the blockchain management platform, and acquires a query result corresponding to the data query request from a corresponding blockchain process, wherein the query result comprises blockchain data corresponding to a block with the highest height in the blockchain on the target node;
and the target node sends the query result to the block chain management platform.
6. The method of claim 5, wherein the target node runs a proxy process of the blockchain management platform, and the target node queries the blockchain for the height of the blockchain according to the identifier of the blockchain, and comprises:
the target node calls the agent process to determine a data read-write port of the corresponding block chain process according to the identification of the block chain;
the target node calls the proxy process to encapsulate the block height query request into a block height request packet according to the protocol specification of the data read-write port;
and the target node calls the proxy process to transmit the block height request packet to the data read-write port so as to read the block height of the block chain from the block chain process.
7. The method according to claim 5 or 6, wherein an agent process of the blockchain management platform runs on the target node, and the target node receives a data acquisition request sent by the blockchain management platform and acquires an inquiry result corresponding to the data inquiry request from a corresponding blockchain process, including:
the target node receives a data acquisition request sent by the block chain management platform;
the target node calls the agent process to determine a data read-write port of the corresponding block chain process according to the identification of the block chain;
the target node calls the agent process to package the data acquisition request into a data reading request packet according to the protocol specification of the data reading and writing port;
and the target node calls the proxy process to transmit the data reading request packet into the data reading and writing port so as to read the query result corresponding to the data query request from the block chain process.
8. A blockchain management platform, comprising:
a receiving unit, configured to receive a data query request submitted by a user through a terminal device, where the data query request includes an identifier of a block chain;
a determining unit, configured to determine, according to the identifier of the blockchain, a plurality of nodes corresponding to the blockchain;
the determining unit is further configured to determine, from the plurality of nodes, a target node of the block chain, where data on the chain is the latest;
an obtaining unit, configured to obtain, from the target node, a query result corresponding to the data query request, where the query result includes block data corresponding to a block with a highest degree in the block chain on the target node.
9. A node apparatus, comprising:
a receiving unit, configured to receive a block height query request sent by a block chain management platform, where the block height query request is sent by the block chain management platform to a plurality of nodes corresponding to identifiers of a block chain when the block chain management platform receives a data query request, and the target node is a node of the plurality of nodes where data on the block chain is the latest;
the query unit is used for querying the block height of the block chain according to the identification of the block chain;
a sending unit, configured to send the block height to the blockchain management platform, so that the blockchain management platform determines, according to the block height sent by each node of the multiple nodes, the target node of the blockchain with the latest data on the chain;
the receiving unit is further configured to receive a data acquisition request sent by the blockchain management platform, and acquire a query result corresponding to the data query request from a corresponding blockchain process, where the query result includes blockchain data corresponding to a highest-degree block in the blockchain on the target node;
the sending unit is further configured to send the query result to the blockchain management platform.
10. A computer-readable storage medium, characterized in that the computer storage medium stores a computer program comprising program instructions for execution by a processor for performing the method according to any one of claims 1-7.
CN202010117495.1A 2020-02-25 2020-02-25 Data query method, related equipment and readable storage medium Pending CN111339130A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010117495.1A CN111339130A (en) 2020-02-25 2020-02-25 Data query method, related equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010117495.1A CN111339130A (en) 2020-02-25 2020-02-25 Data query method, related equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN111339130A true CN111339130A (en) 2020-06-26

Family

ID=71185737

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010117495.1A Pending CN111339130A (en) 2020-02-25 2020-02-25 Data query method, related equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN111339130A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112131266A (en) * 2020-08-12 2020-12-25 迅鳐成都科技有限公司 Method, device, system and storage medium for supporting block chain complex query
CN114676166A (en) * 2022-05-26 2022-06-28 阿里巴巴(中国)有限公司 Data processing method and device

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018119587A1 (en) * 2016-12-26 2018-07-05 深圳前海达闼云端智能科技有限公司 Data processing method, device, and system, and information acquisition apparatus
CN108734453A (en) * 2018-05-21 2018-11-02 腾讯科技(深圳)有限公司 Block chain data processing method, device, computer equipment and storage medium
CN109063109A (en) * 2018-07-27 2018-12-21 电子科技大学 A kind of data query system based on ether mill
CN110287226A (en) * 2019-05-10 2019-09-27 深圳壹账通智能科技有限公司 Data query method and device based on block chain
WO2019184210A1 (en) * 2018-03-27 2019-10-03 深圳春沐源控股有限公司 Multi-warehouse data management method based on block chain and related device
CN110490590A (en) * 2019-09-27 2019-11-22 腾讯科技(深圳)有限公司 Activation record querying method, device, equipment and storage medium based on block chain
CN110597887A (en) * 2019-09-27 2019-12-20 腾讯科技(深圳)有限公司 Data management method, device and storage medium based on block chain network
CN110677462A (en) * 2019-09-09 2020-01-10 上海共链信息科技有限公司 Access processing method, system, device and storage medium for multi-block chain network

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018119587A1 (en) * 2016-12-26 2018-07-05 深圳前海达闼云端智能科技有限公司 Data processing method, device, and system, and information acquisition apparatus
WO2019184210A1 (en) * 2018-03-27 2019-10-03 深圳春沐源控股有限公司 Multi-warehouse data management method based on block chain and related device
CN108734453A (en) * 2018-05-21 2018-11-02 腾讯科技(深圳)有限公司 Block chain data processing method, device, computer equipment and storage medium
CN109063109A (en) * 2018-07-27 2018-12-21 电子科技大学 A kind of data query system based on ether mill
CN110287226A (en) * 2019-05-10 2019-09-27 深圳壹账通智能科技有限公司 Data query method and device based on block chain
CN110677462A (en) * 2019-09-09 2020-01-10 上海共链信息科技有限公司 Access processing method, system, device and storage medium for multi-block chain network
CN110490590A (en) * 2019-09-27 2019-11-22 腾讯科技(深圳)有限公司 Activation record querying method, device, equipment and storage medium based on block chain
CN110597887A (en) * 2019-09-27 2019-12-20 腾讯科技(深圳)有限公司 Data management method, device and storage medium based on block chain network

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112131266A (en) * 2020-08-12 2020-12-25 迅鳐成都科技有限公司 Method, device, system and storage medium for supporting block chain complex query
CN112131266B (en) * 2020-08-12 2023-06-13 迅鳐成都科技有限公司 Method, device, system and storage medium for supporting block chain complex query
CN114676166A (en) * 2022-05-26 2022-06-28 阿里巴巴(中国)有限公司 Data processing method and device

Similar Documents

Publication Publication Date Title
CN107396360B (en) Block verification method and device
CN110493261B (en) Verification code obtaining method based on block chain, client, server and storage medium
CN108846010B (en) Method, system, computer system and storage medium for tracing product source in network
CN108734028B (en) Data management method based on block chain, block chain link point and storage medium
CN108470265B (en) Multi-warehouse data management method based on block chain and related equipment
CN110049016B (en) Data query method, device, system, equipment and storage medium of block chain
CN109831527B (en) File processing method, user side, server and readable storage medium
CN110059055B (en) File storage and reading method and device based on distributed private cloud
CN111740966B (en) Data processing method based on block chain network and related equipment
CN109376172B (en) Data acquisition method and system based on block chain
CN111460458B (en) Data processing method, related device and computer storage medium
CN110096551A (en) Credit data storage method, device, equipment and medium based on block chain
CN108769186B (en) Service authority control method and device
CN105337941A (en) Method and device for providing device identifier
CN113094334B (en) Digital service method, device, equipment and storage medium based on distributed storage
US20230079672A1 (en) Cross-chain data transmission method and apparatus, computer device, storage medium, and computer program product
CN112468540B (en) Cloud platform-based data distribution method, equipment and medium
CN111488372A (en) Data processing method, device and storage medium
CN111339130A (en) Data query method, related equipment and readable storage medium
CN110351276A (en) Data processing method, equipment and computer readable storage medium
EP4357950A1 (en) Device management method, system and apparatus
CN108846671B (en) Online secure transaction method and system based on block chain
CN111553669B (en) Transaction routing method, device and computer readable storage medium
CN112564901A (en) Key generation method and system, storage medium and electronic device
CN116011013A (en) Database access method and apparatus, computing device and computer program product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40024708

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination