CN114138867A - Block chain multi-item query method, computer device and storage medium - Google Patents
Block chain multi-item query method, computer device and storage medium Download PDFInfo
- Publication number
- CN114138867A CN114138867A CN202111457961.1A CN202111457961A CN114138867A CN 114138867 A CN114138867 A CN 114138867A CN 202111457961 A CN202111457961 A CN 202111457961A CN 114138867 A CN114138867 A CN 114138867A
- Authority
- CN
- China
- Prior art keywords
- query
- result
- parameter sets
- contract
- query result
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 32
- 238000004806 packaging method and process Methods 0.000 claims abstract description 5
- 238000004590 computer program Methods 0.000 claims description 9
- 230000006870 function Effects 0.000 claims description 8
- 238000010586 diagram Methods 0.000 description 8
- 238000004891 communication Methods 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 2
- 230000007812 deficiency Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000012856 packing Methods 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2458—Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
- G06F16/2471—Distributed queries
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/248—Presentation of query results
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/25—Integrating or interfacing systems involving database management systems
- G06F16/252—Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/547—Remote procedure calls [RPC]; Web services
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Software Systems (AREA)
- Computational Linguistics (AREA)
- Computing Systems (AREA)
- Fuzzy Systems (AREA)
- Mathematical Physics (AREA)
- Probability & Statistics with Applications (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention provides a block chain multi-item query method, computer equipment and a storage medium, wherein the method comprises the following steps: configuring a first query interface supporting one-time query of multiple states; receiving a first query request, and analyzing the first query request to obtain a plurality of first query parameter sets; loading corresponding first contracts according to first contract addresses in the first query parameter sets respectively and querying according to first query keys to obtain first single query results; respectively judging whether the data format of each first single query result is a readable format: if not, performing deserialization to obtain a second single query result; and packaging each first single query result and each second single query result in a readable format to generate a first multi-item query result and returning. The invention improves the query efficiency and reduces the rpc request times received by the block chain node.
Description
Technical Field
The present application relates to the field of blockchain technologies, and in particular, to a blockchain multi-item query method, a computer device, and a storage medium.
Background
In the current blockchain system, only one item of state data can be queried by sending a query request once, and when a plurality of items of data need to be queried, the query can be completed by sending a plurality of query requests, so that blockchain nodes receive a great number of rpc requests during a query service peak period, and the query efficiency of users is low.
Disclosure of Invention
In view of the above-mentioned deficiencies or inadequacies in the prior art, it would be desirable to provide a blockchain multi-item query method, computer device, and storage medium that improve query efficiency and reduce the number of rpc requests received by blockchain nodes.
In a first aspect, the present invention provides a method for querying a plurality of terms in a blockchain applicable to a blockchain node, including:
configuring a first query interface supporting one-time query of multiple states; the first query interface supports a query request comprising a plurality of query parameter groups, and each query parameter group comprises a contract address and a query key of a single query;
receiving a first query request, and analyzing the first query request to obtain a plurality of first query parameter sets;
loading corresponding first contracts according to first contract addresses in the first query parameter sets respectively and querying according to first query keys to obtain first single query results;
respectively judging whether the data format of each first single query result is a readable format: if not, performing deserialization to obtain a second single query result;
and packaging each first single query result and each second single query result in a readable format to generate a first multi-item query result and returning.
In a second aspect, the present invention also provides a computer apparatus comprising one or more processors and a memory, wherein the memory contains instructions executable by the one or more processors to cause the one or more processors to perform a block chain multi-query method provided according to embodiments of the present invention.
In a third aspect, the present invention further provides a storage medium storing a computer program, where the computer program makes a computer execute the block chain multi-item query method provided in accordance with the embodiments of the present invention.
According to the block chain multi-item query method, the computer device and the storage medium provided by the embodiments of the invention, the query interface supporting multi-item query is configured for the block chain nodes, the query request generated by the interface is analyzed and called to obtain a plurality of groups of query parameter sets, the query is respectively carried out according to each group of query parameter sets, and finally, each query result is combined and returned, so that the completion of multi-item query through one query request is realized, the query efficiency is improved, and the rpc request times received by the block chain nodes are reduced.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
fig. 1 is a flowchart of a block chain multi-item query method according to an embodiment of the present invention.
FIG. 2 is a flow diagram of a preferred embodiment of the method shown in FIG. 1.
Fig. 3 is a schematic structural diagram of a computer device according to an embodiment of the present invention.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the present invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Fig. 1 is a flowchart of a block chain multi-item query method according to an embodiment of the present invention.
As shown in fig. 1, in the present embodiment, the present invention provides a method for querying a blockchain multinomial applicable to a blockchain node, including:
s11: configuring a first query interface supporting one-time query of multiple states; the first query interface supports a query request comprising a plurality of query parameter groups, and each query parameter group comprises a contract address and a query key of a single query;
s13: receiving a first query request, and analyzing the first query request to obtain a plurality of first query parameter sets;
s15: loading corresponding first contracts according to first contract addresses in the first query parameter sets respectively and querying according to first query keys to obtain first single query results;
s17: respectively judging whether the data format of each first single query result is a readable format: if not, performing deserialization to obtain a second single query result;
s19: and packaging each first single query result and each second single query result in a readable format to generate a first multi-item query result and returning.
The above method is exemplarily described below by taking the example of configuring the federation chain a that originally does not support multiple queries and performing multiple queries in the federation chain a after configuration.
First, configuring a first query interface supporting one-time query of multiple states and a function module executing steps S13-S19 for a plurality of nodes (which may be one node, part of nodes or all nodes) of the federation chain A according to actual requirements.
With node A1For example, in step S11, node A1The first query interface described above and the function module performing steps S13-S19 are configured.
In particular, the first query interface supports a query request comprising a plurality of query parameter sets query _ para _ i.
Wherein i is an index number of the query parameter set.
The query parameter set query _ para _ i includes two parameters of a single query: contract Address Contract _ Address and query Key Key.
Taking the user side of the user a needing to perform 10 queries as an example, for the original federation chain a, the user side of the user a has to generate 10 query requests and send rpc requests for 10 times; whileFor federation chain A configured through step S11, the client of UserA only needs to call the first query interface to generate the first query request Q comprising 10 query parameter sets query _ para _0-query _ para _91And requests the first query Q by 1 time rpc1Sent to node A1。
In step S13, node a1Receiving a first query request Q1Analysis of Q1To obtain query parameter sets query _ para _0-query _ para _ 9.
In step S15, node a1And respectively carrying out 10 times of single queries according to the 10 query parameter sets, namely query _ para _0-query _ para _ 9.
For example, the contract address addr in query parameter set query _ para _00The contract a is loaded and according to the query key in the query _ para _00Querying to obtain single query result r0;
According to the contract address addr in the query parameter group query _ para _11Loading contract b and according to query key in query _ para _11Querying to obtain single query result r1;
According to the contract address addr in the query parameter group query _ para _21Loading contract b and according to query key in query _ para _22Querying to obtain single query result r2;
……
According to the contract address addr in the query parameter group query _ para _97The contract g is loaded and according to the query key in the query _ para _99Querying to obtain single query result r9。
In step S17, node a1Judging the individual query results r obtained in step S150-r9Whether the data format of (1) is a readable format.
For example, r0-r3、r5、r8-r9Is in a readable format, and r4、r6、r7Is not in a readable format, node A1Are respectively to r4、r6、r7Performing deserialization to obtain r4’、r6’、r7’。
In step S19, node a1To be in a readable format0-r3、r4’、r5、r6’、r7’、r8-r9Packing to generate multiple query results R1And returns to the user end of the user A.
Preferably, the single query result further includes a state parameter (true or false) of the query result, where the state parameter is true, that is, the query is successful, and the state parameter is false, that is, the query is failed (that is, the user end is informed that the query is failed, and the corresponding query result can be ignored).
The above embodiment takes the block chain a as an example, and the user side of the user a needs to perform 10 queries, and exemplarily explains the method shown in fig. 1; in further embodiments, the method shown in fig. 1 is also applicable to different types of block chains such as public chains, and different devices perform any number of multiple queries, which can achieve the same technical effect, and is not limited to the above examples.
Preferably, each first contract comprises a go contract, and the data format of the second single query result is in proto-buffer message format.
FIG. 2 is a flow diagram of a preferred embodiment of the method shown in FIG. 1. As shown in fig. 2, in a preferred embodiment, the method further comprises:
s10: redefining the query function modules of the go contracts into a query result in a proto-buffer message format.
Specifically, also taking the above federation chain a as an example, when each first single query result and each second single query result are unified into a proto-buffer message format, the packaging in step S19 is facilitated.
In a preferred embodiment, each first contract comprises evm contracts, and said querying according to the first query key comprises:
serializing the first query key by abi.
And inputting the serialized first query key into a uniform contract query entrance for query.
Specifically, in this embodiment, the query of the evm contract is performed by serializing the first query key through abi.
The calls [ i ] target is the contract entry address of the ith query, and the calls [ i ] callData is the first query key serialized through abi.
Fig. 3 is a schematic structural diagram of a computer device according to an embodiment of the present invention.
As shown in fig. 3, as another aspect, the present application also provides a computer apparatus including one or more Central Processing Units (CPUs) 301 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)302 or a program loaded from a storage section 308 into a Random Access Memory (RAM) 303. In the RAM303, various programs and data necessary for the operation of the apparatus 300 are also stored. The CPU301, ROM302, and RAM303 are connected to each other via a bus 304. An input/output (I/O) interface 305 is also connected to bus 304.
The following components are connected to the I/O interface 305: an input portion 306 including a keyboard, a mouse, and the like; an output section 307 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 308 including a hard disk and the like; and a communication section 309 including a network interface card such as a LAN card, a modem, or the like. The communication section 309 performs communication processing via a network such as the internet. A drive 310 is also connected to the I/O interface 305 as needed. A removable medium 311 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 310 as necessary, so that a computer program read out therefrom is mounted into the storage section 308 as necessary.
In particular, according to an embodiment of the present disclosure, the method described in any of the above embodiments may be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program comprising program code for performing any of the methods described above. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 309, and/or installed from the removable medium 311.
As yet another aspect, the present application also provides a computer-readable storage medium, which may be the computer-readable storage medium included in the apparatus of the above-described embodiment; or it may be a separate computer readable storage medium not incorporated into the device. The computer readable storage medium stores one or more programs for use by one or more processors in performing the methods described in the present application.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units or modules described in the embodiments of the present application may be implemented by software or hardware. The described units or modules may also be provided in a processor, for example, each unit may be a software program provided in a computer or a mobile intelligent device, or may be a separately configured hardware device. Wherein the designation of a unit or module does not in some way constitute a limitation of the unit or module itself.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention herein disclosed is not limited to the particular combination of features described above, but also encompasses other arrangements formed by any combination of the above features or their equivalents without departing from the spirit of the present application. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.
Claims (6)
1. A blockchain multi-item query method, the method being applicable to blockchain nodes, the method comprising:
configuring a first query interface supporting one-time query of multiple states; wherein the first query interface supports a query request comprising a plurality of query parameter sets, the query parameter sets comprising a contract address and a query key of a single query;
receiving a first query request, and analyzing the first query request to obtain a plurality of first query parameter sets;
loading corresponding first contracts according to first contract addresses in the first query parameter sets respectively and querying according to first query keys to obtain first single query results;
respectively judging whether the data format of each first single query result is a readable format: if not, performing deserialization to obtain a second single query result;
and packaging each first single query result and each second single query result in a readable format to generate a first multi-item query result and returning.
2. The method of claim 1, wherein each of the first contracts comprises a go contract, and wherein the data format of the second single query result is a proto-buffer message format.
3. The method of claim 2, further comprising:
redefining the query function modules of the go contracts into a query result in a proto-buffer message format.
4. The method of claim 1, wherein each of the first contracts comprises evm contracts, and wherein querying according to a first query key comprises:
serializing the first query key by abi.
And inputting the serialized first query key into a uniform contract query entrance for query.
5. A computer device, the device comprising:
one or more processors;
a memory for storing one or more programs,
the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method recited in any of claims 1-4.
6. A storage medium storing a computer program, characterized in that the program, when executed by a processor, implements the method according to any one of claims 1-4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111457961.1A CN114138867A (en) | 2021-12-02 | 2021-12-02 | Block chain multi-item query method, computer device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111457961.1A CN114138867A (en) | 2021-12-02 | 2021-12-02 | Block chain multi-item query method, computer device and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114138867A true CN114138867A (en) | 2022-03-04 |
Family
ID=80386942
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111457961.1A Pending CN114138867A (en) | 2021-12-02 | 2021-12-02 | Block chain multi-item query method, computer device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114138867A (en) |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109710859A (en) * | 2019-01-21 | 2019-05-03 | 北京字节跳动网络技术有限公司 | Data query method and apparatus |
CN110609679A (en) * | 2019-09-17 | 2019-12-24 | 腾讯科技(深圳)有限公司 | Data processing method, data processing device, computer readable storage medium and computer equipment |
CN110943911A (en) * | 2019-12-19 | 2020-03-31 | 北京轻元科技有限公司 | High-efficiency data transmission method for Internet of things based on protobuf |
US20200133949A1 (en) * | 2018-10-26 | 2020-04-30 | Alibaba Group Holding Limited | Data processing method, apparatus, and device |
CN111259044A (en) * | 2020-01-15 | 2020-06-09 | 网易(杭州)网络有限公司 | Data query method, device, equipment and medium |
CN111782647A (en) * | 2020-05-29 | 2020-10-16 | 易联众信息技术股份有限公司 | Block data storage method, system, medium and equipment of EOS network |
CN112613866A (en) * | 2020-12-17 | 2021-04-06 | 中国工商银行股份有限公司 | Data access method and device applied to block chain |
WO2021129062A1 (en) * | 2019-12-27 | 2021-07-01 | 中国银联股份有限公司 | Data query method, apparatus, device and system, and medium |
CN113094395A (en) * | 2021-03-19 | 2021-07-09 | 杭州复杂美科技有限公司 | Data query method, computer device and storage medium |
-
2021
- 2021-12-02 CN CN202111457961.1A patent/CN114138867A/en active Pending
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20200133949A1 (en) * | 2018-10-26 | 2020-04-30 | Alibaba Group Holding Limited | Data processing method, apparatus, and device |
CN109710859A (en) * | 2019-01-21 | 2019-05-03 | 北京字节跳动网络技术有限公司 | Data query method and apparatus |
CN110609679A (en) * | 2019-09-17 | 2019-12-24 | 腾讯科技(深圳)有限公司 | Data processing method, data processing device, computer readable storage medium and computer equipment |
CN110943911A (en) * | 2019-12-19 | 2020-03-31 | 北京轻元科技有限公司 | High-efficiency data transmission method for Internet of things based on protobuf |
WO2021129062A1 (en) * | 2019-12-27 | 2021-07-01 | 中国银联股份有限公司 | Data query method, apparatus, device and system, and medium |
CN111259044A (en) * | 2020-01-15 | 2020-06-09 | 网易(杭州)网络有限公司 | Data query method, device, equipment and medium |
CN111782647A (en) * | 2020-05-29 | 2020-10-16 | 易联众信息技术股份有限公司 | Block data storage method, system, medium and equipment of EOS network |
CN112613866A (en) * | 2020-12-17 | 2021-04-06 | 中国工商银行股份有限公司 | Data access method and device applied to block chain |
CN113094395A (en) * | 2021-03-19 | 2021-07-09 | 杭州复杂美科技有限公司 | Data query method, computer device and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110019080B (en) | Data access method and device | |
CN111538605B (en) | Distributed data access layer middleware and command execution method and device | |
US11243921B2 (en) | Database expansion system, equipment, and method of expanding database | |
WO2018035799A1 (en) | Data query method, application and database servers, middleware, and system | |
US20180220292A1 (en) | Blockchain-Based Subscription Management | |
CN110909022A (en) | Data query method and device | |
CN108363741B (en) | Big data unified interface method, device, equipment and storage medium | |
EP2693349A1 (en) | A system and method for massive call data storage and retrieval | |
US20060149760A1 (en) | LDAP bulk append | |
CN114356971A (en) | Data processing method, device and system | |
CN111752939A (en) | Data processing method, device, computer system and medium for multiple systems | |
CN110764769B (en) | Method and device for processing user request | |
CN114327799B (en) | Distributed transaction processing method and device, electronic equipment and storage medium | |
CN113094395B (en) | Data query method, computer device and storage medium | |
CN112099864A (en) | Asynchronous data processing method and device | |
CN110705935B (en) | Logistics document processing method and device | |
CN113297305A (en) | Session state processing method, device, equipment and storage medium | |
CN114138867A (en) | Block chain multi-item query method, computer device and storage medium | |
CN110347654B (en) | Method and device for online cluster characteristics | |
CN115357606A (en) | Data source query method, system, computer equipment and storage medium | |
CN107977448A (en) | The method and apparatus for loading multi-data source data | |
CN112231405B (en) | Data storage device | |
US20120303571A1 (en) | Optimal multi-factor evaluation in computing systems | |
CN111506644B (en) | Application data processing method and device and electronic equipment | |
CN113535768A (en) | Production monitoring method and device |
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 |