CN110096381B - Method, device, equipment and medium for realizing remote procedure call - Google Patents

Method, device, equipment and medium for realizing remote procedure call Download PDF

Info

Publication number
CN110096381B
CN110096381B CN201910389697.9A CN201910389697A CN110096381B CN 110096381 B CN110096381 B CN 110096381B CN 201910389697 A CN201910389697 A CN 201910389697A CN 110096381 B CN110096381 B CN 110096381B
Authority
CN
China
Prior art keywords
message
remote procedure
procedure call
call request
feedback
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
CN201910389697.9A
Other languages
Chinese (zh)
Other versions
CN110096381A (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.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and 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 Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201910389697.9A priority Critical patent/CN110096381B/en
Publication of CN110096381A publication Critical patent/CN110096381A/en
Application granted granted Critical
Publication of CN110096381B publication Critical patent/CN110096381B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • 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/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Telephonic Communication Services (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The embodiment of the invention discloses a method, a device, equipment and a medium for realizing remote procedure call. The method is applied to a block chain node, wherein a message center and at least one functional module are locally deployed on the block chain node, and the method comprises the following steps: the message center registers message subscription requirements for the functional module according to a remote procedure call request initiated by the functional module, and takes the functional module as a subscriber, wherein the remote procedure call request is sent to one or more other nodes in a block chain network; and when the message center receives feedback messages of other nodes aiming at the remote process calling request, the message center feeds back calling results corresponding to the feedback messages to the subscriber according to the corresponding message subscription requirements. The scheme of the embodiment of the invention can exert the advantages of decentralized multi-node of the blockchain system when the remote procedure call function is realized.

Description

Method, device, equipment and medium for realizing remote procedure call
Technical Field
The embodiment of the invention relates to a data transmission technology in a block chain system, in particular to a method, a device, equipment and a medium for realizing remote procedure call.
Background
In the prior art, a device may need to make a Remote Procedure Call (RPC) according to some requirements. For example, an application on a certain mobile terminal needs to send an RPC request to a corresponding service server to obtain a feedback result. As can be seen, RPC technology is typically based on a server/client schema to implement function calls.
The blockchain system is a typical decentralized network system, and generally includes a plurality of blockchain nodes, between which data can be exchanged to implement functions supported by the blockchain. The blockchain system generally implements communication between nodes based on a Peer-to-Peer network (p 2p network for short), that is, a network module may be arranged on a node, and the respective network modules of the node perform communication interaction based on a p2p protocol.
Therefore, when the program in the blockchain node needs to implement the RPC function, the program is not matched with the decentralized blockchain network implemented based on the p2p network, and the call mode of the client/server cannot be implemented, and the advantages of decentralized multiple nodes of the blockchain system cannot be exerted.
Disclosure of Invention
Embodiments of the present invention provide a method, an apparatus, a device, and a medium for implementing remote procedure call, so as to exert the advantages of decentralized multi-node of a blockchain system when implementing a remote procedure call function.
In a first aspect, an embodiment of the present invention provides a method for implementing a remote procedure call, where the method is applied to a blockchain node, where the blockchain node is locally deployed with a message center and at least one function module, and the method includes:
the message center registers message subscription requirements for the functional module according to a remote procedure call request initiated by the functional module, and takes the functional module as a subscriber, wherein the remote procedure call request is sent to one or more other nodes in a block chain network;
and when the message center receives feedback messages of other nodes aiming at the remote process calling request, the message center feeds back calling results corresponding to the feedback messages to the subscriber according to the corresponding message subscription requirements.
In a second aspect, an embodiment of the present invention further provides a method for implementing a remote procedure call, where the method is applied to a blockchain node, where the blockchain node is locally deployed with a message center and at least one function module, and the method includes:
the message center registers message subscription requirements for the functional module according to a remote procedure call request initiated by the functional module, and takes the functional module as a subscriber, wherein the remote procedure call request is sent to one or more other nodes in a block chain network;
and when the message center receives feedback messages of other nodes aiming at the remote process calling request, the message center feeds back calling results corresponding to the feedback messages to the subscriber according to the corresponding message subscription requirements.
In a third aspect, an embodiment of the present invention further provides an apparatus for implementing remote procedure call, where the apparatus is configured in a message center of a blockchain node, and the blockchain node is locally deployed with the message center and at least one functional module, and the apparatus includes:
a subscription requirement registration module, configured to register a message subscription requirement for the function module according to a remote procedure call request initiated by the function module, and use the function module as a subscriber, where the remote procedure call request is sent to one or more other nodes in a blockchain network;
and the calling result feedback module is used for feeding back a calling result corresponding to the feedback message to the subscriber according to the corresponding message subscription requirement when receiving the feedback message of other nodes aiming at the remote process calling request.
In a fourth aspect, an embodiment of the present invention further provides an apparatus for implementing a remote procedure call, where the apparatus is configured to a function module of a blockchain node, and the blockchain node is locally deployed with a message center and at least one function module, and the apparatus includes:
the request generation and sending module is used for generating a remote procedure call request and sending the remote procedure call request to one or more other nodes in the block chain network;
a registration request module, configured to use the remote procedure call request as a message subscription requirement, and request the message center to register the message subscription requirement;
and the calling result acquisition module is used for acquiring the calling result of the remote procedure call fed back by the message center when other nodes provide feedback messages to the message center aiming at the remote procedure call request.
In a fifth aspect, an embodiment of the present invention further provides an apparatus, where the apparatus includes:
one or more processors;
a memory for storing one or more programs;
when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement a method for implementing a remote procedure call as described in any embodiment of the invention.
In a sixth aspect, the embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method for implementing a remote procedure call according to any embodiment of the present invention.
According to the technical scheme of the embodiment of the invention, a message center and at least one functional module are locally deployed at a block chain node, the message center registers a message subscription requirement for the functional module according to a remote process call request initiated by the functional module, and the functional module is used as a subscriber, wherein the remote process call request is sent to one or more other nodes in a block chain network; and when the message center receives feedback messages of other nodes aiming at the remote process calling request, the message center feeds back calling results corresponding to the feedback messages to the subscriber according to the corresponding message subscription requirements. According to the technical scheme of the embodiment of the invention, the message center is locally deployed at the block chain node, and the remote process call request generated by the local function module can register the subscription requirement in the message center. When other nodes provide feedback information to the node, the message center finds the initiator of the remote procedure call request corresponding to the feedback information according to the registration of the subscription requirement, so as to perform feedback. Therefore, the problem that the nodes communicate with each other in the p2p network but cannot identify the specific function module initiating the remote procedure call request inside the node is solved. Therefore, the RPC technology can be realized in the blockchain network, the multi-node advantage of a decentralized network is also exerted, and the function module does not need to fixedly initiate a remote procedure call request to a certain specific node.
Drawings
Fig. 1 is a schematic diagram of a local structure deployment of a blockchain node according to an embodiment of the present invention;
FIG. 2 is a flowchart of a method for implementing a remote procedure call according to an embodiment of the present invention;
fig. 3 is a flowchart of a method for implementing a remote procedure call according to a second embodiment of the present invention;
fig. 4 is a flowchart of an implementation method of a remote procedure call according to a third embodiment of the present invention;
fig. 5 is a flowchart of a method for implementing a remote procedure call according to a fourth embodiment of the present invention;
fig. 6 is a flowchart of a method for implementing a remote procedure call according to a fifth embodiment of the present invention;
fig. 7 is a block diagram of an apparatus for implementing a remote procedure call according to a sixth embodiment of the present invention;
fig. 8 is a block diagram of an apparatus for implementing a remote procedure call according to a seventh embodiment of the present invention;
fig. 9 is a schematic structural diagram of an apparatus according to an eighth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Before introducing the embodiment of the present invention, a local deployment situation of a block link point in the embodiment of the present invention is described, and specifically, fig. 1 is a schematic local structure deployment diagram of a block link node provided in the embodiment of the present invention. As shown in fig. 1, a message center 10 and at least one functional module 11 are locally deployed in a block chain node according to an embodiment of the present invention, where the message center 10 may be a processing process pre-deployed in a node, and the message center 10 may implement functions of registering a message subscription requirement, receiving and feeding back a call result 12 to the functional module 11, and the like. The message center 10 is normally always in the on state except for special cases such as local node device off. The functional module 11 is a module that is pre-deployed inside a node and used for implementing some functions, where the functional module 11 may be deployed inside the node in the form of hardware and/or software (which may be system-level software, application-level software, or a subroutine that implements some functions), and there are many functions that the functional module 11 can implement, for example, implementing a transfer function, a verification function, a data writing and deleting function, and the like, which is not limited in this embodiment. After generating a remote procedure call request, the functional module 11 of the embodiment of the present invention sends the request to one or more nodes in the block chain network; and, the subscription requirement registration of the remote procedure call request is performed to the message center 10; the message center acquires and processes feedback messages provided by other nodes, and feeds back the required calling result 12 to the functional module 11. Specifically, how the block link point deployed in the embodiment of the present invention implements the detailed execution process of the remote procedure call will be described in detail in the following embodiments.
Example one
Fig. 2 is a flowchart of a method for implementing a remote procedure call according to an embodiment of the present invention, where the embodiment is applicable to a situation where a decentralized manner is used to implement a remote procedure call in a blockchain network. The method may be executed by a block chain node, and preferably may be executed by a message center in the block chain node, where it should be noted that, in the block chain node according to the embodiment of the present invention, the message center and at least one functional module are locally deployed. The method may be implemented by an implementation means of a remote procedure call configured in a blockchain node, for example, an implementation means of a remote procedure call in a message center configured in a blockchain node. The device can be implemented in a software and/or hardware manner, and can be integrated in an electronic device bearing a blockchain node, and the method specifically includes the following steps:
s201, the message center registers the message subscription requirement for the function module according to the remote procedure call request initiated by the function module, and takes the function module as a subscriber.
Wherein the remote procedure call request is sent to one or more other nodes in a blockchain network.
A Remote Procedure Call (RPC) request may be a request to request a service from a remote computer program over a network without knowledge of underlying network technology protocols. The remote procedure call request is a request which is generated when the function module has a remote procedure call requirement and is used for requesting other equipment to feed back a call result. And (4) optional. The remote procedure call requirement can be generated when the functional module needs to remotely call data from other equipment in the process of running the program code corresponding to the hardware or software of the functional module. For example, if the local node device is a lightweight node device that does not store blockchain data, a remote procedure call request for calling the balance data of the account a may be generated if the transfer transaction function module in the local node device needs to call the balance data of the account a.
In an embodiment of the present invention, after initiating a remote procedure call request, the functional module sends the request to one or more other nodes in the blockchain network. The transmissions are preferably broadcast to other nodes in the blockchain network via a peer-to-peer network. Alternatively, the transmission may be in unicast or multicast form to one or more other nodes.
Since the function module is an internal program of the node, when other nodes feed back a message of a call result to the node, it is impossible to locate to which function module the feedback message is provided. Therefore, in the embodiment of the present invention, when the function module initiates the remote procedure call request, the function module further registers the message subscription requirement with the message center.
Optionally, in the embodiment of the present invention, the message center acquires a remote procedure call request initiated by the function module, and then executes message subscription. There are many ways to obtain the data, and the embodiment of the present invention is not limited thereto. For example, after the function module initiates a remote procedure call request, it may trigger to start a related program code of the message center, and use the generated remote procedure call request as an input parameter of the program code, at this time, the message center will receive the remote procedure call request initiated by the function module. The message center may also receive the remote procedure call request initiated by the function module by intercepting the remote procedure call request generated by each function module in the local node, for example, the message center is provided with a monitoring process, the monitoring process monitors each function module deployed in the local node in real time, and when it is monitored that a certain function module generates the remote procedure call request, the message center intercepts the message request to obtain the remote procedure call request.
The message subscription requirement may refer to a data call requirement corresponding to a remote procedure call request initiated by the function module, for example, if the remote procedure call request requests to call the current block data, the message subscription requirement may be: subscribing feedback information of the current block data; if the remote procedure call request is a request for calling a transfer transaction intelligent contract, the message subscription requirement at this time may be: and subscribing feedback information of the transfer transaction intelligent contract.
In the embodiment of the invention, after receiving the remote procedure call request, the message center can take the remote procedure call request as a message subscription requirement and register the message subscription requirement for the functional module, so that when the message center subsequently acquires the feedback messages of other nodes in the block chain network, the message center can timely and accurately feed back the call results corresponding to the feedback messages to all subscribers. For example, after a message subscription request for subscribing the current block data is registered for the first functional module, and after the message center acquires the current block data fed back by each server node, the current block data can be fed back to the first functional module according to the registered message subscription requirement. Optionally, registering a message subscription requirement for a functional module may be registering the functional module as a subscriber and registering a call result requiring feedback for the subscriber. The subscriber may refer to a party with a message subscription requirement, and in the embodiment of the present invention, the subscriber may be a functional module that initiates a remote procedure call request. Specifically, there are many ways for the message center to register message subscription requirements for the function module according to the remote procedure call request. For example, the method may be that a call message type corresponding to the remote procedure call request is analyzed, and a message subscription requirement for a message queue of the message type is registered for the function module; the method can also be used for determining a callback function corresponding to the remote procedure call request according to the remote procedure call request, and registering a result generated by the callback function as a feedback result of the message subscription requirement; other ways may also be adopted to register the message subscription requirement for the function module, which is not limited in this embodiment of the present invention. Optionally, a specific method for how to register the message subscription requirement of the message queue for the message type for the function module, how to determine the callback function according to the remote procedure call request, and register the callback function as the feedback result of the message subscription requirement will be described in detail in the following embodiments.
Further, there may be situations where different functional modules in a blockchain node need to be called with the same data at the same time or for a period of time. When the message center receives a remote procedure call request initiated by the functional module and executes the message subscription requirement for the registration of the functional module, the message center can identify whether the remote procedure call request has the message subscription requirement; if not, the message center registers the message subscription requirement for the functional module and takes the functional module as a subscriber; if yes, the message center adds the functional module as a subscriber of the existing message subscription requirement. When other nodes in the network feed back a plurality of same messages according to the remote procedure call request, the message center can refuse to receive subsequent repeated messages within the set effective time.
Specifically, if for a certain remote procedure call request, the message center has registered a message subscription requirement corresponding to the remote procedure call request for a certain functional module before obtaining the remote procedure call request this time, and the message subscription requirement is not cancelled (in a general case, for a message subscription requirement, after a call result is fed back to a subscriber, the message center may cancel the message subscription requirement), it indicates that the remote procedure call request received by the message center this time has a message subscription requirement in the process of the message center, and at this time, it is not necessary to register a new message subscription requirement for the functional module that sends the request again, and a functional module that sends the remote procedure call request this time may be added to the subscriber corresponding to the existing message subscription requirement. If the process of the message center does not have the message subscription requirement corresponding to the received remote procedure call request, the message subscription requirement can be registered for the functional module sending the request according to the received remote procedure call request, and the functional module is used as the subscriber.
S202, when the message center receives the feedback message of other nodes aiming at the remote process calling request, the message center feeds back the calling result corresponding to the feedback message to the subscriber according to the corresponding message subscription requirement.
For example, if the remote invocation request is to acquire current block data, the feedback message of the other node may be the data of the current block at this time. If the remote overcalling request is to obtain the transfer transaction intelligent contract, the feedback message of other nodes at the moment can be the data of the block in which the transfer transaction intelligent contract is stored, and can also be the transfer transaction intelligent contract. The call result may be data that the function module sends a remote procedure call request and is desired to call, which may be a feedback message received by the message center, or may be data obtained after further processing of the feedback message is required. For example, if the data to be called when the function module sends the remote procedure call request is a transfer transaction intelligent contract, at this time, if the feedback message is data of a block in which the transfer transaction intelligent contract is stored, the feedback message needs to be further processed, and the transfer transaction intelligent contract is found out from the data of the block in which the transfer transaction intelligent contract is stored as a call result corresponding to the feedback message; if the feedback message is the transfer transaction intelligent contract, the feedback message is the corresponding calling result.
Optionally, when the local node receives a feedback message sent by a node willing to call data in each node of the remote procedure call request, the message center may monitor the feedback message, determine each subscriber registered with the message subscription requirement according to the message subscription requirement corresponding to the message, and feed back a call result corresponding to the feedback message to each corresponding subscriber. It should be noted that, in the embodiment of the present invention, when the message center performs the feedback of the invocation result corresponding to the feedback message to the subscriber according to the corresponding message subscription requirement, the adopted mode depends on the mode of registering the message subscription requirement. Specifically, how to perform the operation of this step according to different ways of registering message subscription requirements will be described in detail in the following embodiments.
Alternatively, when a remote procedure call request is sent to a plurality of nodes in the blockchain network, a plurality of feedback messages fed back by the plurality of nodes may be received. When the message center receives a plurality of feedback messages of a plurality of nodes aiming at the remote procedure call request, forming a message array by the plurality of feedback messages; and the message center feeds back the message array to the subscriber according to the corresponding message subscription requirement so that the subscriber can obtain the calling result by screening from the message array. Specifically, when the message center receives a plurality of feedback messages, the message center may not perform screening processing on the plurality of feedback messages, but directly form a message array from the plurality of received feedback messages, determine a subscriber who registers the message subscription requirement according to the message subscription requirement corresponding to the message array, and feed back the message array to each subscriber who registers the message subscription requirement, and each subscriber performs analysis and screening on data in the message array to determine a final calling result. Optionally, the process of analyzing and screening the data in the message array by the functional module as the subscriber may be to select the data with the highest repetition rate from the message array as a final calling result; or selecting data fed back by the trusted node from the message array as a final calling result; or the data fed back by nodes with a ratio greater than a preset ratio (for example, 80%) in the message array may be used as the final calling result.
It should be noted that, in the embodiment of the present invention, for the registered message subscription requirement, after the calling result corresponding to the message subscription requirement is fed back to the subscriber, the message center may log off the message subscription requirement, and release the storage space. Optionally, in order to facilitate that a subsequent functional module can quickly find a call result when the message subscription requirement exists, in the embodiment of the present invention, after the call result corresponding to the message subscription requirement is fed back to the subscriber, the message subscription requirement is not immediately cleared (for example, cleared after the preset time is reserved), but the subscriber that has obtained the call result is deleted from the subscriber that has the message subscription requirement, so as to ensure that the subscriber is not repeatedly sent a subscription message reading notification.
According to the technical scheme of the embodiment of the invention, the message center is locally deployed at the block chain node, and the remote process call request generated by the local function module can register the subscription requirement in the message center. When other nodes provide feedback information to the node, the message center finds the initiator of the remote procedure call request corresponding to the feedback information according to the registration of the subscription requirement, so as to perform feedback. Therefore, the problem that the nodes communicate with each other in the p2p network but cannot identify the specific function module initiating the remote procedure call request inside the node is solved. Therefore, the RPC technology can be realized in the blockchain network, the multi-node advantage of a decentralized network is also exerted, and the function module does not need to fixedly initiate a remote procedure call request to a certain specific node.
Example two
Fig. 3 is a flowchart of a method for implementing remote procedure call according to a second embodiment of the present invention, where this embodiment performs further optimization on the basis of the foregoing embodiment, and specifically provides a specific introduction of a specific case where a message queue is used to register a message subscription requirement for a function module, so as to implement remote procedure call, where the method specifically includes:
s301, the message center determines whether the message type of the message to be called has a message queue of a corresponding type according to the remote procedure calling request, wherein the number of the message queues is at least one.
The message type may be obtained by classifying the content of the message data that needs to be called by the remote procedure call request. The message type may include at least one of: a block data query message, a transaction data query message, and an intelligent contract invocation message. Optionally, the block chain data query message has a coarser granularity than the transaction data query message and the intelligent contract message, so that the block chain data query message can be further divided into a current block data query message, a historical block data query message, and the like. It should be noted that, the present embodiment does not limit the type of the divided message, and the type of the message may be divided according to the actual situation.
In the embodiment of the present invention, one or more message queues may be registered in the process of the message center, and are used to store received feedback messages fed back by other nodes in the blockchain network, and in the embodiment, each message type is provided with a message queue storing the type of feedback message in the process of the message center. Optionally, the message queue in the message center process may be preset (that is, at least one message queue corresponding to each message type is preset); or may be created in real time as a new message type is generated. Optionally, the message queue corresponding to the message type with high calling frequency may be set as a long-term message queue; and setting the message queue corresponding to the message type with low calling frequency as a short-term message queue. The long-term message queue may be a message queue that is fixedly present in the message center process, and for the short-term message queue, when there is no data in the message queue or there is no data subscribed by the subscriber to the message queue, the message queue may be logged off, and the storage space is released, so as to set up a message queue corresponding to another message type.
Optionally, the message center may first determine, according to the remote procedure call request, a message type to which message data that the function module initiates the request needs to be called belongs, and then determine whether at least one message queue corresponding to the message type exists in a process of the message center. For example, if the message center recognizes that the remote procedure call request is a request to call the current block data, the remote procedure call request may be analyzed first to determine that the current block data that the function module initiates the request is to call belongs to the block data query message type, and then determine whether a message queue corresponding to the block data query message type exists in the process of the message center. Alternatively, the function module may explicitly specify the message type to be subscribed to the message center.
S302, if the corresponding message queue exists, the message center registers the message subscription requirement aiming at the message queue of the corresponding type for the functional module, and takes the functional module as a subscriber.
In the embodiment of the invention, if a message queue of the message type to which the message to be called belongs exists in the process of the message center, the message subscription requirement for acquiring the data to be called from the message queue can be directly registered for the functional module initiating the remote procedure call request, and the functional module is taken as the subscriber of the message queue. For example, if a message queue corresponding to the block data query message type exists in the process of the message center, the message subscription requirement for invoking the current block data from the message queue of the block data query message type may be directly registered for the functional module at this time, and the functional module initiating the remote procedure invocation request at this time is used as the subscriber.
Optionally, if there is no message queue of the message type to which the message needs to be called in the process of the message center, after at least one new message queue is created for the message type in the process of the message center, the message subscription requirement for the message queue of the corresponding type registered for the function module is executed, and the function module is used as the subscriber.
It should be noted that, in the embodiment of the present invention, for one message queue, there may be multiple message subscription requirements and multiple subscribers.
S303, when the message center receives the feedback message of other nodes aiming at the remote procedure call request, the message center identifies the message type of the feedback message.
Optionally, in the embodiment of the present invention, after receiving the message fed back by the other node, the message center needs to identify the type to which the feedback message belongs first because the feedback message is to be added to the message queue for the subscriber to call. Specifically, when the message type to which the feedback message belongs is identified, if the feedback message includes message type related information (such as a message type identifier) to which the feedback message belongs, the message type to which the feedback message belongs may be directly identified and determined from the message type related information. If the feedback message does not contain the information related to the message type, the content of the feedback message can be analyzed, and the message type of the feedback message is further determined. For example, if the feedback message received by the message center from the other node is the current block data, the current block data content in the feedback message is analyzed to obtain that the feedback data is the block data, and at this time, the type of the feedback message is determined as the type of the block data query message.
S304, the message center adds the feedback message to the message queue of the corresponding type according to the message type.
Optionally, after determining the message type to which the feedback message belongs, the message center may directly add the received feedback messages fed back by each node to the message queue of the message type corresponding to the feedback message. For example, if current block data fed back by 3 nodes of the block chain network is received, the current block data fed back by the 3 nodes may be all added to the message queue of the corresponding block data query message type.
Optionally, the feedback messages added to the message queue are subject to a first-in first-out principle, wherein the stored data includes the feedback messages newly added this time and the feedback messages added in history. For the data stored in the message queue, it is uncertain whether all the subscribers have read the required data from the message queue, and it is uncertain whether other subscribers also need to call the data in the message queue; therefore, after the data stored in the message queue is read by the subscriber, the data clearing operation is not executed, but only the feedback message is added into the message queue, when the data in the message queue reaches the upper storage limit, the data which is firstly added into the message queue is automatically overflowed according to a first-in first-out principle, and at the moment, the overflowed data is deleted from the message queue by default. Optionally, queue storage spaces of different sizes may be set for the message queues in advance according to characteristics of data stored in the message queues (e.g., the size of a memory occupied by the data).
S305, the message center informs at least one subscriber to read the new message in the message queue according to at least one message subscription requirement corresponding to the message queue as a calling result.
Optionally, for the message subscription requirement of the message queue for which each subscriber registers a corresponding message type, for each message queue, at least one message subscription requirement is corresponding to each message queue, and at least one subscriber exists for each message subscription requirement, at this time, all subscribers registering the message requirement may be notified to read new data from the message queue according to each message subscription requirement corresponding to the message queue.
For example, when the message subscription requirement is registered for the subscriber, a message subscription requirement for calling current block data is registered for the subscriber 1, a message subscription requirement for calling block data of 101 th block is registered for the subscriber 2, and a message subscription requirement for calling block data of 10 th to 20 th blocks is registered for the subscriber 3, and the message subscription requirements of the three subscribers all correspond to the block data query message type. After the message center adds the received feedback message to the message queue of the block data query message type, the message subscription requirements corresponding to the message queue include a message subscription requirement for calling current block data, a message subscription requirement for calling 101 th block data, and a message subscription requirement for calling 10 th-20 th block data, so that the newly added messages in the message queue are read by the subscriber 1, the subscriber 2, and the subscriber 3 corresponding to the three calling requirements as a calling result.
It should be noted that the newly added message in the message queue is not necessarily a call result corresponding to the message subscription requirement, so in the embodiment of the present invention, when the message center notifies at least one subscriber to read the newly added message in the message queue, there may be some call results that the subscriber does not read the newly added message in the message queue, for example, if the newly added message in the message queue is current block data, the subscriber 2 and the subscriber 3 cannot find the block data to be called from the newly added message in the message queue. However, since the remote procedure call process is usually performed in real time, a feedback message for the remote procedure call request is usually received by the functional module after the remote procedure call request is initiated, so that in the actual operation process, the probability that the subscriber does not read the required call result in the message queue is relatively low.
According to the technical scheme of the embodiment of the invention, when the function module registers the message subscription requirement, a mode of registering the message queue corresponding to the message type for the function module is adopted, one message queue can correspond to a plurality of subscribers, the registration amount of the message subscription requirement is greatly reduced, the efficiency of registering the message subscription requirement for the function module by the message center is improved, and further the efficiency of remote process calling is improved.
EXAMPLE III
Fig. 4 is a flowchart of a method for implementing remote procedure call according to a third embodiment of the present invention, where this embodiment performs further optimization on the basis of the foregoing embodiments, and specifically gives a specific introduction of a specific case where a callback function is used to register a message subscription requirement for a function module, so as to implement remote procedure call, where the method specifically includes:
s401, the message center registers a message subscription requirement for the function module according to the remote process call request, determines a callback function corresponding to the remote process call request, registers the callback function as a feedback result of the message subscription requirement, and takes the function module as a subscriber.
The callback function may be a function having a certain function, which may be used to determine data required for the message subscription requirement from feedback messages fed back by one or more nodes in the blockchain network. Optionally, the callback function may have functions including, but not limited to, an indexing function, a decryption function, and the like. For example, a callback function of the index function may be used to query transaction data of the account a from a large amount of block data, or to query some intelligent contract, etc.; for the callback function of the decryption function, the callback function can be used for decrypting the encrypted feedback data to obtain the decrypted feedback data.
Optionally, when the function module initiates a remote procedure call request, the request already includes message data to be called and a callback function required for calling the message data. At this time, when the message center registers the message subscription requirement for the function module according to the remote procedure call request, the message subscription requirement corresponding to the message data to be called can be registered for the function module according to the message data to be called included in the request, the callback function corresponding to the request is determined as the callback function corresponding to the remote procedure call request, the result processed by the callback function is used as the feedback result of the message subscription requirement, namely, the call result is fed back to the subscriber, and the function module initiating the remote procedure call request is used as the subscriber of the message subscription requirement. The callback function may generally be a common program provided by a system level program of block chain nodes.
For example, if the remote procedure call request initiated by the function module is a transaction record calling the account a from the current block, and the required callback function is a callback function having an index transaction record function, at this time, the message center may register, for the function module, a subscription requirement for calling the transaction record of the user a according to the remote procedure call request, and determine that the callback function corresponding to the remote procedure call request is a callback function having an index transaction record function, register a result processed by the callback function as a feedback result of the message subscription requirement, and the function module serves as a subscriber of the subscription requirement for calling the transaction record of the user a.
S402, when the message center receives feedback messages of other nodes aiming at the remote process call request, a callback function and a subscriber are determined according to corresponding message subscription requirements.
Optionally, when receiving a feedback message of another node for a remote procedure call request, the message center needs to determine, according to a message subscription requirement corresponding to the remote procedure call request, a callback function registered as a feedback result of the message subscription requirement and a subscriber corresponding to the message subscription requirement.
For example, if for a remote procedure call request initiated by a function module to call a transaction record of an account a from a current block, a feedback message of other nodes in a block chain is current block data, at this time, the message center may determine, according to the remote procedure call request initiated by the function module, that a message subscription requirement is the transaction record of the account a called from the current block, and since in S402, a callback function registered for a feedback result of the message subscription requirement is a callback function having an index transaction record function, at this time, it may be determined that the callback function is a callback function having an index transaction record function according to the message subscription requirement, and a subscriber is a function module corresponding to the message subscription requirement.
And S403, the message center calls a callback function to process the content in the feedback message, a call result is formed, and the call result is fed back to the subscriber.
Optionally, after the callback function and the subscriber are determined, the message center may call the determined callback function to process the received feedback message of the other node for the remote procedure call request, so as to form a call result. Specifically, the message center may use the received feedback information as an input parameter of the callback function, run a program code related to the callback function, determine that a result output by the callback function is a call result, and then feed back the call result to the subscriber. For example, the message center determines that the callback function is a callback function with an index transaction recording function, the subscriber is a function module, the callback function with the index transaction recording function can be called at this time, the received current block data fed back by other nodes according to the remote overcall request is processed, the transaction record of the account a contained in the callback function is found out and used as a calling result, and the found transaction record of the account a is fed back to the function module.
Optionally, in the embodiment of the present invention, there are many ways for the message center to feed back the invocation result to the subscriber, for example, the invocation result may be directly pushed to the subscriber. Or adding the push result into a certain message queue, and sending a subscription reading notification to the subscriber to notify the subscriber to read the call result in the message queue. The calling result may also be fed back to the subscriber in other manners, which is not limited in this embodiment.
According to the technical scheme of the embodiment of the invention, when the function module registers the message subscription requirement, and the callback function is registered as the feedback result of the message subscription requirement. The calling result required by the subscriber can be accurately fed back through the callback function, the subscriber can quickly and accurately obtain the calling result without searching from all feedback messages, the power consumption of the subscriber is reduced, and the efficiency of remote process calling is improved.
Example four
Fig. 5 is a flowchart of a method for implementing a remote procedure call according to a fourth embodiment of the present invention, where this embodiment is applicable to a case where a decentralized manner is used to implement a remote procedure call in a blockchain network. The method may be performed by a blockchain node, preferably by a functional module in the blockchain node. The block link point in this embodiment is similar to the above embodiments, and a message center and at least one functional module are locally deployed at the block link point. The method may be implemented by an implementation means of a remote procedure call configured in a blockchain node, for example, an implementation means of a remote procedure call configured in a functional module in a blockchain node. The apparatus can be implemented in software and/or hardware, and can be integrated in an electronic device carrying the blockchain node.
It should be noted that the remote procedure call request based on the message center in the foregoing embodiment is initiated by the functional module in this embodiment, and when the message center in the foregoing embodiment receives the feedback message of other nodes, the message center feeds back the call result of the feedback message to the functional module in this embodiment according to the corresponding message subscription requirement. The message center of the above embodiment interacts with the functional module of the present embodiment, and a decentralized manner may be adopted in a blockchain network to complete a remote procedure call operation.
As shown in fig. 5, the method specifically includes the following steps:
s501, the function module generates a remote procedure call request and sends the remote procedure call request to one or more other nodes in the block chain network.
Optionally, when the function module in the blockchain node has a remote procedure call requirement, a remote procedure call request for requesting other nodes to feed back a call result is generated. For example, if the local node device is a lightweight node device that does not store blockchain data, a remote procedure call request for calling the balance data of the account a may be generated if the transfer transaction function module in the local node device needs to call the balance data of the account a.
The function module broadcasts and sends remote procedure call requests to a plurality of nodes in the blockchain network preferably through the p2p network, so as to fully obtain the feedback result of the plurality of nodes and exert the advantage of decentralizing the plurality of nodes. Preferably, the remote procedure call request can also be sent to other nodes in a unicast or multicast mode.
S502, the function module takes the remote procedure call request as a message subscription requirement and requests the message center to register the message subscription requirement.
In the embodiment of the invention, after the functional module initiates a remote procedure call request, the initiated remote procedure call request is provided to the message center as the message subscription requirement.
Specifically, the operation of the message center may include: registering a message subscription requirement for the functional module according to the remote procedure call request, and taking the functional module as a subscriber; and when receiving feedback messages of other nodes aiming at the remote process call request, feeding back the call result corresponding to the feedback message to the subscriber according to the corresponding message subscription requirement. The above-mentioned specific implementation method has been described in detail in the foregoing embodiments, and is not described herein again.
Optionally, in this embodiment of the present invention, after the functional module uses the remote procedure call request as a message subscription requirement and requests the message center to register the message subscription requirement, a subscription monitoring process may be started to monitor a subscription message reading notification sent by the message center, and after the subscription message reading notification sent by the message center is monitored, it indicates that the message center has already acquired data that the functional module needs to call, and at this time, S503 is executed to acquire a call result of the remote procedure call fed back by the message center.
S503, when other nodes provide feedback information to the information center aiming at the remote procedure call request, the function module obtains the call result of the remote procedure call fed back by the information center.
Optionally, the manner in which the message center feeds back the call result to the function module depends on the manner in which the message center registers the message subscription requirement for the function module, for example, if the message center registers the message subscription requirement for the message queue of the message type to which the message to be called belongs, the message center identifies the message type to which the feedback message belongs when receiving the feedback message of the remote procedure call request from another node; adding the feedback message into a message queue of a corresponding type according to the type of the message; and informing at least one subscriber to read the newly added message in the message queue as a calling result according to at least one message subscription requirement corresponding to the message queue. For this situation, the functional module may search for a call result required for obtaining from a message queue read by the message center notification as a subscriber. Optionally, there are many data in the message queue, but not all the data are call data required by the function module, so that the function module may sequentially traverse the data in the message queue to obtain the data required to be called, if the data required to be called is not obtained, it may be that when a subscription message reading notification is received next time, it is searched from the message queue whether the newly added data is the data required to be called, if the data required to be called is obtained, the function module may feed back a message call success message to the message center, and after the message center receives the message call success message, it is default that the message subscription requirement of the subscriber is completed, and the message subscription requirement is cancelled.
If the message center registers a message subscription requirement for the function module, determines a callback function corresponding to the remote procedure call request, and registers the callback function as a feedback result of the message subscription requirement, when the message center receives a feedback message of other nodes aiming at the remote procedure call request, the callback function and a subscriber are determined according to the corresponding message subscription requirement; and calling the callback function to process the feedback message to form a calling result, and feeding the calling result back to the subscriber. For the situation, if the message center directly pushes the calling result to the subscriber, the functional module as the subscriber can directly obtain the calling result of the remote procedure call fed back by the message center; if the message center adds the push result into a certain message queue and sends a subscription message reading notice to inform the subscriber to read the call result from the certain message queue, the functional module is taken as the subscriber to read the call result of the remote procedure call from the notified message queue according to the message reading notice.
Alternatively, when a remote procedure call request is sent to a plurality of nodes in the blockchain network, a plurality of feedback messages fed back by the plurality of nodes may be received. When the message center receives a plurality of feedback messages of a plurality of nodes aiming at the remote procedure call request, forming a message array by the plurality of feedback messages; and the message center feeds back the message array to the subscriber according to the corresponding message subscription requirement. At this time, the function module obtains the call result of the remote procedure call fed back by the message center, and the call result comprises: if the obtained calling result of the remote procedure call fed back by the message center is a message array, the function module screens and obtains the calling result according to the repetition proportion of the contents of a plurality of feedback messages in the message array or the node condition of providing the plurality of feedback messages.
Specifically, when the message center receives a plurality of feedback messages, the message center does not perform screening processing on the plurality of feedback messages, but directly forms a message array with the plurality of received feedback messages, according to the message subscription requirement corresponding to the message array, a subscriber who registers the message subscription requirement is determined, the message array is fed back to each subscriber who registers the message subscription requirement, and each subscriber analyzes and screens data in the message array to determine a final calling result. Specifically, the process of analyzing and screening the data in the message array by the functional module as the subscriber may be to select the data with the highest repetition rate from the message array as the final calling result; or selecting data fed back by the trusted node from the message array as a final calling result; or the data fed back by nodes with a ratio greater than a preset ratio (for example, 80%) in the message array may be used as the final calling result.
It should be noted that, although the embodiment of the present invention is described in the context of implementing a remote procedure call by interaction between one function module and a message center deployed in a block chain, the embodiment of the present invention is not limited to the case that the message center can only perform an implementation method of a remote procedure call by interaction with one function module at a time, and for a message center deployed in a block link point, the embodiment of the present invention can concurrently implement an implementation method of a remote procedure call by aiming at multiple function modules in the block link point.
According to the technical scheme of the embodiment of the invention, the message center is locally deployed at the block chain node, and after the local function module generates the remote process call request, the subscription registration of the feedback message is carried out to the message center. The message center determines the calling result and feeds the calling result back to the function module, thereby realizing remote procedure calling. Therefore, the problem that the node cannot identify which function module initiates the remote procedure call request after receiving the feedback message in the p2p network is solved, a fixed server is not required to be arranged for each function module, the remote procedure call service is allowed to be requested to a plurality of nodes in the network, and the advantages of decentralized multi-node of the blockchain system are exerted when the remote procedure call function is realized.
EXAMPLE five
Fig. 6 is a flowchart of a method for implementing a remote procedure call according to a fifth embodiment of the present invention. On the basis of the foregoing embodiments, this embodiment provides a preferred example, which needs to be implemented by matching a message center and a function module in a blockchain node in a process of implementing a remote procedure call.
As shown in fig. 6, the method includes:
s601, the function module generates a remote procedure call request and sends the request to one or more other nodes in the block chain network.
S602, the function module takes the remote procedure call request as a message subscription requirement, and requests the message center to register the message subscription requirement.
S603, the message center acquires the subscription requirement of the registration message.
S604, the message center registers the message subscription requirement for the function module according to the remote procedure call request, and takes the function module as a subscriber.
And S605, when receiving the feedback message of the remote process call request from other nodes, the message center feeds back the call result corresponding to the feedback message to the subscriber according to the corresponding message subscription requirement.
And S606, the functional module acquires the call result of the remote procedure call fed back by the message center.
According to the technical scheme of the embodiment of the invention, the message center is locally deployed at the block chain node, and the remote process call request generated by the local function module can register the subscription requirement in the message center. When other nodes provide feedback information to the node, the message center finds the initiator of the remote procedure call request corresponding to the feedback information according to the registration of the subscription requirement, so as to perform feedback. Therefore, the problem that the nodes communicate with each other in the p2p network but cannot identify the specific function module initiating the remote procedure call request inside the node is solved. Therefore, the RPC technology can be realized in the blockchain network, the multi-node advantage of a decentralized network is also exerted, and the function module does not need to fixedly initiate a remote procedure call request to a certain specific node.
EXAMPLE six
Fig. 7 is a block diagram of an apparatus for implementing a remote procedure call according to a sixth embodiment of the present invention, where the apparatus may configure a message center associated with a blockchain node. The block chain node of the present embodiment is locally deployed with a message center and at least one functional module. The device can execute the implementation method for remote procedure call provided by the first embodiment to the third embodiment and the fifth embodiment of the invention, and specifically execute the corresponding functional modules and the beneficial effects of the method. As shown in fig. 7, the apparatus includes:
a subscription requirement registration module 701, configured to register a message subscription requirement for the function module according to a remote procedure call request initiated by the function module, and use the function module as a subscriber, where the remote procedure call request is sent to one or more other nodes in a blockchain network;
a calling result feedback module 702, configured to, when receiving a feedback message of the remote procedure call request from another node, feed back a calling result corresponding to the feedback message to the subscriber according to the corresponding message subscription requirement.
According to the technical scheme of the embodiment of the invention, the message center is locally deployed at the block chain node, and the remote process call request generated by the local function module can register the subscription requirement in the message center. When other nodes provide feedback information to the node, the message center finds the initiator of the remote procedure call request corresponding to the feedback information according to the registration of the subscription requirement, so as to perform feedback. Therefore, the problem that the nodes communicate with each other in the p2p network but cannot identify the specific function module initiating the remote procedure call request inside the node is solved. Therefore, the RPC technology can be realized in the blockchain network, the multi-node advantage of a decentralized network is also exerted, and the function module does not need to fixedly initiate a remote procedure call request to a certain specific node.
Further, the remote procedure call request is broadcast to other nodes in the blockchain network through the peer-to-peer network.
Further, the subscription requirement registering module 701 is specifically configured to:
determining whether a message type to which a message to be called belongs has a message queue of a corresponding type according to the remote procedure call request, wherein the number of the message queues is at least one;
and if the corresponding message queue exists, registering the message subscription requirement aiming at the message queue of the corresponding type for the functional module.
Further, the message type includes at least one of: a block data query message, a transaction data query message, and an intelligent contract invocation message.
Further, the call result feedback module 702 is specifically configured to:
when receiving a feedback message of other nodes aiming at the remote procedure call request, identifying the message type of the feedback message;
adding the feedback message into a message queue of a corresponding type according to the type of the message;
and notifying at least one subscriber to read the newly added message in the message queue as a calling result according to at least one message subscription requirement corresponding to the message queue.
Further, the subscription requirement registering module 701 is further specifically configured to:
registering a message subscription requirement for the functional module according to the remote procedure call request, determining a callback function corresponding to the remote procedure call request, and registering the callback function as a feedback result of the message subscription requirement;
correspondingly, the call result feedback module 702 is further specifically configured to:
when feedback messages of other nodes aiming at the remote process call request are received, determining a callback function and a subscriber according to the corresponding message subscription requirements;
and calling the callback function to process the content in the feedback message to form a calling result, and feeding the calling result back to the subscriber.
Further, the subscription requirement registering module 701 is further configured to:
identifying whether a message subscription requirement already exists in the remote procedure call request;
if not, registering a message subscription requirement for the functional module, and taking the functional module as a subscriber;
and if so, adding the functional module as a subscriber of the existing message subscription requirement.
Further, the call result feedback module 702 is further specifically configured to:
when a plurality of feedback messages of a plurality of nodes aiming at the remote procedure call request are received, forming a message array by the plurality of feedback messages;
and feeding back the message array to the subscriber according to the corresponding message subscription requirement so that the subscriber can obtain a calling result by screening from the message array.
EXAMPLE seven
Fig. 8 is a block diagram of an apparatus for implementing a remote procedure call according to a seventh embodiment of the present invention, where the apparatus may be configured in a functional module associated with a blockchain node. The block chain node of the present embodiment is locally deployed with a message center and at least one functional module. The device can execute the implementation method for remote procedure call provided by the fourth to fifth embodiments of the present invention, and specifically execute the corresponding functional modules and beneficial effects of the method. As shown in fig. 8, the apparatus includes:
a request generation and transmission module 801, configured to generate a remote procedure call request and transmit the remote procedure call request to one or more other nodes in the blockchain network;
a registration request module 802, configured to use the remote procedure call request as a message subscription requirement, and request the message center to register the message subscription requirement;
a calling result obtaining module 803, configured to obtain, when another node provides a feedback message to the message center for the remote procedure call request, a calling result of the remote procedure call fed back by the message center.
According to the technical scheme of the embodiment of the invention, the message center is locally deployed at the block chain node, and the remote process call request generated by the local function module can register the subscription requirement in the message center. When other nodes provide feedback information to the node, the message center finds the initiator of the remote procedure call request corresponding to the feedback information according to the registration of the subscription requirement, so as to perform feedback. Therefore, the problem that the nodes communicate with each other in the p2p network but cannot identify the specific function module initiating the remote procedure call request inside the node is solved. Therefore, the RPC technology can be realized in the blockchain network, the multi-node advantage of a decentralized network is also exerted, and the function module does not need to fixedly initiate a remote procedure call request to a certain specific node.
Further, the above apparatus further comprises:
a message monitoring module, configured to use the remote procedure call request as a message subscription requirement by the registration request module 802, and start a subscription monitoring process after requesting the message center to register the message subscription requirement, so as to monitor a subscription message reading notification sent by the message center.
Further, the calling result obtaining module 803 is specifically configured to:
and if the obtained calling result of the remote procedure call fed back by the message center is a message array, screening to obtain the calling result according to the repetition proportion of the contents of a plurality of feedback messages in the message array or the condition of nodes providing a plurality of feedback messages.
Example eight
Fig. 9 is a schematic structural diagram of an apparatus according to an eighth embodiment of the present invention, and fig. 9 shows a block diagram of an exemplary apparatus suitable for implementing the embodiment of the present invention. The device shown in fig. 9 is only an example and should not bring any limitation to the function and the scope of use of the embodiments of the present invention. The device may typically be a device configured with blockchain nodes.
As shown in fig. 9, device 900 is in the form of a general purpose computing device. The components of device 900 may include, but are not limited to: one or more processors or processing units 916, a memory 928, and a bus 918 that couples the various system components including the memory 928 and the processing unit 916.
Bus 918 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Device 900 typically includes a variety of computer system readable media. Such media can be any available media that is accessible by device 900 and includes both volatile and nonvolatile media, removable and non-removable media.
The memory 928 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)930 and/or cache memory 932. Device 900 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 934 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 9, and typically referred to as a "hard disk drive"). Although not shown in FIG. 9, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 918 through one or more data media interfaces. Memory 928 may include at least one program product having a set (e.g., at least one) of program modules configured to carry out the functions of embodiments of the invention.
A program/utility 940 having a set (at least one) of program modules 942, which may include but are not limited to an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may include an implementation of a network environment, may be stored in, for example, the memory 928. The program modules 942 generally perform the functions and/or methodologies of embodiments described herein.
Device 900 may also communicate with one or more external devices 914 (e.g., keyboard, pointing device, display 924, etc.), with one or more devices that enable a user to interact with the device 900, and/or with any devices (e.g., network card, modem, etc.) that enable the device 900 to communicate with one or more other computing devices. Such communication may occur via input/output (I/O) interfaces 922. Also, device 900 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN) and/or a public network, such as the Internet) through network adapter 920. As shown in fig. 9, the network adapter 920 communicates with the other modules of the device 900 via the bus 918. It should be appreciated that although not shown in FIG. 9, other hardware and/or software modules may be used in conjunction with device 900, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processing unit 916 executes programs stored in the memory 928 to execute various functional applications and data processing, and the device according to the embodiment of the present invention may be configured in a message center of a block-node device or a functional module of the block-node device, so as to implement the implementation method of the remote procedure call provided by any embodiment of the present invention.
Example nine
An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program (or referred to as computer-executable instructions) is stored, where the program, when being configured on a processor of a message center of a blockchain node, may be used to execute an implementation method of a remote procedure call, where the method includes:
the message center registers message subscription requirements for the functional module according to a remote procedure call request initiated by the functional module, and takes the functional module as a subscriber, wherein the remote procedure call request is sent to one or more other nodes in a block chain network;
and when the message center receives feedback messages of other nodes aiming at the remote process calling request, the message center feeds back calling results corresponding to the feedback messages to the subscriber according to the corresponding message subscription requirements.
The program can be used for executing a realization method of remote procedure call when being configured to be executed by a processor of a functional module of a block chain node, and the method comprises the following steps:
the functional module generates a remote procedure call request and sends the remote procedure call request to one or more other nodes in the blockchain network;
the function module takes the remote procedure call request as a message subscription requirement and requests the message center to register the message subscription requirement;
and when other nodes provide feedback information to the message center aiming at the remote procedure call request, the functional module acquires a call result of the remote procedure call fed back by the message center.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for embodiments of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the embodiments of the present invention have been described in more detail through the above embodiments, the embodiments of the present invention are not limited to the above embodiments, and many other equivalent embodiments may be included without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (15)

1. A method for implementing remote procedure call is applied to a blockchain node, wherein a message center and at least one functional module are locally deployed on the blockchain node, and the method comprises the following steps:
the message center registers message subscription requirements for the functional module according to a remote procedure call request initiated by the functional module, and takes the functional module as a subscriber, wherein the remote procedure call request is sent to one or more other nodes in a block chain network;
and when the message center receives feedback messages of other nodes aiming at the remote process calling request, the message center feeds back calling results corresponding to the feedback messages to the subscriber according to the corresponding message subscription requirements.
2. The method of claim 1, wherein: the remote procedure call request is broadcast to other nodes in the blockchain network through the peer-to-peer network.
3. The method of claim 1, wherein the message center registering message subscription requirements for the functional module based on the remote procedure call request initiated by the functional module comprises:
the message center determines whether the message type of the message to be called has a message queue of a corresponding type according to the remote procedure calling request, wherein the number of the message queues is at least one;
and if the corresponding message queue exists, the message center registers the message subscription requirement aiming at the message queue of the corresponding type for the functional module.
4. The method of claim 3, wherein the message type comprises at least one of: a block data query message, a transaction data query message, and an intelligent contract invocation message.
5. The method according to claim 3, wherein when the message center receives a feedback message of the other node for the remote procedure call request, feeding back a call result corresponding to the feedback message to the subscriber according to the corresponding message subscription requirement comprises:
when the message center receives feedback messages of other nodes aiming at the remote process call request, identifying the message type of the feedback messages;
the message center adds the feedback message to a message queue of a corresponding type according to the type of the message to which the feedback message belongs;
and the message center informs at least one subscriber to read the newly added message in the message queue as a calling result according to at least one message subscription requirement corresponding to the message queue.
6. The method of claim 1, wherein the message center registering message subscription requirements for the functional module based on the remote procedure call request initiated by the functional module comprises:
the message center registers a message subscription requirement for the functional module according to the remote process call request, determines a callback function corresponding to the remote process call request, and registers the callback function as a feedback result of the message subscription requirement;
correspondingly, when the message center receives a feedback message of other nodes for the remote procedure call request, feeding back a call result corresponding to the feedback message to the subscriber according to the corresponding message subscription requirement includes:
when the message center receives feedback messages of other nodes aiming at the remote process call request, determining a callback function and a subscriber according to the corresponding message subscription requirements;
and the message center calls the callback function to process the content in the feedback message to form a calling result, and feeds the calling result back to the subscriber.
7. The method of claim 1, wherein the message center registers a message subscription requirement for the functional module according to the remote procedure call request initiated by the functional module, and using the functional module as a subscriber comprises:
the message center identifies whether the remote procedure call request has a message subscription requirement;
if not, the message center registers the message subscription requirement for the functional module and takes the functional module as a subscriber;
and if so, the message center adds the functional module as a subscriber of the existing message subscription requirement.
8. The method of claim 1, wherein when the message center receives a feedback message of another node for the remote procedure call request, feeding back a call result corresponding to the feedback message to the subscriber according to the corresponding message subscription requirement comprises:
when the message center receives a plurality of feedback messages of a plurality of nodes aiming at the remote procedure call request, the plurality of feedback messages form a message array;
and the message center feeds the message array back to the subscriber according to the corresponding message subscription requirement so that the subscriber can obtain a calling result by screening from the message array.
9. A method for implementing remote procedure call is applied to a blockchain node, wherein a message center and at least one functional module are locally deployed on the blockchain node, and the method comprises the following steps:
the functional module generates a remote procedure call request and sends the remote procedure call request to one or more other nodes in the blockchain network;
the function module takes the remote procedure call request as a message subscription requirement and requests the message center to register the message subscription requirement;
and when other nodes provide feedback information to the message center aiming at the remote procedure call request, the functional module acquires a call result of the remote procedure call fed back by the message center.
10. The method of claim 9, wherein the function module treats the remote procedure call request as a message subscription requirement, and further comprising, after requesting the message center to register the message subscription requirement:
and the functional module starts a subscription monitoring process and monitors a subscription message reading notice sent by the message center.
11. The method of claim 9, wherein the obtaining, by the functional module, the invocation result of the remote procedure call fed back by the message center comprises:
and if the obtained calling result of the remote procedure call fed back by the message center is a message array, the functional module screens and obtains the calling result according to the repetition proportion of the contents of a plurality of feedback messages in the message array or the node condition of a plurality of feedback messages.
12. An apparatus for implementing a remote procedure call, configured to a message center of a blockchain node, the blockchain node having the message center and at least one function module deployed locally, the apparatus comprising:
a subscription requirement registration module, configured to register a message subscription requirement for the function module according to a remote procedure call request initiated by the function module, and use the function module as a subscriber, where the remote procedure call request is sent to one or more other nodes in a blockchain network;
and the calling result feedback module is used for feeding back a calling result corresponding to the feedback message to the subscriber according to the corresponding message subscription requirement when receiving the feedback message of other nodes aiming at the remote process calling request.
13. An apparatus for implementing remote procedure call, configured to a function module of a blockchain node, the blockchain node having a message center and at least one function module deployed locally, the apparatus comprising:
the request generation and sending module is used for generating a remote procedure call request and sending the remote procedure call request to one or more other nodes in the block chain network;
a registration request module, configured to use the remote procedure call request as a message subscription requirement, and request the message center to register the message subscription requirement;
and the calling result acquisition module is used for acquiring the calling result of the remote procedure call fed back by the message center when other nodes provide feedback messages to the message center aiming at the remote procedure call request.
14. An electronic device, characterized in that the device comprises:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement a method for implementing a remote procedure call as recited in any of claims 1-8 or 9-11.
15. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out a method for carrying out a remote procedure call as claimed in any one of claims 1 to 8 or 9 to 11.
CN201910389697.9A 2019-05-10 2019-05-10 Method, device, equipment and medium for realizing remote procedure call Active CN110096381B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910389697.9A CN110096381B (en) 2019-05-10 2019-05-10 Method, device, equipment and medium for realizing remote procedure call

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910389697.9A CN110096381B (en) 2019-05-10 2019-05-10 Method, device, equipment and medium for realizing remote procedure call

Publications (2)

Publication Number Publication Date
CN110096381A CN110096381A (en) 2019-08-06
CN110096381B true CN110096381B (en) 2021-05-07

Family

ID=67447683

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910389697.9A Active CN110096381B (en) 2019-05-10 2019-05-10 Method, device, equipment and medium for realizing remote procedure call

Country Status (1)

Country Link
CN (1) CN110096381B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111526047B (en) * 2020-04-15 2022-11-08 杭州溪塔科技有限公司 Block chain-based message queue design method and device
CN111614761B (en) * 2020-05-21 2021-11-23 腾讯科技(深圳)有限公司 Block chain message transmission method, device, computer and readable storage medium
CN114116883A (en) * 2020-08-28 2022-03-01 京东方科技集团股份有限公司 Data management method, data management device, block chain network and system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106789095A (en) * 2017-03-30 2017-05-31 腾讯科技(深圳)有限公司 Distributed system and message treatment method
TW201810148A (en) * 2016-09-02 2018-03-16 現代財富控股有限公司 Load balancing system for blockchain and method thereof
CN107886329A (en) * 2017-11-28 2018-04-06 无锡井通网络科技有限公司 The clocked flip call method of system contract based on block chain technology
CN108023893A (en) * 2017-12-18 2018-05-11 王松山 A kind of method of block chain data recognizing system
CN108509523A (en) * 2018-03-13 2018-09-07 深圳前海微众银行股份有限公司 Structuring processing method, equipment and the readable storage medium storing program for executing of block chain data
CN108765159A (en) * 2018-06-04 2018-11-06 杭州秘猿科技有限公司 A kind of cochain based on block chain and condition processing method, device and interacted system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW201810148A (en) * 2016-09-02 2018-03-16 現代財富控股有限公司 Load balancing system for blockchain and method thereof
CN106789095A (en) * 2017-03-30 2017-05-31 腾讯科技(深圳)有限公司 Distributed system and message treatment method
CN107886329A (en) * 2017-11-28 2018-04-06 无锡井通网络科技有限公司 The clocked flip call method of system contract based on block chain technology
CN108023893A (en) * 2017-12-18 2018-05-11 王松山 A kind of method of block chain data recognizing system
CN108509523A (en) * 2018-03-13 2018-09-07 深圳前海微众银行股份有限公司 Structuring processing method, equipment and the readable storage medium storing program for executing of block chain data
CN108765159A (en) * 2018-06-04 2018-11-06 杭州秘猿科技有限公司 A kind of cochain based on block chain and condition processing method, device and interacted system

Also Published As

Publication number Publication date
CN110096381A (en) 2019-08-06

Similar Documents

Publication Publication Date Title
EP4120166A1 (en) Blockchain message processing method and apparatus, computer and readable storage medium
CN110096381B (en) Method, device, equipment and medium for realizing remote procedure call
EP2954403B1 (en) Cloud-based streaming data receiver and persister
CN111800443B (en) Data processing system and method, device and electronic equipment
CN111221793B (en) Data mining method, platform, computer equipment and storage medium
EP3126961A1 (en) Monitoring of node.js applications
US20190238352A1 (en) Communication Method and Apparatus
CN113326155A (en) Information processing method, device, system and storage medium
CN110677475A (en) Micro-service processing method, device, equipment and storage medium
CN112838935A (en) Electronic data exchange method and system
CN106598758B (en) Centralized forwarding and calling method and system
CN113055493B (en) Data packet processing method, device, system, scheduling device and storage medium
CN112738153B (en) Gateway selection method, system, device, server and medium in service system
CN111935316B (en) Method and device for acquiring front-end equipment catalog
CN109309583B (en) Information acquisition method and device based on distributed system, electronic equipment and medium
CN113079055B (en) AGV operation data dynamic acquisition method and device
CN111182047B (en) Method and system for transferring files between large data platforms across a network
CN114465997A (en) Data synchronization method and device, electronic equipment and storage medium
CN113094131A (en) Prompt resource display method, device, terminal, server and storage medium
CN111240867A (en) Information communication system and method
CN111901366A (en) Data pushing method, device, equipment and storage medium
CN112291209B (en) Method and device for acquiring front-end equipment catalog
CN112291210B (en) Method and device for acquiring front-end equipment catalog
KR102134552B1 (en) System and method for transmitting message capable of seperate accounting
CN103560976B (en) A kind of method, apparatus and system that control data are sent

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