Ledger updating methods, apparatus, equipment, storage media, and computer program products

By introducing a channel mechanism and a consensus verification mechanism into the blockchain, the channel to which a node belongs maintains a ledger, which solves the problems of high maintenance cost and large storage space occupation of blockchain ledger, and achieves cost reduction and improved security.

CN114841807BActive Publication Date: 2025-10-28SIKUAI TECH (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210298243.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-24
Publication Date
2025-10-28
Estimated Expiration
2042-03-24

AI Technical Summary

Technical Problem

In existing blockchain technology, all nodes jointly maintain the same ledger, resulting in high ledger maintenance costs and a large amount of storage space consumption.

Method used

By introducing a channel mechanism into the blockchain, the channel to which a node belongs maintains a ledger, uses consensus nodes to verify transactions, and updates transaction information to the target ledger through the target chaincode.

Benefits of technology

It reduces ledger maintenance costs, decreases node storage space usage, and improves the security and isolation of transaction information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114841807B_ABST
    Figure CN114841807B_ABST
Patent Text Reader

Abstract

This invention discloses a ledger update method, apparatus, device, storage medium, and computer program product, relating to the field of blockchain technology. The method includes: upon receiving a target transaction, obtaining the target node corresponding to the target transaction and the target channel to which the target node belongs; performing consensus verification on the target transaction through consensus nodes within the target channel; if the consensus verification passes, obtaining the transaction information of the target transaction; and calling the target chaincode corresponding to the target node to update the transaction information into the target ledger corresponding to the target channel. This invention maintains a ledger through a channel containing multiple nodes, reducing ledger maintenance costs while minimizing node storage space usage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of blockchain technology, and in particular to ledger updating methods, apparatus, devices, storage media, and computer program products. Background Technology

[0002] Blockchain is essentially a shared database. Data stored in the blockchain has characteristics such as traceability and non-forgeability. Existing blockchain technology adopts a distributed ledger model, that is, all nodes in the blockchain jointly maintain the same ledger. Transactions between nodes are broadcast in the blockchain, and all nodes record the received transactions in the same ledger in sequence. However, in actual business applications, the joint maintenance of the same ledger by all nodes in the blockchain will increase the maintenance cost of the ledger and occupy a large amount of storage space for the nodes. Summary of the Invention

[0003] The main objective of this invention is to provide a ledger update method, apparatus, device, storage medium, and computer program product, aiming to solve the technical problems of high maintenance costs and large storage space requirements of existing blockchain ledgers.

[0004] Furthermore, to achieve the above objectives, the present invention also provides a ledger updating method, the ledger updating method comprising the following steps:

[0005] When a target transaction is received, the target node corresponding to the target transaction and the target channel to which the target node belongs are obtained;

[0006] The target transaction is verified through consensus nodes within the target channel. If the consensus verification passes, the transaction information of the target transaction is obtained.

[0007] The target chaincode corresponding to the target node is invoked to update the transaction information in the target ledger corresponding to the target channel.

[0008] Optionally, before the step of obtaining the target node corresponding to the target transaction and the target channel to which the target node belongs when the target transaction is received, the method includes:

[0009] When a consensus mechanism creation instruction is received, the first channel corresponding to the consensus mechanism creation instruction is obtained;

[0010] Obtain the first public key and the first private key generated by the first node in the first channel, and store the first private key at the private key storage point in the first channel;

[0011] The first public key is sent to all nodes in the first channel except the first node, so that each node in the first channel has the public keys of all nodes in the first channel.

[0012] Optionally, the step of performing consensus verification on the target transaction through consensus nodes within the target channel, and obtaining the transaction information of the target transaction if the consensus verification passes, includes:

[0013] The public key of the consensus node in the target channel is matched with the private key corresponding to the target transaction, and it is determined whether the private key storage point in the target channel stores the private key corresponding to the target transaction.

[0014] If the public key possessed by the consensus node matches the private key corresponding to the target transaction, and the private key storage point in the target channel stores the private key corresponding to the target transaction, then the target transaction is signed by the consensus node.

[0015] If the target transaction has the signatures of all the consensus nodes, then the target transaction is determined to have passed consensus verification, and the transaction information of the target transaction is obtained.

[0016] Optionally, before the step of obtaining the target node corresponding to the target transaction and the target channel to which the target node belongs when the target transaction is received, the method includes:

[0017] If a transaction initiating node initiates a first transaction to a transaction receiving node, and the channel to which the transaction initiating node belongs is different from the channel to which the transaction receiving node belongs, then the first number of the first channel to which the transaction initiating node belongs, and the second number of the second channel to which the transaction receiving node belongs, are obtained.

[0018] Generate first transaction information and second transaction information for the first transaction, wherein the first transaction information includes the second number and the node information of the transaction receiving node, and the second transaction information includes the first number and the node information of the transaction initiating node;

[0019] If a transaction initiating node initiates a first transaction to a transaction receiving node, and the channel to which the transaction initiating node belongs is the same as the channel to which the transaction receiving node belongs, then first transaction information for the first transaction is generated, wherein the first transaction information includes the node information of the transaction initiating node and the node information of the transaction receiving node.

[0020] Optionally, the target node includes a transaction start node and a transaction end node, and the step of calling the target chaincode corresponding to the target node to update the transaction information in the target ledger corresponding to the target channel includes:

[0021] If the channel to which the transaction start node belongs is different from the channel to which the transaction end node belongs, and the transaction information includes the node information of the transaction start node, then the chaincode corresponding to the transaction end node is called to update the transaction information in the ledger corresponding to the channel to which the transaction end node belongs.

[0022] If the channel to which the transaction initiation node belongs is different from the channel to which the transaction end node belongs, and the transaction information includes the node information of the transaction end node, then the chaincode corresponding to the transaction initiation node is invoked to update the transaction information in the ledger corresponding to the channel to which the transaction initiation node belongs.

[0023] Optionally, after the step of performing consensus verification on the target transaction through consensus nodes within the target channel, and obtaining the transaction information of the target transaction if the consensus verification passes, the method further includes:

[0024] If the transaction start node and the transaction end node do not belong to the same channel, then obtain the transaction initiation amount and transaction receipt amount of the target transaction;

[0025] The transaction initiation amount is locked in the channel to which the transaction initiation node belongs, and the transaction receipt amount is locked in the channel to which the transaction end node belongs;

[0026] The step of calling the target chaincode corresponding to the target node to update the transaction information in the target ledger corresponding to the target channel includes:

[0027] After the transaction received amount is locked, the chaincode corresponding to the transaction initiation node is called to update the transaction information in the ledger corresponding to the channel to which the transaction initiation node belongs, and the chaincode corresponding to the transaction end node is called to update the transaction information in the ledger corresponding to the channel to which the transaction end node belongs.

[0028] Furthermore, to achieve the above objectives, the present invention also provides a ledger updating device, the ledger updating device comprising:

[0029] The acquisition module is used to acquire the target node corresponding to the target transaction and the target channel to which the target node belongs when the target transaction is received;

[0030] The consensus verification module is used to perform consensus verification on the target transaction through the consensus nodes in the target channel. If the consensus verification is successful, the transaction information of the target transaction is obtained.

[0031] The ledger update module is used to call the target chaincode corresponding to the target node and update the transaction information to the target ledger corresponding to the target channel.

[0032] In addition, to achieve the above objectives, the present invention also provides a ledger updating device, the ledger updating device comprising: a memory, a processor, and a ledger updating program stored in the memory and executable on the processor, wherein the ledger updating program, when executed by the processor, implements the steps of the ledger updating method as described above.

[0033] In addition, to achieve the above objectives, the present invention also provides a computer-readable storage medium storing a ledger update program, which, when executed by a processor, implements the steps of the ledger update method as described above.

[0034] This invention provides a ledger update method, apparatus, device, storage medium, and computer program product. In this embodiment, the ledger update method is applied to a blockchain. When the blockchain receives a target transaction, it obtains the target node corresponding to the target transaction and the target channel to which the target node belongs. Then, it performs consensus verification on the target transaction through consensus nodes within the target channel. If the consensus verification passes, it obtains the transaction information of the target transaction. Finally, it calls the target chaincode corresponding to the target node to update the transaction information to the target ledger corresponding to the target channel. This invention maintains a ledger through a channel containing multiple nodes, reducing ledger maintenance costs while also reducing the storage space occupied by nodes. Attached Figure Description

[0035] Figure 1 A schematic diagram of the hardware structure of one embodiment of the ledger update device provided in this invention;

[0036] Figure 2 This is a flowchart illustrating the first embodiment of the ledger update method of the present invention;

[0037] Figure 3 This is a schematic diagram of the blockchain structure in the first embodiment of the ledger update method of the present invention;

[0038] Figure 4 This is a flowchart illustrating the second embodiment of the ledger update method of the present invention;

[0039] Figure 5 This is a schematic diagram of the functional modules of an embodiment of the ledger updating device of the present invention.

[0040] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0041] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0042] In the following description, the use of suffixes such as "module," "part," or "unit" to denote elements is solely for the purpose of illustrative purposes and has no specific meaning in itself. Therefore, "module," "part," or "unit" may be used interchangeably.

[0043] In this embodiment of the invention, the ledger update terminal (also called a terminal, device, or terminal device) can be a PC, or a device with program compilation capabilities such as a smartphone, tablet computer, or portable computer.

[0044] like Figure 1 As shown, the terminal may include: a processor 1001, such as a CPU (Central Processing Unit), a communication bus 1002, and a memory 1003. The communication bus 1002 is used to establish communication between these components. The memory 1003 may be high-speed RAM or stable non-volatile memory, such as disk storage. Optionally, the memory 1003 may also be a storage device independent of the aforementioned processor 1001.

[0045] Those skilled in the art will understand that Figure 1 The terminal structure shown does not constitute a limitation on the terminal and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0046] like Figure 1 As shown, the memory 1003, which serves as a computer storage medium, may include a ledger update program.

[0047] exist Figure 1 In the terminal shown, the processor 1001 can be used to call the ledger update program stored in the memory 1003 and perform the following operations:

[0048] When a target transaction is received, the target node corresponding to the target transaction and the target channel to which the target node belongs are obtained;

[0049] The target transaction is verified through consensus nodes within the target channel. If the consensus verification passes, the transaction information of the target transaction is obtained.

[0050] The target chaincode corresponding to the target node is invoked to update the transaction information in the target ledger corresponding to the target channel.

[0051] exist Figure 1 In the terminal shown, the processor 1001 can be used to call the ledger update program stored in the memory 1003 and perform the following operations:

[0052] When a consensus mechanism creation instruction is received, the first channel corresponding to the consensus mechanism creation instruction is obtained;

[0053] Obtain the first public key and the first private key generated by the first node in the first channel, and store the first private key at the private key storage point in the first channel;

[0054] The first public key is sent to all nodes in the first channel except the first node, so that each node in the first channel has the public keys of all nodes in the first channel.

[0055] exist Figure 1 In the terminal shown, the processor 1001 can be used to call the ledger update program stored in the memory 1003 and perform the following operations:

[0056] The public key of the consensus node in the target channel is matched with the private key corresponding to the target transaction, and it is determined whether the private key storage point in the target channel stores the private key corresponding to the target transaction.

[0057] If the public key possessed by the consensus node matches the private key corresponding to the target transaction, and the private key storage point in the target channel stores the private key corresponding to the target transaction, then the target transaction is signed by the consensus node.

[0058] If the target transaction has the signatures of all the consensus nodes, then the target transaction is determined to have passed consensus verification, and the transaction information of the target transaction is obtained.

[0059] exist Figure 1 In the terminal shown, the processor 1001 can be used to call the ledger update program stored in the memory 1003 and perform the following operations:

[0060] If a transaction initiating node initiates a first transaction to a transaction receiving node, and the channel to which the transaction initiating node belongs is different from the channel to which the transaction receiving node belongs, then the first number of the first channel to which the transaction initiating node belongs, and the second number of the second channel to which the transaction receiving node belongs, are obtained.

[0061] Generate first transaction information and second transaction information for the first transaction, as well as chaincode connecting the first channel and the second channel, wherein the first transaction information includes the second number and the node information of the transaction receiving node, and the second transaction information includes the first number and the node information of the transaction initiating node;

[0062] If a transaction initiating node initiates a first transaction to a transaction receiving node, and the channel to which the transaction initiating node belongs is the same as the channel to which the transaction receiving node belongs, then first transaction information for the first transaction is generated, wherein the first transaction information includes the node information of the transaction initiating node and the node information of the transaction receiving node.

[0063] exist Figure 1 In the terminal shown, the processor 1001 can be used to call the ledger update program stored in the memory 1003 and perform the following operations:

[0064] If the channel to which the transaction start node belongs is different from the channel to which the transaction end node belongs, and the transaction information includes the node information of the transaction start node, then the chaincode corresponding to the transaction end node is called to update the transaction information in the ledger corresponding to the channel to which the transaction end node belongs.

[0065] If the channel to which the transaction initiation node belongs is different from the channel to which the transaction end node belongs, and the transaction information includes the node information of the transaction end node, then the chaincode corresponding to the transaction initiation node is invoked to update the transaction information in the ledger corresponding to the channel to which the transaction initiation node belongs.

[0066] exist Figure 1 In the terminal shown, the processor 1001 can be used to call the ledger update program stored in the memory 1003 and perform the following operations:

[0067] If the transaction start node and the transaction end node do not belong to the same channel, then obtain the transaction initiation amount and transaction receipt amount of the target transaction;

[0068] The transaction initiation amount is locked in the channel to which the transaction initiation node belongs, and the transaction receipt amount is locked in the channel to which the transaction end node belongs;

[0069] The step of calling the target chaincode corresponding to the target node to update the transaction information in the target ledger corresponding to the target channel includes:

[0070] After the transaction received amount is locked, the chaincode corresponding to the transaction initiation node is called to update the transaction information in the ledger corresponding to the channel to which the transaction initiation node belongs, and the chaincode corresponding to the transaction end node is called to update the transaction information in the ledger corresponding to the channel to which the transaction end node belongs.

[0071] Based on the above-described device hardware structure, an embodiment of the ledger update method of the present invention is proposed.

[0072] Reference Figure 2In a first embodiment of the ledger update method of the present invention, the ledger update method includes:

[0073] Step S10: When a target transaction is received, obtain the target node corresponding to the target transaction and the target channel to which the target node belongs;

[0074] It should be noted that the ledger update method disclosed in this invention is applied to, for example, Figure 3 The blockchain network shown (hereinafter referred to as blockchain) involves transactions occurring between two different nodes within the blockchain network. Figure 3 As can be seen, in a blockchain, a node can belong to only one channel (for example, node 1 belongs to only channel 1), or a node can belong to multiple channels (for example, node 2 belongs to both channel 1 and channel 2). In the blockchain disclosed in this invention, not every node needs to maintain a ledger, but rather each channel maintains a ledger. The ledger records the transactions in which the nodes in that channel participate. For example, the ledger maintained by channel 1 records the transactions in which nodes 1, 2, and 3 participate.

[0075] When the blockchain receives a target transaction, it identifies the nodes participating in the target transaction, i.e., the target nodes in this embodiment, and obtains the target channels described by the target nodes. For example, if the target transaction occurs between node 1 and node 3, where node 1 and node 3 are the initiator and responder of the target transaction respectively, then node 1 and node 3 are the target nodes in this embodiment, and channel 1 to which node 1 and node 3 belong is the target channel in this embodiment. Alternatively, if the target transaction occurs between node 3 and node 6, then node 3 and node 6 are the target nodes in this embodiment, and channel 1 to which node 3 belongs and channel 3 to which node 6 belongs are the target channels in this embodiment. Yet another example: if the target transaction occurs between node 3 and node 4, then node 3 and node 4 are the target nodes in this embodiment, and channel 1 to which node 1 belongs and channels 2 and 3 to which node 4 belong are the target channels in this embodiment.

[0076] Step S20: Perform consensus verification on the target transaction through the consensus node in the target channel. If the consensus verification is successful, obtain the transaction information of the target transaction.

[0077] It should be noted that the ledger update method disclosed in this embodiment also performs consensus verification on the authenticity of the target transaction. The purpose of consensus verification is to determine the authenticity of the target transaction, that is, whether the target transaction was initiated or responded to by the target node. If the consensus verification determines that the target transaction was initiated or responded to by the target node, the consensus verification is passed. After the consensus verification is passed, the transaction information of the target transaction is obtained, such as the transaction amount and transaction time. In this embodiment, the consensus node is one or more of the other nodes in the target channel besides the target node.

[0078] by Figure 3 For example, this embodiment provides a consensus verification method. Suppose the target transaction occurs between node 1 and node 6, and node 1 is the initiator of the target transaction. In channel 1, nodes 2 and 3 are the consensus nodes for the target transaction. Before the target transaction is initiated, nodes 2 and 3 have already stored the public key of node 1 (pre-generated). Only nodes deemed capable of being consensus nodes can store the public keys of other nodes. The private key pre-generated by node 1 is stored in a storage area within channel 1 specifically used to store the private keys generated by each node in channel 1 (hereinafter referred to as the private key storage point). At the start of consensus verification, nodes 2 and 3... Point 2 and Node 3 verify the public key carried in the target transaction based on their own stored public keys, and the private key storage point verifies the private key carried in the target transaction initiated by Node 1. After all the above verifications are passed, the consensus verification is determined to be successful. Specifically, this embodiment provides an example of a specific verification process. If the public key of Node 1 stored by Node 2 and Node 3 is the same as the public key carried in the target transaction, and the private key of Node 1 stored by the private key storage point is the same as the private key carried in the target transaction, then the consensus verification is determined to be successful. The consensus verification as described above will also be performed in channel 3 to which Node 6 belongs to, in order to verify the authenticity of Node 6's response to the target transaction.

[0079] Step S30: Call the target chaincode corresponding to the target node to update the transaction information to the target ledger corresponding to the target channel.

[0080] It should be noted that the ledger update method disclosed in this embodiment, in addition to reducing ledger maintenance costs and node storage space usage, can also isolate transaction data. That is, nodes can only obtain transaction information from the ledger maintained by their respective channels. For example, Figure 3 As shown, node 3 can only obtain transaction information from the channel 1 ledger, that is, transaction information related to nodes 1, 2 and 3, but cannot obtain transaction information related to nodes 4, 5 and 6, which also improves the security of transaction information.

[0081] Based on the above, it is clear that node 1 cannot obtain transaction information related to node 6. That is, channel 1, to which node 1 belongs, cannot obtain transaction information related to node 6 recorded in the ledger of channel 3 by connecting with channel 3. In the ledger update method disclosed in this embodiment, the connection between channel 1 and channel 3 is implemented through chaincode (i.e., smart contract). When the target transaction occurs between node 1 and node 6, node 1 and node 6 are the target nodes in this embodiment. The transaction information needs to be sent to channel 3 through the connection between channel 1 and channel 3. The connection between channel 1 and channel 3 is implemented through the target chaincode. The target chaincode corresponding to the target node is called to realize the connection between channel 1 and channel 3. Then, the transaction information is updated to the ledger maintained by channel 3 (i.e., the target ledger in this embodiment). After the consensus verification of the target transaction in channel 1 and channel 3 is passed, the transaction information is directly updated to the ledger maintained by channel 1.

[0082] Furthermore, in a feasible embodiment, step S10 above, when a target transaction is received, involves obtaining the target node corresponding to the target transaction and the target channel to which the target node belongs. The preceding steps include:

[0083] Step a1: When a consensus mechanism creation instruction is received, obtain the first channel corresponding to the consensus mechanism creation instruction;

[0084] Step a2: Obtain the first public key and the first private key generated by the first node in the first channel, and store the first private key in the private key storage point in the first channel;

[0085] Step a3: Send the first public key to all nodes in the first channel except the first node, so that each node in the first channel has the public key of all nodes in the first channel.

[0086] It should be noted that the blockchain consensus mechanism is pre-created. During the blockchain construction phase before receiving the target transaction, the blockchain receives the consensus mechanism creation instruction, obtains the channel for creating the consensus mechanism (i.e., the first channel in this embodiment), and then obtains the first public key and first private key generated by the first node within the first channel. The first private key generated by the first node is then stored in the private key storage point within the first channel. Simultaneously, the first public key generated by the first node is sent to all other nodes within the first channel except for the first node, so that each node in the first channel possesses the public keys of all nodes within the first channel. It is also possible that the first public key is sent only to a few nodes within the first channel besides the first node. Nodes within the first channel that receive public keys sent by other nodes can act as consensus nodes for transactions related to the node that sent the public key, such as... Figure 3As shown, for example, if node 1 in channel 1 sends its own generated public key to node 3, then node 3 can serve as a consensus node for transactions related to node 1. Node 3 can participate in the consensus verification process for transactions related to node 1. For node 1, node 3 is a trustworthy node.

[0087] Furthermore, in a feasible embodiment, step S20 above involves consensus verification of the target transaction through consensus nodes within the target channel. If the consensus verification passes, the transaction information of the target transaction is obtained. Detailed steps include:

[0088] Step S21: Match the public key owned by the consensus node in the target channel with the private key corresponding to the target transaction, and determine whether the private key storage point in the target channel stores the private key corresponding to the target transaction.

[0089] Step S22: If the public key owned by the consensus node matches the private key corresponding to the target transaction, and the private key storage point in the target channel stores the private key corresponding to the target transaction, then the consensus node signs the target transaction.

[0090] Step S23: If the target transaction has the signatures of all the consensus nodes, then the target transaction is determined to have passed consensus verification, and the transaction information of the target transaction is obtained.

[0091] like Figure 3 As shown, assuming the target channel in this embodiment includes channel 1, and the target transaction is a transaction initiated by node 1 to node 6, with node 1 being the initiating node, and node 2 and node 3 being the consensus nodes of node 1 in channel 1, then during the consensus verification process, the public key of node 1 held by the consensus node (node ​​2) of node 1 in channel 1 is matched with the private key carried in the transaction initiated by node 1 to node 6. If the public key of node 1 held by node 2 matches the private key carried in the transaction initiated by node 1 to node 6, it indicates that the private key carried in the transaction initiated by node 1 to node 6 is the private key generated by node 1, verifying that the target transaction was initiated by node 1 and that the target transaction is genuine. At the same time, the private key storage point in channel 1 stores the private key (carried in the transaction initiated by node 1 to node 6), thus determining that the consensus verification of the target transaction has passed. Node 2 signs the target transaction, and then node 3 also performs the above operation. If the transaction initiated by node 1 to node 6 (i.e., the target transaction in this embodiment) has the signatures of nodes 2 and 3, then it is determined that the target transaction has passed the consensus verification, and the transaction information of the target transaction is obtained.

[0092] Furthermore, in a feasible embodiment, step S10 above, when a target transaction is received, involves obtaining the target node corresponding to the target transaction and the target channel to which the target node belongs. The preceding steps include:

[0093] Step b1: If the transaction initiating node initiates a first transaction to the transaction receiving node, and the channel to which the transaction initiating node belongs is different from the channel to which the transaction receiving node belongs, then obtain the first number of the first channel to which the transaction initiating node belongs, and the second number of the second channel to which the transaction receiving node belongs.

[0094] Step b2: Generate first transaction information and second transaction information for the first transaction, wherein the first transaction information includes the second number and the node information of the transaction receiving node, and the second transaction information includes the first number and the node information of the transaction initiating node;

[0095] Step b3: If the transaction initiating node initiates a first transaction to the transaction receiving node, and the channel to which the transaction initiating node belongs is the same as the channel to which the transaction receiving node belongs, then the first transaction information of the first transaction is generated, wherein the first transaction information includes the node information of the transaction initiating node and the node information of the transaction receiving node.

[0096] like Figure 3 As shown, assuming the first transaction in this embodiment is a transaction initiated by node 1 to node 6, the transaction initiating node in this embodiment is node 1, the transaction receiving node in this embodiment is node 6, the channel to which the transaction initiating node belongs is channel 1, and the channel to which the transaction receiving node belongs is channel 3. The channel to which the transaction initiating node belongs is different from the channel to which the transaction receiving node belongs. In this case, the first number of the first channel to which the transaction initiating node belongs is obtained, that is, the number of channel 1 is obtained. In the ledger update method disclosed in this embodiment, each channel has its corresponding number. Assuming the number of channel 1 is 001 and the number of channel 3 is 003. Because there are two channels related to the first transaction, the transaction information of the first transaction needs to be updated in the ledgers maintained by the two channels, namely, the channel 1 ledger and the channel 3 ledger. In this embodiment, the transaction information updated in the channel 1 ledger and the channel 3 ledger are different. The transaction information of the first transaction includes first transaction information and second transaction information. The first transaction information updated in the channel 1 ledger includes the channel number 003 of channel 3 and the node information of node 6. The second transaction information updated in the channel 3 ledger includes the channel number 001 of channel 1 and the node information of node 1. When a transaction occurs in multiple channels, the channel number of the channel to which the transaction receiving node belongs is added to the transaction information updated in the ledger of the channel corresponding to the transaction initiating node, making the transaction information of cross-channel transactions clearer.

[0097] Assuming the first transaction in this embodiment is a transaction initiated by node 1 to node 3, with node 1 as the initiating node and node 3 as the receiving node, and the channels to which the initiating node and the receiving node belong are the same (channel 1), then there is no need to obtain the channel 1 number. The transaction information of the first transaction only needs to be updated in the channel 1 ledger. The first transaction information updated in the channel 1 ledger includes the node information of node 1 and node 3. When the transaction only occurs within one channel, the channel number is not added to the transaction information updated in the channel ledger, thus reducing the storage space of the transaction information in the channel ledger.

[0098] Furthermore, in a feasible embodiment, step S30 above, which involves calling the target chaincode corresponding to the target node to update the transaction information in the target ledger corresponding to the target channel, includes the following detailed steps:

[0099] Step c1: If the channel to which the transaction start node belongs is different from the channel to which the transaction end node belongs, and the transaction information includes the node information of the transaction start node, then call the chaincode corresponding to the transaction end node to update the transaction information to the ledger corresponding to the channel to which the transaction end node belongs.

[0100] Step c2: If the channel to which the transaction start node belongs is different from the channel to which the transaction end node belongs, and the transaction information includes the node information of the transaction end node, then the chaincode corresponding to the transaction start node is called to update the transaction information in the ledger corresponding to the channel to which the transaction start node belongs.

[0101] It is known that if the channel to which the transaction initiation node belongs is different from the channel to which the transaction end node belongs, and the transaction information includes the node information of the transaction initiation node, then, as described above, the transaction information including the node information of the transaction initiation node will be updated to the ledger corresponding to the channel to which the transaction end node belongs. In this case, by calling the chaincode corresponding to the transaction end node, the transaction information including the node information of the transaction initiation node is updated to the ledger corresponding to the channel to which the transaction end node belongs. In this embodiment, updating the transaction information to the ledger is achieved through chaincode. One ledger can correspond to one chaincode. For example, the channel 1 ledger corresponds to the first chaincode, and all transaction information that needs to be updated to the channel 1 ledger can be achieved through the first chaincode. One node can correspond to one chaincode. For example, node 1 corresponds to the second chaincode, and all transaction information related to node 1 can be updated to the channel 1 ledger through the second chaincode.

[0102] In this embodiment, the ledger update method is applied to the blockchain. When the blockchain receives a target transaction, it obtains the target node corresponding to the target transaction and the target channel to which the target node belongs. Then, it performs consensus verification on the target transaction through the consensus node in the target channel. If the consensus verification is successful, it obtains the transaction information of the target transaction. Finally, it calls the target chaincode corresponding to the target node to update the transaction information to the target ledger corresponding to the target channel. This invention maintains a ledger through a channel containing multiple nodes, which reduces the ledger maintenance cost and the occupation of node storage space.

[0103] Furthermore, referring to Figure 4 Based on the above embodiments of the present invention, a second embodiment of the ledger update method of the present invention is proposed.

[0104] This embodiment is a step following step S20 in the first embodiment. The difference between this embodiment and the above embodiments of the present invention is as follows:

[0105] Step S40: If the transaction start node and the transaction end node do not belong to the same channel, then obtain the transaction initiation amount and transaction receipt amount of the target transaction;

[0106] like Figure 3 As shown, assuming the transaction starts at node 1 and ends at node 6, with node 1 belonging to channel 1 and node 6 belonging to channel 3, the transaction start node and the transaction end node do not belong to the same channel. The target transaction is node 1 exchanging 80a for 100b from node 6. The target transaction is initiated by node 1, where 'a' is the "currency" unit used by node 1 for the transaction and 'b' is the "currency" unit used by node 6 for the transaction. Therefore, the transaction initiation amount and transaction receipt amount of the target transaction are 80a and 100b, respectively.

[0107] Step S50: Lock the transaction initiation amount in the channel to which the transaction initiation node belongs, and lock the transaction receipt amount in the channel to which the transaction end node belongs;

[0108] As can be seen from the above, after determining the transaction initiation amount and the transaction receipt amount, 80a is locked in channel 1 and 100b is locked in channel 3. Locking 80a in channel 1 occurs after the target transaction passes consensus verification in channel 1. Similarly, locking 100b in channel 3 occurs after the target transaction passes consensus verification in channel 3. It should be noted that 80a is locked in channel 1 first, and then 100b is locked in channel 3. If the target transaction fails to pass consensus verification in channel 3 after locking 80a in channel 1, the target transaction is canceled, and 80a is unlocked in channel 1. The benefits of locking the transaction initiation amount and the transaction receipt amount are: to prevent node 6 from "reneging" or "underpaying" after node 1 has "paid," to reduce communication between channel 1 and channel 3 during the transaction process, and to prevent node 1 from withdrawing 80a after node 6 receives it, causing the problem of 80a being respent. After both 80a and 100b are locked, the blockchain will mark 80a and 100b as spent.

[0109] Step S30 above involves calling the target chaincode corresponding to the target node to update the transaction information in the target ledger corresponding to the target channel. Detailed steps include:

[0110] Step S31: After the transaction received amount is locked, the chaincode corresponding to the transaction start node is called to update the transaction information to the ledger corresponding to the channel to which the transaction start node belongs, and the chaincode corresponding to the transaction end node is called to update the transaction information to the ledger corresponding to the channel to which the transaction end node belongs.

[0111] It should be noted that 80a is locked in channel 1 first, and then 100b is locked in channel 3. Once 100b is locked in channel 3, it means that the target transaction can be basically confirmed as completed. The remaining process is for the blockchain to mark 80a and 100b as spent. In this case, the chaincode corresponding to node 1 (or the chaincode corresponding to channel 1) is called to update the transaction information containing node 6 and 003 (channel code of channel 3) in the channel 1 ledger, and the chaincode corresponding to node 6 (or the chaincode corresponding to channel 3) is called to update the transaction information containing node 1 and 001 (channel code of channel 1) in the channel 3 ledger.

[0112] In this embodiment, by locking the amount related to the target transaction in the channel, the ledger maintenance cost and node storage space are reduced, while the problem of transaction amount respending is also avoided.

[0113] In addition, refer to Figure 5 The present invention also proposes a ledger updating device, the ledger updating device comprising:

[0114] The acquisition module 10 is used to acquire the target node corresponding to the target transaction and the target channel to which the target node belongs when the target transaction is received;

[0115] The consensus verification module 20 is used to perform consensus verification on the target transaction through the consensus node in the target channel. If the consensus verification is successful, the transaction information of the target transaction is obtained.

[0116] Ledger update module 30 is used to call the target chaincode corresponding to the target node and update the transaction information to the target ledger corresponding to the target channel.

[0117] Optionally, the ledger updating device further includes:

[0118] The first channel acquisition module is used to acquire the first channel corresponding to the consensus mechanism creation instruction when a consensus mechanism creation instruction is received.

[0119] The private key storage module is used to obtain the first public key and the first private key generated by the first node in the first channel, and store the first private key in the private key storage point in the first channel;

[0120] The public key sending module is used to send the first public key to other nodes in the first channel besides the first node, so that each node in the first channel has the public keys of all nodes in the first channel.

[0121] Optionally, the consensus verification module 20 includes:

[0122] The judgment unit is used to match the public key owned by the consensus node in the target channel with the private key corresponding to the target transaction, and to determine whether the private key storage point in the target channel stores the private key corresponding to the target transaction.

[0123] A node signing unit is used to sign the target transaction if the public key owned by the consensus node matches the private key corresponding to the target transaction, and the private key storage point in the target channel stores the private key corresponding to the target transaction.

[0124] The transaction information acquisition unit is used to determine that the target transaction has passed consensus verification if the target transaction has the signatures of all the consensus nodes, and to acquire the transaction information of the target transaction.

[0125] Optionally, the ledger updating device further includes:

[0126] The channel number acquisition module is used to acquire the first number of the first channel to which the transaction initiating node belongs and the second number of the second channel to which the transaction receiving node belongs if the transaction initiating node initiates a first transaction to the transaction receiving node and the channel to which the transaction initiating node belongs is different from the channel to which the transaction receiving node belongs.

[0127] The first transaction information generation module is used to generate first transaction information and second transaction information of the first transaction, wherein the first transaction information includes the second number and the node information of the transaction receiving node, and the second transaction information includes the first number and the node information of the transaction initiating node;

[0128] The second transaction information generation module is used to generate first transaction information for the first transaction if the transaction initiating node initiates a first transaction to the transaction receiving node, and the channel to which the transaction initiating node belongs is the same as the channel to which the transaction receiving node belongs. The first transaction information includes the node information of the transaction initiating node and the node information of the transaction receiving node.

[0129] Optionally, the target node includes a transaction start node and a transaction end node, and the ledger update module 30 includes:

[0130] The chaincode invocation unit is used to invoke the chaincode corresponding to the transaction end node to update the transaction information to the ledger corresponding to the channel to which the transaction end node belongs if the channel to which the transaction start node belongs is different from the channel to which the transaction end node belongs, and the transaction information includes the node information of the transaction start node.

[0131] The transaction information update unit is used to call the chaincode corresponding to the transaction start node to update the transaction information to the ledger corresponding to the channel to which the transaction start node belongs if the channel to which the transaction start node belongs is different from the channel to which the transaction end node belongs, and the transaction information includes the node information of the transaction end node.

[0132] Optionally, the ledger updating device further includes:

[0133] The transaction amount acquisition module is used to acquire the transaction initiation amount and transaction receipt amount of the target transaction if the transaction start node and the transaction end node do not belong to the same channel.

[0134] The amount locking module is used to lock the transaction initiation amount in the channel to which the transaction initiation node belongs, and to lock the transaction received amount in the channel to which the transaction end node belongs;

[0135] The ledger update module 30 includes:

[0136] The ledger update unit is used to, after the transaction received amount is locked, call the chaincode corresponding to the transaction start node to update the transaction information to the ledger corresponding to the channel to which the transaction start node belongs, and call the chaincode corresponding to the transaction end node to update the transaction information to the ledger corresponding to the channel to which the transaction end node belongs.

[0137] Furthermore, this embodiment of the invention also proposes a computer-readable storage medium storing a ledger update program, which, when executed by a processor, implements the operations in the ledger update method provided in the above embodiments.

[0138] The methods executed by the above-mentioned program modules can be referred to in the various embodiments of the ledger update method of the present invention, and will not be repeated here.

[0139] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity / operation / object from another, and do not necessarily require or imply any such actual relationship or order between these entities / operations / objects; the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.

[0140] For the apparatus embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and relevant details can be found in the description of the method embodiments. The apparatus embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separate. Some or all of the modules can be selected according to actual needs to achieve the purpose of the present invention. Those skilled in the art can understand and implement this without any creative effort.

[0141] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0142] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the ledger update method described in the various embodiments of the present invention.

[0143] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.

Claims

1. A ledger updating method, characterized in that, The ledger update method includes the following steps: When a target transaction is received, the target node corresponding to the target transaction and the target channel to which the target node belongs are obtained; The public key of the consensus node in the target channel is matched with the private key corresponding to the target transaction, and it is determined whether the private key storage point in the target channel stores the private key corresponding to the target transaction. If the public key possessed by the consensus node matches the private key corresponding to the target transaction, and the private key storage point in the target channel stores the private key corresponding to the target transaction, then the target transaction is signed by the consensus node. If the target transaction has the signatures of all the consensus nodes, then the target transaction is determined to have passed consensus verification, and the transaction information of the target transaction is obtained; The target chaincode corresponding to the target node is invoked to update the transaction information in the target ledger corresponding to the target channel; If the target transaction is a cross-channel transaction, the transaction initiation amount is locked in the channel to which the transaction initiation node belongs, and the transaction reception amount is locked in the channel to which the transaction end node belongs. The target chaincode is invoked to update the ledgers of both channels after the locking is completed.

2. The ledger update method as described in claim 1, characterized in that, Before the step of obtaining the target node corresponding to the target transaction and the target channel to which the target node belongs when the target transaction is received, the following steps are included: When a consensus mechanism creation instruction is received, the first channel corresponding to the consensus mechanism creation instruction is obtained; Obtain the first public key and the first private key generated by the first node in the first channel, and store the first private key at the private key storage point in the first channel; The first public key is sent to all nodes in the first channel except the first node, so that each node in the first channel has the public keys of all nodes in the first channel.

3. The ledger updating method as described in claim 1, characterized in that, Before the step of obtaining the target node corresponding to the target transaction and the target channel to which the target node belongs when the target transaction is received, the following steps are included: If a transaction initiating node initiates a first transaction to a transaction receiving node, and the channel to which the transaction initiating node belongs is different from the channel to which the transaction receiving node belongs, then the first number of the first channel to which the transaction initiating node belongs, and the second number of the second channel to which the transaction receiving node belongs, are obtained. Generate first transaction information and second transaction information for the first transaction, wherein the first transaction information includes the second number and the node information of the transaction receiving node, and the second transaction information includes the first number and the node information of the transaction initiating node; If a transaction initiating node initiates a first transaction to a transaction receiving node, and the channel to which the transaction initiating node belongs is the same as the channel to which the transaction receiving node belongs, then first transaction information for the first transaction is generated, wherein the first transaction information includes the node information of the transaction initiating node and the node information of the transaction receiving node.

4. The ledger update method as described in claim 3, characterized in that, The target node includes a transaction start node and a transaction end node. The step of calling the target chaincode corresponding to the target node to update the transaction information in the target ledger corresponding to the target channel includes: If the channel to which the transaction start node belongs is different from the channel to which the transaction end node belongs, and the transaction information includes the node information of the transaction start node, then the chaincode corresponding to the transaction end node is called to update the transaction information in the ledger corresponding to the channel to which the transaction end node belongs. If the channel to which the transaction initiation node belongs is different from the channel to which the transaction end node belongs, and the transaction information includes the node information of the transaction end node, then the chaincode corresponding to the transaction initiation node is invoked to update the transaction information in the ledger corresponding to the channel to which the transaction initiation node belongs.

5. The ledger update method as described in claim 4, characterized in that, After the step of determining that the target transaction has passed consensus verification and obtaining the transaction information of the target transaction if the target transaction has the signatures of all the consensus nodes, the method includes: If the transaction start node and the transaction end node do not belong to the same channel, then obtain the transaction initiation amount and transaction receipt amount of the target transaction; The transaction initiation amount is locked in the channel to which the transaction initiation node belongs, and the transaction receipt amount is locked in the channel to which the transaction end node belongs; The step of calling the target chaincode corresponding to the target node to update the transaction information in the target ledger corresponding to the target channel includes: After the transaction received amount is locked, the chaincode corresponding to the transaction initiation node is called to update the transaction information in the ledger corresponding to the channel to which the transaction initiation node belongs, and the chaincode corresponding to the transaction end node is called to update the transaction information in the ledger corresponding to the channel to which the transaction end node belongs.

6. A ledger updating device, characterized in that, The ledger updating device includes: The acquisition module is used to acquire the target node corresponding to the target transaction and the target channel to which the target node belongs when the target transaction is received; The consensus verification module is used to match the public key owned by the consensus node in the target channel with the private key corresponding to the target transaction, and to determine whether the private key storage point in the target channel stores the private key corresponding to the target transaction. If the public key owned by the consensus node matches the private key corresponding to the target transaction, and the private key storage point in the target channel stores the private key corresponding to the target transaction, then the consensus node signs the target transaction. If the target transaction has the signatures of all the consensus nodes, then the target transaction is determined to have passed the consensus verification, and the transaction information of the target transaction is obtained. The ledger update module is used to call the target chaincode corresponding to the target node and update the transaction information to the target ledger corresponding to the target channel.

7. A ledger updating device, characterized in that, The ledger update device includes: a memory, a processor, and a ledger update program stored in the memory and executable on the processor, wherein the ledger update program, when executed by the processor, implements the steps of the ledger update method as described in any one of claims 1 to 5.

8. A storage medium, characterized in that, The storage medium stores a ledger update program, which, when executed by a processor, implements the steps of the ledger update method as described in any one of claims 1 to 5.

9. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the steps of the ledger update method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Transaction method of multi-channel block chain, electronic equipment and storage medium

    CN111222989A