WO2022048357A1 - 交易背书方法、装置及存储介质 - Google Patents

交易背书方法、装置及存储介质 Download PDF

Info

Publication number
WO2022048357A1
WO2022048357A1 PCT/CN2021/109254 CN2021109254W WO2022048357A1 WO 2022048357 A1 WO2022048357 A1 WO 2022048357A1 CN 2021109254 W CN2021109254 W CN 2021109254W WO 2022048357 A1 WO2022048357 A1 WO 2022048357A1
Authority
WO
WIPO (PCT)
Prior art keywords
nodes
standby
transaction endorsement
transaction
node
Prior art date
Application number
PCT/CN2021/109254
Other languages
English (en)
French (fr)
Inventor
姚杰
Original Assignee
深圳壹账通智能科技有限公司
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 深圳壹账通智能科技有限公司 filed Critical 深圳壹账通智能科技有限公司
Publication of WO2022048357A1 publication Critical patent/WO2022048357A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • H04L41/0654Management of faults, events, alarms or notifications using network fault recovery
    • H04L41/0668Management of faults, events, alarms or notifications using network fault recovery by dynamic selection of recovery network elements, e.g. replacement by the most appropriate element after failure
    • 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

Definitions

  • the present application relates to the field of blockchain technology, and in particular to a transaction endorsement method, device and storage medium.
  • Blockchain is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
  • a node in the blockchain can provide endorsement services to the client, including the repetition check of transaction IDs, the generation of transaction read-write sets, and the final signature.
  • the master node Under the existing master-standby synchronization architecture, the master node mainly It is responsible for obtaining blocks from the ordering node and performing signature verification and multi-version checking on the blocks, while the standby node mainly provides endorsement services to clients.
  • the inventor realized that under this architecture, once some standby nodes go down, the client cannot collect enough transaction endorsements, resulting in the inability of transactions in the entire blockchain network, which will affect the entire blockchain network. endorsement efficiency.
  • the embodiments of the present application provide a transaction endorsement method, device, and storage medium, which are beneficial to improve the endorsement efficiency of a blockchain network.
  • a first aspect of the embodiments of the present application provides a transaction endorsement method, which is applied to a first master node among multiple master nodes of a blockchain platform, where the blockchain platform includes the multiple master nodes and multiple backup nodes node, each primary node corresponds to multiple standby nodes, including: receiving a transaction endorsement request initiated by a client; selecting M candidate nodes from the multiple standby nodes according to the transaction endorsement request, where M is a positive Integer; detect the node states corresponding to the M candidate nodes; if there are N candidate nodes in the down state among the M candidate nodes, obtain the preset corresponding to the multiple standby nodes Sorting list, the preset sorting list is obtained by sorting multiple resource lists corresponding to the multiple standby nodes, and N is a positive integer less than or equal to M; from the preset sorting list, select the sorting position in the N N standby nodes after the candidate nodes to be selected are target standby nodes, and N target standby nodes are obtained; the N target standby no
  • a second aspect of the embodiments of the present application provides a transaction endorsement device, which is applied to a first master node among multiple master nodes of a blockchain platform, where the blockchain platform includes the multiple master nodes and multiple backup nodes node, each master node corresponds to a plurality of standby nodes, the device includes: a receiving unit, a detection unit, an acquisition unit, a selection unit, a replacement unit, and a sending unit, wherein the receiving unit is used to receive a client-initiated transaction endorsement request; according to the transaction endorsement request, select M candidate nodes from the multiple standby nodes, where M is a positive integer; the detection unit is used to detect the corresponding M candidate nodes node status; the acquiring unit is configured to acquire a preset sorting list corresponding to the multiple standby nodes if there are N standby nodes to be selected in the M standby nodes that are in a down state, and the preset sorting list Suppose that the sorting list is obtained by sorting multiple resource lists corresponding to the multiple stand
  • a third aspect of the embodiments of the present application provides a server, the server includes a processor, a communication interface, a memory, and one or more programs, the processor, the communication interface, and the memory are connected to each other, wherein the memory is used for A computer program is stored, where the computer program includes program instructions, and the processor is configured to invoke the program instructions to execute the method described in the first aspect of the embodiments of the present application, the method including: receiving a transaction initiated by a client endorsement request; according to the transaction endorsement request, select M candidate nodes from multiple standby nodes, where M is a positive integer; detect the node status corresponding to the M candidate nodes; If there are N standby nodes to be selected in the down state, the preset sorting list corresponding to the multiple standby nodes is obtained, and the preset sorting list is sorted by the multiple resource lists corresponding to the multiple standby nodes.
  • N is a positive integer less than or equal to M; select N standby nodes whose sorting positions are after the N candidates to be selected from the preset sorting list as target standby nodes, and obtain N target standby nodes; Replacing the N target standby nodes for the N candidate nodes in the M candidate nodes to obtain M target standby nodes; sending the transaction endorsement request to the M target standby nodes, the The transaction endorsement request is used to indicate the M target standby nodes.
  • a fourth aspect of the embodiments of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for electronic data exchange, wherein the computer program causes a computer to execute the following method: The transaction endorsement request initiated by the terminal; according to the transaction endorsement request, select M candidate nodes from multiple standby nodes, where M is a positive integer; detect the node status corresponding to the M candidate nodes; if the If there are N to-be-selected nodes in the down state among the M to-be-selected nodes, a preset sorting list corresponding to the multiple standby nodes is obtained, and the preset sorting list is composed of multiple standby nodes corresponding to the multiple standby nodes.
  • the resource lists are sorted and obtained, and N is a positive integer less than or equal to M; N standby nodes whose sorting positions are after the N candidates to be selected are selected from the preset sorting list as the target standby nodes, and N are obtained.
  • target backup nodes replace the N target backup nodes among the M target backup nodes to obtain M target backup nodes; send the transaction to the M target backup nodes An endorsement request, where the transaction endorsement request is used to indicate the M target standby nodes.
  • FIG. 1A provides a schematic structural diagram of a node system according to an embodiment of the present application.
  • FIG. 1B provides a schematic flowchart of a transaction endorsement method according to an embodiment of the present application.
  • FIG. 2 provides a schematic flowchart of a transaction endorsement method according to an embodiment of the present application.
  • FIG. 3 provides a schematic structural diagram of a transaction endorsement system according to an embodiment of the present application.
  • FIG. 4 provides a schematic structural diagram of a server according to an embodiment of the present application.
  • FIG. 5 provides a schematic structural diagram of a transaction endorsement device according to an embodiment of the present application.
  • This application may relate to the field of artificial intelligence technology, for example, relevant data may be acquired and processed based on artificial intelligence technology.
  • This application can be applied to endorsement scenarios based on blockchain, for example, it can be specifically applied to the endorsement scenarios of medical data in digital healthcare, such as medical insurance data, and can be specifically applied to the endorsement scenarios of transaction data in financial technology, etc. Etc., the following takes transaction endorsement as an example to illustrate.
  • the servers mentioned in the embodiments of this application may include but are not limited to background servers, component servers, cloud servers, transaction endorsement system servers, or data distribution software servers, etc.
  • the server may provide cloud services, cloud databases, cloud computing, cloud Cloud servers for basic cloud computing services such as functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms.
  • CDN Content Delivery Network
  • FIG. 1A is a schematic structural diagram of a node system provided by an embodiment of the present application.
  • a server which may include a blockchain network
  • the blockchain is a new application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
  • Blockchain essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information to verify its Validity of information (anti-counterfeiting) and generation of the next block.
  • the blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.
  • the FiMax blockchain platform is a blockchain network composed of S3C as the basic framework.
  • the S3C is composed of blockchain solution modules, districts A framework system composed of blockchain kernel module, blockchain privacy protection module and blockchain network management module.
  • the above-mentioned FiMax blockchain platform may include multiple nodes, which may include: ordering nodes (adapter nodes) and peer nodes (data nodes), wherein the peer nodes can be used to store data and execute specific programs.
  • the peer node can be used to store ledgers, smart contracts, etc., and can be used to provide an endorsement service to the client.
  • the endorsement service can be executed based on a program, and the peer node can be a physical server or a virtual server. server.
  • the above-mentioned peer node can be divided into a master node and a slave node; the above-mentioned adapter node can be used to generate a block, and the master node can obtain a block from the adapter node and sign the transaction data corresponding to each transaction in the block.
  • Information for verification and multi-version checking of transaction data, while standby nodes can be used to provide endorsement services to clients.
  • the peer nodes are divided into two types: the primary node and the standby node, which can realize different business requirements in a distributed manner. Each node is used to realize different functions, so as to avoid the failure to continue when one of the nodes is down. business requirements, thereby affecting the operation of the entire blockchain network.
  • the above-mentioned primary node and multiple backup nodes should belong to the same organization, so that information security can be improved.
  • the above-mentioned FiMax blockchain platform may include multiple master nodes, and each master node may correspond to multiple (two or more) standby nodes.
  • each master node may correspond to multiple (two or more) standby nodes.
  • Cocoa receives a transaction endorsement request initiated by the client; Select M candidates to be selected, M is a positive integer; detect the node status corresponding to the M candidates to be selected; if there are N candidates to be selected in the down state of the M candidates to be selected The preset sorting list corresponding to the node.
  • the preset sorting list is obtained by sorting multiple resource lists corresponding to multiple standby nodes, and N is a positive integer less than or equal to M; the sorting positions are selected from the preset sorting list.
  • the N standby nodes after the standby node are the target standby nodes, and N target standby nodes are obtained; the N target standby nodes are replaced by the N standby nodes to be selected among the M standby nodes to obtain M target standby nodes;
  • Each target standby node sends a transaction endorsement request, and the transaction endorsement request is used to instruct the M target standby nodes to endorse the chain code in the transaction endorsement request.
  • multiple standby nodes in the same organization as the first master node can be selected, and when the to-be-selected standby node is down, the one with the higher ranking can be selected according to the preset sorting list.
  • the target standby node replaces the above-mentioned candidate nodes, that is to say, other standby nodes with the best resource conditions are selected to provide endorsement services for the client, which is beneficial to improve the endorsement efficiency.
  • FIG. 1B is a schematic flowchart of a transaction endorsement method provided by an embodiment of the present application.
  • the first master node among multiple master nodes of a blockchain platform includes the multiple master nodes.
  • the embodiments of the present application are applied to a blockchain platform, and the blockchain platform can be built in a server, and the server can be a virtual server or a physical server.
  • the first master node may be the master node in the node system diagram shown in FIG. 1A , which may correspond to a plurality of backup nodes, and may communicate with each backup node.
  • the above-mentioned client can refer to any program that provides services to customers, for example, a banking service client, an insurance service client, a government and enterprise service client, etc., which are not limited here;
  • a transaction is initiated in the blockchain network corresponding to the platform. For example, if user A needs to transfer 1W yuan to user B, a transaction application will be generated, and a transaction endorsement request will be issued to all blocks in the entire blockchain network.
  • the transaction endorsement request is used to prove or declare that the transaction corresponding to the transaction endorsement request is valid, which is conducive to promoting the subsequent transactions.
  • the first master node may, according to the demand of the transaction endorsement request, select M standby nodes to be selected from multiple standby nodes in the same organization, and A transaction endorsement service is provided to the client through the M candidates to be selected, where M is a positive integer.
  • the above-mentioned selecting M candidate nodes from the multiple standby nodes according to the transaction endorsement request may include the following steps: according to the transaction endorsement request, determine the pre-stored multiple resource lists, each resource list corresponds to a standby node; according to the chain code, select M candidate resource lists from the multiple resource lists, and obtain the candidate node corresponding to each candidate resource list, The M candidate nodes to be selected are obtained.
  • the above chain code can generally refer to the code on the chain, which is the business processing logic code according to the state of operating the distributed ledger of the blockchain; specifically, the chain code can be automatically generated when the client initiates a transaction endorsement; the chain code in The parameters can be determined by specific application scenarios.
  • each standby node may correspond to a resource list, and the resource list may include resource information corresponding to the standby node, and the resource information may include but not limited to: hardware configuration information, communication rate and other information.
  • the first master node may sort the multiple standby nodes in advance according to multiple resource lists corresponding to the multiple standby nodes to obtain a preset resource list, and in the preset resource list, the better the hardware configuration information of the standby nodes, and The better the communication rate, the higher the ranking position.
  • a plurality of resource lists corresponding to the plurality of standby nodes can be selected from multiple resource lists that match the information carried in the above chain code, that is, in the above scenario, the Multiple candidate resource lists that match the above parameter information, and select M candidate resource lists that are ranked at the top of the above preset resource list, so as to obtain a candidate node corresponding to each candidate resource list, and obtain M candidate nodes to be selected.
  • determining the multiple pre-stored resource lists according to the transaction endorsement request may include the following steps: determining at least one institution corresponding to the transaction endorsement request according to the transaction endorsement request; For at least one organization, at least one standby node corresponding to each organization is selected to obtain multiple standby nodes; a resource list corresponding to each standby node is determined from a preset resource pool to obtain multiple resource lists.
  • At least one structure corresponding to the above transaction endorsement request can be selected, and multiple standby nodes corresponding to the same organization can be selected to Ensure the security of information.
  • the above-mentioned preset resource pool can be set by the user or the system defaults, which is not limited here; in addition, the above-mentioned preset resource pool can store the resource list corresponding to all standby nodes in the blockchain platform.
  • the certificate information carried in the transaction endorsement request can be obtained, and the certificate information can include but is not limited to: the public key and the signature of the public key; and according to the certificate information, determine at least one institution corresponding to it;
  • the node identification information corresponding to each standby node may be stored in a mechanism, and at least one standby node corresponding to each mechanism may be determined according to at least one node identification information stored correspondingly by each mechanism, thereby obtaining multiple standby nodes.
  • the following steps may be further included: sending the transaction endorsement request to each candidate node to be selected, and after determining all the candidate nodes.
  • the step of detecting the node states corresponding to the M to-be-selected nodes is performed.
  • the node status of each node to be selected can be detected, so as to ensure that feedback information of each node to be selected can be collected.
  • the above-mentioned node state may at least include: down state, normal working state, etc., which are not limited here; wherein, the normal working state may be understood as the normal operation state of the node, for example, the area of the above-mentioned first master node can be obtained normally. Blocks, endorsement services can be provided to clients normally, and so on.
  • the above-mentioned detecting the node states corresponding to the multiple nodes to be selected may include the following steps: if the N heartbeats sent by the N nodes to be selected are not received within a preset period information, it is determined that the N standby nodes to be selected are down, and each standby node to be selected corresponds to a heartbeat message.
  • the above-mentioned preset period may be set by the user or defaulted by the system, which is not limited herein.
  • Heartbeat Message is a message sent by a sender to a receiver, and this message can allow the first master node to determine whether and when the plurality of backup nodes fail or are currently unavailable or down.
  • the above-mentioned first master node can time each node to be selected, and can allocate a timer to each node to be selected, and each timer can correspond to a preset period.
  • the preset period if the preset period is exceeded, it can be determined that the connection of the candidate node to the first master node has timed out, and the node state of the candidate node can also be determined to be down.
  • multiple nodes to be selected can actively detect the working state of the first master node through heartbeat information.
  • the N heartbeat information indicates that the above N candidates to be selected are in a down state, and N is a positive integer less than or equal to M.
  • the first master node does not need to actively detect the working state of each candidate node to be selected, and the candidate node can actively detect the working state of the first master node.
  • the first master node The working state of the node to be selected can be determined directly through the received heartbeat information, which is beneficial to reduce the resource consumption of the first master node.
  • the above-mentioned detecting the node statuses corresponding to the multiple nodes to be selected may further include the following step: if the first master node does not receive the M nodes to be selected within the preset period Corresponding M pieces of heartbeat information, then it is determined that the M to-be-selected nodes are in a down state, and the first master node completes the endorsement operation of the chain code in the transaction endorsement request.
  • the first master node does not receive the heartbeat information of each candidate node to be selected within the preset period, it indicates that the M candidate nodes selected by the first master node are all in a down state. At this time, in order to ensure the entire If the transaction endorsement is carried out effectively, the transaction endorsement can be completed by the first master node, that is, the endorsement operation of the chain code in the transaction endorsement request can be completed by the first master node.
  • N to-be-selected nodes are in the down state among the M to-be-selected nodes, obtain a preset sorting list corresponding to the multiple standby nodes, and the preset sorting list is composed of the multiple standby nodes.
  • the multiple resource lists corresponding to the standby node are sorted and obtained, and N is a positive integer less than or equal to M.
  • the above-mentioned preset sorting list can be obtained by sorting a plurality of resource information corresponding to a plurality of standby nodes in the same organization in advance by the first master node. It can be set by the user or the system defaults, which is not limited here.
  • the resource list corresponding to each standby node may include resource information corresponding to the node, and the resource information may include at least one of the following: hardware configuration information and communication rate, etc., which are not limited herein.
  • the sorting can be performed according to the hardware configuration information and communication rate in the resource list corresponding to each standby node.
  • the standby nodes with good hardware configuration information for example, large remaining available memory
  • high communication rate can be sorted. It is ranked in the front position of the preset sorting list.
  • a weight can be preset for each resource information, and according to the weight and each resource information, the resources of the standby node are scored to obtain multiple score values and hardware configuration information. The better and the higher the communication rate, the higher the score.
  • Multiple standby nodes can be sorted according to multiple score values. The resulting pre-sorted list.
  • N standby nodes corresponding to the sorting positions after the above-mentioned N to-be-selected nodes can be selected from the preset sorting list (It may include any one of the M candidate nodes to be selected, or may not include any one of the M candidate nodes to be selected) as the N target standby nodes.
  • the first one of the N standby nodes to be selected in the above-mentioned downtime situation is used as the starting node, and the N standby nodes that are not in the downtime state are screened backwards as N standby nodes.
  • the target standby node if it encounters any standby node in a down state during the screening process, it can be skipped, and continue to filter down according to the above preset sorting list to obtain N target standby nodes.
  • N target standby nodes with the best resource information can be selected, which is conducive to subsequent effective endorsement.
  • the resources of each standby node are The information is different, that is, the resource configuration information and network status are different, and the endorsement efficiency of the transaction is also different.
  • the N target standby nodes selected above have better resource information than other nodes.
  • the above-mentioned N candidate nodes to be selected exist in the preset sorting list. Compared with the remaining standby nodes in the plurality of standby nodes, the above-mentioned N candidate nodes to be selected are ranked higher in sequence number; After the standby node to be selected in the down state, immediately according to the sorting number in the preset sorting list, the standby node after the sorting number corresponding to the standby node to be selected in the down state is used as a substitute to obtain N target standby nodes, To replace the above-mentioned N standby nodes that are down, M target standby nodes can still be obtained.
  • the number N of the N standby nodes that are in the down state can be determined, and according to the number N, N standby nodes that meet the number N in order are selected from the preset sorting list to replace the above-mentioned N standby nodes.
  • the N standby nodes in the down state form a target standby node set with MN standby nodes that do not appear in the down state to obtain M target standby nodes, so as to complete the subsequent transaction endorsement through the M target standby nodes.
  • the node and its corresponding resource list information may be deleted from the above-mentioned preset sorting list.
  • the M target standby nodes are the M standby nodes with better configuration information among the above-mentioned multiple standby nodes.
  • the transaction endorsement efficiency is compared with that of It is faster for other standby nodes, which is conducive to improving the endorsement efficiency of the entire blockchain network.
  • the above-mentioned transaction endorsement request is used to instruct the M target standby nodes to endorse the chain code in the transaction endorsement request, which may include the following steps: instructing the M target standby nodes Simulate the transaction corresponding to the transaction endorsement request to obtain the transaction endorsement result; record the read set and write set in the transaction process; sign the transaction endorsement result, read set and write set and send it to the client .
  • the above transaction endorsement request can be completed by the above M target standby nodes.
  • each target standby node can obtain a block from the first master node, and the block can correspond to transaction data, and according to the transaction data Simulate the transaction to obtain the transaction endorsement result corresponding to each target standby node; and record the read set and write set of data changes during the transaction process.
  • the read set and write set may include transaction information, and finally the above transaction endorsement results, After the read set and write set are signed according to the preset method, they are sent to the client to complete the transaction endorsement.
  • the transaction endorsement method described in the embodiment of this application is applied to the first master node among the multiple master nodes of the blockchain platform, and the first master node can receive the transaction endorsement request initiated by the client; according to For transaction endorsement request, select M candidate nodes from multiple standby nodes, where M is a positive integer; detect the node status corresponding to M candidate nodes; if there are N candidate nodes in M candidate nodes In the down state, the preset sorting list corresponding to multiple standby nodes is obtained, and the preset sorting list is obtained by sorting multiple resource lists corresponding to multiple standby nodes, and N is a positive integer less than or equal to M; In the list, select N standby nodes after the N standby nodes to be selected as the target standby nodes, and obtain N target standby nodes; replace the N target standby nodes with the N standby nodes to be selected in the M standby nodes to be selected , obtain M target standby nodes; send transaction endorsement requests to M target standby nodes, and the transaction
  • the standby node when the standby node is down, other surviving standby nodes can be selected in time according to the preset sorting list to replace the above-mentioned standby node in the downtime situation, so as to maintain the operation of the entire endorsement operation.
  • the node is the standby node with the higher ranking in the preset sorting list, that is to say, the other standby node with the best resource status is beneficial to improve the endorsement efficiency when providing the endorsement service to the client.
  • FIG. 2 is an example flow chart of a transaction endorsement method disclosed in an embodiment of the present application, which is applied to the first master node among the multiple master nodes of the blockchain platform.
  • the blockchain platform includes the multiple master nodes and multiple backup nodes, each master node corresponds to multiple backup nodes, and the transaction endorsement method may include the following steps.
  • At least one mechanism select at least one standby node corresponding to each mechanism to obtain multiple standby nodes; determine a resource list corresponding to each standby node from a preset resource pool to obtain multiple resource lists.
  • N to-be-selected nodes are down among the M to-be-selected nodes, acquire a preset sorting list corresponding to the multiple standby nodes, where the preset sorting list consists of the multiple standby nodes.
  • the multiple resource lists corresponding to the standby node are sorted and obtained, and N is a positive integer less than or equal to M.
  • the transaction endorsement method described in the embodiment of this application is applied to the first master node among the multiple master nodes of the blockchain platform, and can receive the transaction endorsement request initiated by the client; according to the transaction endorsement request, determine At least one institution corresponding to the transaction endorsement request. According to at least one institution, at least one standby node corresponding to each institution is selected to obtain multiple standby nodes; a resource list corresponding to each standby node is determined from a preset resource pool to obtain multiple resource lists. According to the chain code, M candidate resource lists are selected from multiple resource lists, and the candidate nodes corresponding to each candidate resource list are obtained, and M candidate nodes are obtained. Detect node states corresponding to the M candidate nodes to be selected.
  • a preset sorting list corresponding to multiple standby nodes is obtained, and the preset sorting list is obtained by sorting multiple resource lists corresponding to multiple standby nodes , where N is a positive integer less than or equal to M.
  • N standby nodes whose sorting positions are after the N candidates to be selected are selected as target standby nodes, and N target standby nodes are obtained.
  • the N target standby nodes are replaced by the N to-be-selected standby nodes among the M to-be-selected standby nodes to obtain M target standby nodes.
  • a transaction endorsement request is sent to the M target standby nodes, and the transaction endorsement request is used to instruct the M target standby nodes to endorse the chain code in the transaction endorsement request.
  • multiple standby nodes in the same organization can be selected, and when one of the standby nodes is down, the standby node with a higher ranking can be selected according to the preset sorting list, that is, the resource
  • the other standby nodes in the best condition provide endorsement services for clients, which is beneficial to improve endorsement efficiency.
  • FIG. 3 is an example flow chart of a transaction endorsement method disclosed in an embodiment of the present application, which is applied to the first master node among the multiple master nodes of the blockchain platform.
  • the platform includes multiple master nodes and multiple backup nodes, each master node corresponds to multiple backup nodes, and the transaction endorsement method may include the following steps.
  • the first master node If the first master node has not received the M heartbeat messages corresponding to the M candidates for selection within the preset period, perform determining that the M candidates for selection are in a down state, Then, the first master node completes the endorsement operation of the chain code in the transaction endorsement request.
  • N pieces of heartbeat information sent by the N to-be-selected nodes are not received within a preset period, determine that the N to-be-selected nodes are down, and each to-be-selected node corresponds to one heartbeat information.
  • N to-be-selected nodes are in the down state among the M to-be-selected nodes, obtain a preset sorting list corresponding to the multiple standby nodes, where the preset sorting list consists of the multiple standby nodes.
  • the multiple resource lists corresponding to the standby node are sorted and obtained, and N is a positive integer less than or equal to M.
  • N standby nodes whose sorting positions are after the N candidate nodes to be selected as target standby nodes, and obtain N target standby nodes.
  • the transaction endorsement method described in the embodiment of the present application is applied to the first master node among the multiple master nodes of the blockchain platform, and can receive the transaction endorsement request initiated by the client; according to the transaction endorsement request, from Select M to-be-selected standby nodes from multiple standby nodes, where M is a positive integer. If the first master node has not received the M heartbeat information corresponding to the M candidates to be selected within the preset period, it will execute to determine that the M candidates to be selected are down, and the first master node will complete the endorsement of the transaction The endorsement operation of the chaincode in the request.
  • N pieces of heartbeat information sent by the N to-be-selected nodes are not received within the preset period, it is determined that the N to-be-selected nodes are down, and each to-be-selected node corresponds to one heartbeat information. If there are N to-be-selected nodes in the down state among the M to-be-selected nodes, a preset sorting list corresponding to multiple standby nodes is obtained, and the preset sorting list is obtained by sorting multiple resource lists corresponding to multiple standby nodes , where N is a positive integer less than or equal to M.
  • N standby nodes whose sorting positions are after the N candidates to be selected are selected as target standby nodes, and N target standby nodes are obtained.
  • the N target standby nodes are replaced by the N to-be-selected standby nodes among the M to-be-selected standby nodes to obtain M target standby nodes.
  • a transaction endorsement request is sent to the M target standby nodes, and the transaction endorsement request is used to instruct the M target standby nodes to endorse the chain code in the transaction endorsement request.
  • the backup node with the highest ranking position can be selected according to the preset sorting list to replace the backup node with the above-mentioned downtime situation, so as to maintain the integrity of the entire transaction endorsement.
  • the chain code in the transaction endorsement request can be endorsed by the first master node, which is beneficial to ensure valid transaction endorsement in the blockchain network.
  • FIG. 4 is a schematic structural diagram of a server provided by an embodiment of the present application. As shown in FIG. 4, it includes a processor, a communication interface, a memory, and one or more programs.
  • a processor, a communication interface, and a memory are interconnected, wherein the memory is used to store a computer program, the computer program includes program instructions, the processor is configured to invoke the program instructions, and the one or more program programs include An instruction for performing the following steps: receiving a transaction endorsement request initiated by a client; selecting M candidate nodes from the multiple standby nodes according to the transaction endorsement request, where M is a positive integer; detecting the M node states corresponding to the candidate nodes to be selected; if N of the M candidate nodes to be selected are in a down state, a preset sorting list corresponding to the multiple standby nodes is acquired, and the preset sorting list is obtained.
  • the sorting list is obtained by sorting multiple resource lists corresponding to the multiple standby nodes, and N is a positive integer less than or equal to M; the sorting position is selected from the preset sorting list after the N candidate nodes to be selected
  • the N standby nodes are target standby nodes, and N target standby nodes are obtained; the N target standby nodes are replaced by the N standby nodes to be selected among the M standby nodes to be selected, and M target standby nodes are obtained. ; Send the transaction endorsement request to the M target standby nodes, where the transaction endorsement request is used to indicate the M target standby nodes.
  • the server described in the embodiment of the present application can receive the transaction endorsement request initiated by the client; according to the transaction endorsement request, M candidate nodes to be selected are selected from multiple standby nodes, where M is a positive integer; Node states corresponding to the M candidates for selection; if there are N candidate nodes in the down state among the M candidates for selection, a preset sorting list corresponding to multiple standby nodes is obtained, and the preset sorting list consists of multiple nodes.
  • the multiple resource lists corresponding to each standby node are obtained by sorting, and N is a positive integer less than or equal to M; from the preset sorting list, select N standby nodes whose sorting positions are after the N standby nodes to be selected as the target standby nodes, and obtain N target standby nodes; replace the N target standby nodes among the M candidate standby nodes to obtain M target standby nodes; send a transaction endorsement request to the M target standby nodes, and the transaction endorsement request is used for Instruct M target standby nodes to endorse the chaincode in the transaction endorsement request.
  • the standby node when the standby node is down, other surviving standby nodes can be selected in time according to the preset sorting list to replace the above-mentioned standby node in the downtime situation, so as to maintain the operation of the entire endorsement operation.
  • the node is the standby node with the higher ranking in the preset sorting list, that is to say, the other standby node with the best resource status is beneficial to improve the endorsement efficiency when providing the endorsement service to the client.
  • the program is used to execute the instructions of the following steps: according to the transaction endorsement Request, determine the multiple resource lists stored in advance, each resource list corresponds to a standby node; according to the chain code, select M candidate resource lists from the multiple resource lists, and obtain each candidate resource List the corresponding candidate nodes to be selected, and obtain the M candidate nodes to be selected.
  • the program is used to execute the instructions of the following steps: determining the transaction endorsement according to the transaction endorsement request Request at least one corresponding institution; according to at least one institution, select at least one standby node corresponding to each institution to obtain multiple standby nodes; determine the resource list corresponding to each standby node from the preset resource pool to obtain multiple resource lists .
  • the program is used to execute an instruction of the following steps: sending the transaction endorsement request, and after it is determined that the M candidate nodes to be selected have received the transaction endorsement request, the step of detecting node states corresponding to the M candidate nodes to be selected is performed.
  • the program in terms of detecting the node states corresponding to the plurality of nodes to be selected, the program is configured to execute the instructions of the following steps: if the N waiting nodes are not received within a preset period N pieces of heartbeat information sent by the candidate node, it is determined that the N to-be-selected nodes are down, and each to-be-selected node corresponds to one heartbeat information.
  • the program is further configured to execute the instruction of the following steps: if the first master node is within the preset period If the node has not received the M pieces of heartbeat information corresponding to the M candidate nodes to be selected, then executes to determine that the M candidate nodes to be selected are in a down state, and the first master node completes the transaction endorsement request Endorsement operations for chaincodes in .
  • the program is further configured to execute the instruction of the following steps: indicating The M target standby nodes simulate the transaction corresponding to the transaction endorsement request to obtain a transaction endorsement result; record the read set and write set in the transaction process; sign the transaction endorsement result, read set and write set and then sent to the client.
  • the server includes corresponding hardware structures and/or software modules for executing each function.
  • the present application can be implemented in hardware or in the form of a combination of hardware and computer software, in combination with the units and algorithm steps of each example described in the embodiments provided herein. Whether a function is performed by hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each particular application, but such implementations should not be considered beyond the scope of this application.
  • the server may be divided into functional units according to the foregoing method examples.
  • each functional unit may be divided corresponding to each function, or two or more functions may be integrated into one processing unit.
  • the above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units. It should be noted that the division of units in the embodiments of the present application is illustrative, and is only a logical function division, and other division methods may be used in actual implementation.
  • FIG. 5 is a schematic structural diagram of a transaction endorsement device disclosed in an embodiment of the present application, which is applied to the first master node among multiple master nodes of a blockchain platform.
  • the chain platform includes the multiple master nodes and multiple backup nodes, each master node corresponds to multiple backup nodes, and the device includes: a receiving unit 501, a detection unit 502, an acquisition unit 503, a selection unit 504, a replacement unit 505 and Sending unit 506 .
  • the receiving unit 501 is configured to receive a transaction endorsement request initiated by a client; according to the transaction endorsement request, select M candidates to be selected from the multiple standby nodes, where M is a positive integer.
  • the detection unit 502 is configured to detect node states corresponding to the M nodes to be selected.
  • the obtaining unit 503 is configured to obtain a preset sorting list corresponding to the plurality of standby nodes if N to-be-selected nodes are in a down state among the M to-be-selected nodes, the preset sorting The list is obtained by sorting multiple resource lists corresponding to the multiple standby nodes, and N is a positive integer less than or equal to M.
  • the selecting unit 504 is configured to select, from the preset sorting list, N standby nodes whose sorting positions are after the N to-be-selected nodes as target standby nodes, and obtain N target standby nodes.
  • the replacement unit 505 is configured to replace the N target backup nodes among the M target backup nodes for the N target backup nodes to obtain M target backup nodes.
  • the sending unit 506 is configured to send the transaction endorsement request to the M target standby nodes, where the transaction endorsement request is used to indicate the M target standby nodes.
  • the transaction endorsement device described in the embodiment of this application is applied to the first master node among the multiple master nodes of the blockchain platform, and can receive the transaction endorsement request initiated by the client; according to the transaction endorsement request, Select M standby nodes from multiple standby nodes, where M is a positive integer; detect the node status corresponding to the M standby nodes; if N standby nodes are down in the M standby nodes , the preset sorting list corresponding to multiple standby nodes is obtained, and the preset sorting list is obtained by sorting multiple resource lists corresponding to multiple standby nodes, and N is a positive integer less than or equal to M; select the sorting list from the preset sorting list
  • the N standby nodes located after the N candidates to be selected are the target standby nodes, and N target standby nodes are obtained; the N target standby nodes are replaced by the N candidate nodes in the M candidates to be selected, and the M candidate nodes are obtained.
  • the target standby node sends a transaction endorsement request to the M target standby nodes, and the transaction endorsement request is used to instruct the M target standby nodes to endorse the chain code in the transaction endorsement request.
  • the standby node is down, other surviving standby nodes can be selected in time according to the preset sorting list to replace the above-mentioned standby node in the downtime situation, so as to maintain the operation of the entire endorsement operation.
  • the node is the standby node with the higher ranking in the preset sorting list, that is to say, the other standby node with the best resource status is beneficial to improve the endorsement efficiency when providing the endorsement service to the client.
  • the receiving unit 501 is specifically configured to: according to the transaction endorsement request, Determine the plurality of pre-stored resource lists, and each resource list corresponds to a standby node; according to the chain code, select M resource lists to be selected from the plurality of resource lists, and obtain the corresponding resource list for each resource list.
  • the candidate nodes to be selected are obtained, and the M candidate nodes to be selected are obtained.
  • the receiving unit 501 is further configured to: determine the transaction endorsement request according to the transaction endorsement request Corresponding at least one institution; according to at least one institution, select at least one standby node corresponding to each institution to obtain multiple standby nodes; determine the resource list corresponding to each standby node from the preset resource pool to obtain multiple resource lists.
  • the detection unit 502 is specifically configured to: if the N nodes to be selected are not received within a preset period For N pieces of heartbeat information sent by the node, it is determined that the N to-be-selected nodes are down, and each to-be-selected node corresponds to one heartbeat information.
  • the detecting unit 502 is further configured to: if the first master node fails to operate within the preset period After receiving the M pieces of heartbeat information corresponding to the M candidate nodes to be selected, execute to determine that the M candidate nodes to be selected are in a down state, and then the first master node completes the transaction endorsement request. Chaincode endorsement operation.
  • the sending unit 506 is specifically configured to: instruct the M Each target standby node simulates the transaction corresponding to the transaction endorsement request, and obtains the transaction endorsement result; records the read set and write set in the transaction process; signs the transaction endorsement result, read set and write set and sends it to the client.
  • Embodiments of the present application further provide a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for electronic data exchange, and the computer program enables a computer to execute any transaction as described in the foregoing method embodiments Some or all of the steps of the endorsement method.
  • the storage medium involved in this application such as a computer-readable storage medium, may be non-volatile or volatile.
  • Embodiments of the present application further provide a computer program product, the computer program product comprising a non-transitory computer-readable storage medium storing a computer program, the computer program being operable to cause a computer to execute the methods described in the foregoing method embodiments Some or all of the steps of any transaction endorsement method.
  • the computer program product may be a software installation package.
  • the disclosed apparatus may be implemented in other manners.
  • the apparatus embodiments described above are only illustrative, for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation, for example, multiple units or components may be combined or Integration into another system, or some features can be ignored, or not implemented.
  • the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, and may be in electrical or other forms.
  • the units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units can be implemented in the form of hardware, and can also be implemented in the form of software program modules.
  • the integrated unit if implemented in the form of a software program module and sold or used as a stand-alone product, may be stored in a computer readable memory.
  • the technical solution of the present application can be embodied in the form of a software product in essence, or the part that contributes to the prior art, or all or part of the technical solution, and the computer software product is stored in a memory.
  • a computer device which may be a personal computer, a server, or a network device, etc.
  • the aforementioned memory includes: U disk, read-only memory (read-only memory) memory, ROM), random access memory (random) Access memory, RAM), removable hard disk, magnetic disk or optical disk and other media that can store program code.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Computer And Data Communications (AREA)

Abstract

本申请涉及区块链技术领域,尤其涉及一种交易背书方法、装置及存储介质,应用于区块链平台的多个主节点中的第一主节点,所述方法包括:可接收到客户端发起的交易背书请求;根据交易背书请求,从多个备节点中选取M个待选备节点;检测M个待选备节点对应的节点状态;若M个待选备节点中存在N个待选备节点处于宕机状态,则获取多个备节点对应的预设排序列表;从预设排序列表中选取排序位置在N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点;将N个目标备节点替换M个待选备节点中N个待选备节点,得到M个目标备节点;向M个目标备节点发送交易背书请求。采用本申请实施例,有利于提高背书效率。

Description

交易背书方法、装置及存储介质
本申请要求于2020年9月3日提交中国专利局、申请号为202010916268.5,发明名称为“交易背书方法、装置及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及区块链技术领域,具体涉及一种交易背书方法、装置及存储介质。
背景技术
区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链中一个节点可向客户端提供背书服务,包括对交易ID的重复性检查,交易读写集的生成以及最终的签名等等服务;在现有的主备同步架构下,主节点主要负责从排序节点获取区块并对区块进行验签和多版本检查,而备节点主要向客户端提供背书服务。发明人意识到,在这种架构下,一旦某些备节点宕机,客户端便无法收集到足够多的交易背书,导致整个区块链网络中的交易都无法进行会影响整个区块链网络的背书效率。
技术问题
本申请实施例提供一种交易背书方法、装置及存储介质,有利于提高区块链网络的背书效率。
技术解决方案
本申请实施例第一方面提供了一种交易背书方法,应用于区块链平台的多个主节点中的第一主节点,所述区块链平台包括所述多个主节点和多个备节点,每个主节点对应多个备节点,包括:接收到客户端发起的交易背书请求;根据所述交易背书请求,从所述多个备节点中选取M个待选备节点,M为正整数;检测所述M个待选备节点对应的节点状态;若所述M个待选备节点中存在N个待选备节点处于宕机状态,则获取所述多个备节点对应的预设排序列表,所述预设排序列表由所述多个备节点对应的多个资源列表排序得到,N为小于或等于M的正整数;从所述预设排序列表中选取排序位置在所述N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点;将所述N个目标备节点替换所述M个待选备节点中所述N个待选备节点,得到M个目标备节点;向所述M个目标备节点发送所述交易背书请求,所述交易背书请求用于指示所述M个目标备节点。
本申请实施例第二方面提供了一种交易背书装置,应用于区块链平台的多个主节点中的第一主节点,所述区块链平台包括所述多个主节点和多个备节点,每个主节点对应多个备节点,所述装置包括:接收单元、检测单元、获取单元、选取单元、替换单元和发送单元,其中,所述接收单元,用于接收到客户端发起的交易背书请求;根据所述交易背书请求,从所述多个备节点中选取M个待选备节点,M为正整数;所述检测单元,用于检测所述M个待选备节点对应的节点状态;所述获取单元,用于若所述M个待选备节点中存在N个待选备节点处于宕机状态,则获取所述多个备节点对应的预设排序列表,所述预设排序列表由所述多个备节点对应的多个资源列表排序得到,N为小于或等于M的正整数;所述选取单元,用于从所述预设排序列表中选取排序位置在所述N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点;所述替换单元,用于将所述N个目标备节点替换所述M个待选备节点中所述N个待选备节点,得到M个目标备节点;所述发送单元,用于向所述M个目标备节点发送所述交易背书请求,所述交易背书请求用于指示所述M个目标备节点。
本申请实施例的第三方面提供一种服务器,所述服务器包括处理器、通信接口、存储器以及一个或多个程序,所述处理器、通信接口和存储器相互连接,其中,所述存储器用于存储计算机程序,所述计算机程序包括程序指令,所述处理器被配置用于调用所述程序指令,执行本申请实施例第一方面所述的方法,该方法包括:接收到客户端发起的交易背书请求;根据所述交易背书请求,从多个备节点中选取M个待选备节点,M为正整数;检测所述M个待选备节点对应的节点状态;若所述M个待选备节点中存在N个待选备节点处于宕机状态,则获取所述多个备节点对应的预设排序列表,所述预设排序列表由所述多个备节点对应的多个资源列表排序得到,N为小于或等于M的正整数;从所述预设排序列表中选取排序位置在所述N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点;将所述N个目标备节点替换所述M个待选备节点中所述N个待选备节点,得到M个目标备节点;向所述M个目标备节点发送所述交易背书请求,所述交易背书请求用于指示所述M个目标备节点。
本申请实施例的第四方面提供了一种计算机可读存储介质,其中,上述计算机可读存储介质存储用于电子数据交换的计算机程序,其中,上述计算机程序使得计算机执行以下方法:接收到客户端发起的交易背书请求;根据所述交易背书请求,从多个备节点中选取M个待选备节点,M为正整数;检测所述M个待选备节点对应的节点状态;若所述M个待选备节点中存在N个待选备节点处于宕机状态,则获取所述多个备节点对应的预设排序列表,所述预设排序列表由所述多个备节点对应的多个资源列表排序得到,N为小于或等于M的正整数;从所述预设排序列表中选取排序位置在所述N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点;将所述N个目标备节点替换所述M个待选备节点中所述N个待选备节点,得到M个目标备节点;向所述M个目标备节点发送所述交易背书请求,所述交易背书请求用于指示所述M个目标备节点。
有益效果
实施本申请实施例,有利于提高背书效率。
附图说明
图1A为本申请实施例提供了一种节点系统的架构示意图。
图1B为本申请实施例提供了一种交易背书方法的流程示意图。
图2为本申请实施例提供了一种交易背书方法的流程示意图。
图3为本申请实施例提供了一种交易背书系统的架构示意图。
图4为本申请实施例提供了一种服务器的结构示意图。
图5为本申请实施例提供了一种交易背书装置的结构示意图。
本发明的实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
本申请可涉及人工智能技术领域,比如可以基于人工智能技术对相关的数据进行获取和处理。本申请可应用于基于区块链的背书场景,例如,可具体应用于数字医疗中的医疗数据如医疗保险数据的背书场景,又如可具体应用于金融科技中的交易数据的背书场景,等等,下面以交易背书为例进行说明。
为了能够更好地理解本申请实施例,下面将对应用本申请实施例的方法进行介绍。
本申请实施例中提到的服务器可以包括但不限于后台服务器、组件服务器、云端服务器、交易背书系统服务器或数据分配软件服务器等,比如该服务器可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、内容分发网络(Content Delivery Network,CDN)、以及大数据和人工智能平台等基础云计算服务的云服务器。可以理解,上述仅是举例,而非穷举,包含但不限于上述装置;在该服务器中可包括区块链平台。
请参见图1A,图1A是本申请实施例提供的一种节点系统的架构示意图。
其中,本申请实施例应用于服务器,该服务器可包括区块链网络,区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链(Blockchain),本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链可以包括区块链底层平台、平台产品服务层以及应用服务层。
其中,本申请实施例具体可应用于FiMax区块链平台中,该FiMax区块链平台是一种以S3C为基础框架组成的区块链网络,该S3C是由区块链解决方案模块、区块链内核模块、区块链隐私保护模块和区块链网络管理模块组成的框架系统。
其中,在上述FiMax区块链平台中可包括多个节点,可包括:排序节点(adapter节点)和peer节点(数据节点),其中,peer节点可用于存储数据,并且执行特定的程序。在本申请实施例中,该peer节点可用于存储账本、智能合约等等,可用于向客户端提供背书服务,该背书服务可基于程序执行,该peer节点可以为一个物理服务器或者可为一个虚拟服务器。
其中,上述peer节点可分为主节点和从节点;上述adapter节点可用于产生区块,主节点可从该adapter节点中获取区块,并对该区块中每笔交易对应的交易数据的签名信息进行验证和对交易数据的多版本检查,而备节点可用于向客户端提供背书服务。
另外,在进行交易背书时,若均由同一节点完成,若其中一些节点宕机,那么客户端无法接收交易背书,会导致整个区块链网络的交易无法正常运行;因此,相比于一种节点来说,将peer节点划分为主节点和备节点两种,可分布式实现不同的业务需求,每种节点以用于实现不同的功能,以避免当其中一个节点宕机时,不能继续完成业务需求,从而影响整个区块链网络的运行。
其中,上述主节点和多个备节点应该属于同一机构中,如此,可提高信息安全性。
其中,上述FiMax区块链平台中可包括多个主节点,每一主节点可对应有多个(2个或2个以上)备节点。在本申请实施例中,如图1A所示,仅以其中一个主节点(第一主节点)为例,可可接收到客户端发起的交易背书请求;根据交易背书请求,从多个备节点中选取M个待选备节点,M为正整数;检测M个待选备节点对应的节点状态;若M个待选备节点中存在N个待选备节点处于宕机状态,则获取多个备节点对应的预设排序列表,预设排序列表由多个备节点对应的多个资源列表排序得到,N为小于或等于M的正整数;从预设排序列表中选取排序位置在N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点;将N个目标备节点替换M个待选备节点中N个待选备节点,得到M个目标备节点;向M个目标备节点发送交易背书请求,交易背书请求用于指示M个目标备节点对交易背书请求中的链码进行背书。
可以看出,为了保证数据安全性,可选取与第一主节点同一机构中的多个备节点,并在有待选备节点出现宕机时,可根据预设排序列表,选取排名较为靠前的目标备节点替换上述待选备节点,也就是说选取资源状况最好的其他备节点为客户端提供背书服务,有利于提高背书效率。
请参见图1B,图1B是本申请实施例提供的一种交易背书方法的流程示意图,区块链平台的多个主节点中的第一主节点,所述区块链平台包括所述多个主节点和多个备节点,每个主节点对应多个备节点,上述方法包括以下步骤。
101、接收到客户端发起的交易背书请求;根据所述交易背书请求,从所述多个备节点中选取M个待选备节点,M为正整数。
其中,本申请实施例应用于区块链平台,该区块链平台可搭建在服务器中,该服务器可为虚拟服务器或者物理服务器。上述第一主节点可为上述如图1A所示的节点系统图中的主节点,其可对应有多个备节点,并可与每一备节点进行通信。
其中,上述客户端可指任意一个为客户提供服务的程序,例如,银行服务客户端、保险服务客户端、政企服务客户端等等,在此不作限定;该客户端可在上述区块链平台对应的区块链网络中发起一笔交易,例如,用户A需要向用户B转账1W元,则会生成一个交易申请,并向整个区块链网络中的所有区块发出交易背书请求,该交易背书请求用于证明或者声明该交易背书请求对应的交易是有效的,有利于推进后续交易的进行。
其中,上述第一主节点在接收到来自于客户端发起的交易背书请求以后,可根据该交易背书请求的需求量,从同一机构中的多个备节点中选取M个待选备节点,并通过该M个待选备节点向上述客户端提供交易背书服务,其中,M为正整数。
在一种可能的示例中,上述根据所述交易背书请求,从所述多个备节点中选取M个待选备节点,可包括如下步骤:根据所述交易背书请求,确定预先存储的所述多个资源列表,每一资源列表对应一个备节点;根据所述链码,从所述多个资源列表中选取M个待选资源列表,得到每一待选资源列表对应的待选备节点,得到所述M个待选备节点。
其中,上述链码一般可指链上代码,是根据操作区块链分布式账本的状态的业务处理逻辑代码;具体地,该链码可由客户端发起交易背书时,自动生成;该链码中的参数可由具体的应用场景决定。
其中,每一备节点可对应一个资源列表,该资源列表中可包括该备节点对应的资源信息,该资源信息可包括但不限于:硬件配置信息、通信速率等信息。第一主节点可事先根据上述多个备节点对应的多个资源列表,对上述多个备节点进行排序,得到预设资源列表,该预设资源列表中,备节点硬件配置信息越好,以及通信速率越好,则其的排序位置越靠前。
具体实现中,可根据上述链码中携带的具体场景以及参数信息,从多个备节点对应的多个资源列表中选取与上述链码中携带的信息相匹配,也就是选取上述场景下,与上述参数信息相匹配的多个待选资源列表,并选取在上述预设资源列表中排序位置靠前的M个待选资源列表,以得到每一待选资源列表对应的待选备节点,得到M个待选备节点。
在一种可能的示例中,上述根据所述交易背书请求,确定预先存储的多个资源列表,可包括如下步骤:根据所述交易背书请求,确定所述交易背书请求对应的至少一个机构;根据至少一个机构,选取每一机构对应的至少一个备节点,得到多个备节点;从预设资源池中确定每一备节点对应的资源列表,得到多个资源列表。
其中,在本申请实施例中,为了保证在区块链网络中数据传输的安全性,可选取与上述交易背书请求对应的至少一个结构,并选取在同一机构中对应的多个备节点,以确保信息的安全性。
其中,上述预设资源池可由用户自行设置或系统默认,在此不作限定;此外,上述预设资源池中可存储区块链平台中所有备节点对应的资源列表。
具体实现中,可获取交易背书请求中携带的证书信息,该证书信息中可包括但不限于:公钥以及对该公钥的签名;并根据该证书信息,确定其对应的至少一个机构;每一机构中可对应存储有每一备节点对应的节点标识信息,可根据每一机构对应存储的至少一个节点标识信息,确定每一机构对应的至少一个备节点,从而可得到多个备节点。
可选地,在所述从所述多个备节点中选取M个待选备节点之后,还可包括如下步骤:向每一所述待选备节点发送所述交易背书请求,并在确定所述M个待选备节点接收到所述交易背书请求以后,执行所述检测所述M个待选备节点对应的节点状态的步骤。
其中,可在确保每一待选备节点接收到交易背书请求以后,执行检测每一待选备节点的节点状态,以保证能收集到每一待选备节点的反馈信息。
102、检测所述M个待选备节点对应的节点状态。
其中,上述节点状态至少可包括:宕机状态、正常工作状态等等,在此不作限定;其中,正常工作状态可理解为该节点正常运行状态,例如,可正常获取上述第一主节点的区块、可向客户端正常提供背书服务等等。
在一种可能的示例中,上述检测所述多个待选备节点对应的节点状态,可包括如下步骤:若在预设周期内未接收到所述N个待选备节点发送的N个心跳信息,则确定所述N个待选备节点宕机,每一待选备节点对应一个心跳信息。
其中,上述预设周期可为用户自行设置或者系统默认,在此不作限定。
其中,上述心跳消息(Heartbeat Message)是一种发送源发送到接收方的消息,这种消息可以让上述第一主节点确定上述多个备节点是否出现故障以及何时出现故障或当前不可用或者宕机。
具体实现中,上述第一主节点可针对每一待选备节点进行计时,可对每一待选备节点分配一个计时器,每一计时器均可对应预设周期,另外,在具体实施例中,若超出该预设周期,则可确定该待选备节点连接第一主节点连接超时,也可确定该待选备节点的节点状态为宕机状态。
进一步地,在本申请实施例中,多个待选备节点可主动通过心跳信息探测第一主节点的工作状态,相对应的,若该第一主节点未接收到N个待选备节点发送的N个心跳信息,则表明上述N个待选备节点处于宕机状态,N为小于或等于M的正整数。
可见,在本申请实施例中,不需要第一主节点主动去探测每一待选备节点的工作状态,待选备节点可主动探测第一主节点的工作状态,同时,该第一主节点可直接通过接收到的心跳信息,从而实现对该待选备节点的工作状态的确定,有利于减少第一主节点的资源消耗。
可选地,上述检测所述多个待选备节点对应的节点状态,还可包括如下步骤:若在所述预设周期内所述第一主节点未收到所述M个待选备节点对应的M个心跳信息,则执行确定所述M个待选备节点处于宕机状态,则由所述第一主节点完成对所述交易背书请求中的链码的背书操作。
其中,若上述第一主节点在预设周期内,未接收到每一待选备节点的心跳信息,则表明其选中的M个待选备节点均处于宕机状态,此时,为了保证整个交易背书的有效进行,则可由该第一主节点完成交易背书,也就是可由该第一主节点完成对上述交易背书请求中链码的背书操作。
103、若所述M个待选备节点中存在N个待选备节点处于宕机状态,则获取所述多个备节点对应的预设排序列表,所述预设排序列表由所述多个备节点对应的多个资源列表排序得到,N为小于或等于M的正整数。
其中,上述预设排序列表可由第一主节点事先对与其在同一机构中的多个备节点对应的多个资源信息排序得到。可由用户自行设置或者系统默认,在此不作限定。
其中,上述每一备节点对应的资源列表中可包括该节点对应的资源信息,该资源信息可包括以下至少一种:硬件配置信息和通信速率等等,在此不做限定。
具体实现中,可根据每一备节点对应的资源列表中的硬件配置信息和通信速率进行排序,例如,可将硬件配置信息好的(例如,剩余可用内存大的)和通信速率高的备节点排在预设排序列表的前面位置,具体地,可针每一资源信息预先设置权重,并根据权重以及每一资源信息,对该备节点的资源进行评分,得到多个评分值,硬件配置信息越好,通信速率越高,则评分越高,可根据多个评分值,对多个备节点进行排序,评分值越高,排序位置越靠前,从而,可确定对上述多个备节点依次排列的而得到的预设排序列表。
104、从所述预设排序列表中选取排序位置在所述N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点。
其中,若上述M个待选备节点中存在N个待选备节点处于宕机状态,则可从预设排序列表中,选取上述N个待选备节点之后的排序位置对应的N个备节点(可包括M个待选备节点中任意一个,也可不包括M个待选备节点中任意一个)作为N个目标备节点。
具体实现中,在预设排序列表中,以上述出现宕机情况的N个待选备节点中第一个为起始节点,向后依次筛选未处于宕机状态的N个备节点作为N个目标备节点,若在筛选过程中,遇到任意一个宕机状态的备节点,可跳过,并依据上述预设排序列表继续往下筛选,以得到N个目标备节点。
可见,采用本申请实施例,可在有N个待选备节点出现宕机状况时,选用资源信息最好的N个目标备节点,有利于后续有效背书,同时,由于每一备节点的资源信息不同,即资源配置信息以及网络状态都不同,对交易的背书效率也不同,上述选取得到的N个目标备节点,相较于其他节点资源信息较好,在向客户端提供背书服务时,有利于提高背书效率。
105、将所述N个目标备节点替换所述M个待选备节点中所述N个待选备节点,得到M个目标备节点。
其中,上述N个待选备节点存在于预设排序列表中,相比于多个备节点中的其余备节点来说,上述N个待选备节点的排序序号较为靠前;因此,一旦出现上述宕机状态的待选备节点以后,立马根据预设排序列表中的排序号,将出现宕机状态的待选备节点对应的排序号之后的备节点作为替补,得到N个目标备节点,以替换上述宕机的N个待选备节点,仍然可得到M个目标备节点。
具体实现中,可确定出现宕机状态的N个待选备节点的数量N,并根据该数量N,从预设排序列表中选取顺位的符合该数量N的N个备节点,替补上述处于宕机状态的N个待选备节点,并和M-N个未出现宕机状态的待选备节点组成目标备节点集合,得到M个目标备节点,以通过M个目标备节点完成后续交易背书。
可选地,当确定某一待选备节点宕机以后,可从上述预设排序列表中删除该节点以及其所对应的资源列表信息。
106、向所述M个目标备节点发送所述交易背书请求,所述交易背书请求用于指示所述M个目标备节点对所述交易背书请求中的链码进行背书。
其中,在确定了上述M个目标备节点以后,该M个目标备节点为上述多个备节点中配置信息较好的M个备节点,在完成交易背书时,其交易背书的效率相较于其他备节点来说更快,有利于提高整个区块链网络的背书效率。
在一种可能的示例中,上述所述交易背书请求用于指示所述M个目标备节点对所述交易背书请求中的链码进行背书,可包括如下步骤:指示所述M个目标备节点模拟所述交易背书请求对应的交易,得到交易背书结果;记录在所述交易过程中的读集和写集;对所述交易背书结果、读集和写集进行签名后发送给所述客户端。
其中,上述交易背书请求可由上述M个目标备节点完成,具体实现中,可通过每一目标备节点从第一主节点获取区块,该区块中可对应有交易数据,并根据该交易数据模拟交易,得到每一目标备节点对应的交易背书结果;并记录在交易过程中发生数据变化的读集和写集,该读集和写集中可包括交易信息,最后可将上述交易背书结果、读集和写集按照预设方式进行签名以后,再发送给客户端,以完成交易背书。
可以看出,本申请实施例中所描述的交易背书方法,应用于区块链平台的多个主节点中的第一主节点,第一主节点可接收到客户端发起的交易背书请求;根据交易背书请求,从多个备节点中选取M个待选备节点,M为正整数;检测M个待选备节点对应的节点状态;若M个待选备节点中存在N个待选备节点处于宕机状态,则获取多个备节点对应的预设排序列表,预设排序列表由多个备节点对应的多个资源列表排序得到,N为小于或等于M的正整数;从预设排序列表中选取排序位置在N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点;将N个目标备节点替换M个待选备节点中N个待选备节点,得到M个目标备节点;向M个目标备节点发送交易背书请求,交易背书请求用于指示M个目标备节点对交易背书请求中的链码进行背书。如此,可在备节点出现宕机的情况时,根据预设排序列表,及时选取存活的其他备节点以替换上述出现宕机情况的备节点,以维持整个背书操作的运行,上述选取的目标备节点为预设排序列表中排名较为靠前的备节点,也就是说资源状况最好的其他备节点,在对客户端提供背书服务时,有利于提高背书效率。
与上述一致地,请参阅图2,图2是本申请实施例公开的一种交易背书方法的流程示例图,应用于区块链平台的多个主节点中的第一主节点,所述区块链平台包括所述多个主节点和多个备节点,每个主节点对应多个备节点,,该交易背书方法可包括如下步骤。
201、接收到客户端发起的交易背书请求;根据所述交易背书请求,确定所述交易背书请求对应的至少一个机构。
202、根据至少一个机构,选取每一机构对应的至少一个备节点,得到多个备节点;从预设资源池中确定每一备节点对应的资源列表,得到多个资源列表。
203、根据所述链码,从所述多个资源列表中选取M个待选资源列表,得到每一待选资源列表对应的待选备节点,得到所述M个待选备节点。
204、检测所述M个待选备节点对应的节点状态。
205、若所述M个待选备节点中存在N个待选备节点处于宕机状态,则获取所述多个备节点对应的预设排序列表,所述预设排序列表由所述多个备节点对应的多个资源列表排序得到,N为小于或等于M的正整数。
206、从所述预设排序列表中选取排序位置在所述N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点。
207、将所述N个目标备节点替换所述M个待选备节点中所述N个待选备节点,得到M个目标备节点。
208、向所述M个目标备节点发送所述交易背书请求,所述交易背书请求用于指示所述M个目标备节点对所述交易背书请求中的链码进行背书。
其中,上述步骤201-208的具体描述可以参照图1B所述的交易背书方法的相应描述,在此不再赘述。
可以看出,本申请实施例所描述的交易背书方法,应用于区块链平台的多个主节点中的第一主节点,可接收到客户端发起的交易背书请求;根据交易背书请求,确定交易背书请求对应的至少一个机构。根据至少一个机构,选取每一机构对应的至少一个备节点,得到多个备节点;从预设资源池中确定每一备节点对应的资源列表,得到多个资源列表。根据链码,从多个资源列表中选取M个待选资源列表,得到每一待选资源列表对应的待选备节点,得到M个待选备节点。检测M个待选备节点对应的节点状态。若M个待选备节点中存在N个待选备节点处于宕机状态,则获取多个备节点对应的预设排序列表,预设排序列表由多个备节点对应的多个资源列表排序得到,N为小于或等于M的正整数。从预设排序列表中选取排序位置在N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点。将N个目标备节点替换M个待选备节点中N个待选备节点,得到M个目标备节点。向M个目标备节点发送交易背书请求,交易背书请求用于指示M个目标备节点对交易背书请求中的链码进行背书。如此,为了保证数据安全性,可选取同一机构中的多个备节点,并在其中有备节点出现宕机时,可根据预设排序列表,选取排名较为靠前的备节点,也就是说资源状况最好的其他备节点为客户端提供背书服务,有利于提高背书效率。
与上述一致地,请参阅图3,图3是本申请实施例公开的一种交易背书方法的流程示例图,应用于区块链平台的多个主节点中的第一主节点,区块链平台包括多个主节点和多个备节点,每个主节点对应多个备节点,,该交易背书方法可包括如下步骤。
301、接收到客户端发起的交易背书请求;根据所述交易背书请求,从所述多个备节点中选取M个待选备节点,M为正整数。
302、若在所述预设周期内所述第一主节点未收到所述M个待选备节点对应的M个心跳信息,则执行确定所述M个待选备节点处于宕机状态,则由所述第一主节点完成对所述交易背书请求中的链码的背书操作。
303、若在预设周期内未接收到所述N个待选备节点发送的N个心跳信息,则确定所述N个待选备节点宕机,每一待选备节点对应一个心跳信息。
304、若所述M个待选备节点中存在N个待选备节点处于宕机状态,则获取所述多个备节点对应的预设排序列表,所述预设排序列表由所述多个备节点对应的多个资源列表排序得到,N为小于或等于M的正整数。
305、从所述预设排序列表中选取排序位置在所述N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点。
306、将所述N个目标备节点替换所述M个待选备节点中所述N个待选备节点,得到M个目标备节点。
307、向所述M个目标备节点发送所述交易背书请求,所述交易背书请求用于指示所述M个目标备节点对所述交易背书请求中的链码进行背书。
其中,上述步骤301-307的具体描述可以参照图1B所述的交易背书方法的相应描述,在此不再赘述。
可以看出,本申请实施例所描述的交易背书方法,应用于区块链平台的多个主节点中的第一主节点,可接收到客户端发起的交易背书请求;根据交易背书请求,从多个备节点中选取M个待选备节点,M为正整数。若在预设周期内第一主节点未收到M个待选备节点对应的M个心跳信息,则执行确定M个待选备节点处于宕机状态,则由第一主节点完成对交易背书请求中的链码的背书操作。若在预设周期内未接收到N个待选备节点发送的N个心跳信息,则确定N个待选备节点宕机,每一待选备节点对应一个心跳信息。若M个待选备节点中存在N个待选备节点处于宕机状态,则获取多个备节点对应的预设排序列表,预设排序列表由多个备节点对应的多个资源列表排序得到,N为小于或等于M的正整数。从预设排序列表中选取排序位置在N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点。将N个目标备节点替换M个待选备节点中N个待选备节点,得到M个目标备节点。向M个目标备节点发送交易背书请求,交易背书请求用于指示M个目标备节点对交易背书请求中的链码进行背书。如此,当多个备节点中存在备节点出现宕机的情况下,可根据预设排序列表,选取排序位置靠前的备节点以替换上述出现宕机情况的备节点,以维持整个交易背书的进行,并且,若存在所有备节点均出现宕机情况,则可由该第一主节点对交易背书请求中的链码进行背书,有利于保证区块链网络中的有效交易背书。
与上述一致地,请参阅图4,图4为本申请实施例提供的一种服务器的结构示意图,如图4所示,包括处理器、通信接口、存储器以及一个或多个程序,所述处理器、通信接口和存储器相互连接,其中,所述存储器用于存储计算机程序,所述计算机程序包括程序指令,所述处理器被配置用于调用所述程序指令,上述一个或多个程序程序包括用于执行以下步骤的指令:接收到客户端发起的交易背书请求;根据所述交易背书请求,从所述多个备节点中选取M个待选备节点,M为正整数;检测所述M个待选备节点对应的节点状态;若所述M个待选备节点中存在N个待选备节点处于宕机状态,则获取所述多个备节点对应的预设排序列表,所述预设排序列表由所述多个备节点对应的多个资源列表排序得到,N为小于或等于M的正整数;从所述预设排序列表中选取排序位置在所述N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点;将所述N个目标备节点替换所述M个待选备节点中所述N个待选备节点,得到M个目标备节点;向所述M个目标备节点发送所述交易背书请求,所述交易背书请求用于指示所述M个目标备节点。
可以看出,本申请实施例中所描述的服务器,可接收到客户端发起的交易背书请求;根据交易背书请求,从多个备节点中选取M个待选备节点,M为正整数;检测M个待选备节点对应的节点状态;若M个待选备节点中存在N个待选备节点处于宕机状态,则获取多个备节点对应的预设排序列表,预设排序列表由多个备节点对应的多个资源列表排序得到,N为小于或等于M的正整数;从预设排序列表中选取排序位置在N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点;将N个目标备节点替换M个待选备节点中N个待选备节点,得到M个目标备节点;向M个目标备节点发送交易背书请求,交易背书请求用于指示M个目标备节点对交易背书请求中的链码进行背书。如此,可在备节点出现宕机的情况时,根据预设排序列表,及时选取存活的其他备节点以替换上述出现宕机情况的备节点,以维持整个背书操作的运行,上述选取的目标备节点为预设排序列表中排名较为靠前的备节点,也就是说资源状况最好的其他备节点,在对客户端提供背书服务时,有利于提高背书效率。
在一个可能的示例中,在所述根据所述交易背书请求,从所述多个备节点中选取M个待选备节点方面,所述程序用于执行以下步骤的指令:根据所述交易背书请求,确定预先存储的所述多个资源列表,每一资源列表对应一个备节点;根据所述链码,从所述多个资源列表中选取M个待选资源列表,得到每一待选资源列表对应的待选备节点,得到所述M个待选备节点。
在一个可能的示例中,在所述根据所述交易背书请求,确定预先存储的多个资源列表方面,所述程序用于执行以下步骤的指令:根据所述交易背书请求,确定所述交易背书请求对应的至少一个机构;根据至少一个机构,选取每一机构对应的至少一个备节点,得到多个备节点;从预设资源池中确定每一备节点对应的资源列表,得到多个资源列表。
在一个可能的示例中,在所述从所述多个备节点中选取M个待选备节点之后,所述程序用于执行以下步骤的指令:向每一所述待选备节点发送所述交易背书请求,并在确定所述M个待选备节点接收到所述交易背书请求以后,执行所述检测所述M个待选备节点对应的节点状态的步骤。
在一个可能的示例中,在所述检测所述多个待选备节点对应的节点状态方面,所述程序用于执行以下步骤的指令:若在预设周期内未接收到所述N个待选备节点发送的N个心跳信息,则确定所述N个待选备节点宕机,每一待选备节点对应一个心跳信息。
在一个可能的示例中,在所述检测所述多个待选备节点对应的节点状态方面,所述程序还用于执行以下步骤的指令:若在所述预设周期内所述第一主节点未收到所述M个待选备节点对应的M个心跳信息,则执行确定所述M个待选备节点处于宕机状态,则由所述第一主节点完成对所述交易背书请求中的链码的背书操作。
在一个可能的示例中,在所述交易背书请求用于指示所述M个目标备节点对所述交易背书请求中的链码进行背书方面,所述程序还用于执行以下步骤的指令:指示所述M个目标备节点模拟所述交易背书请求对应的交易,得到交易背书结果;记录在所述交易过程中的读集和写集;对所述交易背书结果、读集和写集进行签名后发送给所述客户端。
上述主要从方法侧执行过程的角度对本申请实施例的方案进行了介绍。可以理解的是,服务器为了实现上述功能,其包含了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本文中所提供的实施例描述的各示例的单元及算法步骤,本申请能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
本申请实施例可以根据上述方法示例对服务器进行功能单元的划分,例如,可以对应各个功能划分各个功能单元,也可以将两个或两个以上的功能集成在一个处理单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。需要说明的是,本申请实施例中对单元的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
与上述一致地,请参阅图5,图5是本申请实施例公开的一种交易背书装置的结构示意图,应用于区块链平台的多个主节点中的第一主节点,所述区块链平台包括所述多个主节点和多个备节点,每个主节点对应多个备节点,所述装置包括:接收单元501、检测单元502、获取单元503、选取单元504、替换单元505和发送单元506。
所述接收单元501,用于接收到客户端发起的交易背书请求;根据所述交易背书请求,从所述多个备节点中选取M个待选备节点,M为正整数。
所述检测单元502,用于检测所述M个待选备节点对应的节点状态。
所述获取单元503,用于若所述M个待选备节点中存在N个待选备节点处于宕机状态,则获取所述多个备节点对应的预设排序列表,所述预设排序列表由所述多个备节点对应的多个资源列表排序得到,N为小于或等于M的正整数。
所述选取单元504,用于从所述预设排序列表中选取排序位置在所述N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点。
所述替换单元505,用于将所述N个目标备节点替换所述M个待选备节点中所述N个待选备节点,得到M个目标备节点。
所述发送单元506,用于向所述M个目标备节点发送所述交易背书请求,所述交易背书请求用于指示所述M个目标备节点。
可以看出,本申请实施例中所描述的交易背书装置,应用于区块链平台的多个主节点中的第一主节点,可接收到客户端发起的交易背书请求;根据交易背书请求,从多个备节点中选取M个待选备节点,M为正整数;检测M个待选备节点对应的节点状态;若M个待选备节点中存在N个待选备节点处于宕机状态,则获取多个备节点对应的预设排序列表,预设排序列表由多个备节点对应的多个资源列表排序得到,N为小于或等于M的正整数;从预设排序列表中选取排序位置在N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点;将N个目标备节点替换M个待选备节点中N个待选备节点,得到M个目标备节点;向M个目标备节点发送交易背书请求,交易背书请求用于指示M个目标备节点对交易背书请求中的链码进行背书。如此,可在备节点出现宕机的情况时,根据预设排序列表,及时选取存活的其他备节点以替换上述出现宕机情况的备节点,以维持整个背书操作的运行,上述选取的目标备节点为预设排序列表中排名较为靠前的备节点,也就是说资源状况最好的其他备节点,在对客户端提供背书服务时,有利于提高背书效率。
在一个可能的示例中,在所述根据所述交易背书请求,从所述多个备节点中选取M个待选备节点方面,所述接收单元501具体用于:根据所述交易背书请求,确定预先存储的所述多个资源列表,每一资源列表对应一个备节点;根据所述链码,从所述多个资源列表中选取M个待选资源列表,得到每一待选资源列表对应的待选备节点,得到所述M个待选备节点。
在一个可能的示例中,在所述根据所述交易背书请求,确定预先存储的多个资源列表方面,所述接收单元501具体还用于:根据所述交易背书请求,确定所述交易背书请求对应的至少一个机构;根据至少一个机构,选取每一机构对应的至少一个备节点,得到多个备节点;从预设资源池中确定每一备节点对应的资源列表,得到多个资源列表。
在一个可能的示例中,在所述检测所述多个待选备节点对应的节点状态方面,所述检测单元502具体用于:若在预设周期内未接收到所述N个待选备节点发送的N个心跳信息,则确定所述N个待选备节点宕机,每一待选备节点对应一个心跳信息。
在一个可能的示例中,在所述检测所述多个待选备节点对应的节点状态方面,所述检测单元502具体还用于:若在所述预设周期内所述第一主节点未收到所述M个待选备节点对应的M个心跳信息,则执行确定所述M个待选备节点处于宕机状态,则由所述第一主节点完成对所述交易背书请求中的链码的背书操作。
在一个可能的示例中,在所述交易背书请求用于指示所述M个目标备节点对所述交易背书请求中的链码进行背书方面,所述发送单元506具体用于:指示所述M个目标备节点模拟所述交易背书请求对应的交易,得到交易背书结果;记录在所述交易过程中的读集和写集;对所述交易背书结果、读集和写集进行签名后发送给所述客户端。
本申请实施例还提供一种计算机可读存储介质,其中,该计算机可读存储介质存储用于电子数据交换的计算机程序,该计算机程序使得计算机执行如上述方法实施例中记载的任何一种交易背书方法的部分或全部步骤。
可选的,本申请涉及的存储介质如计算机可读存储介质可以是非易失性的,也可以是易失性的。
本申请实施例还提供一种计算机程序产品,所述计算机程序产品包括存储了计算机程序的非瞬时性计算机可读存储介质,所述计算机程序可操作来使计算机执行如上述方法实施例中记载的任何一种交易背书方法的部分或全部步骤。该计算机程序产品可以为一个软件安装包。
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请并不受所描述的动作顺序的限制,因为依据本申请,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本申请所必须的。
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。
在本申请所提供的几个实施例中,应该理解到所揭露的装置,可通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件程序模块的形式实现。
所述集成的单元如果以软件程序模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储器中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储器中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储器包括:U盘、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序可以存储于一计算机可读存储器中,存储器可以包括:闪存盘、ROM、RAM、磁盘或光盘等。
以上对本申请实施例进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。

Claims (20)

  1. 一种交易背书方法,应用于区块链平台的多个主节点中的第一主节点,所述区块链平台包括所述多个主节点和多个备节点,每个主节点对应多个备节点,包括:
    接收到客户端发起的交易背书请求;根据所述交易背书请求,从所述多个备节点中选取M个待选备节点,M为正整数;
    检测所述M个待选备节点对应的节点状态;
    若所述M个待选备节点中存在N个待选备节点处于宕机状态,则获取所述多个备节点对应的预设排序列表,所述预设排序列表由所述多个备节点对应的多个资源列表排序得到,N为小于或等于M的正整数;
    从所述预设排序列表中选取排序位置在所述N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点;
    将所述N个目标备节点替换所述M个待选备节点中所述N个待选备节点,得到M个目标备节点;
    向所述M个目标备节点发送所述交易背书请求,所述交易背书请求用于指示所述M个目标备节点。
  2. 根据权利要求1所述的方法,其中,所述根据所述交易背书请求,从所述多个备节点中选取M个待选备节点,包括:
    根据所述交易背书请求,确定预先存储的所述多个资源列表,每一资源列表对应一个备节点;
    根据所述链码,从所述多个资源列表中选取M个待选资源列表,得到每一待选资源列表对应的待选备节点,得到所述M个待选备节点。
  3. 根据权利要求2所述的方法,其中,所述根据所述交易背书请求,确定预先存储的多个资源列表,包括:
    根据所述交易背书请求,确定所述交易背书请求对应的至少一个机构;
    根据至少一个机构,选取每一机构对应的至少一个备节点,得到多个备节点;从预设资源池中确定每一备节点对应的资源列表,得到多个资源列表。
  4. 根据权利要求1所述的方法,其中,在所述从所述多个备节点中选取M个待选备节点之后,所述方法还包括:
    向每一所述待选备节点发送所述交易背书请求,并在确定所述M个待选备节点接收到所述交易背书请求以后,执行所述检测所述M个待选备节点对应的节点状态的步骤。
  5. 根据权利要求1所述的方法,其中,所述检测所述多个待选备节点对应的节点状态,包括:
    若在预设周期内未接收到所述N个待选备节点发送的N个心跳信息,则确定所述N个待选备节点宕机,每一待选备节点对应一个心跳信息。
  6. 根据权利要求1或5所述的方法,其中,所述检测所述多个待选备节点对应的节点状态,所述方法还包括:
    若在预设周期内所述第一主节点未收到所述M个待选备节点对应的M个心跳信息,则执行确定所述M个待选备节点处于宕机状态,则由所述第一主节点完成对所述交易背书请求中的链码的背书操作。
  7. 根据权利要求1所述的方法,所述交易背书请求用于指示所述M个目标备节点对所述交易背书请求中的链码进行背书,包括:
    指示所述M个目标备节点模拟所述交易背书请求对应的交易,得到交易背书结果;记录在所述交易过程中的读集和写集;对所述交易背书结果、读集和写集进行签名后发送给所述客户端。
  8. 一种交易背书装置,其中,应用于区块链平台的多个主节点中的第一主节点,所述区块链平台包括所述多个主节点和多个备节点,每个主节点对应多个备节点,所述装置包括接收单元、检测单元、获取单元、选取单元、替换单元和发送单元,其中,
    所述接收单元,用于接收到客户端发起的交易背书请求;根据所述交易背书请求,从所述多个备节点中选取M个待选备节点,M为正整数;
    所述检测单元,用于检测所述M个待选备节点对应的节点状态;
    所述获取单元,用于若所述M个待选备节点中存在N个待选备节点处于宕机状态,则获取所述多个备节点对应的预设排序列表,所述预设排序列表由所述多个备节点对应的多个资源列表排序得到,N为小于或等于M的正整数;
    所述选取单元,用于从所述预设排序列表中选取排序位置在所述N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点;
    所述替换单元,用于将所述N个目标备节点替换所述M个待选备节点中所述N个待选备节点,得到M个目标备节点;
    所述发送单元,用于向所述M个目标备节点发送所述交易背书请求,所述交易背书请求用于指示所述M个目标备节点。
  9. 一种服务器,包括处理器、通信接口、存储器以及一个或多个程序,所述处理器、通信接口和存储器相互连接,其中,所述存储器用于存储计算机程序,所述计算机程序包括程序指令,所述处理器被配置用于调用所述程序指令,执行以下方法:
    接收到客户端发起的交易背书请求;根据所述交易背书请求,从多个备节点中选取M个待选备节点,M为正整数;
    检测所述M个待选备节点对应的节点状态;
    若所述M个待选备节点中存在N个待选备节点处于宕机状态,则获取所述多个备节点对应的预设排序列表,所述预设排序列表由所述多个备节点对应的多个资源列表排序得到,N为小于或等于M的正整数;
    从所述预设排序列表中选取排序位置在所述N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点;
    将所述N个目标备节点替换所述M个待选备节点中所述N个待选备节点,得到M个目标备节点;
    向所述M个目标备节点发送所述交易背书请求,所述交易背书请求用于指示所述M个目标备节点。
  10. 根据权利要求9所述的服务器,其中,执行所述根据所述交易背书请求,从多个备节点中选取M个待选备节点,包括:
    根据所述交易背书请求,确定预先存储的所述多个资源列表,每一资源列表对应一个备节点;
    根据所述链码,从所述多个资源列表中选取M个待选资源列表,得到每一待选资源列表对应的待选备节点,得到所述M个待选备节点。
  11. 根据权利要求10所述的服务器,其中,执行所述根据所述交易背书请求,确定预先存储的多个资源列表,包括:
    根据所述交易背书请求,确定所述交易背书请求对应的至少一个机构;
    根据至少一个机构,选取每一机构对应的至少一个备节点,得到多个备节点;从预设资源池中确定每一备节点对应的资源列表,得到多个资源列表。
  12. 根据权利要求9所述的服务器,其中,执行所述检测所述多个待选备节点对应的节点状态,包括:
    若在预设周期内未接收到所述N个待选备节点发送的N个心跳信息,则确定所述N个待选备节点宕机,每一待选备节点对应一个心跳信息。
  13. 根据权利要求9或12所述的服务器,其中,所述检测所述多个待选备节点对应的节点状态,还包括:
    若在预设周期内第一主节点未收到所述M个待选备节点对应的M个心跳信息,则执行确定所述M个待选备节点处于宕机状态,则由所述第一主节点完成对所述交易背书请求中的链码的背书操作。
  14. 根据权利要求9所述的服务器,所述交易背书请求用于指示所述M个目标备节点对所述交易背书请求中的链码进行背书,包括:
    指示所述M个目标备节点模拟所述交易背书请求对应的交易,得到交易背书结果;记录在所述交易过程中的读集和写集;对所述交易背书结果、读集和写集进行签名后发送给所述客户端。
  15. 一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行以下方法:
    接收到客户端发起的交易背书请求;根据所述交易背书请求,从多个备节点中选取M个待选备节点,M为正整数;
    检测所述M个待选备节点对应的节点状态;
    若所述M个待选备节点中存在N个待选备节点处于宕机状态,则获取所述多个备节点对应的预设排序列表,所述预设排序列表由所述多个备节点对应的多个资源列表排序得到,N为小于或等于M的正整数;
    从所述预设排序列表中选取排序位置在所述N个待选备节点之后的N个备节点为目标备节点,得到N个目标备节点;
    将所述N个目标备节点替换所述M个待选备节点中所述N个待选备节点,得到M个目标备节点;
    向所述M个目标备节点发送所述交易背书请求,所述交易背书请求用于指示所述M个目标备节点。
  16. 根据权利要求15所述的计算机可读存储介质,其中,执行所述根据所述交易背书请求,从多个备节点中选取M个待选备节点,包括:
    根据所述交易背书请求,确定预先存储的所述多个资源列表,每一资源列表对应一个备节点;
    根据所述链码,从所述多个资源列表中选取M个待选资源列表,得到每一待选资源列表对应的待选备节点,得到所述M个待选备节点。
  17. 根据权利要求16所述的计算机可读存储介质,其中,执行所述根据所述交易背书请求,确定预先存储的多个资源列表,包括:
    根据所述交易背书请求,确定所述交易背书请求对应的至少一个机构;
    根据至少一个机构,选取每一机构对应的至少一个备节点,得到多个备节点;从预设资源池中确定每一备节点对应的资源列表,得到多个资源列表。
  18. 根据权利要求15所述的计算机可读存储介质,其中,执行所述检测所述多个待选备节点对应的节点状态,包括:
    若在预设周期内未接收到所述N个待选备节点发送的N个心跳信息,则确定所述N个待选备节点宕机,每一待选备节点对应一个心跳信息。
  19. 根据权利要求15或18所述的计算机可读存储介质,其中,所述检测所述多个待选备节点对应的节点状态,还包括:
    若在预设周期内第一主节点未收到所述M个待选备节点对应的M个心跳信息,则执行确定所述M个待选备节点处于宕机状态,则由所述第一主节点完成对所述交易背书请求中的链码的背书操作。
  20. 根据权利要求15所述的计算机可读存储介质,所述交易背书请求用于指示所述M个目标备节点对所述交易背书请求中的链码进行背书,包括:
    指示所述M个目标备节点模拟所述交易背书请求对应的交易,得到交易背书结果;记录在所述交易过程中的读集和写集;对所述交易背书结果、读集和写集进行签名后发送给所述客户端。
PCT/CN2021/109254 2020-09-03 2021-07-29 交易背书方法、装置及存储介质 WO2022048357A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010916268.5 2020-09-03
CN202010916268.5A CN111988188A (zh) 2020-09-03 2020-09-03 交易背书方法、装置及存储介质

Publications (1)

Publication Number Publication Date
WO2022048357A1 true WO2022048357A1 (zh) 2022-03-10

Family

ID=73447495

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/109254 WO2022048357A1 (zh) 2020-09-03 2021-07-29 交易背书方法、装置及存储介质

Country Status (2)

Country Link
CN (1) CN111988188A (zh)
WO (1) WO2022048357A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115379019A (zh) * 2022-08-19 2022-11-22 济南浪潮数据技术有限公司 一种服务调度方法、装置、设备及存储介质
CN115829276A (zh) * 2022-12-05 2023-03-21 国网数字科技控股有限公司 基于元宇宙的电力交易处理方法、装置及电子设备

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111988188A (zh) * 2020-09-03 2020-11-24 深圳壹账通智能科技有限公司 交易背书方法、装置及存储介质
CN112688996A (zh) * 2020-12-16 2021-04-20 宁波云麟信息科技有限公司 基于区块链的电子存证数据存储方法和电子设备
CN112995167B (zh) * 2021-02-20 2023-05-26 国网冀北电力有限公司计量中心 基于Kafka机制的用电信息采集方法、区块链网络及用户端
US20220321605A1 (en) * 2021-04-01 2022-10-06 Cisco Technology, Inc. Verifying trust postures of heterogeneous confidential computing clusters
CN115065526A (zh) * 2022-06-10 2022-09-16 网络通信与安全紫金山实验室 基于区块链的动态背书方法、装置、电子设备和存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106330523A (zh) * 2015-07-03 2017-01-11 中国移动通信集团广西有限公司 一种集群服务器容灾系统、方法和服务器节点
CN109688012A (zh) * 2018-12-29 2019-04-26 杭州趣链科技有限公司 一种联盟链节点热备切换的方法
CN109729111A (zh) * 2017-10-27 2019-05-07 伊姆西Ip控股有限责任公司 用于管理分布式系统的方法、设备和计算机程序产品
CN110414979A (zh) * 2019-06-21 2019-11-05 深圳壹账通智能科技有限公司 线上背书签名方法、装置、设备和存储介质
CN111368344A (zh) * 2020-03-31 2020-07-03 西安理工大学 一种基于动态选举的提高背书节点容错性方法
CN111988188A (zh) * 2020-09-03 2020-11-24 深圳壹账通智能科技有限公司 交易背书方法、装置及存储介质

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10944624B2 (en) * 2019-06-28 2021-03-09 Advanced New Technologies Co., Ltd. Changing a master node in a blockchain system
CN110572287B (zh) * 2019-09-05 2022-03-18 腾讯科技(深圳)有限公司 数据容灾方法、装置、计算机设备和存储介质
CN110971663B (zh) * 2019-10-28 2021-03-12 北京大学 一种面向数据交易的可信处理方法与系统
CN111028902A (zh) * 2019-12-09 2020-04-17 天津开心生活科技有限公司 基于节点切换的请求处理方法及装置、设备和介质
CN111563830B (zh) * 2020-05-09 2023-11-28 电子科技大学 一种基于石墨烯区块链的分布式能源交易系统

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106330523A (zh) * 2015-07-03 2017-01-11 中国移动通信集团广西有限公司 一种集群服务器容灾系统、方法和服务器节点
CN109729111A (zh) * 2017-10-27 2019-05-07 伊姆西Ip控股有限责任公司 用于管理分布式系统的方法、设备和计算机程序产品
CN109688012A (zh) * 2018-12-29 2019-04-26 杭州趣链科技有限公司 一种联盟链节点热备切换的方法
CN110414979A (zh) * 2019-06-21 2019-11-05 深圳壹账通智能科技有限公司 线上背书签名方法、装置、设备和存储介质
CN111368344A (zh) * 2020-03-31 2020-07-03 西安理工大学 一种基于动态选举的提高背书节点容错性方法
CN111988188A (zh) * 2020-09-03 2020-11-24 深圳壹账通智能科技有限公司 交易背书方法、装置及存储介质

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115379019A (zh) * 2022-08-19 2022-11-22 济南浪潮数据技术有限公司 一种服务调度方法、装置、设备及存储介质
CN115829276A (zh) * 2022-12-05 2023-03-21 国网数字科技控股有限公司 基于元宇宙的电力交易处理方法、装置及电子设备
CN115829276B (zh) * 2022-12-05 2023-10-20 国网数字科技控股有限公司 基于元宇宙的电力交易处理方法、装置及电子设备

Also Published As

Publication number Publication date
CN111988188A (zh) 2020-11-24

Similar Documents

Publication Publication Date Title
WO2022048357A1 (zh) 交易背书方法、装置及存储介质
CN110417558B (zh) 签名的验证方法和装置、存储介质及电子装置
CN111988203B (zh) 节点选举方法、装置及存储介质
US20200134613A1 (en) Method and Apparatus for Running Smart Contract
US11546419B2 (en) Methods, devices and systems for a distributed coordination engine-based exchange that implements a blockchain distributed ledger
US11334678B2 (en) Method and system for a distributed computing system
US20180308091A1 (en) Fairness preserving byzantine agreements
CN103226493B (zh) 多操作系统业务的部署方法和系统
CN107771321A (zh) 数据中心中的恢复
CN112291372B (zh) 区块链的异步落账方法、装置、介质及电子设备
EP1821218A2 (en) Method for enhancing the operation of a database
CN106537386A (zh) 识别用于数据写操作的文件
CN113900598B (zh) 基于区块链的数据存储方法、装置、设备以及存储介质
US20230259938A1 (en) Blockchain-based data processing method and apparatus, device, readable storage medium and computer program product
WO2020221292A1 (zh) 基于多个节点的网络交易验证方法及其系统和存储介质
US20240063946A1 (en) Ingesting and Storing Data in a Massive Data Ingestion System
CN107135097A (zh) 基于簿记建档的容灾系统及容灾方法
CN114844891B (zh) 基于Raft算法的区块链共识方法及系统
CN116233146A (zh) 实现跨分布式存储集群的缓存一致性的技术
CN108874947A (zh) 一种数据处理系统及数据处理方法
CN111653052B (zh) 收银系统及收银机切换方法
CN105447121A (zh) 一种数据库集群重建连接高可用的方法
CN115168203A (zh) 接口模拟方法、装置、系统、计算机设备和存储介质
CN111666132B (zh) 分布式事务实现方法、装置、计算机系统及可读存储介质
CN113450084A (zh) 集团客户的签约审批流转装置及方法

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 17.07.2023)

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21863425

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 21863425

Country of ref document: EP

Kind code of ref document: A1