CN110083745B - Data query method, device and storage medium - Google Patents

Data query method, device and storage medium Download PDF

Info

Publication number
CN110083745B
CN110083745B CN201910359200.9A CN201910359200A CN110083745B CN 110083745 B CN110083745 B CN 110083745B CN 201910359200 A CN201910359200 A CN 201910359200A CN 110083745 B CN110083745 B CN 110083745B
Authority
CN
China
Prior art keywords
main chain
chain node
parallel
block
link
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910359200.9A
Other languages
Chinese (zh)
Other versions
CN110083745A (en
Inventor
马登极
王志文
吴思进
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Fuzamei Technology Co Ltd
Original Assignee
Hangzhou Fuzamei Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Fuzamei Technology Co Ltd filed Critical Hangzhou Fuzamei Technology Co Ltd
Priority to CN201910359200.9A priority Critical patent/CN110083745B/en
Publication of CN110083745A publication Critical patent/CN110083745A/en
Application granted granted Critical
Publication of CN110083745B publication Critical patent/CN110083745B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • G06F16/9024Graphs; Linked lists
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/143Termination or inactivation of sessions, e.g. event-controlled end of session

Abstract

The invention provides a data query method, equipment and a storage medium, wherein the method comprises the following steps: sending a first connection request for connecting the main chain node to the load balancing server, so that the load balancing server establishes a link between the parallel chain node and the first main chain node after receiving the first connection request; generating first query request information for querying first data; sending first query request information to the first main chain node through the link, so that the main chain node judges whether a first main chain block exists according to the first block hash: if not, returning error information to the parallel chain node so that the parallel chain node can receive the error information, disconnecting the link, and returning to send a first connection request for connecting the main chain node to the load balancing server; if so, the first data is returned to the parallel link node. The invention ensures that the data acquired by the parallel chain nodes are consistent without influencing the cloud load balancing function.

Description

Data query method, device and storage medium
Technical Field
The present application relates to the field of block chain technology, and in particular, to a data query method, device, and storage medium.
Background
The current parallel chain supports access to main chain nodes on a plurality of cloud ends, parallel chain transactions are pulled from the main chain and executed in the parallel chain, and in some scenes, the pulled transactions need to be inquired into the main chain or executed by means of certain characteristic results of the main chain;
in the existing scheme, the obtained result is directly inquired from a cloud main chain node through a load balancing technology of a grpc or a cloud load balancing technology, but different main chain nodes may diverge at the current moment to generate a data inconsistent state, and data obtained by parallel chain link points is not expected data; that is, it is assumed that after the parallel link node a pulls a transaction to the main chain node a, the transaction needs to be executed after the main chain query result is executed, after the cloud load is balanced, a link is established between the parallel link node a and the main chain node B, but the main chain node a and the main chain node B are forked, and the result obtained by the parallel link node a from the main chain node B is not the data expected by the parallel link node a, which may cause the problem of data inconsistency between the parallel link nodes.
Disclosure of Invention
In view of the foregoing defects or shortcomings in the prior art, it is desirable to provide a data query method, device, and storage medium for ensuring consistency of data acquired by parallel chain nodes without affecting the function of cloud load balancing.
In a first aspect, the present invention provides a data query method, including:
sending a first connection request for connecting the main chain node to the load balancing server, so that the load balancing server establishes a link between the parallel chain node and the first main chain node after receiving the first connection request;
generating first query request information for querying first data; the first query request message comprises a first block hash of a first main chain block corresponding to the first parallel chain block, and the first block hash is acquired when the transaction of the parallel chain in the first main chain block is synchronized;
sending first query request information to the first main chain node through the link, so that the main chain node judges whether a first main chain block exists according to the first block hash:
if not, returning error information to the parallel chain node so that the parallel chain node can receive the error information, disconnecting the link, and returning to send a first connection request for connecting the main chain node to the load balancing server;
if so, the first data is returned to the parallel link node.
In a second aspect, the present invention provides a data query method, including:
receiving first query request information for querying first data sent by parallel chain nodes through links; after the link sends a first connection request for connecting the main chain node to the load balancing server, the load balancing server receives the link between the main chain node and the parallel chain node established after the first connection request, the first query request information comprises a first block hash of a first main chain block corresponding to the first parallel chain block, and the first block hash is obtained when the parallel chain node synchronizes the transaction of the parallel chain in the first main chain block;
judging whether a first main chain block exists according to the first block hash:
if not, returning error information to the parallel link node;
if so, the first data is returned to the parallel link node.
In a third aspect, the present invention also provides an 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 data query method provided according to embodiments of the present invention.
In a fourth aspect, the present invention also provides a storage medium storing a computer program that causes a computer to execute the data query method provided according to the embodiments of the present invention.
According to the data query method, the data query equipment and the storage medium provided by the embodiments of the invention, the first connection request for connecting the main chain node is sent to the load balancing server, so that the load balancing server establishes the link between the parallel chain node and the first main chain node after receiving the first connection request; generating first query request information for querying first data; the first query request message comprises a first block hash of a first main chain block corresponding to the first parallel chain block, and the first block hash is acquired when the transaction of the parallel chain in the first main chain block is synchronized; sending first query request information to the first main chain node through the link, so that the main chain node judges whether a first main chain block exists according to the first block hash: if not, returning error information to the parallel chain node so that the parallel chain node can receive the error information, disconnecting the link, and returning to send a first connection request for connecting the main chain node to the load balancing server; and if so, returning the first data to the parallel chain link point, and ensuring that the data acquired by the parallel chain link point is consistent without affecting the cloud load balancing function.
The data query method, the device, and the storage medium provided by some embodiments of the present invention further release resources quickly and improve user experience by disconnecting a link and returning a method of sending a first connection request for connecting a main-chain node to a load balancing server if no error information or first data is received within a preconfigured timeout period.
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 data 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 flowchart of a data query method according to an embodiment of the present invention.
Fig. 4 is a schematic structural diagram of an apparatus 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 data query method according to an embodiment of the present invention. As shown in fig. 1, in the present embodiment, the present invention provides a data query method, including:
s11: sending a first connection request for connecting the main chain node to the load balancing server, so that the load balancing server establishes a link between the parallel chain node and the first main chain node after receiving the first connection request;
s12: generating first query request information for querying first data; the first query request message comprises a first block hash of a first main chain block corresponding to the first parallel chain block, and the first block hash is acquired when the transaction of the parallel chain in the first main chain block is synchronized;
s14: sending first query request information to the first main chain node through the link, so that the main chain node judges whether a first main chain block exists according to the first block hash:
otherwise, step S15 is executed: returning error information to the parallel chain nodes so that the parallel chain nodes can receive the error information, disconnecting the link and returning to send a first connection request for connecting the main chain nodes to the load balancing server;
if yes, go to step S16: the first data is returned to the parallel link node.
Specifically, assume that the parallel link node is a, the main chain has a plurality of main chain nodes, and taking main chain node a and main chain node B as an example, main chain node a and main chain node B have a bifurcation, a does not have a requested first main chain block, B has a requested first main chain block; a, after a first connection request for connecting a main chain node is sent to a load balancing server for the first time, the load balancing server establishes a link between a and A;
the first query request message comprises a first block hash of a first main chain block corresponding to the first parallel chain block, and the first block hash is acquired when the transaction of the parallel chain in the first main chain block is synchronized;
in step S11, a sends a first connection request for connecting the main chain node to the load balancing server, and the load balancing server establishes a link between a and a after receiving the first connection request;
in step S12, a generates first query request information for querying the first data;
in step S14, a sends a first query request message to a through a link, and a determines whether a first main-chain chunk exists according to the first chunk hash:
since a does not have the first main-chain block requested by a, step S15 is executed: a returns error information to a, a receives the error information, disconnects the link between a and A, and returns to the step S12;
after returning to step S11, a sends a first connection request for connecting the main chain node to the load balancing server, and the load balancing server establishes a link between a and B after receiving the first connection request;
in step S12, a generates first query request information for querying the first data;
in step S14, a sends a first query request message to B through the link, and B determines whether there is a first main-chain chunk according to the first chunk hash:
since B does not have the first main-chain block requested by a, step S16 is executed: the first data is returned to a.
In further embodiments, the first query request information may be configured as the first timestamp of the first main-chain block corresponding to the first parallel-chain block, or configured as the first meikel root of the first main-chain block corresponding to the first parallel-chain block, as long as the first query request information is configured as the public information of the first main-chain block corresponding to the first parallel-chain block, the same technical effect may be achieved.
In further embodiments, the first parallel chain block may be configured as a first block hash of a first main chain block corresponding to the first parallel chain newly generated block, that is, the first query request information may be configured as a first block hash of a first main chain block corresponding to the first parallel chain newly generated block, and the first parallel chain block may be configured as a first block hash of a first main chain block corresponding to the first parallel chain newly commonly generated block, that is, the first query request information may be configured as a first block hash of a first main chain block corresponding to the first parallel chain newly commonly generated block, which may achieve the same technical effect.
The embodiment ensures that the data acquired by the parallel chain nodes are consistent without affecting the cloud load balancing function.
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:
s13: if no error message or first data is received within the preconfigured timeout period, execute step S18: and disconnecting the link, and sending a first connection request for connecting the main chain node back to the load balancing server.
According to the embodiment, when the parallel chain node cannot receive any error information or first data given by any main chain node, the first connection request for connecting the main chain node is sent to the load balancing server again, the first data is obtained from the main chain node again in the newly established link, resources are released quickly, and user experience is improved.
Fig. 3 is a flowchart of a data query method according to an embodiment of the present invention. As shown in fig. 3, in this embodiment, the present invention provides a data query method, including:
s22: receiving first query request information for querying first data sent by parallel chain nodes through links; after the link sends a first connection request for connecting the main chain node to the load balancing server, the load balancing server receives the link between the main chain node and the parallel chain node established after the first connection request, the first query request information comprises a first block hash of a first main chain block corresponding to the first parallel chain block, and the first block hash is obtained when the parallel chain node synchronizes the transaction of the parallel chain in the first main chain block;
s23: judging whether a first main chain block exists according to the first block hash:
otherwise, step S24 is executed: returning error information to the parallel chain link points;
if yes, go to step S25: the first data is returned to the parallel link node.
The transaction replacement principle of the above embodiment can refer to the method shown in fig. 1, and is not described herein again.
Fig. 4 is a schematic structural diagram of an apparatus according to an embodiment of the present invention.
As shown in fig. 4, as another aspect, the present application also provides an apparatus 400 including one or more Central Processing Units (CPUs) 401 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)402 or a program loaded from a storage section 408 into a Random Access Memory (RAM) 403. In the RAM403, various programs and data necessary for the operation of the device 400 are also stored. The CPU401, ROM402, and RAM403 are connected to each other via a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
The following components are connected to the I/O interface 405: an input section 406 including a keyboard, a mouse, and the like; an output section 407 including a display device such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 408 including a hard disk and the like; and a communication section 409 including a network interface card such as a LAN card, a modem, or the like. The communication section 409 performs communication processing via a network such as the internet. A driver 410 is also connected to the I/O interface 405 as needed. A removable medium 411 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 410 as necessary, so that a computer program read out therefrom is mounted into the storage section 408 as necessary.
In particular, according to an embodiment of the present disclosure, the data query 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 containing program code for performing a method of data querying. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 409, and/or installed from the removable medium 411.
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 data query methods described herein.
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 of the described units 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 (5)

1. A data query method, applied to parallel chain nodes, includes:
sending a first connection request for connecting a main chain node to a load balancing server, so that after the load balancing server receives the first connection request, a link between the parallel chain node and the first main chain node is established;
generating first query request information for querying first data; the first query request message includes a first block hash of a first main chain block corresponding to a first parallel chain block, and the first block hash is obtained when the transaction of the parallel chain in the first main chain block is synchronized;
sending the first query request message to the first main chain node through the link, so that the main chain node judges whether the first main chain block exists according to the first block hash:
if not, returning error information to the parallel chain node so that the parallel chain node receives the error information, disconnecting the link, and returning the first connection request for sending the connection main chain node to the load balancing server;
and if so, returning the first data to the parallel chain node.
2. The method of claim 1, further comprising:
and if the error information or the first data is not received within the preset timeout duration, disconnecting the link and returning the first connection request for connecting the main chain node to the load balancing server.
3. A data query method is applicable to a main chain node and comprises the following steps:
receiving first query request information for querying first data sent by parallel chain nodes through links; after the link sends a first connection request for connecting a main chain node to a load balancing server, the load balancing server receives the link between the main chain node and the parallel chain node established after the first connection request, the first query request information includes a first block hash of a first main chain block corresponding to the first parallel chain block, and the first block hash is obtained when the parallel chain node synchronizes with a transaction of the parallel chain in the first main chain block;
judging whether the first main chain block exists according to the first block hash:
if not, returning error information to the parallel link node;
and if so, returning the first data to the parallel chain node.
4. An apparatus, characterized in that the apparatus comprises:
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-3.
5. 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-3.
CN201910359200.9A 2019-04-30 2019-04-30 Data query method, device and storage medium Active CN110083745B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910359200.9A CN110083745B (en) 2019-04-30 2019-04-30 Data query method, device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910359200.9A CN110083745B (en) 2019-04-30 2019-04-30 Data query method, device and storage medium

Publications (2)

Publication Number Publication Date
CN110083745A CN110083745A (en) 2019-08-02
CN110083745B true CN110083745B (en) 2021-07-06

Family

ID=67417971

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910359200.9A Active CN110083745B (en) 2019-04-30 2019-04-30 Data query method, device and storage medium

Country Status (1)

Country Link
CN (1) CN110083745B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110535922B (en) * 2019-08-15 2021-10-01 杭州复杂美科技有限公司 State data storage method and parallel chain block generation method
CN111008249B (en) * 2019-12-04 2023-04-07 杭州复杂美科技有限公司 Parallel chain block synchronization method, device and storage medium
CN111400752A (en) * 2020-03-12 2020-07-10 杭州城市大数据运营有限公司 Data query method and system based on block chain and electronic equipment
CN111524011B (en) * 2020-05-06 2023-05-30 杭州复杂美科技有限公司 Parallel link consensus validation method, apparatus, and storage medium
CN111639140A (en) * 2020-06-08 2020-09-08 杭州复杂美科技有限公司 Distributed data storage method, device and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109146681A (en) * 2018-07-26 2019-01-04 百度在线网络技术(北京)有限公司 A kind of element processing method, device, equipment and the storage medium of block chain
CN109271446A (en) * 2018-08-30 2019-01-25 杭州复杂美科技有限公司 A kind of parallel chain method of data synchronization, equipment and storage medium
CN109325762A (en) * 2018-08-30 2019-02-12 杭州复杂美科技有限公司 Across the chain method of commerce of parallel chain, equipment and storage medium
CN109587271A (en) * 2018-12-29 2019-04-05 杭州复杂美科技有限公司 Main chain parallel chain architecture system and block synchronous method, equipment and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018094299A2 (en) * 2016-11-19 2018-05-24 Dominic Williams System architecture and method of processing data therein

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109146681A (en) * 2018-07-26 2019-01-04 百度在线网络技术(北京)有限公司 A kind of element processing method, device, equipment and the storage medium of block chain
CN109271446A (en) * 2018-08-30 2019-01-25 杭州复杂美科技有限公司 A kind of parallel chain method of data synchronization, equipment and storage medium
CN109325762A (en) * 2018-08-30 2019-02-12 杭州复杂美科技有限公司 Across the chain method of commerce of parallel chain, equipment and storage medium
CN109587271A (en) * 2018-12-29 2019-04-05 杭州复杂美科技有限公司 Main chain parallel chain architecture system and block synchronous method, equipment and storage medium

Also Published As

Publication number Publication date
CN110083745A (en) 2019-08-02

Similar Documents

Publication Publication Date Title
CN110083745B (en) Data query method, device and storage medium
CN109087204B (en) Cross-chain transaction verification method, device and storage medium
CN110442579B (en) State tree data storage method, synchronization method and equipment and storage medium
US20120323846A1 (en) Sending Category Information
CN110392121B (en) Parallel chain block generation method, device and storage medium
CN110837505B (en) State data storage method, state data synchronization device and storage medium
CN111277639A (en) Method and device for maintaining data consistency
CN109104368B (en) Connection request method, device, server and computer readable storage medium
CN111008249B (en) Parallel chain block synchronization method, device and storage medium
CN111625592A (en) Load balancing method and device for distributed database
CN111338834B (en) Data storage method and device
CN109995585B (en) Exception handling method, device and storage medium
CN110210972B (en) Method, device and storage medium for sending consensus transaction
CN111259074A (en) Block synchronization method, device and storage medium
CN110071952B (en) Service call quantity control method and device
CN107818027B (en) Method and device for switching main name node and standby name node and distributed system
CN112328693A (en) Block synchronization method, device and storage medium
CN111343220B (en) Repeater, distributed file transmission method, distributed file transmission system, medium and electronic equipment
CN111405037A (en) Block synchronization method, device and storage medium
US11153399B2 (en) Facilitating inter-proxy communication via an existing protocol
CN111161072A (en) Block chain-based random number generation method, equipment and storage medium
CN109542981A (en) A kind of system and method, electronic equipment, storage medium that data synchronize
CN110535922B (en) State data storage method and parallel chain block generation method
US20210149709A1 (en) Method and apparatus for processing transaction
CN112688982B (en) User request processing 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
GR01 Patent grant
GR01 Patent grant