WO2021068567A1 - 区块链的区块分发方法、装置、计算机设备和存储介质 - Google Patents

区块链的区块分发方法、装置、计算机设备和存储介质 Download PDF

Info

Publication number
WO2021068567A1
WO2021068567A1 PCT/CN2020/099257 CN2020099257W WO2021068567A1 WO 2021068567 A1 WO2021068567 A1 WO 2021068567A1 CN 2020099257 W CN2020099257 W CN 2020099257W WO 2021068567 A1 WO2021068567 A1 WO 2021068567A1
Authority
WO
WIPO (PCT)
Prior art keywords
block
cache
target
temporary
data node
Prior art date
Application number
PCT/CN2020/099257
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 WO2021068567A1 publication Critical patent/WO2021068567A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/568Storing data temporarily at an intermediate stage, e.g. caching
    • 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
    • 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
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3236Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions
    • 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/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3247Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving digital signatures
    • 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 distributed ledgers, and in particular to a block distribution method, device, computer equipment, and storage medium of a blockchain.
  • the consensus node After the consensus node saves the block to the local file ledger, that is, writes it to the disk, if the consensus node finds that there is a monitoring data node waiting for a new block to be generated, the consensus node will start from the disk. Read the corresponding block and send it to the data node.
  • the inventor realizes that in this process, if multiple data nodes monitor the consensus node, the consensus node needs to read the block from the disk and return it to the data node multiple times; on the one hand, the consensus node may frequently read the disk.
  • This application provides a block distribution method, device, computer equipment, and storage medium of a blockchain.
  • the target block is first cached in a temporary cache area and distributed to data nodes, and then the cache block in the temporary cache area Write to the target disk to isolate the distribution of the cache block to the data node and the process of writing to the target disk, which can achieve the effect of reducing the frequency of reading the target disk and reducing the delay time of the cache block distribution.
  • this application provides a block distribution method of the block chain, the method includes:
  • the cache block is written into the target disk to add the cache block to the blockchain stored on the target disk.
  • the present application also provides a block distribution device of the block chain, the device includes:
  • Block acquisition module used to acquire the target block to be written into the blockchain
  • the first block writing module is used to write the target block into the temporary buffer area, obtain the buffer block corresponding to the target block, and send to the data node to indicate that the target block has been written The written notification of the blockchain;
  • the first block sending module is configured to, if a block receiving request sent by the data node according to the written notification is received, send the cache block in the temporary buffer area corresponding to the block receiving request to Sent by the data node;
  • the second block writing module is used to write the cache block to the target disk so as to add the cache block to the blockchain stored in the target disk.
  • the present application also provides a computer device, the computer device includes a memory and a processor, the processor and the memory are connected to each other, wherein the memory is used to store a computer program, the computer The program includes program instructions, and the processor is used to execute the program instructions of the memory, wherein:
  • the cache block is written into the target disk to add the cache block to the blockchain stored on the target disk.
  • the present application also provides a computer-readable storage medium, the computer-readable storage medium stores a computer program, the computer program includes program instructions, and when the program instructions are executed by a processor, they are used to implement The following steps:
  • the cache block is written into the target disk to add the cache block to the blockchain stored on the target disk.
  • This application discloses a block distribution method, device, computer equipment, and storage medium of a block chain.
  • the cache block corresponding to the target block is obtained, and the cache block is sent to the data node.
  • Send a written notification to avoid directly writing the target block to the target disk and then distribute it from the target disk, so as to reduce the frequency of reading the target disk; if the data node receives the block sent according to the written notification Receive the request and send the corresponding cache block in the temporary cache area to the data node.
  • the cache block can be distributed to the data node from the temporary cache area first, so as to quickly distribute the block to the data node and reduce the cost of cache block distribution. Delay time; then the cache block in the temporary cache area is written to the target disk, and the process of distributing the cache block to the data node and writing to the target disk can be isolated, which can effectively improve the stability of the entire blockchain system.
  • Fig. 1 is a schematic flowchart of a block distribution method of a block chain provided by an embodiment of the present application
  • FIG. 2 is a schematic flow chart of the sub-steps of writing a block into a temporary buffer area in FIG.
  • Fig. 3 is a schematic flowchart of steps after the block in Fig. 1 is sent;
  • FIG. 4 is a schematic flowchart of steps after the block in FIG. 1 is written to the target disk;
  • FIG. 5 is a schematic flowchart of steps after the cache block in FIG. 4 is sent;
  • Fig. 6 is a schematic flowchart of steps after the block in Fig. 4 is sent;
  • Fig. 7 is a schematic block diagram of a block distribution device of a block chain provided by an embodiment of the application.
  • FIG. 8 is a schematic block diagram of the sub-modules of the block distribution device of the blockchain in FIG. 7;
  • FIG. 9 is a schematic block diagram of the structure of a computer device according to an embodiment of the application.
  • the embodiments of the present application provide a block distribution method, device, computer equipment, and storage medium of a block chain.
  • the block distribution method of the block chain can be applied to the terminal or server as the block chain node.
  • the process of distributing the cache block to the data node and writing to the target disk the reduction of reading the target disk is realized.
  • the effect of the frequency is realized.
  • the terminal can be an electronic device such as a smart phone, a tablet computer, a notebook computer, a desktop computer, a personal digital assistant, and a wearable device.
  • the server can be an independent server or a server cluster.
  • the block distribution method of the blockchain includes steps S10 to S40.
  • Step S10 Obtain the target block to be written into the blockchain.
  • the node may be any computer device, such as a PC computer, a notebook, a mobile phone, a router, and so on.
  • the nodes are used to perform operations on blocks in the blockchain system, such as reading blocks, writing blocks, deleting blocks, sending blocks, querying blocks, and so on.
  • the consensus node refers to a node that operates on the blockchain in the distributed ledger, for example, writes blocks to the blockchain and reads blocks in the blockchain.
  • the consensus node may sort transactions, package to generate blocks, and save the newly generated blocks in the blockchain maintained by the consensus node.
  • the target block is a block obtained by arranging and packaging transaction proposals by the consensus node according to the transaction request of the client.
  • the transaction request is a request sent by the client after the data node packs the transaction data into a transaction proposal.
  • the transaction proposal is sent to the designated endorsing node according to the endorsement strategy.
  • the endorsing node verifies and signs the transaction proposal to obtain a signed transaction proposal; the endorsement node submits the signed transaction proposal to the consensus node.
  • the endorsement strategy determines whether to release or reject the transaction proposal according to preset conditions.
  • the preset condition may be approved by one node, approved by a majority of nodes, or approved by all nodes.
  • the endorsing node After receiving the transaction proposal, the endorsing node invokes a chain code (Chaincode) for verification, for example, the endorsing node verifies whether the transaction proposal is legal and can be submitted normally. If the transaction proposal passes the verification, the endorsement node invokes the Endorsement System Chaincode (ESCC) to endorse and sign the transaction proposal to obtain a signed transaction proposal. It should be noted that the endorsement system chain code is used to endorse and sign the transaction proposal.
  • ESCC Endorsement System Chaincode
  • the consensus node sorts the signed transaction proposal according to the transaction request of the client to obtain a series of sorted data.
  • the consensus node packs the series of sorted data according to a certain amount according to the consensus algorithm to generate a target block to be written into the blockchain, and the target block includes at least one sorted data.
  • the consensus algorithm refers to a process by which consensus nodes reach a consensus on a transaction proposal, including agreeing to a proposal or denying a proposal, and obtaining sequenced consistent ranking data.
  • the consensus algorithm may include a PoW (Proof of Word) algorithm, a PBFT (Practical Byzantine Fault Tolerance) algorithm, or a PoS (Proof of Stake) algorithm.
  • the certain number refers to at least one consecutive one in the series of sorted data.
  • the target block may include a block header and block data, wherein the block header contains metadata.
  • the consensus node packs the series of sorted data to generate a target block
  • the block header and block data are written into the target block.
  • the consensus node when the series of sorted data is packaged to generate a target block, the consensus node hashes and encrypts the block data in the target block according to the SHA (Secure Hash Algorithm)-256 digest algorithm To generate a hash value.
  • the consensus node stores the hash value as the hash value of the current block in the block header of the target block, and each block header contains the hash value of its previous block. Through the hash value of the current block, the consensus node can identify the current block in the blockchain.
  • the consensus node before writing the acquired target block to be written to the blockchain into the blockchain, the consensus node first caches the target block to be written to the blockchain to a temporary cache In the area, to indicate that the target block is successfully written into the blockchain. In this way, the target block can be distributed to the monitoring data nodes from the temporary buffer area in advance.
  • Step S20 Write the target block into a temporary buffer area to obtain a buffer block corresponding to the target block, and send to the data node a written message indicating that the target block has been written into the blockchain. Notice.
  • the consensus node Before the consensus node writes the target block into the temporary buffer area, it creates a temporary buffer area with a preset capacity in a random access memory (Random Access Memory, RAM), and the temporary buffer area is used for To cache the target block.
  • RAM Random Access Memory
  • the consensus node creates a temporary cache area with a capacity of L, the temporary cache area stores the target block as temporary data, and the temporary cache area can store L cache blocks.
  • the consensus node first writes the target block to be written to the blockchain into the temporary cache area to obtain the cache block corresponding to the target block; then the consensus node then writes the The cache blocks in the temporary cache area are sequentially written to the blockchain in the target disk.
  • the target block is written into the temporary buffer area first, and if there are four target blocks, the target blocks are sequentially buffered in the temporary buffer area to obtain A and B , C, and D are four cache blocks, among which cache block A is the earliest cached, and cache block D is the last cached.
  • the consensus node first caches the target block in the temporary cache area, and may save the target block as temporary data in the temporary cache area; the cache block in the temporary cache area may be distributed to The corresponding data node does not have to wait until the target block is saved on the blockchain in the target disk before reading it from the blockchain and distributing it to the corresponding data node.
  • the speed at which the consensus node writes the target block into the temporary buffer area is faster than that of the target disk. Much faster. By writing the target block into the temporary buffer area, the target block can be quickly distributed to the monitoring data node, and the delay of the target block distribution can be reduced.
  • the consensus node After the consensus node writes the target block into the temporary buffer area, it sends a written notification indicating that the target block has been written to the blockchain to the data node that is monitoring.
  • the data node is used to monitor whether a written notification is generated or actively initiate a block read request.
  • the consensus node After the consensus node writes the acquired target block into the temporary buffer area, a buffer block corresponding to the target block is obtained in the temporary buffer area, which may represent the target block Successfully write to the blockchain. Therefore, the consensus node generates a written notification corresponding to the cache block. The consensus node broadcasts the written notification to the blockchain network to send the written notification to the monitoring data node.
  • the written notification is used to indicate that a cache block is generated in the temporary cache area.
  • the written notification corresponds to a cache block in the temporary cache area and includes description information of the cache block.
  • the description information may include a hash value corresponding to the cache block.
  • Step S30 If a block reception request sent by the data node according to the written notification is received, send a cache block in the temporary cache area corresponding to the block reception request to the data node.
  • the data node in the blockchain network is used to monitor in real time whether there is a written notification corresponding to the target block in the blockchain network. If it is detected that a written notification is generated in the blockchain network, the data node responds to the written notification and sends a block receiving request corresponding to the written notification.
  • the response may include generating a block receiving request corresponding to the written notification according to the description information carried in the written notification.
  • the block receiving request includes the description information of the cache block included in the written notification.
  • the description information may include the hash value of the cache block.
  • the consensus node receives the block reception request sent by the data node according to the written notification, it sends the cache block in the temporary cache area corresponding to the block reception request to the Data node sent.
  • the consensus node queries the temporary cache area for a cache block consistent with the description information in the block reception request, and sends the cache block to the data node corresponding to the block reception request .
  • the consensus node searches the temporary cache for a cache block whose hash value is consistent with the hash value in the description information from the temporary cache area according to the description information of the block receiving request. For example, if the consensus node finds that the hash value of cache block A in the temporary cache area is consistent with the hash value in the description information, it returns the cache block A to the block Receive the data node corresponding to the request.
  • the consensus node queries the temporary cache area for the cache corresponding to the written notification multiple times. Blocks, and cache blocks with consistent hash values are returned to the data nodes corresponding to the block receiving request.
  • the consensus node By receiving the request according to the block of the monitored data node, the consensus node reads the cache block in the temporary buffer area and sends it to the monitored data node, which can realize fast block distribution and effectively reduce the number of reads. Fetch the frequency of the disk, thereby extending the life of the disk.
  • Step S40 Write the cache block to the target disk, so as to add the cache block to the blockchain stored on the target disk.
  • a blockchain is stored in the target disk.
  • the target disk stores a block chain of the full amount of data, or stores a partial block chain including some blocks.
  • the consensus node may read the blockchain in the target disk; or write the cache block to the target disk to add the cache block to the blockchain.
  • the target disk is a non-volatile memory, such as a mechanical hard disk, a solid state hard disk, a smart memory card, a secure digital card, or a flash memory card.
  • a non-volatile memory such as a mechanical hard disk, a solid state hard disk, a smart memory card, a secure digital card, or a flash memory card.
  • the consensus node after the consensus node saves the target block as temporary data in the temporary cache area, it also needs to write the cache block in the temporary cache area to the target disk to save the cache block Join the block chain stored in the target disk.
  • the consensus node can realize the persistence of the target block by adding the cache block to the block chain for storage.
  • the persistence is a mechanism for converting a program or data in a transient state into a persistent state, for example, writing a cache block temporarily stored in the temporary cache area to a block in the target disk The chain is persisted.
  • the consensus node writes each cache block to the target disk in turn based on the first-in-first-out rule and according to the writing order of each cache block in the temporary cache area, so as to write each cache block to the target disk.
  • the cache block is added to the blockchain stored on the target disk.
  • the first-in-first-out means that the cache blocks cached in the temporary cache area are written to the target disk first, and the cache blocks cached in the temporary cache area are then written to the target disk in order.
  • the consensus node puts the cache block obtained in step S20 into the disk queue to be written according to a first-in-first-out rule, so as to write the cache block to the target disk and update the disk file Blockchain.
  • four cache blocks A, B, C, and D are sequentially cached in the temporary cache area, wherein cache block A is the earliest cached, and cache block D is the last cached; the consensus When the node writes the four cache blocks of A, B, C, and D to the target disk, first puts the cache block A into the disk queue to be written, and then puts the cache blocks B, C, and D in sequence. Enter the disk queue to be written to write the cache block to the target disk and update the blockchain in the disk file.
  • the consensus node writes the target block into the temporary buffer area and obtains the buffer block corresponding to the target block, if the temporary buffer area is full, and the target area is blocked waiting
  • the number of blocks is greater than the preset threshold, and the capacity of the temporary buffer area is increased.
  • the consensus node may adjust the size of the disk queue to be written according to the increase in the capacity of the temporary buffer area, so as to store more buffer blocks. Add to the disk queue to be written to ensure that the target block in the blocked waiting state is cached in the temporary buffer area as much as possible.
  • the consensus node needs to increase the size of the disk queue to be written to by 2 cache block lengths. After the size of the disk queue to be written is increased by two cache block lengths, two more cache blocks can be added.
  • the consensus node adjusts the size of the disk queue to be written according to the capacity of the temporary buffer area, so as to satisfy that the blockchain system can operate efficiently under different transaction volume scenarios.
  • the consensus node first caches the target block in the temporary cache area, and then writes the cache block in the temporary cache area to the blockchain in the target disk for persistence; after receiving the data
  • the consensus node preferentially obtains the cache block from the temporary cache area and distributes it to the corresponding data node.
  • FIG. 2 shows that in step S20, the target block is written into the temporary buffer area, and the buffer block corresponding to the target block is obtained, and sent to the data node to indicate that the target block has been written
  • the schematic diagram of the written notification into the blockchain specifically includes the following steps S201 to S204.
  • Step S201 Determine whether the temporary buffer area is full according to the number of stored buffer blocks in the temporary buffer area.
  • the consensus node judges whether the temporary buffer area is full according to the number of cache blocks stored in the temporary buffer area.
  • the consensus node determines that the temporary cache area is not full; if the cache blocks already stored in the temporary cache area If the number is exactly L, the consensus node determines that the temporary buffer area is full.
  • Step S202 If the temporary buffer area is not full, write the target block into the temporary buffer area to obtain a buffer block corresponding to the target block.
  • the consensus node determines that the temporary cache area is not full.
  • the consensus node sequentially writes the target block into the temporary buffer area to obtain a buffer block corresponding to the target block.
  • Step S203 If the temporary buffer area is full, block and wait for the target block.
  • the consensus node determines that the temporary cache area is full.
  • the consensus node After determining that the temporary buffer area is full, the consensus node performs blocking wait for the target block.
  • the cache block in the temporary cache area is put into the disk queue to be written, the cache block is not allowed to be removed from the temporary cache area. For example, when a target block needs to be written into the temporary buffer area, if the temporary buffer area is full and the earliest buffer block written into the temporary buffer area has not been put into the disk queue to be written , The target block needs to be blocked and waited until the earliest cache block written into the temporary cache area is removed after being written to the target disk, and a vacancy is generated in the temporary cache area.
  • the culling refers to deleting the cache block written to the target disk from the temporary cache area.
  • the consensus node when the consensus node writes the target block into the temporary buffer area, if the temporary buffer area is full, the target block is blocked and waited; After the first cache block in the cache area is deleted from the temporary cache area after being written to the target disk, the consensus node continues to write the blocked waiting target block into the temporary cache area.
  • the first cache block refers to the cache block with the earliest cache time in the temporary cache area; the first cache block is relative to other cache blocks in the temporary cache area, It can be written to the target disk first.
  • the target block does not consume the memory space of the temporary buffer area while waiting for blocking.
  • the temporary buffer area When the temporary buffer area is full, by blocking and waiting for the target block, the temporary buffer area can be prevented from causing memory overflow, and abnormal errors in the temporary buffer area can be avoided.
  • Step S204 If there is a cache block in the temporary cache area written to the target disk, stop waiting for blocking the target block and write the target block into the temporary cache area to obtain the target The cache block corresponding to the block.
  • the consensus node may also sequentially add the cache blocks in the temporary cache area to the disk queue to be written to, so as to save the temporary
  • the cache block in the cache area is written into the blockchain of the target disk.
  • the consensus node deletes the cache block, and a space is generated in the temporary cache area.
  • the consensus node blocks and waits for the target block, if a cache block in the temporary cache area is written to the target disk and a space is generated in the temporary cache area, then The consensus node stops blocking and waiting for the target block.
  • the consensus node rewrites the target block in the blocked waiting state into the temporary cache area, and the cache block corresponding to the target block can be obtained.
  • Figure 2 is a step S20 to write the target block into the temporary buffer area to obtain the buffer block corresponding to the target block, and send to the data node to indicate that the target block has been written
  • the schematic diagram of the written notification of the blockchain further includes the following steps S205 and S206.
  • Step S205 If the temporary buffer area is full and the number of target blocks waiting for blocking is greater than a preset threshold, increase the capacity of the temporary buffer area.
  • the consensus node if the consensus node obtains too many target blocks, the target blocks waiting for blocking will also increase. In order to quickly cache the blocked waiting target block in the temporary buffer area, the consensus node needs to adjust the capacity of the temporary buffer area according to the blocked waiting block.
  • the consensus node increases the capacity of the temporary buffer area to cache the blocked waiting target blocks in the temporary buffer area.
  • the preset value may be 3.
  • the consensus node increases the capacity of the temporary buffer area. For example, the consensus node increases the capacity of the temporary buffer area. Increase the length of 2 blocks. At this time, the capacity of the temporary buffer area is L+2, which can store L+2 buffer blocks.
  • the temporary buffer area By adjusting the capacity of the temporary buffer area according to the number of target blocks in a blocked waiting state, the temporary buffer area can be prevented from causing memory overflow; at the same time, it can be satisfied that the blockchain system can be efficient in scenarios with different transaction volumes. run.
  • Step S206 Stop waiting for blocking of the target block and write the target block into a temporary buffer area with increased capacity to obtain a buffer block corresponding to the target block.
  • the temporary cache area can store more cache blocks.
  • the consensus node can stop blocking and waiting for the target block, and write the target block sequentially After increasing the capacity of the temporary cache area, the cache block corresponding to the target block is obtained.
  • FIG. 3 shows that if a block receiving request sent by the data node according to the written notification is received in step S30, the temporary buffer area corresponding to the block receiving request is set A schematic diagram of the steps performed after the block is sent to the data node, specifically including the following steps S31 to S32.
  • Step S31 Obtain a transaction verification result that the data node performs transaction verification on the received cache block.
  • the data node performs transactions on the cache block sent by the consensus node verification.
  • the data node performs transaction verification on the returned cache block according to the verification system chain code (Endorsement System Chaincode, VSCC).
  • the VSCC is mainly used to verify whether the endorsement signature of the returned cache block is valid, whether the endorsement signature comes from a valid endorsing node, and whether the endorsement policy is satisfied.
  • the data node performs transaction verification on the cache block sent by the consensus node, and if the transaction verification fails, the value of the transaction verification result is set to 1; if the transaction verification is passed, the value of the transaction verification result is set to 0.
  • the data node if the transaction verification is passed, updates the local blockchain ledger data according to the received cache block, and verifies the cache block and the transaction verification result corresponding to the cache block Send to the client corresponding to the data node, and the entire transaction process ends; if the transaction verification result fails, the data node deletes the cache block.
  • the consensus node obtains the transaction verification result of the data node performing transaction verification on the cache block.
  • the transaction verification result obtained by the consensus node is 0 or 1.
  • Step S32 If it is determined according to the transaction verification result that the cache block includes an erroneous transaction, delete the cache block from the temporary cache area.
  • the consensus node obtains the transaction verification result of the transaction verification performed by the data node on the received cache block, it determines whether the cache block is correct according to the transaction verification result. If the transaction verification result is 0, it means that the cache block has passed the transaction verification of the data node, and it is determined that the cache block is correct; if the transaction verification result is 1, it means that the cache block is correct. If the transaction verification of the data node is not passed, it is determined that the cache block includes an erroneous transaction.
  • deleting the cache block from the temporary cache area can prevent the cache block including erroneous transactions from being written to the target disk. On the blockchain.
  • the data node may also receive a block read request, as shown in FIG. As shown in 4, it specifically includes the following steps S50 to S70.
  • Step S50 If a block read request sent by the data node is received, query whether there is a cache block corresponding to the block read request in the temporary cache area.
  • some data nodes can actively send a block read request to the consensus node to read the block corresponding to the block read request from the consensus node.
  • the data node may actively initiate a block read request according to a transaction request of the corresponding client to obtain a block in the blockchain.
  • the block read request includes information of the block to be read, for example, includes the hash value of the block to be read.
  • the consensus node when a data node actively initiates a block read request, the consensus node obtains the block read request, and obtains that the block read request includes the hash value of the block to be read. According to the hash value of the block to be read, the consensus node preferentially searches for a cache block whose hash value is consistent with the hash value of the block to be read in the temporary cache area.
  • the consensus node searches for a cache block whose hash value is consistent with the hash value of the block to be read from the temporary cache area, if there is a hash value that is consistent with the block to be read For a cache block with a consistent hash value, the consensus node returns the cache block to the data node corresponding to the block read request. If there is no cache block whose hash value is consistent with the hash value of the block to be read in the temporary cache area, the consensus node queries the block chain on the target disk. The block whose value is consistent with the hash value of the block to be read is selected, and the block that meets the conditions is queried and returned to the data node corresponding to the block read request.
  • the frequency of reading the target disk can be reduced, thereby prolonging the life of the target disk.
  • Step S60 If there is a cache block corresponding to the block read request in the temporary cache area, send the cache block to the data node.
  • the consensus node after receiving the block read request from the data node, preferentially searches for the hash value in the temporary buffer area and the hash of the block to be read in the block read request Cache block with consistent value.
  • the consensus node will cache the corresponding one from the temporary cache area The block is returned to the data node corresponding to the block read request.
  • the consensus node preferentially reads the cache block from the temporary cache area, which can quickly read the cache block and distribute it to the data node, reducing the delay of cache block distribution.
  • the consensus node quickly returns the read cache block to the corresponding data node, and the data node verifies according to the returned cache block, which improves the processing efficiency of the transaction and shortens the time of the entire process of the transaction, thereby effectively improving the entire process.
  • the throughput of the blockchain system The throughput of the blockchain system.
  • FIG. 5 is a schematic diagram of the steps performed after the cache block is sent to the data node in step S60, and specifically includes the following steps S61 to S62.
  • Step S61 Obtain a verification result of the data node verifying the received cache block.
  • the data node performs processing on the cache block sent by the consensus node verification.
  • the data node verifies the hash value of the received cache block. If the hash value of the cache block is inconsistent with the hash value of the block to be read included in the block read request, it is determined that the cache block has an error.
  • the reason for the error in the cache block may be that bytes of the cache block are lost or tampered with during the process of sending the cache block by the consensus node.
  • the data node sets the verification result corresponding to the cache block to 1; if the cache block is correct, the data node sets the cache area The verification result corresponding to the block is set to 0.
  • the data node if the cache block is verified and determined to be an erroneous block, the data node sets the verification result corresponding to the cache block to 1, to indicate that the cache block is erroneous ; The data node deletes the wrong cache block.
  • the data node if the cache block is verified to be a correct block, the data node sets the verification result corresponding to the cache block to 0 to indicate that the cache block is correct of.
  • the data node updates the received cache block to the local blockchain ledger data, and sends the cache block and the verification result corresponding to the cache block to the client corresponding to the data node .
  • the consensus node obtains the verification result of the data node verifying the cache block.
  • the data node By verifying the received cache block, the data node will delete the wrong cache block, which can avoid updating the wrong cache block to the local blockchain ledger data.
  • Step S62 If it is determined that the cache block is incorrect according to the verification result, the cache block in the temporary cache area is sent to the data node again.
  • the consensus node determines according to the verification result that the cache block in the temporary cache area corresponding to the block read request is in the process of sending Whether there is an error. If the verification result is 0, it is determined that the cache block has no error during the sending process; if the verification result is 1, it is determined that the cache block has an error during the sending process.
  • the consensus node again sends the cache block from the temporary cache area to the data node corresponding to the block read request.
  • the error cache block By verifying the received cache block, the error cache block can be found in time, avoiding updating the wrong cache block to the local blockchain ledger data; by obtaining the verification result, it can be realized from the temporary cache area again Reading the corresponding cache block in the middle and distributing it to the data node is conducive to improving the processing efficiency of the transaction and shortening the time of the entire process of the transaction.
  • Step S70 If there is no cache block corresponding to the block read request in the temporary cache area, read the block corresponding to the block read request from the target disk, and store all the blocks corresponding to the block read request. The block is sent to the data node.
  • the consensus node after receiving the block read request from the data node, the consensus node preferentially inquires whether there is a cache block corresponding to the block read request in the temporary cache area.
  • the cache block if there is no cache block corresponding to the block read request in the temporary cache area, for example, there is no hash value in the temporary cache area that corresponds to the block to be read.
  • the possible reason for the cache block with the same hash value is that after the cache block whose hash value is consistent with the hash value of the block to be read is written to the target disk, the cache block is removed from the temporary Removed from the buffer. Therefore, the consensus node needs to read the block corresponding to the block read request from the target disk.
  • the consensus node queries the block with the hash value consistent with the hash value of the block to be read in the block chain of the target disk, and compares the hash value in the block chain with the hash value of the block to be read.
  • the block with the same hash value of the block to be read is sent to the data node.
  • the consensus node reads from the target disk the data in the block chain.
  • the block corresponding to the hash value of the block to be read can effectively reduce the frequency of reading the target disk, thereby prolonging the service life of the target disk.
  • FIG. 6 is a schematic diagram of the steps performed after the block is sent to the data node in step S70, and specifically includes the following steps S71 to S72.
  • Step S71 Obtain a verification result of the data node verifying the received block.
  • the data node verifies the hash value of the block.
  • the hash value of the block is inconsistent with the hash value of the block to be read included in the block read request, it means that an error has occurred in the block.
  • the reason for the error of the block may be that bytes of the block are lost or tampered with during the process of sending the block by the consensus node.
  • the verification result corresponding to the block is set to 1; if the block is correct, the verification result corresponding to the block is set to 0.
  • the data node if the cache block is verified and determined to be an erroneous block, the data node sets the verification result corresponding to the block to 1, to indicate that the block is erroneous. The data node deletes the wrong block.
  • the data node if the block is verified and determined to be a correct block, the data node sets the verification result corresponding to the block to 0 to indicate that the block is correct.
  • the data node updates the received block to the local blockchain ledger data, and sends the block and the verification result corresponding to the block to the client corresponding to the data node.
  • the consensus node obtains the verification result of the data node verifying the block.
  • the data node By verifying the received block, the data node will delete the wrong block, which can avoid updating the wrong block to the local blockchain ledger data.
  • Step S72 If it is determined that the block is incorrect according to the verification result, the block is sent from the target disk to the data node again.
  • the consensus node determines according to the verification result that the block corresponding to the block read request in the target disk's blockchain is in the sending process Whether there is an error in.
  • the verification result is 0, it is determined that the block has no error during the transmission process; if the verification result is 1, it is determined that the block has an error during the transmission process.
  • the consensus node reads the block from the blockchain of the target disk again and sends it to the corresponding block read request. Data node.
  • the chain reads the corresponding block and returns it to the data node, which is beneficial to improve the processing efficiency of the transaction and shorten the time of the entire process of the transaction.
  • the cache by first writing the target block into the temporary cache area and distributing it to the data node, and then writing the cache block in the temporary cache area to the target disk, the cache can be The process of block distribution to data nodes and writing to the target disk is isolated, which reduces the delay of block distribution and achieves the effect of reducing the frequency of reading the target disk.
  • By blocking and waiting for the target block written in the temporary buffer area and increasing the capacity of the temporary buffer area memory overflow can be prevented, and the blockchain system can operate efficiently in scenarios with different transaction volumes.
  • By obtaining the transaction verification result on the data node it is possible to avoid writing the wrong cache block to the blockchain in the target disk.
  • When receiving a block read request from a data node firstly query whether there are eligible cache blocks in the temporary cache area, and then query in the target disk, which can reduce the frequency of reading the target disk, thereby extending the target The life of the disk.
  • FIG. 7 is a schematic block diagram of a block distribution device of a block chain according to an embodiment of the present application.
  • the block distribution device of the block chain is used to execute the blocks of the aforementioned block chain. Distribution method.
  • the block distribution device of the block chain can be configured in a server or a terminal.
  • the block distribution device 100 of the blockchain includes: a block acquisition module 101, a first block writing module 102, a first block sending module 103, and a second block writing module 104 .
  • the block acquisition module 101 is used to acquire the target block to be written into the blockchain.
  • the first block writing module 102 is used to write the target block into the temporary buffer area, obtain the buffer block corresponding to the target block, and send to the data node to indicate that the target block has been written Written notification of entry into the blockchain.
  • the first block sending module 103 is configured to: if a block receiving request sent by the data node according to the written notification is received, the buffer block in the temporary buffer area corresponding to the block receiving request Send to the data node.
  • the second block writing module 104 is configured to write the cache block to the target disk, so as to add the cache block to the blockchain stored in the target disk.
  • the block distribution device 100 of the block chain further includes: a query module 105, a second block sending module 106, and a third block sending module 107.
  • the query module 105 is configured to, if a block read request sent by the data node is received, query whether there is a cache block corresponding to the block read request in the temporary cache area.
  • the second block sending module 106 is configured to send the cache block to the data node if there is a cache block corresponding to the block read request in the temporary cache area.
  • the third block sending module 107 is configured to read the block read request from the target disk if there is no cache block corresponding to the block read request in the temporary cache area The corresponding block is sent to the data node.
  • the first block writing module 102 includes: a judging sub-module 1021, a first writing sub-module 1022, a blocking waiting sub-module 1023, and a second writing sub-module 1024 , The capacity increasing sub-module 1025 and the third writing sub-module 1026.
  • the judging sub-module 1021 is used for judging whether the temporary buffer area is full according to the number of cache blocks stored in the temporary buffer area.
  • the first writing sub-module 1022 is configured to write the target block into the temporary buffer area if the temporary buffer area is not full to obtain the buffer block corresponding to the target block.
  • the blocking and waiting submodule 1023 is configured to perform blocking and waiting for the target block if the temporary buffer area is full.
  • the second writing sub-module 1024 is configured to, if there is a cache block in the temporary cache area being written to the target disk, stop waiting for blocking the target block and write the target block into the temporary In the cache area, the cache block corresponding to the target block is obtained.
  • the capacity increasing sub-module 1025 is configured to increase the capacity of the temporary buffer area if the temporary buffer area is full and the number of target blocks waiting for blocking is greater than a preset threshold.
  • the third writing sub-module 1026 is configured to stop waiting for blocking of the target block and write the target block into the temporary buffer area with increased capacity to obtain the buffer block corresponding to the target block.
  • the block distribution device 100 of the blockchain further includes: a first verification module 108 and a block deletion module 109.
  • the first verification module 108 is configured to obtain the transaction verification result of the transaction verification performed by the data node on the received cache block.
  • the block deletion module 109 is configured to delete the cache block from the temporary cache area if it is determined that the cache block includes an erroneous transaction according to the transaction verification result.
  • the block distribution device 100 of the blockchain further includes: a second verification module 110 and a second block sending sub-module 111.
  • the second verification module 110 is configured to obtain a verification result of the data node verifying the received cache block.
  • the second block sending submodule 111 is configured to send the cache block in the temporary cache area to the data node again if it is determined that the cache block is incorrect according to the verification result.
  • the block distribution device 100 of the blockchain further includes: a third verification module 112 and a third block sending sub-module 113.
  • the third verification module 112 is configured to obtain a verification result of the data node verifying the received block.
  • the third block sending submodule 113 is configured to send the block from the target disk to the data node again if it is determined that the block is incorrect according to the verification result.
  • the method and device of the present application can be used in many general or special computing system environments or configurations.
  • the above method and device can be implemented in the form of a computer program, and the computer program can be run on the computer device as shown in FIG. 9.
  • the computer equipment can be a terminal or a server.
  • the terminals can be electronic devices such as smart phones, tablet computers, notebook computers, desktop computers, personal digital assistants, and wearable devices.
  • the server can be an independent server or a server cluster.
  • the computer device includes a processor and a memory connected through a system bus, where the memory may include a non-volatile storage medium and an internal memory.
  • the processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.
  • the internal memory provides an environment for the operation of the computer program in the non-volatile storage medium.
  • the processor can execute any block distribution method of the blockchain.
  • the processor may be a central processing unit (Central Processing Unit, CPU), and the processor may also be other general-purpose processors, digital signal processors (Digital Signal Processors, DSPs), and application specific integrated circuits (Application Specific Integrated Circuits). Circuit, ASIC), off-the-shelf programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor.
  • the processor is used to run a computer program stored in a memory to implement the following steps:
  • Obtain the target block to be written to the blockchain write the target block into the temporary cache area to obtain the cache block corresponding to the target block, and send to the data node to indicate that the target block has been Write a written notification to the blockchain; if a block reception request sent by the data node according to the written notification is received, the temporary buffer area corresponding to the block reception request buffer area The block is sent to the data node; the cache block is written to the target disk to add the cache block to the blockchain stored on the target disk.
  • the processor is further configured to implement the following steps:
  • a block read request sent by the data node If a block read request sent by the data node is received, query whether there is a cache block corresponding to the block read request in the temporary cache area; if there is a cache block corresponding to the block read request in the temporary cache area, The cache block corresponding to the block read request is sent to the data node; if there is no cache block corresponding to the block read request in the temporary cache area, the cache block is sent from all The block corresponding to the block read request is read from the target disk, and the block is sent to the data node.
  • the processor when the processor realizes that the target block is written into the temporary cache area and the cache block corresponding to the target block is obtained, it is used to realize:
  • the temporary buffer area If the temporary buffer area is not full, write the target block into the temporary buffer area to obtain the buffer block corresponding to the target block; if the temporary buffer area is full, write to the target block Perform blocking waiting; if there is a cache block in the temporary cache area written to the target disk, stop blocking waiting for the target block and write the target block into the temporary cache area to obtain the The cache block corresponding to the target block.
  • the processor when the processor realizes that the target block is written into the temporary cache area, and the cache block corresponding to the target block is obtained, the processor is further used to realize:
  • the processor when the processor implements writing the cache block to the target disk so as to add the cache block to the blockchain stored by the target disk, the processor is used to implement:
  • each of the cache blocks is written to the target disk in turn, so as to add each of the cache blocks to the The target disk is stored in the blockchain.
  • the processor after the processor implements sending the cache block corresponding to the block reception request in the temporary cache area to the data node, it is further configured to implement:
  • the processor after the processor realizes sending the cache block to the data node, it is further configured to realize:
  • the processor after the processor realizes sending the block to the data node, it is further configured to realize:
  • the embodiments of the present application also provide a computer-readable storage medium, the computer-readable storage medium stores a computer program, the computer program includes program instructions, and the processor executes the program instructions to implement the present application
  • the block distribution method of any block chain provided in the embodiment is not limited to, but not limited to, but not limited to, but not limited to, but not limited to, but not limited to, a computer-readable storage medium, the computer-readable storage medium stores a computer program, the computer program includes program instructions, and the processor executes the program instructions to implement the present application The block distribution method of any block chain provided in the embodiment.
  • the computer-readable storage medium may be non-volatile or volatile.
  • the computer-readable storage medium may be the internal storage unit of the computer device described in the foregoing embodiment, for example, the hard disk or memory of the computer device.
  • the computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), or a secure digital card equipped on the computer device. , SD Card, Flash Card, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Business, Economics & Management (AREA)
  • Finance (AREA)
  • Accounting & Taxation (AREA)
  • Strategic Management (AREA)
  • Theoretical Computer Science (AREA)
  • Development Economics (AREA)
  • Technology Law (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Marketing (AREA)
  • Economics (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Memory System Of A Hierarchy Structure (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请涉及区块链分布式账本领域,其公开了一种区块链的区块分发方法、装置、计算机设备和存储介质,该方法包括:获取待写入区块链的目标区块;将目标区块写入临时缓存区,得到目标区块对应的缓存区块,并向数据节点发送用于表示目标区块已写入区块链的已写入通知;若接收到数据节点根据已写入通知发送的区块接收请求,将临时缓存区中对应于区块接收请求的缓存区块向数据节点发送;将缓存区块写入目标磁盘,以将缓存区块加入到目标磁盘存储的区块链中。采用本申请实施例,减少对目标磁盘的读取频率,降低缓存区块分发的延迟时间。

Description

区块链的区块分发方法、装置、计算机设备和存储介质
本申请要求于2019年10月12日提交中国专利局、申请号为2019109694114,发明名称为“区块链的区块分发方法、装置、计算机设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及区块链分布式账本领域,尤其涉及一种区块链的区块分发方法、装置、计算机设备和存储介质。
背景技术
在现有的区块链系统中,共识节点将区块保存到本地文件账本即写入磁盘后,如果此时共识节点发现有监听的数据节点在等待新的区块产生,共识节点会从磁盘读取对应的区块发送给数据节点。发明人意识到,在这个过程中,如果多个数据节点监听该共识节点,该共识节点需要多次从磁盘读取区块返回给数据节点;一方面,共识节点存在频繁的读取磁盘的可能,频繁读取磁盘会降低磁盘寿命;另一方面,共识节点不能及时地将区块分发给监听的数据节点,直接延长了交易的确认时间,交易处理效率低,导致整个交易流程的耗时长。
发明内容
本申请提供了一种区块链的区块分发方法、装置、计算机设备和存储介质,通过先将目标区块缓存到临时缓存区并分发给数据节点,再将临时缓存区中的缓存区块写入目标磁盘,以将缓存区块的分发到数据节点和写入目标磁盘的过程隔离,可以实现减少对目标磁盘的读取频率的效果和降低缓存区块分发的延迟时间。
第一方面,本申请提供了一种区块链的区块分发方法,所述方法包括:
获取待写入区块链的目标区块;
将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块,并向数据节点发送用于表示所述目标区块已写入区块链的已写入通知;
若接收到所述数据节点根据所述已写入通知发送的区块接收请求,将所述临时缓存区中对应于所述区块接收请求的缓存区块向所述数据节点发送;
将所述缓存区块写入目标磁盘,以将所述缓存区块加入到所述目标磁盘存储的区块链中。
第二方面,本申请还提供了一种区块链的区块分发装置,所述装置包括:
区块获取模块,用于获取待写入区块链的目标区块;
第一区块写入模块,用于将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块,并向数据节点发送用于表示所述目标区块已写入区块链的已写入通知;
第一区块发送模块,用于若接收到所述数据节点根据所述已写入通知发送的区块接收请求,将所述临时缓存区中对应于所述区块接收请求的缓存区块向所述数据节点发送;
第二区块写入模块,用于将所述缓存区块写入目标磁盘,以将所述缓存区块加入到所述目标磁盘存储的区块链中。
第三方面,本申请还提供了一种计算机设备,所述计算机设备包括存储器和处理器,所述处理器、和所述存储器相互连接,其中,所述存储器用于存储计算机程序,所述计算机程序包括程序指令,所述处理器用于执行所述存储器的所述程序指令,其中:
获取待写入区块链的目标区块;
将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块,并向数据节点发送用于表示所述目标区块已写入区块链的已写入通知;
若接收到所述数据节点根据所述已写入通知发送的区块接收请求,将所述临时缓存区 中对应于所述区块接收请求的缓存区块向所述数据节点发送;
将所述缓存区块写入目标磁盘,以将所述缓存区块加入到所述目标磁盘存储的区块链中。
第四方面,本申请还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令被处理器执行时,用于实现以下步骤:
获取待写入区块链的目标区块;
将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块,并向数据节点发送用于表示所述目标区块已写入区块链的已写入通知;
若接收到所述数据节点根据所述已写入通知发送的区块接收请求,将所述临时缓存区中对应于所述区块接收请求的缓存区块向所述数据节点发送;
将所述缓存区块写入目标磁盘,以将所述缓存区块加入到所述目标磁盘存储的区块链中。
本申请公开了一种区块链的区块分发方法、装置、计算机设备和存储介质,通过将获取的目标区块写入临时缓存区,得到目标区块对应的缓存区块,并向数据节点发送已写入通知,避免直接将目标区块写入目标磁盘后再从目标磁盘进行分发,实现减少对目标磁盘的读取频率的效果;若接收到数据节点根据已写入通知发送的区块接收请求,将临时缓存区中对应的缓存区块向数据节点发送,可以优先从临时缓存区中将缓存区块分发给数据节点,实现快速地分发区块给数据节点,降低缓存区块分发的延迟时间;然后将临时缓存区中的缓存区块写入目标磁盘,通过将缓存区块的分发到数据节点和写入目标磁盘的过程隔离,可以有效提升整个区块链系统的稳定性。
附图说明
图1是本申请的实施例提供的一种区块链的区块分发方法的示意流程图;
图2是图1中区块写入临时缓存区的子步骤示意流程图;
图3是图1中区块发送之后的步骤示意流程图;
图4是图1中区块写入目标磁盘之后的步骤示意流程图;
图5是图4中缓存区块发送之后的步骤示意流程图;
图6为图4中区块发送之后的步骤示意流程图;
图7为本申请实施例提供的一种区块链的区块分发装置的示意性框图;
图8为图7中区块链的区块分发装置的子模块的示意性框图;
图9为本申请实施例提供的一种计算机设备的结构示意性框图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
附图中所示的流程图仅是示例说明,不是必须包括所有的内容和操作/步骤,也不是必须按所描述的顺序执行。例如,有的操作/步骤还可以分解、组合或部分合并,因此实际执行的顺序有可能根据实际情况改变。
应当理解,在此本申请说明书中所使用的术语仅仅是出于描述特定实施例的目的而并不意在限制本申请。如在本申请说明书和所附权利要求书中所使用的那样,除非上下文清楚地指明其它情况,否则单数形式的“一”、“一个”及“该”意在包括复数形式。
还应当理解,在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联列 出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。
本申请的实施例提供了一种区块链的区块分发方法、装置、计算机设备和存储介质。其中,该区块链的区块分发方法可以应用于作为区块链节点的终端或服务器中,通过将缓存区块的分发到数据节点和写入目标磁盘的过程隔离,实现减少读取目标磁盘的频率的效果。
其中,终端可以是智能手机、平板电脑、笔记本电脑、台式电脑、个人数字助理和穿戴式设备等电子设备。服务器可以为独立的服务器,也可以为服务器集群。
下面结合附图,对本申请的一些实施方式作详细说明。在不冲突的情况下,下述的实施例及实施例中的特征可以相互组合。
如图1所示,区块链的区块分发方法包括步骤S10至步骤S40。
步骤S10、获取待写入区块链的目标区块。
示例性的,区块链系统中存在多种节点,例如,背书节点、共识节点和数据节点等。所述节点可以是任意的计算机设备,比如PC电脑,笔记本,手机,路由器等。
所述节点用于对区块链系统中的区块进行操作,例如读取区块,写入区块、删除区块、发送区块、查询区块等。
所述共识节点是指对分布式账本中的区块链进行操作的节点,例如,将区块写入区块链、读取区块链中的区块。示例性的,所述共识节点可以对交易进行排序、打包生成区块,并将新生成的区块保存到所述共识节点维护的区块链中。
具体地,所述目标区块是所述共识节点根据客户端的交易请求,对交易提案进行排列和打包得到的区块。所述交易请求为客户端在数据节点将交易数据打包成为交易提案后发出的请求。
在一些实施例中,客户端对应的数据节点将交易数据打包成为交易提案后,根据背书策略将所述交易提案发送给指定的背书节点。所述背书节点对所述交易提案进行验证并签名确认,得到已签名的交易提案;所述背书节点将所述已签名的交易提案提交到共识节点。
需要说明的是,所述背书策略根据预设条件来决定是否放行或拒绝所述交易提案。所述预设条件可以是一个节点认可、多数节点认可或者全部节点认可的。
所述背书节点在接收到所述交易提案后调用链码(Chaincode)进行验证,例如所述背书节点验证所述交易提案是否合法和是否可以正常提交。若所述交易提案通过验证,所述背书节点调用背书管理系统链码(Endorsement System Chaincode,ESCC)对所述交易提案进行背书签名,得到已签名的交易提案。需要说明的是,所述背书系统链码用于对交易提案进行背书签名。
具体地,所述共识节点根据客户端的交易请求对所述已签名的交易提案进行排序,得到一系列的排序数据。所述共识节点根据共识算法将所述一系列的排序数据按照将一定数量进行打包,以生成待写入区块链的目标区块,所述目标区块包括至少一个排序数据。
所述共识算法是指共识节点针对交易提案达成一致意见的过程,包括同意提案或者否定提案,并得到顺序一致性的排序数据。示例性的,所述共识算法可以包括PoW(Proof of Word)算法、PBFT(Practical Byzantine Fault Tolerance)算法或PoS(Proof of Stake)算法。
具体地,所述一定数量是指所述一系列的排序数据中连续的至少一个。
具体地,所述目标区块可以包括区块头和区块数据,其中所述区块头包含元数据。所述共识节点在将所述一系列的排序数据打包生成目标区块时,将区块头和区块数据写入所述目标区块中。
示例性的,在将所述一系列的排序数据打包生成目标区块时,所述共识节点根据SHA(Secure Hash Algorithm)-256摘要算法对所述目标区块中的区块数据进行哈希加密,生成一个哈希值。所述共识节点将所述哈希值作为当前区块的哈希值存放在所述目标区块的 区块头中,并且每个区块头都包含它的上一区块的哈希值。通过所述当前区块的哈希值,所述共识节点可以在区块链中识别出所述当前区块。
具体地,所述共识节点在将获取到的所述待写入区块链的目标区块写入区块链之前,先将所述待写入区块链的目标区块缓存到一个临时缓存区中,以表示所述目标区块成功写入区块链。这样可以提前从所述临时缓存区中将所述目标区块分发给监听的数据节点。
步骤S20、将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块,并向数据节点发送用于表示所述目标区块已写入区块链的已写入通知。
具体地,所述共识节点在将所述目标区块写入临时缓存区之前,在随机存取存储器(Random Access Memory,RAM)中创建一个预设容量的临时缓存区,所述临时缓存区用于缓存所述目标区块。
示例性的,所述共识节点创建一个容量为L的临时缓存区,所述临时缓存区将所述目标区块作为临时数据保存,所述临时缓存区能存储L个缓存区块。
具体地,所述共识节点将所述待写入区块链的目标区块先写入所述临时缓存区,得到所述目标区块对应的缓存区块;然后所述共识节点再将所述临时缓存区中的缓存区块依次写入目标磁盘中的区块链上。
在一些实施例中,将目标区块先写入所述临时缓存区中,若所述目标区块有四个,将所述目标区块依次缓存到所述临时缓存区中,得到A、B、C、D四个缓存区块,其中缓存区块A是最早缓存的,缓存区块D是最后缓存的。
所述共识节点先将所述目标区块缓存到所述临时缓存区,可以将所述目标区块作为临时数据保存到所述临时缓存区;所述临时缓存区中的缓存区块可以分发给对应的数据节点,而不必等到将所述目标区块保存到所述目标磁盘中的区块链上后再从所述区块链上读取并分发给对应的数据节点。
由于所述随机存取存储器的写入速度比所述目标磁盘的写入速度快很多,因此所述共识节点将所述目标区块写入所述临时缓存区比写入所述目标磁盘的速度快很多。通过将目标区块写入到临时缓存区中,可以实现将所述目标区块快速地分发给监听的数据节点,降低目标区块分发的延迟。
具体地,所述共识节点在将所述目标区块写入临时缓存区之后,向正在监听的数据节点发送用于表示所述目标区块已写入区块链的已写入通知。
具体地,所述数据节点用于监听是否有已写入通知生成或者主动发起区块读取请求。
示例性的,所述共识节点将获取的目标区块写入所述临时缓存区后,所述临时缓存区中得到一个与所述目标区块对应的缓存区块,可以表示所述目标区块写入区块链成功。因此所述共识节点产生一个与所述缓存区块对应的已写入通知。所述共识节点将所述已写入通知广播到区块链网络,以将所述已写入通知发送给正在监听的数据节点。
具体地,所述已写入通知用于表示所述临时缓存区中有缓存区块生成。
具体地,所述已写入通知与所述临时缓存区中缓存区块对应,并包含所述缓存区块的描述信息,例如所述描述信息可以包括所述缓存区块对应的哈希值。
通过发送所述缓存区块对应的已写入通知,可以实现快速将所述临时缓存区中的缓存区块分发给监听的数据节点,降低缓存区块分发的延迟,提高交易的处理效率。
步骤S30、若接收到所述数据节点根据所述已写入通知发送的区块接收请求,将所述临时缓存区中对应于所述区块接收请求的缓存区块向所述数据节点发送。
具体地,区块链网络中的数据节点用于实时监听区块链网络中是否有目标区块对应的已写入通知。若监听到区块链网络中有已写入通知生成,所述数据节点则响应所述已写入通知并发送一个与所述已写入通知对应的区块接收请求。
示例性的,所述响应可以包括根据所述已写入通知携带的描述信息,生成一个与所述已写入通知对应的区块接收请求。所述区块接收请求包括所述已写入通知包含的缓存区块的描述信息。所述描述信息可以包括缓存区块的哈希值。
具体地,所述共识节点若接收到所述数据节点根据所述已写入通知发送的区块接收请求,将所述临时缓存区中对应于所述区块接收请求的缓存区块向所述数据节点发送。
具体地,所述共识节点在所述临时缓存区中查询与所述区块接收请求中的描述信息一致的缓存区块,将所述缓存区块发送到所述区块接收请求对应的数据节点。
在一些实施例中,所述共识节点根据所述区块接收请求的描述信息,从所述临时缓存区中查询哈希值与所述描述信息中的哈希值一致的缓存区块。例如,所述共识节点在所述临时缓存区中查询到缓存区块A的哈希值与所述描述信息中的哈希值保持一致,则将所述缓存区块A返回给所述区块接收请求对应的数据节点。
具体地,若有多个监听的数据节点响应于所述已写入通知的区块接收请求,则所述共识节点多次从所述临时缓存区中查询与所述已写入通知对应的缓存区块,并将哈希值一致的缓存区块后分别返回给所述区块接收请求对应的数据节点。
通过根据监听的数据节点的区块接收请求,由所述共识节点将所述临时缓存区中的缓存区块读取并发送给监听的数据节点,可以实现快速分发区块,还可以有效减少读取磁盘的频率,从而延长磁盘的使用寿命。
步骤S40、将所述缓存区块写入目标磁盘,以将所述缓存区块加入到所述目标磁盘存储的区块链中。
示例性的,所述目标磁盘中存储有区块链。例如,所述目标磁盘中存储有全量数据的区块链,或者存储包括部分区块的部分区块链。
所述共识节点可以读取所述目标磁盘中的区块链;或者将缓存区块写入所述目标磁盘,以将所述缓存区块加入区块链中。
示例性的,所述目标磁盘为非易失性存储器,例如机械硬盘、固态硬盘、智能存储卡、安全数字卡或闪存卡。
具体地,所述共识节点将所述目标区块作为临时数据保存到所述临时缓存区后,还需要将所述临时缓存区中的缓存区块写入目标磁盘,以将所述缓存区块加入到所述目标磁盘存储的区块链中。所述共识节点通过将所述缓存区块加入区块链中存储,可以实现对所述目标区块进行持久化。
需要说明的是,所述持久化是一种将程序或数据在瞬时状态转换成持久状态的机制,例如将所述临时缓存区中临时保存的缓存区块写入所述目标磁盘中的区块链进行持久化保存。
具体地,所述共识节点基于先入先出的规则,根据所述临时缓存区中各所述缓存区块的写入顺序,将各所述缓存区块依次写入所述目标磁盘,以将各所述缓存区块加入到所述目标磁盘存储的区块链中。
所述先入先出是指按顺序将先缓存在所述临时缓存区中的缓存区块先写入目标磁盘,后缓存在所述临时缓存区中的缓存区块后写入目标磁盘。
示例性的,所述共识节点将步骤S20中得到的缓存区块按照先入先出的规则放入待写入磁盘队列中,以将所述缓存区块写入所述目标磁盘并更新磁盘文件中的区块链。
在一些实施例中,所述临时缓存区中依次缓存有A、B、C、D四个缓存区块,其中缓存区块A是最早缓存的,缓存区块D是最后缓存的;所述共识节点在将A、B、C、D四个缓存区块写入所述目标磁盘时,先将缓存区块A放入待写入磁盘队列中,然后依次将缓存区块B、C、D放入待写入磁盘队列中,以将所述缓存区块写入所述目标磁盘并更新磁盘文件中的区块链。
具体地,所述共识节点在将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块时,若所述临时缓存区已写满,且进行阻塞等待的目标区块的数量大于预设阈值,增大所述临时缓存区的容量。
具体地,在增大所述临时缓存区的容量后,所述共识节点可以根据所述临时缓存区的容量增大幅度调节所述待写入磁盘队列的大小,以将更多的缓存区块加入所述待写入磁盘队列中,保证将处于阻塞等待状态的目标区块尽量缓存到所述临时缓存区中。
在一些实施例中,若所述临时缓存区的容量L增大,增大幅度为2,则所述共识节点需要将所述待写入磁盘队列的大小增大2个缓存区块长度。所述待写入磁盘队列的大小增加2个缓存区块长度后,可以多放入2个缓存区块。
所述共识节点根据所述临时缓存区的容量调节所述待写入磁盘队列的大小,以满足在不同交易量的场景下,区块链系统均可以高效运行。
所述共识节点先将目标区块缓存到所述临时缓存区中,再将所述临时缓存区中的缓存区块写入到所述目标磁盘中的区块链进行持久化;在接收到数据节点的区块接收请求时,所述共识节点优先从所述临时缓存区中获取缓存区块并分发给对应的数据节点,通过将缓存区块的分发过程与持久化过程隔离,可以有效提升整个区块链系统的稳定性,同时减少读取目标磁盘的频率。
请参阅图2,图2是步骤S20中将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块,并向数据节点发送用于表示所述目标区块已写入区块链的已写入通知的示意图,具体包括以下步骤S201至步骤S204。
步骤S201、根据所述临时缓存区中已存储缓存区块的个数判断所述临时缓存区是否已写满。
由于所述临时缓存区的容量是有限的,最多可以缓存L个缓存区块,因此所述共识节点在将所述目标区块写入所述临时缓存区时,需要判断所述临时缓存区是否已写满。
具体地,所述共识节点根据所述临时缓存区中已存储的缓存区块的个数判断所述临时缓存区是否已写满。
示例性的,若所述临时缓存区中已存储的缓存区块个数小于L,则所述共识节点判定所述临时缓存区未写满;若所述临时缓存区中已存储的缓存区块个数恰好是L个,则所述共识节点判定所述临时缓存区是已写满的。
步骤S202、若所述临时缓存区未写满,将所述目标区块写入所述临时缓存区,得到所述目标区块对应的缓存区块。
示例性的,若所述临时缓存区中已存储的缓存区块个数小于L,则所述共识节点判定所述临时缓存区未写满。
具体地,所述共识节点在判定所述临时缓存区未写满之后,将所述目标区块依次写入所述临时缓存区,得到所述目标区块对应的缓存区块。
步骤S203、若所述临时缓存区已写满,对所述目标区块进行阻塞等待。
示例性的,若所述临时缓存区中已存储的缓存区块个数等于L,则所述共识节点判定所述临时缓存区是已写满的。
具体地,所述共识节点在判定所述临时缓存区已写满之后,对所述目标区块进行阻塞等待。
需要说明的是,所述临时缓存区中的缓存区块被放入待写入磁盘队列之前,所述缓存区块不允许从所述临时缓存区中剔除。例如,当有目标区块需要写入所述临时缓存区时,若所述临时缓存区已写满且最早写入所述临时缓存区的缓存区块还没放入到待写入磁盘队列中,则所述目标区块需要阻塞等待,直到最早写入所述临时缓存区的缓存区块在写入目标磁盘之后被剔除而在所述临时缓存区中产生空位。
具体地,所述剔除是指将写入所述目标磁盘后的缓存区块从所述临时缓存区中删除。
在一些实施例中,所述共识节点将所述目标区块写入所述临时缓存区时,若所述临时缓存区已写满,则将所述目标区块进行阻塞等待;直到所述临时缓存区中的第一个缓存区块在写入所述目标磁盘后从所述临时缓存区中删除后,所述共识节点将所述阻塞等待的目标区块继续写入所述临时缓存区。
示例性的,所述第一个缓存区块是指所述临时缓存区中缓存时间最早的缓存区块;所述第一个缓存区块相对于所述临时缓存区中的其它缓存区块,可以先写入所述目标磁盘中。
具体地,所述目标区块在阻塞等待时不消耗所述临时缓存区的内存空间。
在所述临时缓存区已写满时,通过对所述目标区块进行阻塞等待,可以防止所述临时缓存区导致内存溢出,避免所述临时缓存区出现异常错误。
步骤S204、若所述临时缓存区中有缓存区块写入所述目标磁盘,停止对所述目标区块进行阻塞等待并将所述目标区块写入所述临时缓存区,得到所述目标区块对应的缓存区块。
具体地,所述共识节点在将所述目标区块缓存到所述临时缓存区后,还可以将所述临时缓存区中的缓存区块依次加入待写入磁盘队列中,以将所述临时缓存区中的缓存区块写入所述目标磁盘的区块链中。在所述缓存区块写入所述目标磁盘后,所述共识节点将所述缓存区块删除,则所述临时缓存区中产生空位。
示例性的,所述共识节点在对所述目标区块进行阻塞等待之后,若所述临时缓存区中有缓存区块写入所述目标磁盘而在所述临时缓存区中产生空位,则所述共识节点停止对所述目标区块进行阻塞等待。
具体地,所述共识节点将处于阻塞等待状态的所述目标区块重新写入临时缓存区,可以得到所述目标区块对应的缓存区块。
请参阅图2,图2是步骤S20将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块,并向数据节点发送用于表示所述目标区块已写入区块链的已写入通知的示意图,还包括以下步骤S205和步骤S206。
步骤S205、若所述临时缓存区已写满,且进行阻塞等待的目标区块的数量大于预设阈值,增大所述临时缓存区的容量。
示例性的,如果所述共识节点获取的目标区块的过多,则阻塞等待的目标区块也增多。为了快速将所述阻塞等待的目标区块缓存到临时缓存区中,所述共识节点需要根据所述阻塞等待的区块对所述临时缓存区的容量进行调节。
具体地,若处于阻塞等待状态的目标区块的数量达到预设值,所述共识节点增大所述临时缓存区的容量,以将所述阻塞等待的目标区块缓存到临时缓存区中。
示例性的,所述预设值可以取3。
在一些实施例中,若处于阻塞等待状态的目标区块的个数达到3时,所述共识节点则增大所述临时缓存区的容量,例如所述共识节点将所述临时缓存区的容量增大2个区块长度。此时所述临时缓存区的容量为L+2,可以存储L+2个缓存区块。
通过根据处于阻塞等待状态的目标区块的数量调节所述临时缓存区的容量,可以防止所述临时缓存区导致内存溢出;同时可以满足在不同交易量的场景下,区块链系统均可以高效运行。
步骤S206、停止对所述目标区块进行阻塞等待并将所述目标区块写入增大容量后的临时缓存区,得到所述目标区块对应的缓存区块。
具体地,所述共识节点在增大所述临时缓存区的容量后,所述临时缓存区可以存储更多的缓存区块。
具体地,在增大所述临时缓存区的容量后,所述临时缓存区中产生空位;因此所述共识节点可以停止对所述目标区块进行阻塞等待,将所述目标区块依次写入增大容量后的临 时缓存区,得到所述目标区块对应的缓存区块。
请参阅图3,图3是步骤S30中若接收到所述数据节点根据所述已写入通知发送的区块接收请求,将所述临时缓存区中对应于所述区块接收请求的缓存区块向所述数据节点发送之后执行步骤的示意图,具体包括以下步骤S31至步骤S32。
步骤S31、获取所述数据节点对接收到的缓存区块进行交易验证的交易验证结果。
具体地,所述共识节点将所述临时缓存区中对应于所述区块接收请求的缓存区块向所述数据节点发送之后,所述数据节点对所述共识节点发送的缓存区块进行交易验证。
示例性的,所述数据节点根据验证系统链码(Endorsement System Chaincode,VSCC)对返回的缓存区块进行交易验证。需要说明的是,所述VSCC主要用于验证所述返回的缓存区块的背书签名是否有效、背书签名是否来自有效的背书节点以及是否满足背书策略。
具体地,所述数据节点对所述共识节点发送的缓存区块进行交易验证,若交易验证不通过,将交易验证结果的值置1;若交易验证通过,将交易验证结果的值置0。
在一些实施例中,若交易验证通过,所述数据节点根据所述接收的缓存区块更新本地的区块链账本数据,并将所述缓存区块以及所述缓存区块对应的交易验证结果发送给所述数据节点对应的客户端,整个交易流程结束;若交易验证结果不通过,所述数据节点将所述缓存区块删除。
通过对接收的缓存区块进行交易验证,可以避免将存在错误的缓存区块更新到本地的区块链账本数据。
具体地,所述数据节点对接收到的缓存区块进行交易验证之后,所述共识节点获取所述数据节点对所述缓存区块进行交易验证的交易验证结果。例如,所述共识节点获取的交易验证结果为0或1。
步骤S32、若根据所述交易验证结果判定所述缓存区块包括错误的交易,则从所述临时缓存区中将所述缓存区块删除。
示例性的,所述共识节点获取所述数据节点对所述接收到的缓存区块进行交易验证的交易验证结果后,根据交易验证结果判断所述缓存区块是否正确。若所述交易验证结果为0,说明所述缓存区块通过所述数据节点的交易验证,则判定所述缓存区块是正确的;若所述交易验证结果为1,说明所述缓存区块没有通过所述数据节点的交易验证,则判定所述缓存区块包括错误的交易。
具体地,在判定所述缓存区块包括错误的交易之后,将所述缓存区块从所述临时缓存区中删除,可以避免将包括错误的交易的缓存区块写入所述目标磁盘中的区块链上。
具体地,所述数据节点将所述缓存区块写入目标磁盘,以将所述缓存区块加入到所述目标磁盘存储的区块链中之后,还可以接收区块读取请求,如图4所示,具体包括以下步骤S50至步骤S70。
步骤S50、若接收到所述数据节点发送的区块读取请求,查询所述临时缓存区中是否存在与所述区块读取请求对应的缓存区块。
在区块链系统中,一些数据节点可以主动向所述共识节点发送区块读取请求,以从所述共识节点读取与所述区块读取请求对应的区块。
示例性的,所述数据节点可以根据对应客户端的交易请求主动发起区块读取请求,以获取区块链中的区块。
具体地,所述区块读取请求中包含待读取区块的信息,例如包含待读取区块的哈希值。
具体地,当有数据节点主动发起区块读取请求时,所述共识节点获取所述区块读取请求,得到所述区块读取请求中包含待读取区块的哈希值。根据所述待读取区块的哈希值,所述共识节点优先在所述临时缓存区中查找哈希值与所述待读取区块的哈希值一致的缓存区块。
示例性的,所述共识节点从所述临时缓存区中查找哈希值与所述待读取区块的哈希值一致的缓存区块,若存在哈希值与所述待读取区块的哈希值一致的缓存区块,所述共识节点将所述缓存区块返回给所述区块读取请求对应的数据节点。若所述临时缓存区中不存在任一哈希值与所述待读取区块的哈希值一致的缓存区块,则所述共识节点从所述目标磁盘上的区块链中查询哈希值与所述待读取区块的哈希值一致的区块,并将查询到符合条件的区块返回给所述区块读取请求对应的数据节点。
通过优先在所述临时缓存区中查询符合条件的缓存区块,其次才在所述目标磁盘中查询,可以减少对所述目标磁盘的读取频率,从而延长所述目标磁盘的寿命。
步骤S60、若所述临时缓存区中存在与所述区块读取请求对应的缓存区块,则将所述缓存区块向所述数据节点发送。
具体地,在接收所述数据节点的区块读取请求后,所述共识节点优先在所述临时缓存区中查找哈希值与所述区块读取请求中待读取区块的哈希值一致的缓存区块。
示例性的,若所述临时缓存区中存在哈希值与所述待读取区块的哈希值一致的缓存区块,所述共识节点从所述临时缓存区中将对应的所述缓存区块返回到所述区块读取请求对应的数据节点。
由于随机存取存储器相对于磁盘的读取速度快很多,因此在所述临时缓存区中读取区块的速度比所述目标磁盘中读取区块的速度快很多。所述共识节点优先从所述临时缓存区读取缓存区块,可以实现快速地读取缓存区块并分发给数据节点,降低缓存区块分发的延迟。
所述共识节点将读取的缓存区块快速返回给对应的数据节点,所述数据节点根据返回的缓存区块进行验证,提升交易的处理效率,缩短交易的整个流程的时间,从而有效提升整个区块链系统的吞吐量。
请参阅图5,图5是步骤S60中将所述缓存区块向所述数据节点发送之后执行步骤的示意图,具体还包括以下步骤S61至步骤S62。
步骤S61、获取所述数据节点对接收到的缓存区块进行验证的验证结果。
具体地,所述共识节点将所述临时缓存区中对应于所述区块读取请求的缓存区块向所述数据节点发送之后,所述数据节点对所述共识节点发送的缓存区块进行验证。
具体地,所述数据节点对所述接收到的缓存区块的哈希值进行验证。若所述缓存区块的哈希值与所述区块读取请求中包含的待读取区块的哈希值不一致,则判定所述缓存区块出现错误。所述缓存区块出现错误的原因可能是所述共识节点在发送所述缓存区块的过程中,所述缓存区块出现字节丢失或被篡改。
示例性的,若所述缓存区块是错误的,所述数据节点将所述缓存区块对应的验证结果置1;若所述缓存区块是正确的,所述数据节点将所述缓存区块对应的验证结果置0。
在一些实施例中,若所述缓存区块经过验证,判定是错误的区块,则所述数据节点将所述缓存区块对应的验证结果置1,以表示所述缓存区块是错误的;所述数据节点将所述错误的缓存区块删除。
在另一些实施例中,若所述缓存区块经过验证,判定是正确的区块,则所述数据节点将所述缓存区块对应的验证结果置0,以表示所述缓存区块是正确的。所述数据节点将所述接收到的缓存区块更新到本地的区块链账本数据,并将所述缓存区块以及所述缓存区块对应的验证结果发送给所述数据节点对应的客户端。
具体地,所述数据节点对所述缓存区块进行验证之后,所述共识节点获取所述数据节点对所述缓存区块进行验证的验证结果。
通过对接收到的缓存区块进行验证,数据节点将出现错误的缓存区块删除,可以避免将存在错误的缓存区块更新到本地的区块链账本数据。
步骤S62、若根据所述验证结果判定所述缓存区块错误,则再次将所述临时缓存区中的所述缓存区块向所述数据节点发送。
示例性的,所述共识节点在获取所述缓存区块对应的验证结果后,根据所述验证结果判断所述临时缓存区中对应于所述区块读取请求的缓存区块在发送过程中是否出现错误。若所述验证结果为0,则判定所述缓存区块在发送过程中没有出现错误;若所述验证结果为1,则判定所述缓存区块在发送过程中出现错误。
具体地,在判定所述缓存区块在发送过程中出现错误之后,所述共识节点再次从所述临时缓存区中将所述缓存区块发送到所述区块读取请求对应的数据节点。
通过对接收到的缓存区块进行验证,可以及时发现出现错误的缓存区块,避免将错误的缓存区块更新到本地的区块链账本数据;通过获取验证结果,可以实现再次从临时缓存区中读取对应的缓存区块和分发给数据节点,有利于提升交易的处理效率,缩短交易的整个流程的时间。
步骤S70、若所述临时缓存区中不存在与所述区块读取请求对应的缓存区块,则从所述目标磁盘中读取与所述区块读取请求对应的区块,将所述区块向所述数据节点发送。
具体地,在接收所述数据节点的区块读取请求后,所述共识节点优先在所述临时缓存区中查询是否存在与所述区块读取请求对应的缓存区块。
示例性的,若所述临时缓存区中不存在与所述区块读取请求对应的缓存区块,例如所述临时缓存区中不存在任一哈希值与所述待读取区块的哈希值一致的缓存区块,可能原因是哈希值与所述待读取区块的哈希值一致的缓存区块在写入所述目标磁盘后,所述缓存区块从所述临时缓存区中被剔除。因此所述共识节点需要从所述目标磁盘中读取与所述区块读取请求对应的区块。
具体地,所述共识节点在所述目标磁盘的区块链中查询哈希值与所述待读取区块的哈希值一致的区块,将所述区块链中哈希值与所述待读取区块的哈希值一致的区块向所述数据节点发送。
只有当所述临时缓存区不存在哈希值与所述待读取区块的哈希值一致的缓存区块时,所述共识节点才从所述目标磁盘中读取区块链中与所述待读取区块的哈希值对应的区块,可以有效减少读取所述目标磁盘的频率,从而延长所述目标磁盘的使用寿命。
请参阅图6,图6是步骤S70中将所述区块向所述数据节点发送之后执行步骤的示意图,具体还包括以下步骤S71至步骤S72。
步骤S71、获取所述数据节点对接收到的区块进行验证的验证结果。
具体地,所述共识节点将所述目标磁盘中对应于所述区块读取请求对应的区块向所述数据节点发送之后,所述数据节点对所述区块的哈希值进行验证。
具体地,若所述区块的哈希值与所述区块读取请求中包含的待读取区块的哈希值不一致,则说明所述区块出现错误。所述区块出现错误的原因可能是所述共识节点在发送所述区块的过程中,所述区块出现字节丢失或被篡改。
示例性的,若所述区块是错误的,将所述区块对应的验证结果置1;若所述区块是正确的,将所述区块对应的验证结果置0。
在一些实施例中,若所述缓存区块经过验证,判定是错误的区块,则所述数据节点将所述区块对应的验证结果置1,以表示所述区块是错误的。所述数据节点将所述错误的区块删除。
在另一些实施例中,若所述区块经过验证,判定是正确的区块,则所述数据节点将所述区块对应的验证结果置0,以表示所述区块是正确的。所述数据节点将所述接收到的区块更新到本地的区块链账本数据,并所述区块以及所述区块对应的验证结果发送给所述数据节点对应的客户端。
具体地,所述数据节点对所述区块进行验证之后,所述共识节点获取所述数据节点对所述区块进行验证的验证结果。
通过对接收到的区块进行验证,数据节点将出现错误的区块删除,可以避免将存在错误的区块更新到本地的区块链账本数据。
步骤S72、若根据所述验证结果判定所述区块错误,则再次从所述目标磁盘中将所述区块向所述数据节点发送。
示例性的,所述共识节点在获取所述区块对应的验证结果后,根据所述验证结果判断所述目标磁盘的区块链中对应于所述区块读取请求的区块在发送过程中是否出现错误。
示例性的,若所述验证结果为0,则判定所述区块在发送过程中没有出现错误;若所述验证结果为1,则判定所述区块在发送过程中出现错误。
具体地,在判定所述区块在发送过程中出现错误之后,所述共识节点再次将所述区块从所述目标磁盘的区块链中读取并发送到所述区块读取请求对应的数据节点。
通过对接收到的区块进行验证,可以及时发现出现错误的区块,避免将错误的区块更新到本地的区块链账本数据;通过获取验证结果,可以实现再次从目标磁盘中的区块链读取对应的区块和返回给数据节点,有利于提升交易的处理效率,缩短交易的整个流程的时间。
上述实施例提供的区块链的区块分发方法,通过先将目标区块写入临时缓存区和分发给数据节点,然后再将临时缓存区中的缓存区块写入目标磁盘,可以将缓存区块的分发到数据节点和写入目标磁盘的过程隔离,降低区块分发的延迟,实现减少对目标磁盘的读取频率的效果。通过对写入临时缓存区的目标区块进行阻塞等待和增大临时缓存区的容量,可以防止内存溢出,满足在在不同交易量的场景下,区块链系统均可以高效运行。通过获取数据节点上的交易验证结果,可以避免将错误的缓存区块写入目标磁盘中的区块链上。在接收到数据节点的区块读取请求时,优先从临时缓存区中查询是否有符合条件的缓存区块,其次才在目标磁盘中查询,可以减少对目标磁盘的读取频率,从而延长目标磁盘的寿命。
请参阅图7,图7是本申请的实施例还提供一种区块链的区块分发装置的示意性框图,该区块链的区块分发装置用于执行前述的区块链的区块分发方法。其中,该区块链的区块分发装置可以配置于服务器或终端中。
如图7所示,该区块链的区块分发装置100,包括:区块获取模块101、第一区块写入模块102、第一区块发送模块103和第二区块写入模块104。
区块获取模块101,用于获取待写入区块链的目标区块。
第一区块写入模块102,用于将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块,并向数据节点发送用于表示所述目标区块已写入区块链的已写入通知。
第一区块发送模块103,用于若接收到所述数据节点根据所述已写入通知发送的区块接收请求,将所述临时缓存区中对应于所述区块接收请求的缓存区块向所述数据节点发送。
第二区块写入模块104,用于将所述缓存区块写入目标磁盘,以将所述缓存区块加入到所述目标磁盘存储的区块链中。
在一些实施例中,如图7所示,该区块链的区块分发装置100,还包括:查询模块105、第二区块发送模块106和第三区块发送模块107。
查询模块105,用于若接收到所述数据节点发送的区块读取请求,查询所述临时缓存区中是否存在与所述区块读取请求对应的缓存区块。
第二区块发送模块106,用于若所述临时缓存区中存在与所述区块读取请求对应的缓存区块,则将所述缓存区块向所述数据节点发送。
第三区块发送模块107,用于若所述临时缓存区中不存在与所述区块读取请求对应的 缓存区块,则从所述目标磁盘中读取与所述区块读取请求对应的区块,将所述区块向所述数据节点发送。
在一些实施例中,如图8所示,该第一区块写入模块102,包括:判断子模块1021、第一写入子模块1022、阻塞等待子模块1023、第二写入子模块1024、容量增大子模块1025和第三写入子模块1026。
判断子模块1021,用于根据所述临时缓存区中已存储缓存区块的个数判断所述临时缓存区是否已写满。
第一写入子模块1022,用于若所述临时缓存区未写满,将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块。
阻塞等待子模块1023,用于若所述临时缓存区已写满,对所述目标区块进行阻塞等待。
第二写入子模块1024,用于若所述临时缓存区中有缓存区块写入所述目标磁盘,停止对所述目标区块进行阻塞等待并将所述目标区块写入所述临时缓存区,得到所述目标区块对应的缓存区块。
容量增大子模块1025,用于若所述临时缓存区已写满,且进行阻塞等待的目标区块的数量大于预设阈值,增大所述临时缓存区的容量。
第三写入子模块1026,用于停止对所述目标区块进行阻塞等待并将所述目标区块写入增大容量后的临时缓存区,得到所述目标区块对应的缓存区块。
在一些实施例中,如图8所示,该区块链的区块分发装置100还包括:第一验证模块108和区块删除模块109。
第一验证模块108,用于获取所述数据节点对接收到的缓存区块进行交易验证的交易验证结果。
区块删除模块109,用于若根据所述交易验证结果判定所述缓存区块包括错误的交易,则从所述临时缓存区中将所述缓存区块删除。
在一些实施例中,如图8所示,该区块链的区块分发装置100,还包括:第二验证模块110和第二区块发送子模块111。
第二验证模块110,用于获取所述数据节点对接收到的缓存区块进行验证的验证结果。
第二区块发送子模块111,用于若根据所述验证结果判定所述缓存区块错误,则再次将所述临时缓存区中的所述缓存区块向所述数据节点发送。
在一些实施例中,如图8所示,该区块链的区块分发装置100,还包括:第三验证模块112和第三区块发送子模块113。
第三验证模块112,用于获取所述数据节点对接收到的区块进行验证的验证结果。
第三区块发送子模块113,用于若根据所述验证结果判定所述区块错误,则再次从所述目标磁盘中将所述区块向所述数据节点发送。
需要说明的是,所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的装置和各模块、单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
本申请的方法、装置可用于众多通用或专用的计算系统环境或配置中。例如:个人计算机、服务器计算机、手持设备或便携式设备、平板型设备、多处理器系统、基于微处理器的系统、可编程的消费电子设备、网络PC、小型计算机、大型计算机、包括以上任何系统或设备的分布式计算环境等等。
上述的方法、装置可以实现为一种计算机程序的形式,该计算机程序可以在如图9所示的计算机设备上运行。
请参阅图9,图9是本申请实施例提供的一种计算机设备的结构示意性框图。该计算机设备可以是终端或服务器。其中,终端可以是智能手机、平板电脑、笔记本电脑、台式 电脑、个人数字助理和穿戴式设备等电子设备。服务器可以为独立的服务器,也可以为服务器集群。
请参阅图9,该计算机设备包括通过系统总线连接的处理器和存储器,其中,存储器可以包括非易失性存储介质和内存储器。
处理器用于提供计算和控制能力,支撑整个计算机设备的运行。
内存储器为非易失性存储介质中的计算机程序的运行提供环境,该计算机程序被处理器执行时,可使得处理器执行任意一种区块链的区块分发方法。
应当理解的是,处理器可以是中央处理单元(Central Processing Unit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
其中,在一个实施例中,所述处理器用于运行存储在存储器中的计算机程序,以实现如下步骤:
获取待写入区块链的目标区块;将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块,并向数据节点发送用于表示所述目标区块已写入区块链的已写入通知;若接收到所述数据节点根据所述已写入通知发送的区块接收请求,将所述临时缓存区中对应于所述区块接收请求的缓存区块向所述数据节点发送;将所述缓存区块写入目标磁盘,以将所述缓存区块加入到所述目标磁盘存储的区块链中。
在一个实施例中,所述处理器还用于实现如下步骤:
若接收到所述数据节点发送的区块读取请求,查询所述临时缓存区中是否存在与所述区块读取请求对应的缓存区块;若所述临时缓存区中存在与所述区块读取请求对应的缓存区块,则将所述缓存区块向所述数据节点发送;若所述临时缓存区中不存在与所述区块读取请求对应的缓存区块,则从所述目标磁盘中读取与所述区块读取请求对应的区块,将所述区块向所述数据节点发送。
在一个实施例中,所述处理器在实现将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块时,用于实现:
若所述临时缓存区未写满,将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块;若所述临时缓存区已写满,对所述目标区块进行阻塞等待;若所述临时缓存区中有缓存区块写入所述目标磁盘,停止对所述目标区块进行阻塞等待并将所述目标区块写入所述临时缓存区,得到所述目标区块对应的缓存区块。
在一个实施例中,所述处理器在实现将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块时,还用于实现:
根据所述临时缓存区中已存储缓存区块的个数判断所述临时缓存区是否已写满;若所述临时缓存区已写满,且进行阻塞等待的目标区块的数量大于预设阈值,增大所述临时缓存区的容量;停止对所述目标区块进行阻塞等待并将所述目标区块写入增大容量后的临时缓存区,得到所述目标区块对应的缓存区块。
在一个实施例中,所述处理器在实现将所述缓存区块写入目标磁盘,以将所述缓存区块加入到所述目标磁盘存储的区块链时,用于实现:
基于先入先出的规则,根据所述临时缓存区中各所述缓存区块的写入顺序,将各所述缓存区块依次写入目标磁盘,以将各所述缓存区块加入到所述目标磁盘存储的区块链中。
在一个实施例中,所述处理器在实现将所述临时缓存区中对应于所述区块接收请求的缓存区块向所述数据节点发送之后,还用于实现:
获取所述数据节点对接收到的缓存区块进行交易验证的交易验证结果;若根据所述交 易验证结果判定所述缓存区块包括错误的交易,则从所述临时缓存区中将所述缓存区块删除。
在一个实施例中,所述处理器在实现将所述缓存区块向所述数据节点发送之后,还用于实现:
获取所述数据节点对接收到的缓存区块进行验证的验证结果;若根据所述验证结果判定所述缓存区块错误,则再次将所述临时缓存区中的所述缓存区块向所述数据节点发送。
在一个实施例中,所述处理器在实现将所述区块向所述数据节点发送之后,还用于实现:
获取所述数据节点对接收到的区块进行验证的验证结果;若根据所述验证结果判定所述区块错误,则再次从所述目标磁盘中将所述区块向所述数据节点发送。
本申请的实施例中还提供一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序中包括程序指令,所述处理器执行所述程序指令,实现本申请实施例提供的任一项区块链的区块分发方法。
其中,所述计算机可读存储介质可以是非易失性,也可以是易失性。所述计算机可读存储介质可以是前述实施例所述的计算机设备的内部存储单元,例如所述计算机设备的硬盘或内存。所述计算机可读存储介质也可以是所述计算机设备的外部存储设备,例如所述计算机设备上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字卡(Secure Digital Card,SD Card),闪存卡(Flash Card)等。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。

Claims (20)

  1. 一种区块链的区块分发方法,其中,包括:
    获取待写入区块链的目标区块;
    将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块,并向数据节点发送用于表示所述目标区块已写入区块链的已写入通知;
    若接收到所述数据节点根据所述已写入通知发送的区块接收请求,将所述临时缓存区中对应于所述区块接收请求的缓存区块向所述数据节点发送;
    将所述缓存区块写入目标磁盘,以将所述缓存区块加入到所述目标磁盘存储的区块链中。
  2. 如权利要求1所述的区块链的区块分发方法,其中,所述区块分发方法还包括:
    若接收到所述数据节点发送的区块读取请求,查询所述临时缓存区中是否存在与所述区块读取请求对应的缓存区块;
    若所述临时缓存区中存在与所述区块读取请求对应的缓存区块,则将所述缓存区块向所述数据节点发送;
    若所述临时缓存区中不存在与所述区块读取请求对应的缓存区块,则从所述目标磁盘中读取与所述区块读取请求对应的区块,将所述区块向所述数据节点发送。
  3. 如权利要求1所述的区块链的区块分发方法,其中,所述将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块,包括:
    若所述临时缓存区未写满,将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块;
    若所述临时缓存区已写满,对所述目标区块进行阻塞等待;
    若所述临时缓存区中有缓存区块写入所述目标磁盘,停止对所述目标区块进行阻塞等待并将所述目标区块写入所述临时缓存区,得到所述目标区块对应的缓存区块。
  4. 如权利要求3所述的区块链的区块分发方法,其中,所述将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块,还包括:
    若所述临时缓存区已写满,且进行阻塞等待的目标区块的数量大于预设阈值,增大所述临时缓存区的容量;
    停止对所述目标区块进行阻塞等待并将所述目标区块写入增大容量后的临时缓存区,得到所述目标区块对应的缓存区块。
  5. 如权利要求1所述的区块链的区块分发方法,其中,所述将所述缓存区块写入目标磁盘,以将所述缓存区块加入到所述目标磁盘存储的区块链中,包括:
    基于先入先出的规则,根据所述临时缓存区中各所述缓存区块的写入顺序,将各所述缓存区块依次写入目标磁盘,以将各所述缓存区块加入到所述目标磁盘存储的区块链中。
  6. 如权利要求1所述的区块链的区块分发方法,其中,所述将所述临时缓存区中对应于所述区块接收请求的缓存区块向所述数据节点发送之后,还包括:
    获取所述数据节点对接收到的缓存区块进行交易验证的交易验证结果;
    若根据所述交易验证结果判定所述缓存区块包括错误的交易,则从所述临时缓存区中将所述缓存区块删除。
  7. 如权利要求2所述的区块链的区块分发方法,其中,所述将所述缓存区块向所述数据节点发送之后,还包括:
    获取所述数据节点对接收到的缓存区块进行验证的验证结果;
    若根据所述验证结果判定所述缓存区块错误,则再次将所述临时缓存区中的所述缓存区块向所述数据节点发送;
    所述将所述区块向所述数据节点发送之后,还包括:
    获取所述数据节点对接收到的区块进行验证的验证结果;
    若根据所述验证结果判定所述区块错误,则再次从所述目标磁盘中将所述区块向所述数据节点发送。
  8. 一种区块链的区块分发装置,其中,包括:
    区块获取模块,用于获取待写入区块链的目标区块;
    第一区块写入模块,用于将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块,并向数据节点发送用于表示所述目标区块已写入区块链的已写入通知;
    第一区块发送模块,用于若接收到所述数据节点根据所述已写入通知发送的区块接收请求,将所述临时缓存区中对应于所述区块接收请求的缓存区块向所述数据节点发送;
    第二区块写入模块,用于将所述缓存区块写入目标磁盘,以将所述缓存区块加入到所述目标磁盘存储的区块链中。
  9. 一种计算机设备,其中,所述计算机设备包括存储器和处理器,所述处理器、和所述存储器相互连接,其中,所述存储器用于存储计算机程序,所述计算机程序包括程序指令,所述处理器用于执行所述存储器的所述程序指令,其中:
    获取待写入区块链的目标区块;
    将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块,并向数据节点发送用于表示所述目标区块已写入区块链的已写入通知;
    若接收到所述数据节点根据所述已写入通知发送的区块接收请求,将所述临时缓存区中对应于所述区块接收请求的缓存区块向所述数据节点发送;
    将所述缓存区块写入目标磁盘,以将所述缓存区块加入到所述目标磁盘存储的区块链中。
  10. 如权利要求9所述的计算机设备,其中,所述处理器用于:
    若接收到所述数据节点发送的区块读取请求,查询所述临时缓存区中是否存在与所述区块读取请求对应的缓存区块;
    若所述临时缓存区中存在与所述区块读取请求对应的缓存区块,则将所述缓存区块向所述数据节点发送;
    若所述临时缓存区中不存在与所述区块读取请求对应的缓存区块,则从所述目标磁盘中读取与所述区块读取请求对应的区块,将所述区块向所述数据节点发送。
  11. 如权利要求9所述的计算机设备,其中,所述处理器用于:
    若所述临时缓存区未写满,将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块;
    若所述临时缓存区已写满,对所述目标区块进行阻塞等待;
    若所述临时缓存区中有缓存区块写入所述目标磁盘,停止对所述目标区块进行阻塞等待并将所述目标区块写入所述临时缓存区,得到所述目标区块对应的缓存区块。
  12. 如权利要求11所述的计算机设备,其中,所述处理器用于:
    若所述临时缓存区已写满,且进行阻塞等待的目标区块的数量大于预设阈值,增大所述临时缓存区的容量;
    停止对所述目标区块进行阻塞等待并将所述目标区块写入增大容量后的临时缓存区,得到所述目标区块对应的缓存区块。
  13. 如权利要求9所述的计算机设备,其中,所述处理器用于:
    基于先入先出的规则,根据所述临时缓存区中各所述缓存区块的写入顺序,将各所述缓存区块依次写入目标磁盘,以将各所述缓存区块加入到所述目标磁盘存储的区块链中。
  14. 如权利要求9所述的计算机设备,其中,所述处理器用于:
    获取所述数据节点对接收到的缓存区块进行交易验证的交易验证结果;
    若根据所述交易验证结果判定所述缓存区块包括错误的交易,则从所述临时缓存区中将所述缓存区块删除。
  15. 如权利要求10所述的计算机设备,其中,所述处理器用于:
    获取所述数据节点对接收到的缓存区块进行验证的验证结果;
    若根据所述验证结果判定所述缓存区块错误,则再次将所述临时缓存区中的所述缓存区块向所述数据节点发送;
    所述处理器用于:
    获取所述数据节点对接收到的区块进行验证的验证结果;
    若根据所述验证结果判定所述区块错误,则再次从所述目标磁盘中将所述区块向所述数据节点发送。
  16. 一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令被处理器执行时,用于实现以下步骤:
    获取待写入区块链的目标区块;
    将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块,并向数据节点发送用于表示所述目标区块已写入区块链的已写入通知;
    若接收到所述数据节点根据所述已写入通知发送的区块接收请求,将所述临时缓存区中对应于所述区块接收请求的缓存区块向所述数据节点发送;
    将所述缓存区块写入目标磁盘,以将所述缓存区块加入到所述目标磁盘存储的区块链中。
  17. 如权利要求16所述的计算机可读存储介质,其中,所述程序指令被处理器执行时,还用于实现以下步骤:
    若接收到所述数据节点发送的区块读取请求,查询所述临时缓存区中是否存在与所述区块读取请求对应的缓存区块;
    若所述临时缓存区中存在与所述区块读取请求对应的缓存区块,则将所述缓存区块向所述数据节点发送;
    若所述临时缓存区中不存在与所述区块读取请求对应的缓存区块,则从所述目标磁盘中读取与所述区块读取请求对应的区块,将所述区块向所述数据节点发送。
  18. 如权利要求16所述的计算机可读存储介质,其中,所述程序指令被处理器执行时,还用于实现以下步骤:
    若所述临时缓存区未写满,将所述目标区块写入临时缓存区,得到所述目标区块对应的缓存区块;
    若所述临时缓存区已写满,对所述目标区块进行阻塞等待;
    若所述临时缓存区中有缓存区块写入所述目标磁盘,停止对所述目标区块进行阻塞等待并将所述目标区块写入所述临时缓存区,得到所述目标区块对应的缓存区块。
  19. 如权利要求18所述的计算机可读存储介质,其中,所述程序指令被处理器执行时,还用于实现以下步骤:
    若所述临时缓存区已写满,且进行阻塞等待的目标区块的数量大于预设阈值,增大所述临时缓存区的容量;
    停止对所述目标区块进行阻塞等待并将所述目标区块写入增大容量后的临时缓存区,得到所述目标区块对应的缓存区块。
  20. 如权利要求16所述的计算机可读存储介质,其中,所述程序指令被处理器执行时,还用于实现以下步骤:
    基于先入先出的规则,根据所述临时缓存区中各所述缓存区块的写入顺序,将各所述缓存区块依次写入目标磁盘,以将各所述缓存区块加入到所述目标磁盘存储的区块链中。
PCT/CN2020/099257 2019-10-12 2020-06-30 区块链的区块分发方法、装置、计算机设备和存储介质 WO2021068567A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910969411.4A CN110995776B (zh) 2019-10-12 2019-10-12 区块链的区块分发方法、装置、计算机设备和存储介质
CN201910969411.4 2019-10-12

Publications (1)

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

Family

ID=70081889

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/099257 WO2021068567A1 (zh) 2019-10-12 2020-06-30 区块链的区块分发方法、装置、计算机设备和存储介质

Country Status (2)

Country Link
CN (1) CN110995776B (zh)
WO (1) WO2021068567A1 (zh)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113436015A (zh) * 2021-06-30 2021-09-24 中元众诚(北京)科技有限公司 一种基于区块链的链化数据库及操作方法
CN113590520A (zh) * 2021-06-15 2021-11-02 珠海一微半导体股份有限公司 Spi系统自动写入数据的控制方法及spi系统
CN113596010A (zh) * 2021-07-23 2021-11-02 腾讯科技(深圳)有限公司 一种数据处理方法、装置、节点设备及计算机存储介质
CN113691611A (zh) * 2021-08-23 2021-11-23 湖南大学 一种区块链的分布式高并发事务处理方法及系统、设备、存储介质

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110995776B (zh) * 2019-10-12 2021-11-02 平安科技(深圳)有限公司 区块链的区块分发方法、装置、计算机设备和存储介质
CN112291372B (zh) * 2020-12-28 2021-04-13 腾讯科技(深圳)有限公司 区块链的异步落账方法、装置、介质及电子设备
CN112559637B (zh) * 2021-02-19 2021-06-18 腾讯科技(深圳)有限公司 基于分布式存储的数据处理方法、装置、设备以及介质
CN112765681B (zh) * 2021-04-07 2021-07-09 暗链科技(深圳)有限公司 区块分布式区块链的生成方法、存储介质及电子设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109347935A (zh) * 2018-09-30 2019-02-15 珠海信达九州科技有限公司 一种基于区块链实现实时通讯消息同步的方法
US20190108519A1 (en) * 2017-10-11 2019-04-11 International Business Machines Corporation Transaction scheduling for block space on a blockchain
CN109684408A (zh) * 2018-12-07 2019-04-26 深圳市智税链科技有限公司 区块链系统的数据管理方法、装置、介质及电子设备
CN109816532A (zh) * 2019-04-10 2019-05-28 北京一三链科技有限公司 一种基于区块链技术的资产数字化锚定系统
CN110995776A (zh) * 2019-10-12 2020-04-10 平安科技(深圳)有限公司 区块链的区块分发方法、装置、计算机设备和存储介质

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106649838B (zh) * 2016-12-29 2020-10-30 成都质数斯达克科技有限公司 数据传输方法、区块链节点及分布式数据库
US10630769B2 (en) * 2017-12-26 2020-04-21 Akamai Technologies, Inc. Distributed system of record transaction receipt handling in an overlay network
CN110019235B (zh) * 2017-12-29 2021-08-17 百度在线网络技术(北京)有限公司 基于区块链的数据存储、恢复方法、装置、设备及介质
CN108764906A (zh) * 2018-05-30 2018-11-06 深圳市元征科技股份有限公司 一种服务器及其区块链交易确认方法、装置、存储介质
CN109032802A (zh) * 2018-07-26 2018-12-18 国信优易数据有限公司 一种区块链系统和管理方法
CN109522499A (zh) * 2018-11-20 2019-03-26 平安科技(深圳)有限公司 本地加载页面数据的方法、装置、计算机设备和存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190108519A1 (en) * 2017-10-11 2019-04-11 International Business Machines Corporation Transaction scheduling for block space on a blockchain
CN109347935A (zh) * 2018-09-30 2019-02-15 珠海信达九州科技有限公司 一种基于区块链实现实时通讯消息同步的方法
CN109684408A (zh) * 2018-12-07 2019-04-26 深圳市智税链科技有限公司 区块链系统的数据管理方法、装置、介质及电子设备
CN109816532A (zh) * 2019-04-10 2019-05-28 北京一三链科技有限公司 一种基于区块链技术的资产数字化锚定系统
CN110995776A (zh) * 2019-10-12 2020-04-10 平安科技(深圳)有限公司 区块链的区块分发方法、装置、计算机设备和存储介质

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113590520A (zh) * 2021-06-15 2021-11-02 珠海一微半导体股份有限公司 Spi系统自动写入数据的控制方法及spi系统
CN113590520B (zh) * 2021-06-15 2024-05-03 珠海一微半导体股份有限公司 Spi系统自动写入数据的控制方法及spi系统
CN113436015A (zh) * 2021-06-30 2021-09-24 中元众诚(北京)科技有限公司 一种基于区块链的链化数据库及操作方法
CN113596010A (zh) * 2021-07-23 2021-11-02 腾讯科技(深圳)有限公司 一种数据处理方法、装置、节点设备及计算机存储介质
CN113596010B (zh) * 2021-07-23 2023-04-28 腾讯科技(深圳)有限公司 一种数据处理方法、装置、节点设备及计算机存储介质
CN113691611A (zh) * 2021-08-23 2021-11-23 湖南大学 一种区块链的分布式高并发事务处理方法及系统、设备、存储介质
CN113691611B (zh) * 2021-08-23 2022-11-22 湖南大学 一种区块链的分布式高并发事务处理方法及系统、设备、存储介质

Also Published As

Publication number Publication date
CN110995776B (zh) 2021-11-02
CN110995776A (zh) 2020-04-10

Similar Documents

Publication Publication Date Title
WO2021068567A1 (zh) 区块链的区块分发方法、装置、计算机设备和存储介质
AU2020267132B2 (en) Restore from a cloud-based data protection service
US20190034427A1 (en) Data management system employing a hash-based and tree-based key-value data structure
US8112463B2 (en) File management method and storage system
US8250325B2 (en) Data deduplication dictionary system
JP5816198B2 (ja) 関連コンピューティングシステム間でコンピューティングオペレーションの結果を共有するためのシステムおよび方法
WO2020093501A1 (zh) 文件存储方法、删除方法、服务器及存储介质
US9003228B2 (en) Consistency of data in persistent memory
US10877848B2 (en) Processing I/O operations in parallel while maintaining read/write consistency using range and priority queues in a data protection system
US8930518B2 (en) Processing of write requests in application server clusters
US10073657B2 (en) Data processing apparatus, data processing method, and computer program product, and entry processing apparatus
US20140281147A1 (en) Memory system
CN113824755A (zh) 区块链数据处理的方法、系统及相关装置
US10678453B2 (en) Method and device for checking false sharing in data block deletion using a mapping pointer and weight bits
CN113986833A (zh) 文件合并方法、系统、计算机系统及存储介质
US20230117060A1 (en) Read-write method and apparatus, electronic device, and readable memory medium
US11340964B2 (en) Systems and methods for efficient management of advanced functions in software defined storage systems
US20210019231A1 (en) Method, device and computer program product for backing up data
US10795596B1 (en) Delayed deduplication using precalculated hashes
US11609894B2 (en) Data storage system conflict management
US20230385240A1 (en) Optimizations for data deduplication operations
CN116701426B (zh) 数据处理方法、电子设备及存储介质
CN117591023A (zh) 一种基于硬件卸载的分散聚集列表查询写入读取方法及装置
CN113407462A (zh) 一种数据处理的方法、装置、电子设备及介质
CN115580530A (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: 20875071

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20875071

Country of ref document: EP

Kind code of ref document: A1