WO2021068477A1 - 区块处理方法、装置、计算机设备及存储介质 - Google Patents

区块处理方法、装置、计算机设备及存储介质 Download PDF

Info

Publication number
WO2021068477A1
WO2021068477A1 PCT/CN2020/085562 CN2020085562W WO2021068477A1 WO 2021068477 A1 WO2021068477 A1 WO 2021068477A1 CN 2020085562 W CN2020085562 W CN 2020085562W WO 2021068477 A1 WO2021068477 A1 WO 2021068477A1
Authority
WO
WIPO (PCT)
Prior art keywords
node
data
peer node
peer
orderer
Prior art date
Application number
PCT/CN2020/085562
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 WO2021068477A1 publication Critical patent/WO2021068477A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/12Applying verification of the received information
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees

Definitions

  • This application relates to the field of blockchain technology, in particular to a block processing method, device, computer equipment and storage medium.
  • Blockchain is generally understood as a distributed ledger, and its essence is a distributed database.
  • each peer node needs to receive the completed block, and all transactions and blocks that occur in the blockchain network need to be verified.
  • the traditional method is that the transaction terminal initiates the transaction, and the peer node returns the transaction result to the transaction terminal after executing the transaction, and through the orderer node, the corresponding transaction results of all peer nodes in the blockchain are packaged to generate a complete block, and the block It is sent to each node in the blockchain network, and finally each node verifies the block, and finally each node writes the verified block into the block file.
  • each peer node needs to verify the blocks generated by all transactions in the blockchain.
  • Each peer node has repeated verification work, and the peer node has a large workload and heavy burden. Both need to occupy too much network resources, and the utilization rate of network resources is low.
  • the embodiments of the present application provide a block processing method, device, computer equipment, and storage medium, which are used to solve the problem that the peer node has a heavy workload and needs to occupy too many network resources, and the utilization rate of network resources is low.
  • a block processing method is applied to an orderer node in a blockchain network.
  • the blockchain network further includes a transaction terminal and multiple peer nodes.
  • the method includes:
  • the orderer node packages the transaction data corresponding to each peer node fed back by the transaction terminal into an original block, and each peer node is a peer node corresponding to the same blockchain channel in the blockchain network.
  • the transaction data Is the transaction data generated in the blockchain channel;
  • the orderer node fragments the original block to obtain multiple data fragments, each of the data fragments includes transaction data corresponding to at least one of the peer nodes;
  • the orderer node sends the first data fragment to the first peer node, so that the first peer node according to the first data fragment, the first verification result corresponding to the first data fragment data, and the first peer node
  • the second data fragment and the second verification result data shared by the two peer nodes generate a final block, and write it into the block file corresponding to the first peer node;
  • the first data fragment includes at least one data fragment among the multiple data fragments
  • the first peer node is a certain peer node among peer nodes corresponding to the same blockchain channel
  • the second data fragment is data fragments other than the first data fragment among multiple data fragments
  • the second peer node is a peer node of each peer node that is allocated to the second data fragment.
  • a block processing method is applied to a first peer node in a block chain network, the block chain network further includes an orderer node and a transaction terminal, and the method includes:
  • the first peer node receives the first data fragment sent by the orderer node, where the first data fragment includes at least one data fragment among a plurality of data fragments, and the plurality of data fragments are the
  • the orderer node shards the original block to obtain the original block.
  • the original block is formed by the orderer node packaging the transaction data corresponding to each peer node fed back by the transaction terminal, and each peer node is the zone
  • the peer node corresponding to the same blockchain channel in the blockchain network the transaction data is transaction data generated in the blockchain channel
  • the first peer node is the peer node corresponding to the same blockchain channel A peer node in;
  • the first peer node verifies the legitimacy of the transaction data corresponding to the first data segment to obtain the first verification result data corresponding to the first data segment;
  • the first peer node receives the second data fragment and the second verification result data fed back by the second peer node, wherein the second data fragment is divided by the first data fragment among the plurality of data fragments.
  • the second peer node is a peer node of each peer node that is allocated to the second data shard;
  • the first peer node generates a final block according to the first and second data fragments and the first and second verification result data
  • the first peer node writes the final block into a block file corresponding to the first peer node.
  • a block processing device is applied to an orderer node in a block chain network.
  • the block chain network further includes a transaction terminal and a plurality of peer nodes.
  • the block processing device includes:
  • the packaging module is used to package the transaction data corresponding to each peer node fed back by the transaction terminal into an original block, where each peer node is a peer node corresponding to the same blockchain channel in the blockchain network, and the transaction The data is transaction data generated in the blockchain channel;
  • the fragmentation module is used to fragment the original block to obtain multiple data fragments, each of the data fragments containing transaction data corresponding to at least one of the peer nodes
  • the sending module is configured to send the first data fragment to the first peer node, so that the first peer node according to the first data fragment, the first verification result corresponding to the first data fragment data, and The second data fragment and the second verification result data shared by the second peer node generate a final block, and write it into the block file corresponding to the first peer node;
  • the first data fragment includes at least one data fragment among the multiple data fragments
  • the first peer node is a certain peer node among peer nodes corresponding to the same blockchain channel
  • the second data fragment is data fragments other than the first data fragment among multiple data fragments
  • the second peer node is a peer node of each peer node that is allocated to the second data fragment.
  • a block processing device is applied to a first peer node in a block chain network, the block chain network further includes an orderer node and a transaction terminal, and the block processing device includes:
  • the receiving module is configured to receive the first data fragment sent by the orderer node, wherein the first data fragment includes at least one data fragment among a plurality of data fragments, and the plurality of data fragments are all
  • the orderer node is obtained by slicing the original block, and the original block is formed by the orderer node packaging the transaction data corresponding to each peer node fed back by the transaction terminal, and each peer node is the The peer node corresponding to the same blockchain channel in the blockchain network, the transaction data is transaction data generated in the blockchain channel, and the first peer node is the peer corresponding to the same blockchain channel A certain peer node in the node;
  • the verification module is used to verify the legitimacy of the transaction data corresponding to the first data segment, so as to obtain the first verification result data corresponding to the first data segment;
  • the receiving module is further configured to receive the second data fragment and the second verification result data fed back by the second peer node, wherein the second data fragment is divided by the first data fragment from the plurality of data fragments.
  • the second peer node is the peer node allocated to the second data fragment among the peer nodes;
  • the generation module is used to generate the final block based on the first and second data fragments and the first and second verification result data;
  • the writing module is used to write the final block into the block file corresponding to the first peer node.
  • a computer device includes a memory, a processor, and a computer program that is stored in the memory and can run on the processor, and the processor implements the steps of the block processing method when the computer program is executed.
  • a computer-readable storage medium that stores a computer program that implements the steps of the block processing method described above when the computer program is executed by a processor.
  • the peer node of the same blockchain channel no longer verifies all transaction data of the complete block. Specifically, each peer node only It is only necessary to verify part of the transaction data in a block, which can reduce the repeated verification of each peer node, reduce the workload of each peer node, and reduce the network resources occupied by each peer node, thereby improving the blockchain Utilization of network resources in.
  • FIG. 1 is a schematic diagram of a block chain network used in the block processing method in the embodiment of the present application;
  • FIG. 2 is a schematic flowchart of an embodiment of the block processing method in this application.
  • FIG. 3 is a schematic flowchart of another embodiment of the block processing method in this application.
  • FIG. 5 is a schematic flowchart of another embodiment of the block processing method in this application.
  • FIG. 6 is a schematic flowchart of another embodiment of the block processing party in this application.
  • FIG. 7 is a schematic flowchart of another embodiment of the block processing party in this application.
  • FIG. 8 is a schematic structural diagram of the block processing device in this application.
  • FIG. 9 is a schematic diagram of another structure of the block processing device in the present application.
  • FIG. 10 is a schematic diagram of the structure of the computer equipment in this application.
  • the system framework of this solution mainly involves several main bodies, as shown in Figure 1.
  • This application is implemented
  • the block processing method provided in the example should be in the blockchain network as shown in Figure 1.
  • the above-mentioned subjects are transaction terminals and various transaction institutions.
  • Transaction institutions refer to peers set up for a unit (a certain enterprise or organization).
  • the node network, the orderer node and the peer nodes corresponding to each transaction organization together form a blockchain network, where the transaction organization can deploy multiple peer nodes, and different peer nodes can correspond to multiple blockchain channels, that is to say the same
  • a blockchain channel can correspond to multiple peer nodes, and peer nodes in the same blockchain channel trust each other.
  • the transaction organization includes multiple peer nodes (peer1 node, peer2 node, peer3 node in the figure%) ,
  • the transaction terminal can initiate a transaction request to the peer node in the institution.
  • peer1 node peer1 node
  • peer2 node peer2 node
  • peer3 node peer3 node in the figure.
  • the transaction terminal can initiate a transaction request to the peer node in the institution.
  • the blockchain network described in this specification may specifically be a private chain, a public chain, a consortium chain, etc., which are not particularly limited in the present invention.
  • the above-mentioned blockchain network can be specifically configured by a server of a third-party payment platform, a domestic bank server, an overseas bank server (peer nodes can be deployed on the above-mentioned servers), and a number of user node devices (transaction terminals).
  • a consortium chain composed of member devices.
  • the operator of the alliance chain that is, the trading institution, can rely on the alliance chain to deploy online services such as cross-border transfers and asset transfers based on the alliance chain.
  • the transaction described in this manual refers to a piece of data created by the user through the client of the blockchain and need to be finally released to the distributed database of the blockchain.
  • transactions in the blockchain are divided into narrow transactions and broad transactions.
  • a transaction in a narrow sense refers to a transfer of value issued by a user to the blockchain; for example, in a traditional Bitcoin blockchain network, a transaction can be a transfer initiated by the user in the blockchain.
  • a transaction refers to a piece of business data with business intent released by a user to the blockchain; for example, an operator can build a consortium chain based on actual business needs, and rely on the consortium chain to deploy some other types that are not related to value transfer.
  • Online business for example, renting business, vehicle dispatching business, insurance claims business, credit service, medical service, etc.
  • the transaction can be a business with business intent issued by the user in the alliance chain Message or business request.
  • the consensus algorithm carried by the above-mentioned blockchain network is not particularly limited in this specification; in practical applications, the Byzantine Fault Tolerance series of algorithms can be used as the consensus algorithm, or non-Byzantine A series of fault-tolerant algorithms are used as consensus algorithms.
  • the so-called Byzantine fault-tolerant algorithm means that in a distributed network composed of several node devices, the distributed fault-tolerant algorithm of Byzantine nodes (ie malicious nodes) needs to be considered; for example, the pbft algorithm; if the Byzantine fault-tolerant algorithm is used in the block When performing consensus processing in the chain network, it will be considered that malicious nodes and faulty nodes are stored in the blockchain at the same time.
  • non-Byzantine fault-tolerant algorithm refers to the distributed fault-tolerant algorithm that does not consider Byzantine nodes in a distributed network composed of several node devices; for example, the raft algorithm, etc.; if a non-Byzantine fault-tolerant algorithm is used in the region When performing consensus processing in the blockchain network, it will be considered that there are no malicious nodes in the blockchain, but only faulty nodes. The specific details about the blockchain network will not be described here.
  • a block processing method is provided, which is applied to an orderer node in a blockchain network.
  • the blockchain network further includes a transaction terminal and multiple peer nodes, including the following steps:
  • the orderer node packages the transaction data corresponding to each peer node fed back by the transaction terminal into an original block, each peer node is a peer node corresponding to the same blockchain channel in the blockchain network, and the transaction data is in the blockchain channel The transaction data generated.
  • the transaction terminal communicates with any peer node in the transaction organization in the corresponding blockchain channel according to transaction requirements, and initiates a transaction request to it, and the peer node in the transaction organization executes the corresponding transaction after receiving the transaction request from the transaction terminal Transaction data, such as transaction amount, transaction time and other transaction data.
  • Transaction data such as transaction amount, transaction time and other transaction data.
  • the peer node can feed back the transaction data to the transaction terminal, and the transaction terminal can send the transaction data fed back by the peer node to the orderer node.
  • a peer node can join one or more blockchain channels (that is, have multiple ledgers). After joining the blockchain channel, peer nodes in the same blockchain channel can share or manage the blockchain channels. All ledgers. A peer node can join multiple channels, but the ledger of each blockchain channel is isolated. Therefore, the blockchain channel is a logical structure, which is composed of various physical device nodes that physically exist.
  • the orderer node after the orderer node receives the transaction data fed back by the transaction terminal, the orderer node will package the transaction data generated by all peer nodes in the same blockchain channel into an original block. For the orderer node, after the orderer node receives the transaction data fed back by the transaction terminal, the orderer node will package the transaction data generated by all peer nodes in the same blockchain channel into the original block.
  • the above-mentioned blockchain channel is formed by channel configuration (Channel Configuration), and the blockchain channel controls the authority of each peer node that is accessed.
  • the above-mentioned blockchain network can be constructed based on Hyperledger Fabric.
  • the configuration function of the blockchain channel is completed by the MSP (Membership Service Provider) component. MSP determines the role of a peer node, access to blockchain resources and other permissions. The configuration process of the blockchain channel is not described in detail here.
  • S20 The orderer node fragments the original block to obtain multiple data fragments, and each data fragment contains transaction data corresponding to at least one of the peer nodes.
  • the orderer node After the orderer node packs the transaction data corresponding to each peer node fed back by the transaction terminal into the original block, the orderer node fragments the original block to obtain multiple data fragments, where each data fragment contains at least Transaction data corresponding to a peer node.
  • the above-mentioned original block is packaged by the transaction data corresponding to each peer node. That is to say, the above-mentioned original block includes the transaction data corresponding to each peer node, and the obtained data fragment contains the above-mentioned each peer node. Transaction data corresponding to any peer node.
  • the orderer node sends the first data segment to the first peer node, so that the first peer node can perform the first data segment according to the first data segment, the first verification result corresponding to the data of the first data segment, and the first data shared by the second peer node.
  • the second data segment and the second verification result data generate a final block, and write it into the block file corresponding to the first peer node.
  • the orderer node After obtaining multiple data fragments through step S20, the orderer node sends the first data fragment to the first peer node.
  • the first data fragment includes at least one data fragment among the multiple data fragments, that is to say, the first data fragment is the data fragment among the above-mentioned multiple data fragments, and includes at least one data fragment , That is, the first data fragment refers to one data fragment, or it can refer to two or two data fragments, or data fragments of other orders of magnitude, which is not limited here.
  • the first peer node is one of the peer nodes corresponding to the same blockchain channel, that is, after the first data fragment is obtained, the first data fragment will be sent to the peer node corresponding to the same blockchain channel A peer node in the peer node.
  • the embodiment of the application does not specifically limit how many data fragments will be received by peer nodes in the same blockchain channel, and which peer nodes will receive the data fragments sent by the orderer node.
  • other data shards except the first data shard are called second data shards, and the data received under the same blockchain channel All other peer nodes of the second data fragment sent by the orderer node are called second peer nodes.
  • the first peer node After receiving the first data piece sent by the orderer node, the first peer node verifies the legality of the transaction data corresponding to the first data piece. It can be understood that, as mentioned above, the first data segment includes at least one transaction data, therefore, the first peer node will verify the legality of all transaction data corresponding to the first data segment. Similarly, for the second peer node, after receiving the second data fragment, the second peer node will verify the legality of all transaction data corresponding to the second data fragment.
  • peer nodes under the same blockchain channel will share their data shards and verification result data with each other, that is, the first peer node will receive the second data shard and the second verification result data of the second peer node, and finally , The first peer node generates the final block according to the first data shard, the first verification result corresponding to the first data shard data, and the second data shard and the second verification result data shared by the second peer node, and writes it In the block file corresponding to the first peer node.
  • the processing process of other peer nodes under the same blockchain channel, that is, the second peer node is similar, and will not be described here.
  • verifying the legitimacy of the transaction data corresponding to the first data segment specifically refers to verifying whether the signature of the transaction, the transaction id of the transaction conflict, whether the data version used in this transaction is correct, etc.
  • verifying the legitimacy of transaction data may include the following process: In the first step, it is necessary to verify whether the transaction ID corresponding to the transaction data is duplicated. The second step is to verify whether the transaction signature is normal, that is, a peer node signs the transaction, so it is necessary to verify whether the transaction signature is legal; third, it is necessary to verify whether the transaction data used in the transaction is the latest The data. It is possible that this transaction used old transaction data. If the above requirements are not met, the transaction is deemed invalid and needs to be treated as an invalid transaction. The specific content of the verification of transaction data will not be described here. In addition, the transaction verification process of the second peer node is similar to that of the first peer node, and will not be described here.
  • the first peer node and the second peer node are peer nodes in the same blockchain channel.
  • the peer node under the same blockchain channel verifies the transaction data That is to say, peer nodes in the same blockchain channel no longer verify all transaction data of the complete block.
  • peer nodes only need to verify part of the transaction data in a block, which can reduce each
  • the repeated verification of the peer node reduces the workload of each peer node, and can reduce the network resources occupied by each peer node, thereby improving the utilization of network resources in the blockchain.
  • step S10 that is, the orderer node packs the transaction data corresponding to each peer node fed back by the transaction terminal into an original block, which specifically includes the following steps:
  • the orderer node obtains the first hash value by hashing the transaction data corresponding to each peer node.
  • the orderer node merges the first hash value corresponding to the transaction data corresponding to each peer node to obtain a merged value.
  • the orderer node obtains the second hash value by hashing the merged value.
  • the orderer node uses the second hash value as the total hash value of the original block, and packs the transaction data corresponding to each peer node into the original block according to the total hash value.
  • steps S11-S14 when packaging into the above-mentioned original block, a hash is obtained for each transaction data under the same blockchain channel, and the hash value corresponding to all transaction data is then hashed, thereby The final total hash value is used as the hash value in the block header, and finally the transaction data corresponding to each peer node is packaged into the original block according to the total hash value.
  • the hash value of the entire original block will be changed, which can help maintain the transaction data in the block.
  • the hash value corresponding to all transaction data in the original block can be constructed using the tree organization of the Merkle tree, that is, the hash value of the original block. That is, the above-mentioned total hash value is used as the root of the Merkle tree, and the hash value corresponding to the transaction data in the original block is used as the leaf of the Merkle tree. Using the above form, it can be used to restore the transaction sequence and verify the integrity of each transaction when the final block is subsequently generated, and each transaction data that changes to the original block can be traced.
  • the peer node will analyze the transaction data corresponding to all the received data shards. Hash value, and restore the final block with the same total hash value as the original block based on the hash value of all transactions. Specifically, the hash value of each transaction is compared with the hash value of the leaf nodes on the Merkle tree, because the order on the leaf nodes of the Merkle tree cannot be changed. And each block has a fixed Merkle tree, so as long as each transaction is restored to the Merkle tree, the order of transactions in the blockchain network can be restored to get the final block, that is, The process of using Merkel tree to restore the original block.
  • step S20 that is, the orderer node fragments the original block to obtain multiple data fragments, which specifically includes the following steps:
  • the orderer node determines the number of transactions corresponding to all transaction data in the original block.
  • the number of transactions can be determined to be 10.
  • the orderer node determines the number of shards according to the number of transactions.
  • S23 The orderer node fragments the original block according to the number of fragments to obtain multiple data fragments with the same number of fragments.
  • the orderer node determines the number of fragments according to the number of transactions, and fragments the original block according to the number of fragments to obtain multiple data fragments with the same number of fragments. For example, transaction data 1 corresponding to the peer1 node, transaction data 2 corresponding to the peer2 node, transaction data 3 corresponding to the peer3 node, and transaction data 4 corresponding to the peer4 node, then the transaction data 1, 2, 3, and 4 are packaged into the original block Later, the original block can be fragmented into multiple data fragments, where each data fragment includes at least one transaction data.
  • the original block is divided into 3 data fragments, one of the data fragments contains 2 transaction data, and the other two data fragments each contain 1 transaction data.
  • the purpose of this is to distribute the subsequent transaction verification work of each peer node more evenly, which can improve the verification efficiency.
  • other fragmentation methods can also be used.
  • the embodiments of this application do not make specific restrictions. For example, if there are 5 transaction data, the original The block is divided into 3 data shards, one of the data shards contains 3 transaction data, and the other 2 data shards contain 1 transaction data.
  • step S30 that is, before the orderer node sends the first data fragment to the first peer node, the following steps are further included:
  • the orderer node determines the total number of peer nodes corresponding to the same blockchain channel.
  • the orderer node determines the same blockchain channel The total number of nodes of the corresponding peer node. For example, if there are 10 peer nodes in the same blockchain channel, the total number of nodes is determined to be 10.
  • the orderer node determines the number of first peer nodes to be allocated according to the total number of nodes and the number of shards.
  • the orderer node After obtaining the total number of peer nodes corresponding to the same blockchain channel, the orderer node determines the number of first peer nodes to be allocated according to the total number of nodes and the number of shards, that is to say, it can be determined in the same blockchain channel. , The number of each peer node to be allocated. Among them, when the number of data fragments is equal to the total number of nodes, the data fragments are evenly divided into each peer node, so that each peer node is evenly divided to obtain data fragments. When the amount of fragmented data of the data fragment is greater than the total number of nodes and reaches the evenly divided number, the data fragments can also be evenly divided into each peer node.
  • each peer node can be allocated 2 data shards.
  • the orderer node will sort according to the processing capabilities of each peer node, and allocate the data shards to each peer node.
  • the orderer node will sort according to the processing capabilities of each peer node, and allocate the data fragments to the peer nodes with stronger processing capabilities.
  • the processing capability of the peer node can be determined according to the processing capability of the physical device carried.
  • the transaction verification work of peer nodes under the same blockchain channel can be well distributed. Peer nodes only need to verify part of the transaction data in a block, which can reduce the cost of each peer node. Repeated verification work reduces the workload of each peer node, and can reduce the network resources occupied by each peer node, thereby improving the utilization of network resources in the blockchain.
  • the orderer node determines the data fragments to be allocated from the multiple data fragments according to the number to be allocated.
  • S70 The orderer node uses the data fragment to be allocated as the first data fragment.
  • the data fragments to be allocated can be determined from multiple data fragments, that is, to determine The data fragment that needs to be allocated to the first peer node, that is, the first data fragment. It should be noted that, in some embodiments, data fragments containing transaction data of the first peer node are preferentially allocated to the first peer node. It can be seen that a method to specifically determine the first data shard is proposed here.
  • the orderer node In order to make the fragments sent to each peer node uniform, the orderer node needs to determine the number of target peer nodes to be allocated according to the total number of nodes and the number of fragments. For example, if there are 5 peer nodes, but there are actually 10 data shards, then 2 data shards can be evenly allocated to each peer node, and each peer node only needs to verify the transaction corresponding to the 2 data shards The data is enough, which effectively shares the workload of each peer node and improves the processing efficiency as a whole.
  • the orderer node randomly determines the data fragments to be allocated from multiple data fragments according to the number to be allocated, which is not specifically limited here.
  • step S30 that is, the orderer node sends the first data fragment to the first peer node, specifically includes the following steps:
  • the orderer node selects the main peer node from each peer node according to the main node selection algorithm.
  • S32 The orderer node sends the first data fragment to the master peer node, so that the master peer node forwards the first data fragment to the first peer node, where the peer node and the first peer node are different peer nodes.
  • the master peer node can be selected from each peer node in the blockchain, and other peer nodes act as slave peer nodes, the specific master node The node selection algorithm is not limited here.
  • the orderer node sends the first data fragment to the master peer node, so that the master peer node forwards the first data fragment to the first peer node, where the peer node and the first peer node are different peer nodes.
  • the main peer node can be selected from the blockchain channel by polling, and then the main peer node will distribute the data fragments to each peer node.
  • For the orderer node You only need to send the data fragments to the main peer node uniformly.
  • the distribution work is carried out by the main peer node, and after each round of consensus, different main peer nodes can be determined, and it will not cause much to the same peer node.
  • Work pressure can reduce the workload of the orderer node, thereby reducing the workload of the orderer node, and helping to improve the efficiency of collation verification.
  • the first peer node receives the first data fragment sent by the orderer node, where the first data fragment includes at least one data fragment among the multiple data fragments, and the multiple data fragments are the orderer node pairing the original block
  • the original block is obtained by sharding.
  • the original block is the orderer node and the transaction data corresponding to each peer node fed back by the transaction terminal is packaged.
  • Each peer node is the peer node corresponding to the same blockchain channel in the blockchain network.
  • the transaction data For the transaction data generated in the blockchain channel, the first peer node is one of the peer nodes corresponding to the same blockchain channel.
  • the first peer node verifies the legitimacy of the transaction data corresponding to the first data segment to obtain the first verification result data corresponding to the first data segment.
  • the first peer node receives the second data fragment and the second verification result data fed back by the second peer node, where the second data fragment is data fragments other than the first data fragment among the multiple data fragments.
  • the second peer node is the peer node assigned to the second data fragment among each peer node.
  • the first peer node generates a final block according to the first and second data fragments and the first and second verification result data.
  • the first peer node writes the final block into the block file corresponding to the first peer node.
  • a block processing device 10 is provided.
  • the block processing device 10 is applied to an orderer node in a blockchain network.
  • the blockchain network further includes a transaction terminal and a plurality of peer nodes.
  • the processing device 10 corresponds to the method on the orderer node side in the block processing method in the above embodiment.
  • the block processing device 10 includes a packing module 101, a fragmentation module 102 and a sending module 103.
  • the detailed description of each functional module is as follows:
  • the packaging module 101 is configured to package the transaction data corresponding to each peer node fed back by the transaction terminal into an original block, where each peer node is a peer node corresponding to the same blockchain channel in the blockchain network, and Transaction data is transaction data generated in the blockchain channel;
  • the fragmentation module 102 is configured to fragment the original block to obtain multiple data fragments, each of the data fragments containing transaction data corresponding to at least one of the peer nodes;
  • the sending module 103 is configured to send the first data fragment to the first peer node, so that the first peer node can according to the first data fragment and the first verification result corresponding to the first data fragment data And the second data shard shared by the second peer node and the second verification result data to generate a final block, and write it into the block file corresponding to the first peer node;
  • the first data fragment includes at least one data fragment among the multiple data fragments
  • the first peer node is a certain peer node among peer nodes corresponding to the same blockchain channel
  • the second data fragment is data fragments other than the first data fragment among multiple data fragments
  • the second peer node is a peer node of each peer node that is allocated to the second data fragment.
  • a block processing device 20 is provided, which is applied to the first peer node in a blockchain network.
  • the blockchain network further includes an orderer node and a transaction terminal.
  • the block processing device 20 is similar to the above implementation.
  • the block processing method in the example corresponds to the method on the first peer node side.
  • the block processing device 20 includes a receiving module 201, a verification module 202, a generating module 203 and a writing module 204.
  • the detailed description of each functional module is as follows:
  • the receiving module 201 is configured to receive a first data fragment sent by the orderer node, where the first data fragment includes at least one data fragment among a plurality of data fragments, and the plurality of data fragments are The orderer node shards the original block to obtain the original block.
  • the original block is formed by the orderer node packaging the transaction data corresponding to each peer node fed back by the transaction terminal, and each peer node is The peer node corresponding to the same blockchain channel in the blockchain network, the transaction data is transaction data generated in the blockchain channel, and the first peer node is corresponding to the same blockchain channel A certain peer node among peer nodes;
  • the verification module 202 is configured to verify the legitimacy of the transaction data corresponding to the first data segment, so as to obtain the first verification result data corresponding to the first data segment;
  • the receiving module 201 is further configured to receive the second data fragment and the second verification result data fed back by the second peer node, wherein the second data fragment is the first data fragment except the first data fragment among the plurality of data fragments.
  • the second peer node is a peer node of each peer node that is allocated to the second data fragment;
  • the generating module 203 is configured to generate a final block according to the first and second data fragments and the first and second verification result data;
  • the writing module 204 is configured to write the final block into the block file corresponding to the first peer node.
  • a computer device is provided.
  • the computer device may be a server, and its internal structure diagram may be as shown in FIG. 10.
  • the computer equipment includes a processor, a memory, a network interface, and a database connected through a system bus.
  • the processor of the computer device is used to provide calculation and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system, a computer program, and a database.
  • the internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium.
  • the database of the computer equipment is used to access transaction data and so on.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • a computer device including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, and the processor implements the following steps when the processor executes the computer program:
  • the transaction data corresponding to each peer node fed back by the transaction terminal is packaged into the original block.
  • Each peer node is the peer node corresponding to the same blockchain channel in the blockchain network.
  • the transaction data is the transaction generated in the blockchain channel. data;
  • Fragment the original block to obtain multiple data fragments, each of the data fragments containing transaction data corresponding to at least one of the peer nodes;
  • the first data shard includes at least one of the multiple data shards
  • the first peer node is one of the peer nodes corresponding to the same blockchain channel
  • the second data shard is multiple
  • the second peer node is the peer node of each peer node that is allocated to the second data fragment.
  • the block is the orderer node that packages the transaction data corresponding to each peer node fed back by the transaction terminal.
  • Each peer node is a peer node corresponding to the same blockchain channel in the blockchain network.
  • the transaction data is in the blockchain channel.
  • the first peer node is one of the peer nodes corresponding to the same blockchain channel;
  • the second peer node Receive the second data fragment and the second verification result data fed back by the second peer node, where the second data fragment is data fragments other than the first data fragment among the multiple data fragments, and the second peer node For each peer node assigned to the peer node of the second data shard;
  • a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
  • the transaction data corresponding to each peer node fed back by the transaction terminal is packaged into the original block.
  • Each peer node is the peer node corresponding to the same blockchain channel in the blockchain network.
  • the transaction data is the transaction generated in the blockchain channel. data;
  • Fragment the original block to obtain multiple data fragments, each of the data fragments containing transaction data corresponding to at least one of the peer nodes;
  • the first data shard includes at least one of the multiple data shards
  • the first peer node is one of the peer nodes corresponding to the same blockchain channel
  • the second data shard is multiple
  • the second peer node is the peer node of each peer node that is allocated to the second data fragment.
  • the block is the orderer node that packages the transaction data corresponding to each peer node fed back by the transaction terminal.
  • Each peer node is a peer node corresponding to the same blockchain channel in the blockchain network.
  • the transaction data is in the blockchain channel.
  • the first peer node is one of the peer nodes corresponding to the same blockchain channel;
  • the second peer node Receive the second data fragment and the second verification result data fed back by the second peer node, where the second data fragment is data fragments other than the first data fragment among the multiple data fragments, and the second peer node For each peer node assigned to the peer node of the second data shard;
  • Non-volatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory may include random access memory (RAM) or external cache memory.
  • RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Channel (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请公开了一种区块处理方法、装置、计算机设备及存储介质,用于解决peer节点工作、负担较大且都需占用过多的网络资源,网络资源利用率较低的问题。方法部分包括:orderer节点将交易终端所反馈的各个peer节点对应的交易数据打包成原始区块,各个peer节点为区块链网络中同一区块链通道对应的peer节点,交易数据为在区块链通道所产生的交易数据;对原始区块进行分片,以得到多个数据分片,每个数据分片包含至少一个peer节点对应的交易数据;将第一数据分片发送至第一peer节点。

Description

区块处理方法、装置、计算机设备及存储介质
本申请要求于2019年10月11日提交中国专利局、申请号为201910964135.2,发明名称为“区块处理方法、装置、计算机设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及区块链技术领域,尤其涉及一种区块处理方法、装置、计算机设备及存储介质。
背景技术
区块链一般被理解为一个分布式账本,它的本质是一个分布式的数据库。在现有的区块链网络中,各个peer节点都需要接收完成的区块,且都需要对每笔区块链网络中发生的交易和区块做验证。传统的做法是,交易终端发起交易,peer节点执行交易后向交易终端返回交易结果,并通过orderer节点将区块链的所有peer节点的对应的交易结果打包生成完整的区块,并将区块传送至区块链网络中的各个节点,最后由各个节点验证区块,最后各个节点将验证通过的区块写入区块文件。发明人意识到,在上述传统的做法中,各个peer节点都需对区块链链中的所有交易产生的区块进行验证,各个peer节点存在重复验证的工作,peer节点工作、负担较大且都需占用过多的网络资源,网络资源利用率较低。
发明内容
本申请实施例提供一种区块处理方法、装置、计算机设备及存储介质,用于解决peer节点工作、负担较大且都需占用过多的网络资源,网络资源利用率较低的问题。
一种区块处理方法,应用于区块链网络中的orderer节点,所述区块链网络还包括交易终端和多个peer节点,所述方法包括:
所述orderer节点将交易终端所反馈的各个peer节点对应的交易数据打包成原始区块,所述各个peer节点为所述区块链网络中同一区块链通道对应的peer节点,所述交易数据为在所述区块链通道所产生的交易数据;
所述orderer节点对所述原始区块进行分片,以得到多个数据分片,每个所述数据分片包含所述各个peer节点中至少一个peer节点对应的交易数据;
所述orderer节点将第一数据分片发送至第一peer节点,以使所述第一peer节点根据所述第一数据分片、所述第一数据分片数据对应的第一验证结果以及第二peer节点共享的第二数据分片和第二验证结果数据生成最终区块,并写入所述第一peer节点对应的区块文件中;
其中,所述第一数据分片包括所述多个数据分片中的至少一个数据分片,所述第一peer节点为所述同一区块链通道对应的peer节点中的某一peer节点,所述第二数据分片为多个数据分片中除第一数据分片外的其他数据分片,第二peer节点为各个peer节点中,分配到所述第二数据分片的peer节点。
一种区块处理方法,应用于区块链网络中的第一peer节点,所述区块链网络还包括orderer节点和交易终端,所述方法包括:
第一peer节点接收所述orderer节点发送的第一数据分片,其中,所述第一数据分片包括多个数据分片中的至少一个数据分片,所述多个数据分片为所述orderer节点对原始区 块进行分片得到,所述原始区块为所述orderer节点将所述交易终端所反馈的各个peer节点对应的交易数据打包成而成,所述各个peer节点为所述区块链网络中同一区块链通道对应的peer节点,所述交易数据为在所述区块链通道所产生的交易数据,所述第一peer节点为所述同一区块链通道对应的peer节点中的某一peer节点;
所述第一peer节点验证第一数据分片对应的交易数据的合法性,以获取第一数据分片对应的第一验证结果数据;
所述第一peer节点接收第二peer节点反馈的第二数据分片和第二验证结果数据,其中,所述第二数据分片为所述多个数据分片中除所述第一数据分片外的其他数据分片,所述第二peer节点为所述各个peer节点中分配到所述第二数据分片的peer节点;
所述第一peer节点根据所述第一、二数据分片和第一、二验证结果数据生成最终区块;
所述第一peer节点将所述最终区块写入第一peer节点对应的区块文件中。
一种区块处理装置,应用于区块链网络中的orderer节点,所述区块链网络还包括交易终端和多个peer节点,所述区块处理装置包括:
打包模块,用于将交易终端所反馈的各个peer节点对应的交易数据打包成原始区块,所述各个peer节点为所述区块链网络中同一区块链通道对应的peer节点,所述交易数据为在所述区块链通道所产生的交易数据;
分片模块,用于对所述原始区块进行分片,以得到多个数据分片,每个所述数据分片包含所述各个peer节点中至少一个peer节点对应的交易数据
发送模块,用于将第一数据分片发送至第一peer节点,以使所述第一peer节点根据所述第一数据分片、所述第一数据分片数据对应的第一验证结果以及第二peer节点共享的第二数据分片和第二验证结果数据生成最终区块,并写入所述第一peer节点对应的区块文件中;
其中,所述第一数据分片包括所述多个数据分片中的至少一个数据分片,所述第一peer节点为所述同一区块链通道对应的peer节点中的某一peer节点,所述第二数据分片为多个数据分片中除第一数据分片外的其他数据分片,第二peer节点为各个peer节点中,分配到所述第二数据分片的peer节点。
一种区块处理装置,应用于区块链网络中的第一peer节点,所述区块链网络还包括orderer节点和交易终端,所述区块处理装置包括:
接收模块,用于接收所述orderer节点发送的第一数据分片,其中,所述第一数据分片包括多个数据分片中的至少一个数据分片,所述多个数据分片为所述orderer节点对原始区块进行分片得到,所述原始区块为所述orderer节点将所述交易终端所反馈的各个peer节点对应的交易数据打包成而成,所述各个peer节点为所述区块链网络中同一区块链通道对应的peer节点,所述交易数据为在所述区块链通道所产生的交易数据,所述第一peer节点为所述同一区块链通道对应的peer节点中的某一peer节点;
验证模块,用于验证第一数据分片对应的交易数据的合法性,以获取第一数据分片对应的第一验证结果数据;
所述接收模块,还用于接收第二peer节点反馈的第二数据分片和第二验证结果数据,其中,所述第二数据分片为所述多个数据分片中除所述第一数据分片外的其他数据分片,所述第二peer节点为所述各个peer节点中分配到所述第二数据分片的peer节点;
生成模块,用于根据第一、二数据分片和第一、二验证结果数据生成最终区块;
写入模块,用于将所述最终区块写入第一peer节点对应的区块文件中。
一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现上述区块处理方法的步骤。
一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现上述区块处理方法的步骤。
可见,上述区块处理方法、装置、计算机设备及存储介质所实现的方案中,同一区块链通道的peer节点不再对完整区块的所有交易数据的进行验证,具体地,各个peer节点只需要验证一个区块的内的部分交易数据即可,可减少各个peer节点的重复验证的工作,减少各个peer节点的工作负担,且能减少各个peer节点占用的网络资源,从而提高了区块链中的网络资源利用率。
附图说明
为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例的描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1是本申请实施例中区块处理方法所应用的区块链网络的一结构示意图;
图2是本申请中区块处理方法的一实施例流程示意图;
图3是本申请中区块处理方法另一实施例流程示意图;
图4是本申请中区块处理方法另一实施例流程示意图;
图5是本申请中区块处理方法另一实施例流程示意图;
图6是本申请中区块处理方另一实施例流程示意图;
图7是本申请中区块处理方另一实施例流程示意图;
图8是本申请中区块处理装置的一结构示意图;
图9是本申请中区块处理装置的另一结构示意图;
图10是本申请中计算机设备的一结构示意图。
具体实施方式
本申请本申请本申请本申请本申请首先,为了便于理解本方案,需讲下本方案的一个系统框架,本方案中的系统框架主要涉及到几个主体、如图1所示,本申请实施例提供的区块处理方法应于如图1所述的区块链网络中,上述主体分别是交易终端、各个交易机构,交易机构指的针对一个单位(某个企业或组织)所设置的peer节点网络,orderer节点和各个交易机构对应的pee节点共同构成区块链网络,其中,交易机构可部署多个peer节点,且不同的peer节点可以对应多个区块链通道,也就是说相同的区块链通道可以对应多个peer节点,相同区块链通道的peer节点相互信任,如图1中所示,交易机构包括多个peer节点(图中的peer1节点、peer2节点、peer3节点…)、交易终端可以向机构内的peer节点发起交易请求,需要说明的是,上述系统框架图在这里只是示意说明,不造成限定。
需要说明的是,在本说明书所描述的区块链网络,具体可以是私有链、共有链以及联盟链等,在本说发明中不进行特别限定。例如,在一个场景中,上述区块链网络具体可以是由第三方支付平台的服务器、境内银行服务器、境外银行服务器(可在上述服务器部署peer节点)、以及若干用户节点设备(交易终端)作为成员设备组成的一个联盟链。该联盟链的运营方,也即交易机构可以依托于该联盟链,来在线部署诸如基于联盟链的跨境转账、资产转移等在线业务。在本说明书中所描述的交易,是指用户通过区块链的客户端创建,并需要最终发布至区块链的分布式数据库中的一笔数据。其中,区块链中的交易,存在狭义的交易以及广义的交易之分。狭义的交易是指用户向区块链发布的一笔价值转移;例如,在传统的比特币区块链网络中,交易可以是用户在区块链中发起的一笔转账。而广义的交易是指用户向区块链发布的一笔具有业务意图的业务数据;例如,运营方可以基于实际的业务需求搭建一个联盟链,依托于联盟链部署一些与价值转移无关的其它类型的在线业务(比如,租房业务、车辆调度业务、保险理赔业务、信用服务、医疗服务等),而在这类联盟链中,交易可以是用户在联盟链中发布的一笔具有业务意图的业务消息或者业 务请求。
需要说明的是,上述区块链网络搭载的共识算法,在本说明书中不进行特别限定;在实际应用中,具体可以采用拜占庭容错(Byzantine Fault Tolerance)系列算法作为共识算法,也可以采用非拜占庭容错系列算法作为共识算法。其中,所谓拜占庭容错算法,是指在由若干个节点设备组成的分布式网络中,需要考虑拜占庭节点(即作恶节点)的分布式容错算法;例如,pbft算法;如果采用拜占庭容错算法在区块链网络中进行共识处理时,会认为区块链中同时存储作恶节点和故障节点。而相应的,所谓非拜占庭容错算法,是指在由若干个节点设备组成的分布式网络中,不考虑拜占庭节点的分布式容错算法;例如,raft算法等等;如果采用非拜占庭容错算法在区块链网络中进行共识处理时,会认为区块链中不存在作恶节点,而只存在故障节点。具体关于区块链网络的具体细节这里不展开描述。
下面对本申请实施例一种区块处理方法进行详细的描述:
在一实施例中,如图2所示,提供一种区块处理方法,应用于区块链网络中的orderer节点,区块链网络还包括交易终端和多个peer节点,包括如下步骤:
S10:orderer节点将交易终端所反馈的各个peer节点对应的交易数据打包成原始区块,各个peer节点为区块链网络中同一区块链通道对应的peer节点,交易数据为在区块链通道所产生的交易数据。
可以理解,交易终端根据交易需求在对应的区块链通道里对交易机构内的任意一个peer节点通信,并向其发起交易请求,交易机构内的peer节点收到交易终端的交易请求后执行对应的交易,并生成交易数据,例如交易金额、交易时间等交易数据,对于peer节点而言,peer节点可以将交易数据反馈回交易终端,交易终端可以将peer节点反馈的交易数据发送至orderer节点。
可以理解,一个peer节点可以加入一个或多个区块链通道(即,拥有多个账本),加入区块链通道后,同一区块链通道的peer节点可以共享或管理区块链通道内的所有账本。一个peer节点可以加入到多个通道中,但是每个区块链通道的账本是隔离的。因此,区块链通道是一个逻辑结构,它由物理存在的各种物理设备节点组成。在本申请实施例中,orderer节点接收到交易终端反馈的交易数据后,orderer节点会将同一区块链通道内的所有peer节点所生成的交易数据打包成原始区块。对于orderer节点而言,orderer节点接收到交易终端反馈的交易数据后,orderer节点会将同一区块链通道内的所有peer节点所生成的交易数据打包成原始区块。
其中,需要说明的是,上述区块链通道通过通道配置(Channel Configuration)而成,区块链通道控制接入的每个peer节点的权限。在具体实现中,可基于Hyperledger Fabric构建上述区块链网络,具体地,由MSP(Membership Service Provider)组件完成了区块链通道的配置功能。MSP决定了一个peer节点的角色,访问区块链资源等权限,关于区块链通道的配置过程,这里不详细展开描述。
S20:orderer节点对原始区块进行分片,以得到多个数据分片,每个数据分片包含各个peer节点中至少一个peer节点对应的交易数据。
在orderer节点将交易终端所反馈的各个peer节点对应的交易数据打包成原始区块之后,orderer节点对原始区块进行分片,以得到多个数据分片,其中,每个数据分片包含至少一个peer节点对应的交易数据。可以理解,上述原始区块是是由各个peer节点对应的交易数据打包成,也就是说,上述原始区块包括了各个peer节点对应的交易数据,得到的数据分片包含有上述各个peer节点中任意一个peer节点对应的交易数据。
S30:orderer节点将第一数据分片发送至第一peer节点,以使第一peer节点根据第一数据分片、第一数据分片数据对应的第一验证结果以及第二peer节点共享的第二数据分片和第二验证结果数据生成最终区块,并写入第一peer节点对应的区块文件中。
在经过步骤S20得到多个数据分片之后,orderer节点将第一数据分片发送至第一peer 节点。其中,第一数据分片包括多个数据分片中的至少一个数据分片,也就是说第一数据分片是上述多个数据分片中的数据分片,并且包括了至少一片数据分片,即第一数据分片是指一个数据分片,也可以是指两个或两个数据分片,或者其他数量级的数据分片,这里不做限定。第一peer节点为同一区块链通道对应的peer节点中的某一peer节点,也就是说,在得到第一数据分片之后,会将第一数据分片发送给同一区块链通道对应的peer节点中的某一peer节点。需要说明的是,对于同一区块链通道中的peer节点具体会收到多少数据分片,以及哪些peer节点会收到orderer节点发送的数据分片,本申请实施例不做具体限定。为了便于理解,在本申请实施例中,对于同一区块链通道,将除了第一数据分片外其他的数据分片称为第二数据分片,将同一区块链通道下,接收到的orderer节点发送的第二数据分片的其他所有peer节点称为第二peer节点。
对于第一peer节点而言,在接收到orderer节点发送的第一数据片之后,第一peer节点会验证第一数据分片对应的交易数据的合法性。可以理解,如前述,第一数据分片包括了至少一笔交易数据,因此,第一peer节点会验证第一数据分片对应的所有交易数据的合法性。同理,对于第二peer节点而言,第二peer节点在接收到第二数据分片之后,会验证第二数据分片对应的所有的交易数据的合法性。最后同一区块链通道下的peer节点会相互分享各自的数据分片和验证结果数据,也即第一peer节点会接收到第二pee节点的第二数据分片和第二验证结果数据,最后,第一peer节点根据第一数据分片、第一数据分片数据对应的第一验证结果以及第二peer节点共享的第二数据分片和第二验证结果数据生成最终区块,并写入第一peer节点对应的区块文件中。同一区块链通道下的其他peer节点,也即第二peer节点的处理过程类似,这里不展开描述。
需要说明的是,验证第一数据分片对应的交易数据的合法性,具体指的是验证交易的签名、交易的交易id是否冲突,本次交易所使用到的数据版本是否正确等。例如,验证交易数据的合法性可以包括如下流程:第一步,需要验证该交易数据对应的交易ID是否重复。第二步,需要验证交易的签名是否正常,即某个peer节点对此笔交易做签名,所以这里需要验证交易的签名是否为合法的;第三,需要验证交易中使用的交易数据是否是最新的数据。有可能此笔交易使用了老的交易数据。若不符合上述要求,则认为此次交易无效,需要作为无效交易处理。具体关于交易数据的验证的内容,这里不展开描述,另外,第二peer节点的交易验证过程和第一peer节点类似,这里也不展开描述。
可见,第一peer节点和第二peer节点是同一区块链通道中的peer节点,在接收到orderer节点发送的数据分片后,由同一区块链通道下的peer节点的进行交易数据的验证工作,也就是说同一区块链通道的peer节点不再对完整区块的所有交易数据的进行验证,具体地,peer节点只需要验证一个区块的内的部分交易数据即可,可减少各个peer节点的重复验证的工作,减少各个peer节点的工作负担,且能减少各个peer节点占用的网络资源,从而提高了区块链中的网络资源利用率。
在一实施例中,如图3所示,步骤S10中,即orderer节点将交易终端所反馈的各个peer节点对应的交易数据打包成原始区块,具体包括如下步骤:
S11:orderer节点针对各个peer节点对应的交易数据取哈希得到第一哈希值。
S12:orderer节点将各个peer节点对应的交易数据对应的第一哈希值进行合并得到合并值。
S13:orderer节点针对合并值取哈希得到第二哈希值。
S14:orderer节点将第二哈希值作为原始区块的总哈希值,并根据总哈希值将各个peer节点对应的交易数据打包成原始区块。
对于步骤S11-S14,在打包成上述原始区块时,会针对同一区块链通道下的每一笔交易数据取哈希、并对所有交易数据对应的哈希值再取哈希,从而将最后的总哈希值作为区块头中的哈希值,最后根据该总哈希值将各个peer节点对应的交易数据打包成原始区块。这 样,当区块中的任意一条交易数据被篡改,则整个原始区块的哈希值就会变更,从而可以有利于维护区块中的交易数据。
值得说明的是,对于所生成的原始区块,该原始区块中的所有交易数据对应的哈希值可采用梅克尔树的树形组织进行构建,即原始区块的哈希值,也即上述总哈希值作为梅克尔树的根,原始区块中的笔交易数据对应的哈希值作为梅克尔树的叶。采用上述形式,可以用来后续生成最终区块时还原交易顺序和验证每笔交易的完整性,可追溯该原始区块发生变更的每一笔交易数据。也即第一peer节点和第二peer节点在根据第一、二数据分片和第一、二验证结果数据生成最终区块时,peer节点会解析收到的所有数据分片对应的交易数据的哈希值,并根据所有交易的哈希值还原出总哈希值与原始区块一样的最终区块。具体地,将比对每笔交易的哈希值和梅克尔树上的叶子节点哈希值,由于梅克尔树的叶子节点上的顺序不可更改。而且每个区块都有一颗固定的梅克尔树,那么,只要将每笔交易还原到梅克尔树上,就可以还原在区块链网络中的交易顺序得到最终区块,也即,利用梅克尔树还原出原始区块的过程。
在一实施例中,如图4所示,步骤S20中,即orderer节点对原始区块进行分片,以得到多个数据分片,具体包括如下步骤:
S21:orderer节点确定原始区块中所有的交易数据所对应的交易数量。
例如,若原始区块中存在10笔交易数据,那么可以确定交易数量为10。
S22:orderer节点根据交易数量确定分片数量。
S23:orderer节点根据分片数量对原始区块进行分片,以获得与分片数量相同的多个数据分片。
对于步骤S22-S23,orderer节点在得到交易数量后,根据交易数量确定分片数量,并根据分片数量对原始区块进行分片,以获得与分片数量相同的多个数据分片。例如,peer1节点对应的交易数据1,peer2节点对应的交易数据2,peer3节点对应的交易数据3,peer4节点对应交易数据4,则在对交易数据1、2、3和4打包成原始区块后,可将该原始区块分片成多个数据分片,其中每个数据分片包括至少一笔交易数据。示例性的,则将原始区块分成3个数据分片,其中一个数据分片包含2笔交易数据,另外两个数据分片各包含1笔交易数据。这么做的目的是为了更加均衡的分配后续各个peer节点的交易验证工作,可提高验证效率。需要说明的是,在一些实施方案中,除了采用上述分片的方式外,还可以有其他的分片方式,本申请实施例不做具体限制,例如,存在5笔交易数据,也可以将原始区块分成3个数据分片,其中一个数据分片包含3笔交易数据,其他2个数据分片包含1笔交易数据。
在一实施例中,如图5所示,步骤S30之前,也即orderer节点将第一数据分片发送至第一peer节点之前,还包括如下步骤:
S40:orderer节点确定同一区块链通道对应的peer节点的总节点数量。
可以理解,在上述区块链网络中,存在多条区块链通道,不同的peer节点可以加入1条或多条区块链通道中,本申请实施例中,orderer节点确定同一区块链通道对应的peer节点的总节点数量。例如,若同一区块链通道存在10个peer节点,则确定总节点数量为10。
S50:orderer节点根据总节点数量和分片数量确定第一peer节点的待分配数量。
在得到同一区块链通道对应的peer节点的总节点数量之后,orderer节点根据总节点数量和分片数量确定第一peer节点的待分配数量,也就是说,可以确定上述同一区块链通道中,各个peer节点的待分配数量。其中,当数据分片的分片数量等于总节点数量时,将数据分片均匀划分给各个peer节点,使得各个peer节点均分得到数据分片。当数据分片的分片数据量大于总节点数量且达到均分数量时,也可以将数据分片均匀划分给各个peer节点。例如,分片数量为20,总节点数量为10时,各个peer节点可分配到2个数据分片。 当数据分片的分片数据量大于总节点数量且未达到均分数量时,orderer节点会根据各个peer节点的处理能力进行排序,将数据分片分摊至各个peer节点。当数据分片的分片数据量小于总节点数量时,orderer节点会根据各个peer节点的处理能力进行排序,将数据分片分摊至处理能力较强的peer节点。其中,需要说明的是,peer节点的处理能力,可以依据承载的物理设备的处理能力确定,物理设备的处理能力越高,承载在该物理设备的peer节点的处理能力越高,这里不具体展开描述。通过本申请实施例,可以使得很好的分摊了同一区块链通道下的peer节点的交易验证工作,peer节点只需要验证一个区块的内的部分交易数据即可,可减少各个peer节点的重复验证的工作,减少各个peer节点的工作负担,且能减少各个peer节点占用的网络资源,从而提高了区块链中的网络资源利用率。
S60:orderer节点根据待分配数量从多个数据分片确定出待分配的数据分片。
S70:orderer节点将待分配的数据分片作为第一数据分片。
对于步骤S60-S70,可以理解,orderer节点根据总节点数量和分片数量确定第一peer节点的待分配数量后,即可从多个数据分片确定出待分配的数据分片,也即确定出需分配给第一peer节点的数据分片,也即第一数据分片。需要说明的是,在一些实施例中,优先将包含有第一peer节点的交易数据的数据分片分配给第一peer节点。可见,这里提出了一种具体确定出第一数据分片的方式,由于同一区块链通道中,peer节点的数量不一,且根据区块得到的数据分片的数量也不定,本实施例后续为了使得发送到各个peer节点的分片均匀,从而orderer节点需根据总节点数量和分片数量确定目标peer节点的待分配数量。举例来说,例如有5个peer节点,但实际有10个数据分片,那么可均匀的为每个peer节点分配2个数据分片,各个peer节点只需验证2个数据分片对应的交易数据即可,有效地分担了各个peer节点的工作负担,整体上提高处理效率。另外需要说明的是,orderer节点根据待分配数量从多个数据分片随机确定出待分配的数据分片,具体这里不做限定。
在一实施例中,如图6所示,步骤S30,也即orderer节点将第一数据分片发送至第一peer节点,具体包括如下步骤:
S31:orderer节点根据主节点选取算法从各个peer节点选出主peer节点。
S32:orderer节点将第一数据分片发送至主peer节点,以使主peer节点转发第一数据分片至第一peer节点,其中,peer节点与第一peer节点为不同的peer节点。
对于步骤S31-S32,可以理解,在区块链网络的每一轮共识开始之前,可以在区块链中的各个peer节点中选取出主peer节点,其他peer节点作为从peer节点,具体的主节点选取算法这里不做限定。最后orderer节点将第一数据分片发送至主peer节点,以使主peer节点转发第一数据分片至第一peer节点,其中,peer节点与第一peer节点为不同的peer节点。可以理解,通过本申请实施例,可以轮询的从区块链通道中选取出主peer节点,后续由主peer节点进行数据分片的分发工作,以分发至各个peer节点,对于orderer节点而言,只需统一将数据分片发送至主peer节点即可,分发工作由主peer节点进行,且每一轮共识后可确定出不同的主peer节点,也不会给同个peer节点造成多大的工作压力,却可以减少orderer节点的工作量,从而减少orderer节点的工作负担,有助于提高整理的验证效率。
上述实施例从orderer节点侧对本申请实施中的区块处理方法进行了描述,下面从peer节点侧对本申请实施例进行描述,包括如下步骤:
S100:第一peer节点接收orderer节点发送的第一数据分片,其中,第一数据分片包括多个数据分片中的至少一个数据分片,多个数据分片为orderer节点对原始区块进行分片得到,原始区块为orderer节点将交易终端所反馈的各个peer节点对应的交易数据打包成而成,各个peer节点为区块链网络中同一区块链通道对应的peer节点,交易数据为在区块链通道所产生的交易数据,第一peer节点为同一区块链通道对应的peer节点中的某一peer节点。
S200:第一peer节点验证第一数据分片对应的交易数据的合法性,以获取第一数据分 片对应的第一验证结果数据。
S300:第一peer节点接收第二peer节点反馈的第二数据分片和第二验证结果数据,其中,第二数据分片为多个数据分片中除第一数据分片外的其他数据分片,第二peer节点为各个peer节点中分配到第二数据分片的peer节点。
S400:第一peer节点根据第一、二数据分片和第一、二验证结果数据生成最终区块。
S500:第一peer节点将最终区块写入第一peer节点对应的区块文件中。
需要说明的是,关于第一peer节点执行上述区块处理方法的具体过程,可对应参阅前述实施例关于第一peer节点侧的描述,这里不再重复赘述。
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
在一实施例中,提供一种区块处理装置10,该区块处理装置10应用于区块链网络中的orderer节点,所述区块链网络还包括交易终端和多个peer节点,区块处理装置10与上述实施例中区块处理方法中orderer节点侧的方法相对应。如图8所示,该区块处理装置10包括打包模块101、分片模块102和发送模块103。各功能模块详细说明如下:
打包模块101,用于将交易终端所反馈的各个peer节点对应的交易数据打包成原始区块,所述各个peer节点为所述区块链网络中同一区块链通道对应的peer节点,所述交易数据为在所述区块链通道所产生的交易数据;
分片模块102,用于对所述原始区块进行分片,以得到多个数据分片,每个所述数据分片包含所述各个peer节点中至少一个peer节点对应的交易数据;
发送模块103,用于将第一数据分片发送至第一peer节点,以使所述第一peer节点根据所述第一数据分片、所述第一数据分片数据对应的第一验证结果以及第二peer节点共享的第二数据分片和第二验证结果数据生成最终区块,并写入所述第一peer节点对应的区块文件中;
其中,所述第一数据分片包括所述多个数据分片中的至少一个数据分片,所述第一peer节点为所述同一区块链通道对应的peer节点中的某一peer节点,所述第二数据分片为多个数据分片中除第一数据分片外的其他数据分片,第二peer节点为各个peer节点中,分配到所述第二数据分片的peer节点。
在一实施例中,提供一种区块处理装置20,应用于区块链网络中的第一peer节点,所述区块链网络还包括orderer节点和交易终端,区块处理装置20与上述实施例中区块处理方法中第一peer节点侧的方法相对应。如图9所示,该区块处理装置20包括接收模块201、验证模块202、生成模块203和写入模块204。各功能模块详细说明如下:
接收模块201,用于接收所述orderer节点发送的第一数据分片,其中,所述第一数据分片包括多个数据分片中的至少一个数据分片,所述多个数据分片为所述orderer节点对原始区块进行分片得到,所述原始区块为所述orderer节点将所述交易终端所反馈的各个peer节点对应的交易数据打包成而成,所述各个peer节点为所述区块链网络中同一区块链通道对应的peer节点,所述交易数据为在所述区块链通道所产生的交易数据,所述第一peer节点为所述同一区块链通道对应的peer节点中的某一peer节点;
验证模块202,用于验证第一数据分片对应的交易数据的合法性,以获取第一数据分片对应的第一验证结果数据;
所述接收模块201,还用于接收第二peer节点反馈的第二数据分片和第二验证结果数据,其中,所述第二数据分片为所述多个数据分片中除所述第一数据分片外的其他数据分片,所述第二peer节点为所述各个peer节点中分配到所述第二数据分片的peer节点;
生成模块203,用于根据第一、二数据分片和第一、二验证结果数据生成最终区块;
写入模块204,用于将所述最终区块写入第一peer节点对应的区块文件中。
在一个实施例中,提供了一种计算机设备,该计算机设备可以是服务器,其内部结构 图可以如图10所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机程序和数据库。该内存储器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机设备的数据库用于存取交易数据等。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机程序被处理器执行时以实现orderer节点侧或peer节点侧对应的区块处理方法。
在一个实施例中,提供了一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,处理器执行计算机程序时实现以下步骤:
将交易终端所反馈的各个peer节点对应的交易数据打包成原始区块,各个peer节点为区块链网络中同一区块链通道对应的peer节点,交易数据为在区块链通道所产生的交易数据;
对所述原始区块进行分片,以得到多个数据分片,每个所述数据分片包含所述各个peer节点中至少一个peer节点对应的交易数据;
将第一数据分片发送至第一peer节点,以使第一peer节点根据第一数据分片、第一数据分片数据对应的第一验证结果以及第二peer节点共享的第二数据分片和第二验证结果数据生成最终区块,并写入第一peer节点对应的区块文件中;
其中,第一数据分片包括多个数据分片中的至少一个数据分片,第一peer节点为同一区块链通道对应的peer节点中的某一peer节点,第二数据分片为多个数据分片中除第一数据分片外的其他数据分片,第二peer节点为各个peer节点中,分配到第二数据分片的peer节点。
接收orderer节点发送的第一数据分片,其中,第一数据分片包括多个数据分片中的至少一个数据分片,多个数据分片为orderer节点对原始区块进行分片得到,原始区块为orderer节点将交易终端所反馈的各个peer节点对应的交易数据打包成而成,各个peer节点为区块链网络中同一区块链通道对应的peer节点,交易数据为在区块链通道所产生的交易数据,第一peer节点为同一区块链通道对应的peer节点中的某一peer节点;
验证第一数据分片对应的交易数据的合法性,以获取第一数据分片对应的第一验证结果数据;
接收第二peer节点反馈的第二数据分片和第二验证结果数据,其中,第二数据分片为多个数据分片中除第一数据分片外的其他数据分片,第二peer节点为各个peer节点中分配到第二数据分片的peer节点;
根据第一、二数据分片和第一、二验证结果数据生成最终区块;
将最终区块写入第一peer节点对应的区块文件中。
在一个实施例中,提供了一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现以下步骤:
将交易终端所反馈的各个peer节点对应的交易数据打包成原始区块,各个peer节点为区块链网络中同一区块链通道对应的peer节点,交易数据为在区块链通道所产生的交易数据;
对所述原始区块进行分片,以得到多个数据分片,每个所述数据分片包含所述各个peer节点中至少一个peer节点对应的交易数据;
将第一数据分片发送至第一peer节点,以使第一peer节点根据第一数据分片、第一数据分片数据对应的第一验证结果以及第二peer节点共享的第二数据分片和第二验证结果数据生成最终区块,并写入第一peer节点对应的区块文件中;
其中,第一数据分片包括多个数据分片中的至少一个数据分片,第一peer节点为同一区块链通道对应的peer节点中的某一peer节点,第二数据分片为多个数据分片中除第一数 据分片外的其他数据分片,第二peer节点为各个peer节点中,分配到第二数据分片的peer节点。
或,
接收orderer节点发送的第一数据分片,其中,第一数据分片包括多个数据分片中的至少一个数据分片,多个数据分片为orderer节点对原始区块进行分片得到,原始区块为orderer节点将交易终端所反馈的各个peer节点对应的交易数据打包成而成,各个peer节点为区块链网络中同一区块链通道对应的peer节点,交易数据为在区块链通道所产生的交易数据,第一peer节点为同一区块链通道对应的peer节点中的某一peer节点;
验证第一数据分片对应的交易数据的合法性,以获取第一数据分片对应的第一验证结果数据;
接收第二peer节点反馈的第二数据分片和第二验证结果数据,其中,第二数据分片为多个数据分片中除第一数据分片外的其他数据分片,第二peer节点为各个peer节点中分配到第二数据分片的peer节点;
根据第一、二数据分片和第一、二验证结果数据生成最终区块;
将最终区块写入第一peer节点对应的区块文件中。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一非易失性计算机可读取存储介质中,也可存储于易失性计算机可读存储介质中,该计算机程序在执行时,可包括如上述区块处理方法的各实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。

Claims (20)

  1. 一种区块处理方法,应用于区块链网络中的orderer节点,所述区块链网络还包括交易终端和多个peer节点,所述方法包括:
    所述orderer节点将所述交易终端反馈的各个peer节点对应的交易数据打包成原始区块,所述各个peer节点为所述区块链网络中同一区块链通道对应的peer节点,所述交易数据为在所述区块链通道所产生的交易数据;
    所述orderer节点对所述原始区块进行分片,以得到多个数据分片,每个所述数据分片包含所述各个peer节点中至少一个peer节点对应的交易数据;
    所述orderer节点将第一数据分片发送至第一peer节点,以使所述第一peer节点根据所述第一数据分片、所述第一数据分片对应的第一验证结果以及第二peer节点共享的第二数据分片和第二验证结果数据生成最终区块,并写入所述第一peer节点对应的区块文件中;
    其中,所述第一数据分片包括所述多个数据分片中的至少一个数据分片,所述第一peer节点为所述同一区块链通道对应的peer节点中的某一peer节点,所述第二数据分片为多个数据分片中除所述第一数据分片外的其他数据分片,第二peer节点为所述各个peer节点中,分配到所述第二数据分片的peer节点。
  2. 如权利要求1所述的区块处理方法,所述orderer节点将所述交易终端所反馈的各个peer节点对应的交易数据打包成原始区块,包括:
    所述orderer节点针对所述各个peer节点对应的交易数据取哈希得到第一哈希值;
    所述orderer节点将所述各个peer节点对应的交易数据对应的所述第一哈希值进行合并得到合并值;
    所述orderer节点针对所述合并值取哈希得到第二哈希值;
    所述orderer节点将所述第二哈希值作为原始区块的总哈希值,并根据所述总哈希值将所述各个peer节点对应的交易数据打包成所述原始区块。
  3. 如权利要求1所述的区块处理方法,所述orderer节点对所述原始区块进行分片,以得到多个数据分片,包括:
    所述orderer节点确定所述原始区块中所有的交易数据所对应的交易数量;
    所述orderer节点根据所述交易数量确定分片数量;
    所述orderer节点根据所述分片数量对所述原始区块进行分片,以获得与所述分片数量相同的多个数据分片。
  4. 如权利要求3所述的区块处理方法,所述orderer节点将第一数据分片发送至第一peer节点之前,所述方法还包括:
    所述orderer节点确定所述同一区块链通道对应的peer节点的总节点数量;
    所述orderer节点根据所述总节点数量和所述分片数量确定第一peer节点的待分配数量;
    所述orderer节点根据所述待分配数量从所述多个数据分片确定出待分配的数据分片;
    所述orderer节点将所述待分配的数据分片作为所述第一数据分片。
  5. 如权利要求1-4任一项所述的区块处理方法,所述orderer节点将第一数据分片发送至第一peer节点,包括:
    所述orderer节点根据主节点选取算法从所述各个peer节点选出主peer节点;
    所述orderer节点将所述第一数据分片发送至所述主peer节点,以使所述主peer节点转发所述第一数据分片至所述第一peer节点,其中,所述peer节点与所述第一peer节点为不同的peer节点。
  6. 一种区块处理方法,应用于区块链网络中的第一peer节点,所述区块链网络还包 括orderer节点和交易终端,所述方法包括:
    所述第一peer节点接收所述orderer节点发送的第一数据分片,其中,所述第一数据分片包括多个数据分片中的至少一个数据分片,所述多个数据分片为所述orderer节点对原始区块进行分片得到,所述原始区块为所述orderer节点将所述交易终端所反馈的各个peer节点对应的交易数据打包成而成,所述各个peer节点为所述区块链网络中同一区块链通道对应的peer节点,所述交易数据为在所述区块链通道所产生的交易数据,所述第一peer节点为所述同一区块链通道对应的peer节点中的某一peer节点;
    所述第一peer节点验证第一数据分片对应的交易数据的合法性,以获取所述第一数据分片对应的第一验证结果数据;
    所述第一peer节点接收第二peer节点反馈的第二数据分片和第二验证结果数据,其中,所述第二数据分片为所述多个数据分片中除所述第一数据分片外的其他数据分片,所述第二peer节点为所述各个peer节点中分配到所述第二数据分片的peer节点;
    所述第一peer节点根据所述第一、二数据分片和第一、二验证结果数据生成最终区块;
    所述第一peer节点将所述最终区块写入第一peer节点对应的区块文件中。
  7. 一种区块处理装置,应用于区块链网络中的orderer节点,所述区块链网络还包括交易终端和多个peer节点,所述区块处理装置包括:
    打包模块,用于将所述交易终端所反馈的各个peer节点对应的交易数据打包成原始区块,所述各个peer节点为所述区块链网络中同一区块链通道对应的peer节点,所述交易数据为在所述区块链通道所产生的交易数据;
    分片模块,用于对所述原始区块进行分片,以得到多个数据分片,每个所述数据分片包含所述各个peer节点中至少一个peer节点对应的交易数据;
    发送模块,用于将第一数据分片发送至第一peer节点,以使所述第一peer节点根据所述第一数据分片、所述第一数据分片数据对应的第一验证结果以及第二peer节点共享的第二数据分片和第二验证结果数据生成最终区块,并写入所述第一peer节点对应的区块文件中;
    其中,所述第一数据分片包括所述多个数据分片中的至少一个数据分片,所述第一peer节点为所述同一区块链通道对应的peer节点中的某一peer节点,所述第二数据分片为多个数据分片中除所述第一数据分片外的其他数据分片,第二peer节点为所述各个peer节点中,分配到所述第二数据分片的peer节点。
  8. 如权利要求7所述的区块处理装置,所述打包模块包括:
    第一取值单元,用于所述orderer节点针对所述各个peer节点对应的交易数据取哈希得到第一哈希值;
    合并单元,用于所述orderer节点将所述各个peer节点对应的交易数据对应的所述第一哈希值进行合并得到合并值;
    第二取值单元,用于所述orderer节点针对所述合并值取哈希得到第二哈希值;
    打包单元,用于所述orderer节点将所述第二哈希值作为原始区块的总哈希值,并根据所述总哈希值将所述各个peer节点对应的交易数据打包成所述原始区块。
  9. 如权利要求7所述的区块处理装置,所述分片模块包括:
    第一确定单元,用于所述orderer节点确定所述原始区块中所有的交易数据所对应的交易数量;
    第二确定单元,所述orderer节点根据所述交易数量确定分片数量;
    分片单元,用于所述orderer节点根据所述分片数量对所述原始区块进行分片,以获得与所述分片数量相同的多个数据分片。
  10. 一种区块处理装置,应用于区块链网络中的第一peer节点,所述区块链网络还包括orderer节点和交易终端,所述区块处理装置包括:
    接收模块,用于接收所述orderer节点发送的第一数据分片,其中,所述第一数据分片包括多个数据分片中的至少一个数据分片,所述多个数据分片为所述orderer节点对原始区块进行分片得到,所述原始区块为所述orderer节点将所述交易终端所反馈的各个peer节点对应的交易数据打包成而成,所述各个peer节点为所述区块链网络中同一区块链通道对应的peer节点,所述交易数据为在所述区块链通道所产生的交易数据,所述第一peer节点为所述同一区块链通道对应的peer节点中的某一peer节点;
    验证模块,用于验证第一数据分片对应的交易数据的合法性,以获取第一数据分片对应的第一验证结果数据;
    所述接收模块,还用于接收第二peer节点反馈的第二数据分片和第二验证结果数据,其中,所述第二数据分片为所述多个数据分片中除所述第一数据分片外的其他数据分片,所述第二peer节点为所述各个peer节点中分配到所述第二数据分片的peer节点;
    生成模块,用于根据第一、二数据分片和第一、二验证结果数据生成最终区块;
    写入模块,用于将所述最终区块写入第一peer节点对应的区块文件中。
  11. 一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现区块处理方法:
    其中,所述区块处理方法,应用于区块链网络中的orderer节点,所述区块链网络还包括交易终端和多个peer节点,所述区块处理方法包括:
    所述orderer节点将所述交易终端反馈的各个peer节点对应的交易数据打包成原始区块,所述各个peer节点为所述区块链网络中同一区块链通道对应的peer节点,所述交易数据为在所述区块链通道所产生的交易数据;
    所述orderer节点对所述原始区块进行分片,以得到多个数据分片,每个所述数据分片包含所述各个peer节点中至少一个peer节点对应的交易数据;
    所述orderer节点将第一数据分片发送至第一peer节点,以使所述第一peer节点根据所述第一数据分片、所述第一数据分片对应的第一验证结果以及第二peer节点共享的第二数据分片和第二验证结果数据生成最终区块,并写入所述第一peer节点对应的区块文件中;
    其中,所述第一数据分片包括所述多个数据分片中的至少一个数据分片,所述第一peer节点为所述同一区块链通道对应的peer节点中的某一peer节点,所述第二数据分片为多个数据分片中除所述第一数据分片外的其他数据分片,第二peer节点为所述各个peer节点中,分配到所述第二数据分片的peer节点。
  12. 如权利要求11所述的计算机设备,所述orderer节点将所述交易终端所反馈的各个peer节点对应的交易数据打包成原始区块的步骤包括:
    所述orderer节点针对所述各个peer节点对应的交易数据取哈希得到第一哈希值;
    所述orderer节点将所述各个peer节点对应的交易数据对应的所述第一哈希值进行合并得到合并值;
    所述orderer节点针对所述合并值取哈希得到第二哈希值;
    所述orderer节点将所述第二哈希值作为原始区块的总哈希值,并根据所述总哈希值将所述各个peer节点对应的交易数据打包成所述原始区块。
  13. 如权利要求11所述的计算机设备,所述orderer节点对所述原始区块进行分片,以得到多个数据分片的步骤包括:
    所述orderer节点确定所述原始区块中所有的交易数据所对应的交易数量;
    所述orderer节点根据所述交易数量确定分片数量;
    所述orderer节点根据所述分片数量对所述原始区块进行分片,以获得与所述分片数量相同的多个数据分片。
  14. 如权利要求13所述的计算机设备,所述orderer节点将第一数据分片发送至第一peer节点的步骤之前,所述方法还包括:
    所述orderer节点确定所述同一区块链通道对应的peer节点的总节点数量;
    所述orderer节点根据所述总节点数量和所述分片数量确定第一peer节点的待分配数量;
    所述orderer节点根据所述待分配数量从所述多个数据分片确定出待分配的数据分片;
    所述orderer节点将所述待分配的数据分片作为所述第一数据分片。
  15. 如权利要求11-14任一项所述的计算机设备,所述orderer节点将第一数据分片发送至第一peer节点的步骤包括:
    所述orderer节点根据主节点选取算法从所述各个peer节点选出主peer节点;
    所述orderer节点将所述第一数据分片发送至所述主peer节点,以使所述主peer节点转发所述第一数据分片至所述第一peer节点,其中,所述peer节点与所述第一peer节点为不同的peer节点。
  16. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现区块处理方法:
    其中,所述区块处理方法应用于区块链网络中的orderer节点,所述区块链网络还包括交易终端和多个peer节点,所述方法包括:
    所述orderer节点将所述交易终端反馈的各个peer节点对应的交易数据打包成原始区块,所述各个peer节点为所述区块链网络中同一区块链通道对应的peer节点,所述交易数据为在所述区块链通道所产生的交易数据;
    所述orderer节点对所述原始区块进行分片,以得到多个数据分片,每个所述数据分片包含所述各个peer节点中至少一个peer节点对应的交易数据;
    所述orderer节点将第一数据分片发送至第一peer节点,以使所述第一peer节点根据所述第一数据分片、所述第一数据分片对应的第一验证结果以及第二peer节点共享的第二数据分片和第二验证结果数据生成最终区块,并写入所述第一peer节点对应的区块文件中;
    其中,所述第一数据分片包括所述多个数据分片中的至少一个数据分片,所述第一peer节点为所述同一区块链通道对应的peer节点中的某一peer节点,所述第二数据分片为多个数据分片中除所述第一数据分片外的其他数据分片,第二peer节点为所述各个peer节点中,分配到所述第二数据分片的peer节点。
  17. 如权利要求16所述的计算机可读存储介质,所述orderer节点将所述交易终端所反馈的各个peer节点对应的交易数据打包成原始区块的步骤包括:
    所述orderer节点针对所述各个peer节点对应的交易数据取哈希得到第一哈希值;
    所述orderer节点将所述各个peer节点对应的交易数据对应的所述第一哈希值进行合并得到合并值;
    所述orderer节点针对所述合并值取哈希得到第二哈希值;
    所述orderer节点将所述第二哈希值作为原始区块的总哈希值,并根据所述总哈希值将所述各个peer节点对应的交易数据打包成所述原始区块。
  18. 如权利要求16所述的计算机可读存储介质,所述orderer节点对所述原始区块进行分片,以得到多个数据分片的步骤包括:
    所述orderer节点确定所述原始区块中所有的交易数据所对应的交易数量;
    所述orderer节点根据所述交易数量确定分片数量;
    所述orderer节点根据所述分片数量对所述原始区块进行分片,以获得与所述分片数量相同的多个数据分片。
  19. 如权利要求18所述的计算机可读存储介质,所述orderer节点将第一数据分片发送至第一peer节点的步骤之前,还包括:
    所述orderer节点确定所述同一区块链通道对应的peer节点的总节点数量;
    所述orderer节点根据所述总节点数量和所述分片数量确定第一peer节点的待分配数 量;
    所述orderer节点根据所述待分配数量从所述多个数据分片确定出待分配的数据分片;
    所述orderer节点将所述待分配的数据分片作为所述第一数据分片。
  20. 如权利要求16-19任一项所述的计算机可读存储介质,所述orderer节点将第一数据分片发送至第一peer节点的步骤包括:
    所述orderer节点根据主节点选取算法从所述各个peer节点选出主peer节点;
    所述orderer节点将所述第一数据分片发送至所述主peer节点,以使所述主peer节点转发所述第一数据分片至所述第一peer节点,其中,所述peer节点与所述第一peer节点为不同的peer节点。
PCT/CN2020/085562 2019-10-11 2020-04-20 区块处理方法、装置、计算机设备及存储介质 WO2021068477A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910964135.2 2019-10-11
CN201910964135.2A CN110933022A (zh) 2019-10-11 2019-10-11 区块处理方法、装置、计算机设备及存储介质

Publications (1)

Publication Number Publication Date
WO2021068477A1 true WO2021068477A1 (zh) 2021-04-15

Family

ID=69848798

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/085562 WO2021068477A1 (zh) 2019-10-11 2020-04-20 区块处理方法、装置、计算机设备及存储介质

Country Status (2)

Country Link
CN (1) CN110933022A (zh)
WO (1) WO2021068477A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110933022A (zh) * 2019-10-11 2020-03-27 深圳壹账通智能科技有限公司 区块处理方法、装置、计算机设备及存储介质
CN111917572B (zh) * 2020-07-12 2022-10-25 中信银行股份有限公司 交易请求的处理方法、装置、电子设备及可读存储介质
CN113643031A (zh) * 2021-08-24 2021-11-12 上海点融信息科技有限责任公司 一种联盟链信息验证系统及方法

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180300382A1 (en) * 2017-04-12 2018-10-18 Vijay K. Madisetti Method and System for Tuning Blockchain Scalability for Fast and Low-Cost Payment and Transaction Processing
CN109285006A (zh) * 2018-09-20 2019-01-29 中链科技有限公司 一种区块链数据的并行验证处理方法及装置
CN109359992A (zh) * 2018-10-09 2019-02-19 北京彩球世纪科技有限公司 一种新型的区块链分区分片方式和装置
CN109508968A (zh) * 2018-10-25 2019-03-22 常州唯康信息科技有限公司 区块链系统以及其控制方法
CN110149373A (zh) * 2019-04-28 2019-08-20 平安科技(深圳)有限公司 基于点对点网络的数据存储方法、装置、介质及服务器
CN110933022A (zh) * 2019-10-11 2020-03-27 深圳壹账通智能科技有限公司 区块处理方法、装置、计算机设备及存储介质

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109345386B (zh) * 2018-08-31 2020-04-14 阿里巴巴集团控股有限公司 基于区块链的交易共识处理方法及装置、电子设备
CN109379397B (zh) * 2018-08-31 2019-12-06 阿里巴巴集团控股有限公司 基于区块链的交易共识处理方法及装置、电子设备
CN109447804B (zh) * 2018-10-30 2020-08-14 杭州复杂美科技有限公司 交易分流方法、设备和存储介质
CN110011814B (zh) * 2019-04-16 2019-10-15 北京艾摩瑞策科技有限公司 一种可验证的DPoS共识方法及其系统

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180300382A1 (en) * 2017-04-12 2018-10-18 Vijay K. Madisetti Method and System for Tuning Blockchain Scalability for Fast and Low-Cost Payment and Transaction Processing
CN109285006A (zh) * 2018-09-20 2019-01-29 中链科技有限公司 一种区块链数据的并行验证处理方法及装置
CN109359992A (zh) * 2018-10-09 2019-02-19 北京彩球世纪科技有限公司 一种新型的区块链分区分片方式和装置
CN109508968A (zh) * 2018-10-25 2019-03-22 常州唯康信息科技有限公司 区块链系统以及其控制方法
CN110149373A (zh) * 2019-04-28 2019-08-20 平安科技(深圳)有限公司 基于点对点网络的数据存储方法、装置、介质及服务器
CN110933022A (zh) * 2019-10-11 2020-03-27 深圳壹账通智能科技有限公司 区块处理方法、装置、计算机设备及存储介质

Also Published As

Publication number Publication date
CN110933022A (zh) 2020-03-27

Similar Documents

Publication Publication Date Title
WO2021068477A1 (zh) 区块处理方法、装置、计算机设备及存储介质
CN110727712B (zh) 基于区块链网络的数据处理方法、装置、电子设备及存储介质
US10762479B2 (en) Method and system for processing blockchain-based real-time transaction
US20230289788A1 (en) Systems and methods for addressing security-related vulnerabilities arising in relation to off-blockchain channels in the event of failures in a network
CN109728954B (zh) 联盟链节点管理系统以及方法
US20180293557A1 (en) Method of charging electronic currency automatically based on blockchain and system thereof
EP3731494A1 (en) Blockchain maintaining method and apparatus, server, and computer-readable storage medium
EP3619668B1 (en) Performing parallel execution of transactions in a distributed ledger system
CN110598446A (zh) 基于区块链的测试方法、装置、存储介质和计算机设备
CN111010382A (zh) 在区块链网络中处理数据请求的方法和装置
CN102170440B (zh) 适用于存储云间数据安全迁移的方法
CN110119390B (zh) 基于区块链的金融信息外包管理系统
WO2020177548A1 (zh) 一种区块链的权限控制方法及装置
WO2020253634A1 (zh) 一种数据处理方法、系统及装置
JP6920442B2 (ja) ブロックチェーンシステムのノード間の通信を確立するための方法及びデバイス
CN110992178A (zh) 区块链节点的验证方法、装置、计算机设备及存储介质
US20230289782A1 (en) Smart contract-based data processing
CN110992035A (zh) 区块链节点管理方法、装置及系统
CN112446780A (zh) 账户管理方法、装置、计算机设备及存储介质
WO2023050986A1 (zh) 维护区块链系统的网络架构信息
CN114528601B (zh) 基于区块链数据的访问方法和装置、处理器及电子设备
KR102430135B1 (ko) 에러 정정 코드에 기초하는 동적 블록체인 데이터 저장
WO2021184873A1 (zh) 用于区块链网络中的数据同步的方法、装置和计算设备
CN113449322A (zh) 基于区块链的数据共享方法、装置、电子设备及可读介质
CN112926983A (zh) 一种基于区块链的存证交易加密系统及方法

Legal Events

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

Ref document number: 20874170

Country of ref document: EP

Kind code of ref document: A1

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 18/08/2022)

122 Ep: pct application non-entry in european phase

Ref document number: 20874170

Country of ref document: EP

Kind code of ref document: A1