CN110995776A - Block distribution method and device of block chain, computer equipment and storage medium - Google Patents

Block distribution method and device of block chain, computer equipment and storage medium Download PDF

Info

Publication number
CN110995776A
CN110995776A CN201910969411.4A CN201910969411A CN110995776A CN 110995776 A CN110995776 A CN 110995776A CN 201910969411 A CN201910969411 A CN 201910969411A CN 110995776 A CN110995776 A CN 110995776A
Authority
CN
China
Prior art keywords
block
cache
target
temporary
data node
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910969411.4A
Other languages
Chinese (zh)
Other versions
CN110995776B (en
Inventor
张松松
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201910969411.4A priority Critical patent/CN110995776B/en
Publication of CN110995776A publication Critical patent/CN110995776A/en
Priority to PCT/CN2020/099257 priority patent/WO2021068567A1/en
Application granted granted Critical
Publication of CN110995776B publication Critical patent/CN110995776B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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

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

The application relates to the field of distributed accounts, a target block is cached in a temporary cache area, and then the cache block in the temporary cache area is written into a target disk, so that the processes of distributing the cache block to a data node and writing the cache block into the target disk are isolated, the reading frequency of the target disk is reduced, and the delay time of cache block distribution is shortened. And more particularly, to a method, apparatus, computer device, and storage medium for block distribution of a blockchain, the method comprising: acquiring a target block to be written into a block chain; writing the target block into the temporary cache area to obtain a cache block corresponding to the target block, and sending a written notification for indicating that the target block is written into a block chain to the data node; if a block receiving request sent by the data node according to the written notification is received, sending a cache block corresponding to the block receiving request in the temporary cache area to the data node; and writing the cache block into the target disk so as to add the cache block into a block chain stored in the target disk.

Description

Block distribution method and device of block chain, computer equipment and storage medium
Technical Field
The present application relates to the field of distributed accounts, and in particular, to a block distribution method and apparatus for a block chain, a computer device, and a storage medium.
Background
In the existing block chain system, after the common node saves the block to the local file book, i.e. writes the block into the disk, if the common node finds that the monitored data node waits for the generation of a new block, the common node reads the corresponding block from the disk and sends the block to the data node. In the process, if a plurality of data nodes monitor the consensus node, the consensus node needs to read the block from the disk for a plurality of times and return the block to the data nodes; on one hand, the possibility of frequently reading the disk exists in the consensus node, and the service life of the disk is reduced when the disk is frequently read; on the other hand, the consensus node cannot distribute the blocks to the monitored data nodes in time, so that the confirmation time of the transaction is directly prolonged, the transaction processing efficiency is low, and the time consumption of the whole transaction process is long.
Disclosure of Invention
The application provides a block distribution method, a device, computer equipment and a storage medium of a block chain, wherein a target block is firstly cached in a temporary cache region and distributed to a data node, and then the cache block in the temporary cache region is written into a target disk, so that the processes of distributing the cache block to the data node and writing the cache block into the target disk are isolated, and the effects of reducing the reading frequency of the target disk and reducing the delay time of cache block distribution can be realized.
In a first aspect, the present application provides a method for distributing blocks of a blockchain, where the method includes:
acquiring a target block to be written into a block chain;
writing the target block into a temporary cache region to obtain a cache block corresponding to the target block, and sending a written notification for indicating that the target block is written into a block chain to a data node;
if a block receiving request sent by the data node according to the written notification is received, sending a cache block corresponding to the block receiving request in the temporary cache region to the data node;
and writing the cache block into a target disk so as to add the cache block into a block chain stored in the target disk.
In a second aspect, the present application further provides a block distribution apparatus for a block chain, the apparatus including:
the block acquisition module is used for acquiring a target block to be written into a block chain;
a first block writing module, configured to write the target block into a temporary cache area, obtain a cache block corresponding to the target block, and send a written notification indicating that the target block has been written into a block chain to a data node;
a first block sending module, configured to send, to the data node, a cache block in the temporary cache area corresponding to the block receiving request if a block receiving request sent by the data node according to the written notification is received;
and the second block writing module is used for writing the cache block into a target disk so as to add the cache block into a block chain stored in the target disk.
In a third aspect, the present application further provides a computer device comprising a memory and a processor;
the memory for storing a computer program;
the processor is configured to execute the computer program and implement the block distribution method of the block chain when executing the computer program.
In a fourth aspect, the present application further provides a computer-readable storage medium storing a computer program, which when executed by a processor causes the processor to implement the block distribution method of the block chain as described above.
The application discloses a block distribution method and device of a block chain, computer equipment and a storage medium, wherein a cache block corresponding to a target block is obtained by writing the obtained target block into a temporary cache region, and a written notification is sent to a data node, so that the target block is prevented from being directly written into a target disk and then distributed from the target disk, and the effect of reducing the reading frequency of the target disk is realized; if a block receiving request sent by the data node according to the written notification is received, sending the corresponding cache block in the temporary cache area to the data node, preferentially distributing the cache block to the data node from the temporary cache area, realizing fast distribution of the block to the data node, and reducing the delay time of cache block distribution; and then writing the cache block in the temporary cache area into the target disk, and effectively improving the stability of the whole block chain system by isolating the process of distributing the cache block to the data node and writing the cache block into the target disk.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic flowchart of a block distribution method for a block chain according to an embodiment of the present application;
FIG. 2 is a schematic flow diagram of sub-steps of the block write to temporary buffer of FIG. 1;
FIG. 3 is a schematic flow chart diagram of steps following block transmission in FIG. 1;
FIG. 4 is a schematic flow chart diagram illustrating steps after a block is written to a target disk in FIG. 1;
FIG. 5 is a schematic flow chart diagram illustrating steps after the sending of the buffer block in FIG. 4;
FIG. 6 is a schematic flow chart diagram illustrating steps after a block is sent in FIG. 4;
fig. 7 is a schematic block diagram of a block distribution apparatus for a block chain according to an embodiment of the present application;
fig. 8 is a schematic block diagram of a sub-module of the block distribution apparatus of the block chain in fig. 7;
fig. 9 is a schematic block diagram of a structure of a computer device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The flow diagrams depicted in the figures are merely illustrative and do not necessarily include all of the elements and operations/steps, nor do they necessarily have to be performed in the order depicted. For example, some operations/steps may be decomposed, combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
It is to be understood that the terminology used in the description of the present application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the specification of the present application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
The embodiment of the application provides a block distribution method and device of a block chain, computer equipment and a storage medium. The block distribution method of the block chain can be applied to a terminal or a server serving as a block chain node, and the effect of reducing the frequency of reading a target disk is achieved by isolating the process of distributing the cache block to the data node and writing the cache block into the target disk.
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 servers may be independent servers or server clusters.
Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The embodiments described below and the features of the embodiments can be combined with each other without conflict.
As shown in fig. 1, the tile distribution method of the tile chain includes steps S10 to S40.
And step S10, acquiring a target block to be written into the block chain.
Illustratively, there are various nodes in the blockchain system, such as endorsement nodes, consensus nodes, and data nodes. The node may be any computer device, such as a PC computer, a notebook, a mobile phone, a router, etc.
The nodes are used to operate on blocks in the blockchain system, such as read blocks, write blocks, delete blocks, send blocks, query blocks, etc.
The common node refers to a node that operates on a block chain in the distributed book, for example, a block in a block chain is written into or read from. For example, the consensus node may sort transactions, pack the generated blocks, and save the newly generated blocks into a block chain maintained by the consensus node.
Specifically, the target block is a block obtained by arranging and packaging the transaction proposal 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 packages the transaction data into a transaction proposal.
In some embodiments, after the data node corresponding to the client packages the transaction data into a transaction proposal, the transaction proposal is sent to a designated endorsement node according to the endorsement policy. The endorsement node verifies the transaction proposal and signs and confirms to obtain a signed transaction proposal; the endorsement node submits the signed transaction proposal to a consensus node.
It should be noted that the endorsement policy determines whether to pass or reject the transaction proposal according to a preset condition. The preset condition may be one node approval, most node approval, or all node approval.
The endorsement node calls a chain code (chainode) to verify after receiving the transaction proposal, for example, the endorsement node verifies whether the transaction proposal is legal and can be submitted normally. If the transaction proposal passes the verification, the Endorsement node calls an Endorsement management System chain code (ESCC) to endorse the transaction proposal to obtain a signed transaction proposal. It should be noted that the endorsement system chain code is used for endorsement signature of the transaction proposal.
Specifically, the consensus node sequences the signed transaction proposal according to a transaction request of a client, so as to obtain a series of sequencing data. And the consensus node packs the series of sequencing data according to a certain quantity according to a consensus algorithm to generate a target block to be written into the block chain, wherein the target block comprises at least one sequencing data.
The consensus algorithm is a process that consensus nodes agree on a transaction proposal, and comprises agreeing to the proposal or negating the proposal and obtaining sequencing data with sequence consistency. Illustratively, the consensus algorithm may include a pow (of word) algorithm, a pbft (practical Byzantine Fault probability) algorithm, or a pos (of stamp) algorithm.
Specifically, the certain number refers to at least one consecutive one of the series of sorted data.
In particular, the target tile may comprise a tile header and tile data, wherein the tile header contains metadata. And when the common identification node generates a target block by packaging the series of sequencing data, writing a block head and block data into the target block.
Illustratively, when the series of sorted data is packed to generate a target block, the consensus node performs Hash encryption on the block data in the target block according to the sha (secure Hash algorithm) -256 digest algorithm to generate a Hash value. The common 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 the last block. The consensus node may identify the current chunk in a blockchain by the hash value of the current chunk.
Specifically, before writing the acquired target block of the to-be-written block chain into the block chain, the common identification node caches the target block of the to-be-written block chain in a temporary cache region to indicate that the target block is successfully written into the block chain. This may lead to the early distribution of the target block from the temporary buffer to the snooping data nodes.
Step S20, writing the target block into a temporary buffer area, obtaining a buffer block corresponding to the target block, and sending a written notification for indicating that the target block has been written into a block chain to a data node.
Specifically, before writing the target block into a temporary cache, the common node creates a temporary cache with a preset capacity in a Random Access Memory (RAM), where the temporary cache is used for caching the target block.
Illustratively, 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.
Specifically, the common node writes a target block of the block chain to be written into the temporary cache area first, so as to obtain a cache block corresponding to the target block; and then the common node sequentially writes the cache blocks in the temporary cache area into the block chain in the target disk.
In some embodiments, the target block is written into the temporary buffer first, and if there are four target blocks, the target blocks are sequentially buffered into the temporary buffer, resulting in A, B, C, D four buffer blocks, where buffer a is cached earliest and buffer D is cached latest.
The common node caches the target block in the temporary cache region, and can store the target block as temporary data in the temporary cache region; the cache blocks in the temporary cache area can be distributed to corresponding data nodes, and the target blocks are not required to be read from the block chain and distributed to corresponding data nodes after being stored on the block chain in the target disk.
Since the writing speed of the random access memory is much faster than that of the target disk, the common node writes the target block into the temporary cache area much faster than that of the target disk. By writing the target block into the temporary buffer area, the target block can be quickly distributed to the monitored data nodes, and the delay of target block distribution is reduced.
Specifically, after writing the target block into a temporary cache, the consensus node sends a written notification indicating that the target block is written into a block chain to the listening data node.
Specifically, the data node is configured to listen whether a written notification is generated or a block read request is actively initiated.
For example, after the obtained target block is written into the temporary buffer by the consensus node, a buffer block corresponding to the target block is obtained in the temporary buffer, which may indicate that the target block is successfully written into the block chain. The common node generates a written notification corresponding to the cache block. The consensus node broadcasts the written notification to a blockchain network to send the written notification to the listening data nodes.
Specifically, the written notification is used to indicate that a buffer block is generated in the temporary buffer area.
Specifically, the written notification corresponds to a cache block in the temporary cache region and includes description information of the cache block, for example, the description information may include a hash value corresponding to the cache block.
By sending the written notification corresponding to the cache block, the cache block in the temporary cache region can be quickly distributed to the monitored data nodes, the delay of cache block distribution is reduced, and the transaction processing efficiency is improved.
Step S30, if a block reception request sent by the data node according to the written notification is received, sending a cache block corresponding to the block reception request in the temporary cache area to the data node.
Specifically, the data node in the blockchain network is used to monitor whether there is a written notification corresponding to the target block in the blockchain network in real time. And if the generation of a written notification in the block chain network is monitored, the data node responds to the written notification and sends a block receiving request corresponding to the written notification.
For example, the responding may include generating a block receiving request corresponding to the written notification according to the description information carried by the written notification. The block reception request includes description information of a buffer block included in the written notification. The description information may include a hash value of the cache block.
Specifically, if the common node receives a block reception request sent by the data node according to the written notification, the cache block corresponding to the block reception request in the temporary cache region is sent to the data node.
Specifically, the common node queries a cache block in the temporary cache region, which is consistent with the description information in the block receiving request, and sends the cache block to the data node corresponding to the block receiving request.
In some embodiments, the consensus node queries the cache block with a hash value consistent with the hash value in the description information from the temporary cache according to the description information of the block receiving request. For example, if the consensus node queries that the hash value of the cache block a is consistent with the hash value in the description information in the temporary cache area, the consensus node returns the cache block a to the data node corresponding to the block receiving request.
Specifically, if a plurality of monitored data nodes respond to the block receiving request written with the notification, the common node queries the cache block corresponding to the written notification from the temporary cache area for a plurality of times, and returns the cache block with the consistent hash value to the data node corresponding to the block receiving request.
By receiving the request according to the block of the monitored data node, the common identification node reads the cache block in the temporary cache region and sends the cache block to the monitored data node, the block can be distributed quickly, the frequency of reading the disk can be effectively reduced, and the service life of the disk is prolonged.
And step S40, writing the cache block into a target disk, so as to add the cache block into a block chain stored in the target disk.
Illustratively, the target disk has a block chain stored therein. For example, the target disk stores therein a block chain of full data or stores therein a partial block chain including partial blocks.
The consensus node can read the block chain in the target disk; or writing the cache block into the target disk so as to add the cache block into the block chain.
Illustratively, 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.
Specifically, after the common node saves the target block as temporary data to the temporary cache region, it needs to write a cache block in the temporary cache region into a target disk, so as to add the cache block into a block chain stored in the target disk. The common node can realize the persistence of the target block by adding the cache block into a block chain for storage.
It should be noted that 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 into a block chain in the target disk for persistent storage.
Specifically, the common node writes each cache block into the target disk in sequence according to the writing sequence of each cache block in the temporary cache area based on a first-in first-out rule, so as to add each cache block into a block chain stored in the target disk.
The first-in first-out means that the cache blocks cached in the temporary cache area are written into the target disk firstly and then cached in the cache blocks in the temporary cache area and then written into the target disk in sequence.
Illustratively, the common node puts the cache block obtained in step S20 into a to-be-written disk queue according to a first-in first-out rule, so as to write the cache block into the target disk and update a block chain in the disk file.
In some embodiments, A, B, C, D four cache blocks are sequentially cached in the temporary cache area, wherein cache block a is cached earliest and cache block D is cached latest; when the consensus node writes A, B, C, D four cache blocks into the target disk, the cache block a is first placed into a disk queue to be written, and then the cache block B, C, D is sequentially placed into the disk queue to be written, so that the cache block is written into the target disk and a block chain in a disk file is updated.
Specifically, when the common node writes the target block into a temporary cache area to obtain a cache block corresponding to the target block, if the temporary cache area is full and the number of target blocks waiting for blocking is greater than a preset threshold, the capacity of the temporary cache area is increased.
Specifically, after the capacity of the temporary buffer area is increased, the common node may adjust the size of the disk queue to be written according to the capacity increase range of the temporary buffer area, so as to add more buffer blocks into the disk queue to be written, and ensure that the target block in the blocking waiting state is buffered in the temporary buffer area as much as possible.
In some embodiments, if the capacity L of the temporary buffer area is increased by 2, the common node needs to increase the size of the disk queue to be written by 2 buffer block lengths. After the size of the disk queue to be written is increased by 2 cache block lengths, 2 more cache blocks can be put in.
And the common identification node adjusts the size of the disk queue to be written according to the capacity of the temporary cache region so as to meet the requirement that the block chain system can efficiently operate under the scenes of different transaction amounts.
Caching a target block into the temporary cache region by the consensus node, and writing a cache block in the temporary cache region into a block chain in the target disk for persistence; when a block receiving request of a data node is received, the consensus node preferentially acquires the cache block from the temporary cache region and distributes the cache block to the corresponding data node, and the distribution process and the persistence process of the cache block are isolated, so that the stability of the whole block chain system can be effectively improved, and the frequency of reading a target disk is reduced.
Referring to fig. 2, fig. 2 is a schematic diagram of writing the target block into a temporary buffer in step S20, obtaining a buffer block corresponding to the target block, and sending a written notification indicating that the target block has been written into a block chain to a data node, and specifically includes the following steps S201 to S204.
Step S201, determining whether the temporary buffer area is full according to the number of the stored buffer blocks in the temporary buffer area.
Since the capacity of the temporary cache area is limited, and at most L cache blocks can be cached, when the common node writes the target block into the temporary cache area, it needs to determine whether the temporary cache area is full.
Specifically, the common node determines whether the temporary cache area is full according to the number of the cache blocks stored in the temporary cache area.
For example, if the number of cache blocks stored in the temporary cache area is less than L, the consensus node determines that the temporary cache area is not full; and if the number of the cache blocks stored in the temporary cache area is exactly L, the consensus node judges that the temporary cache area is completely written.
Step S202, if the temporary cache area is not full, writing the target block into the temporary cache area to obtain a cache block corresponding to the target block.
For example, if the number of cache blocks stored in the temporary cache area is less than L, the consensus node determines that the temporary cache area is not full.
Specifically, after determining that the temporary cache area is not full, the consensus node sequentially writes the target blocks into the temporary cache area to obtain cache blocks corresponding to the target blocks.
Step S203, if the temporary buffer area is full, block waiting is performed on the target block.
For example, if the number of cache blocks stored in the temporary cache area is equal to L, the consensus node determines that the temporary cache area is full.
Specifically, after determining that the temporary cache area is full, the consensus node waits for blocking of the target block.
It should be noted that before the cache block in the temporary cache region is placed in the disk queue to be written, the cache block is not allowed to be removed from the temporary cache region. For example, when a target block needs to be written into the temporary buffer, if the temporary buffer is full and the buffer block that was written into the temporary buffer at the earliest is not yet placed in the queue of the disk to be written into, the target block needs to wait until the buffer block that was written into the temporary buffer at the earliest is removed after the target block is written into the target disk, so that a vacancy is generated in the temporary buffer.
Specifically, the removing refers to deleting the cache block written into the target disk from the temporary cache area.
In some embodiments, when the common node writes the target block into the temporary cache area, if the temporary cache area is full, the common node waits for blocking of the target block; and the common node continuously writes the target block waiting for blocking into the temporary cache region until the first cache block in the temporary cache region is deleted from the temporary cache region after being written into the target disk.
Exemplarily, the first cache block refers to a cache block with the earliest cache time in the temporary cache region; the first cache block may be written into the target disk first relative to other cache blocks in the temporary cache area.
Specifically, the target block does not consume the memory space of the temporary cache area while waiting for blocking.
When the temporary cache area is fully written, the target block is subjected to blocking waiting, so that the memory overflow caused by the temporary cache area can be prevented, and the abnormal error of the temporary cache area is avoided.
Step S204, if a cache block in the temporary cache area is written into the target disk, stopping blocking waiting for the target block and writing the target block into the temporary cache area to obtain the cache block corresponding to the target block.
Specifically, after caching the target block in the temporary cache region, the consensus node may further add the cache blocks in the temporary cache region into a disk queue to be written in order to write the cache blocks in the temporary cache region into the block chain of the target disk. And after the cache block is written into the target disk, deleting the cache block by the consensus node, and generating a vacancy in the temporary cache region.
For example, after the common node performs blocking waiting on the target block, if a cache block in the temporary cache region is written into the target disk and a vacancy is generated in the temporary cache region, the common node stops performing blocking waiting on the target block.
Specifically, the common node rewrites the target block in the block waiting state into the temporary buffer area, so as to obtain a buffer block corresponding to the target block.
Referring to fig. 2, fig. 2 is a schematic diagram of writing the target block into a temporary buffer in step S20, obtaining a buffer block corresponding to the target block, and sending a written notification indicating that the target block is written into a block chain to a data node, further including the following step S205 and step S206.
Step S205, if the temporary buffer area is full and the number of target blocks to be subjected to blocking waiting is greater than a preset threshold, increasing the capacity of the temporary buffer area.
Illustratively, if the consensus node acquires too many target blocks, the number of target blocks to block waiting is increased. In order to quickly cache the block waiting target block into a temporary buffer area, the common node needs to adjust the capacity of the temporary buffer area according to the block waiting block.
Specifically, if the number of the target blocks in the block waiting state reaches a preset value, the common identification node increases the capacity of the temporary buffer area to cache the target blocks in the block waiting state into the temporary buffer area.
Illustratively, the preset value may take 3.
In some embodiments, if the number of target blocks in the block wait state reaches 3, the common node increases the capacity of the temporary buffer, for example, the common node increases the capacity of the temporary buffer by 2 blocks. At this time, the capacity of the temporary buffer area is L +2, and L +2 buffer blocks can be stored.
The capacity of the temporary cache area is adjusted according to the number of the target blocks in the blocking waiting state, so that the temporary cache area can be prevented from causing memory overflow; meanwhile, the requirement that the blockchain system can be operated efficiently under the scenes of different transaction amounts can be met.
Step S206, stopping blocking and waiting the target block, and writing the target block into the temporary cache area with increased capacity to obtain a cache block corresponding to the target block.
Specifically, after the capacity of the temporary buffer area is increased by the consensus node, the temporary buffer area can store more buffer blocks.
Specifically, after the capacity of the temporary buffer is increased, a vacancy is generated in the temporary buffer; therefore, the common node may stop to wait for blocking the target block, and sequentially write the target block into the temporary buffer area with the increased capacity to obtain the buffer block corresponding to the target block.
Referring to fig. 3, fig. 3 is a schematic diagram illustrating steps performed after sending a cache block corresponding to the block receiving request in the temporary cache to the data node after receiving the block receiving request sent by the data node according to the written notification in step S30, and specifically includes the following steps S31 to S32.
Step S31, obtaining a transaction verification result of the data node performing transaction verification on the received cache block.
Specifically, after the common node sends the cache block corresponding to the block receiving request in the temporary cache region to the data node, the data node performs transaction verification on the cache block sent by the common node.
Illustratively, the data node performs transaction verification on the returned cache block according to a Verification System Chain Code (VSCC). It should be noted that the VSCC is mainly used to verify whether the endorsement signature of the returned cache block is valid, whether the endorsement signature is from a valid endorsement node, and whether the endorsement policy is satisfied.
Specifically, 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 passes the verification, the value of the transaction verification result is set to 0.
In some embodiments, if the transaction verification passes, the data node updates local blockchain account book data according to the received cache block, and sends the cache block and a transaction verification result corresponding to the cache block to a client corresponding to the data node, and the whole transaction process is ended; and if the transaction verification result does not pass, deleting the cache block by the data node.
By performing transaction verification on the received cache block, updating of the cache block with an error to local blockchain account data can be avoided.
Specifically, after the data node performs transaction verification on the received cache block, the consensus node obtains a transaction verification result of the data node performing transaction verification on the cache block. For example, the transaction verification result obtained by the consensus node is 0 or 1.
Step S32, if it is determined that the cache block includes an erroneous transaction according to the transaction verification result, deleting the cache block from the temporary cache area.
For example, after the consensus node obtains a transaction verification result of the data node performing transaction verification on the received cache block, whether the cache block is correct is determined according to the transaction verification result. If the transaction verification result is 0, the cache block is judged to be correct if the transaction verification result indicates that the cache block passes the transaction verification of the data node; if the transaction verification result is 1, which indicates that the cache block does not pass the transaction verification of the data node, it is determined that the cache block includes an erroneous transaction.
Specifically, after determining that the cache block includes the erroneous transaction, deleting the cache block from the temporary cache area may avoid writing the cache block including the erroneous transaction onto the block chain in the target disk.
Specifically, after the data node writes the cache block to the target disk to add the cache block to the block chain stored in the target disk, a block read request may also be received, as shown in fig. 4, which specifically includes the following steps S50 to S70.
Step S50, if a block read request sent by the data node is received, querying whether a cache block corresponding to the block read request exists in the temporary cache area.
In a blockchain system, some data nodes may actively send a block read request to the common node to read a block corresponding to the block read request from the common node.
For example, the data node may actively initiate a block read request according to a transaction request of a corresponding client to obtain a block in a block chain.
Specifically, the block read request includes information of the block to be read, such as a hash value of the block to be read.
Specifically, when a data node actively initiates a block reading request, the consensus node obtains the block reading request to obtain a hash value of a block to be read contained in the block reading request. And according to the hash value of the block to be read, the consensus node preferentially searches the cache block with the hash value consistent with the hash value of the block to be read in the temporary cache region.
Illustratively, the consensus node searches a cache block with a hash value consistent with the hash value of the block to be read from the temporary cache region, and if a cache block with a hash value consistent with the hash value of the block to be read exists, the consensus node returns the cache block to the data node corresponding to the block read request. And if any cache block with the hash value consistent with the hash value of the block to be read does not exist in the temporary cache area, the common identification node inquires the block with the hash value consistent with the hash value of the block to be read from the block chain on the target disk, and returns the inquired block meeting the condition to the data node corresponding to the block reading request.
By preferentially inquiring the cache blocks meeting the conditions in the temporary cache region and then inquiring in the target disk, the reading frequency of the target disk can be reduced, and the service life of the target disk is prolonged.
Step S60, if there is a cache block corresponding to the block read request in the temporary cache area, sending the cache block to the data node.
Specifically, after receiving the block read request of the data node, the common node preferentially searches the temporary cache area for a cache block with a hash value consistent with the hash value of the block to be read in the block read request.
For example, if there is a cache block whose hash value is consistent with the hash value of the block to be read in the temporary cache region, the common node returns the corresponding cache block from the temporary cache region to the data node corresponding to the block read request.
Since the read speed of the random access memory is much faster than that of the disk, the block is read in the temporary buffer area much faster than that of the target disk. The common identification node preferentially reads the cache blocks from the temporary cache region, so that the cache blocks can be quickly read and distributed to the data nodes, and the delay of cache block distribution is reduced.
The common identification node quickly returns the read cache block to the corresponding data node, and the data node verifies according to the returned cache block, so that the processing efficiency of the transaction is improved, the time of the whole process of the transaction is shortened, and the throughput of the whole block chain system is effectively improved.
Referring to fig. 5, fig. 5 is a schematic diagram illustrating steps executed after the cache block is sent to the data node in step S60, and further includes the following steps S61 to S62.
Step S61, obtaining a verification result of the data node verifying the received cache block.
Specifically, after the common node sends the cache block corresponding to the block read request in the temporary cache region to the data node, the data node verifies the cache block sent by the common node.
Specifically, the data node verifies the hash value of the received cache block. And if the hash value of the cache block is inconsistent with the hash value of the block to be read contained in the block reading request, judging that the cache block has an error. The reason for the error of the cache block may be that the common node loses bytes or is tampered during the process of sending the cache block.
For example, if the cache block is incorrect, 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 verification result corresponding to the cache block to 0.
In some embodiments, 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 erroneous cache block.
In other embodiments, if the cache block is verified and the block is determined to be correct, the data node sets the verification result corresponding to the cache block to 0 to indicate that the cache block is correct. And the data node updates the received cache block to local block chain account data, and sends the cache block and a verification result corresponding to the cache block to a client corresponding to the data node.
Specifically, after the data node verifies the cache block, the consensus node obtains a verification result of the data node verifying the cache block.
By verifying the received cache blocks, the data node deletes the cache blocks with errors, so that the cache blocks with errors can be prevented from being updated to local block chain account book data.
Step S62, if it is determined that the cache block is incorrect according to the verification result, sending the cache block in the temporary cache area to the data node again.
For example, after obtaining the verification result corresponding to the cache block, the consensus node determines whether an error occurs in the cache block corresponding to the block read request in the temporary cache area during the sending process according to the verification result. If the verification result is 0, judging that no error occurs in the sending process of the cache block; and if the verification result is 1, judging that the cache block has errors in the sending process.
Specifically, after determining that the cache block has an error in the sending process, the common node sends the cache block from the temporary cache area to the data node corresponding to the block read request again.
By verifying the received cache blocks, the cache blocks with errors can be found in time, and the cache blocks with errors are prevented from being updated to local block chain account book data; by obtaining the verification result, the corresponding cache block can be read from the temporary cache region and distributed to the data nodes again, which is beneficial to improving the transaction processing efficiency and shortening the time of the whole transaction process.
Step S70, if there is no cache block corresponding to the block read request in the temporary cache area, reading the block corresponding to the block read request from the target disk, and sending the block to the data node.
Specifically, after receiving the block read request of the data node, the common node preferentially queries whether a cache block corresponding to the block read request exists in the temporary cache region.
For example, if there is no cache block corresponding to the block read request in the temporary cache region, for example, there is no cache block in the temporary cache region whose hash value is consistent with the hash value of the block to be read, which may be caused by the cache block whose hash value is consistent with the hash value of the block to be read being removed from the temporary cache region after being written to the target disk. The consensus node needs to read the block corresponding to the block read request from the target disk.
Specifically, the common identification node queries a block in a block chain of the target disk, where a hash value of the block is consistent with a hash value of the block to be read, and sends the block in the block chain, where the hash value of the block is consistent with the hash value of the block to be read, to the data node.
And only when the temporary cache area does not have a cache block with the hash value consistent with that of the block to be read, the common identification node reads the block corresponding to the hash value of the block to be read from the target disk, so that the frequency of reading the target disk can be effectively reduced, and the service life of the target disk is prolonged.
Referring to fig. 6, fig. 6 is a schematic diagram illustrating steps performed after the block is sent to the data node in step S70, and further includes the following steps S71 to S72.
Step S71, obtaining a verification result of the data node verifying the received tile.
Specifically, after the common node sends the block corresponding to the block read request in the target disk to the data node, the data node verifies the hash value of the block.
Specifically, if the hash value of the block is not consistent with the hash value of the block to be read included in the block read request, it indicates that the block has an error. The reason for the error of the block may be that the common node loses bytes or is tampered during the process of sending the block.
For example, if the block is erroneous, the verification result corresponding to the block is set to 1; if the block is correct, setting the verification result corresponding to the block to 0.
In some embodiments, 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 erroneous block.
In other embodiments, 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. And the data node updates the received block to local block chain account data, and sends the block and a verification result corresponding to the block to a client corresponding to the data node.
Specifically, after the data node verifies the block, the consensus node obtains a verification result of the data node verifying the block.
By verifying the received blocks, the data node deletes the blocks with errors, and can avoid updating the blocks with errors to local block chain account book data.
And step S72, if the block is determined to be erroneous according to the verification result, sending the block from the target disk to the data node again.
For example, after obtaining the verification result corresponding to the block, the consensus node determines whether an error occurs in the block corresponding to the block read request in the block chain of the target disk during the sending process according to the verification result.
For example, if the verification result is 0, it is determined that no error occurs in the block in the transmission process; and if the verification result is 1, judging that the block has errors in the sending process.
Specifically, after determining that the block has an error during the sending process, the consensus node reads the block from the block chain of the target disk again and sends the block to the data node corresponding to the block read request.
By verifying the received blocks, the blocks with errors can be found in time, and the blocks with errors are prevented from being updated to local block chain account book data; by obtaining the verification result, the corresponding block can be read from the block chain in the target disk again and returned to the data node, so that the processing efficiency of the transaction is improved, and the time of the whole transaction process is shortened.
In the block distribution method of the block chain provided in the above embodiment, the target block is written into the temporary buffer area and distributed to the data node, and then the buffer block in the temporary buffer area is written into the target disk, so that the processes of distributing the buffer block to the data node and writing the buffer block into the target disk can be isolated, the delay of block distribution is reduced, and the effect of reducing the read frequency of the target disk is achieved. By carrying out blocking waiting on the target blocks written into the temporary cache area and increasing the capacity of the temporary cache area, the memory overflow can be prevented, and the requirement that the block chain system can efficiently operate under the scenes of different transaction amounts is met. By obtaining the transaction verification result on the data node, the wrong cache block can be prevented from being written into the block chain in the target disk. When a block reading request of a data node is received, whether a cache block meeting the conditions exists is firstly inquired from the temporary cache region, and then the cache block is inquired in the target disk, so that the reading frequency of the target disk can be reduced, and the service life of the target disk is prolonged.
Referring to fig. 7, fig. 7 is a schematic block diagram of a block distribution apparatus of a blockchain according to an embodiment of the present application, where the block distribution apparatus of the blockchain is configured to perform the block distribution method of the blockchain. The block distribution device of the block chain may be configured in a server or a terminal.
As shown in fig. 7, the block distribution apparatus 100 of the block chain includes: the block acquisition module 101, the first block writing module 102, the first block sending module 103, and the second block writing module 104.
The block obtaining module 101 is configured to obtain a target block of a block chain to be written.
A first block writing module 102, configured to write the target block into a temporary buffer, obtain a buffer block corresponding to the target block, and send a written notification to a data node, where the written notification is used to indicate that the target block has been written into a block chain.
A first block sending module 103, configured to send, to the data node, a cache block in the temporary cache area corresponding to the block receiving request if a block receiving request sent by the data node according to the written notification is received.
A second block writing module 104, configured to write the cache block into a target disk, so as to add the cache block into a block chain stored in the target disk.
In some embodiments, as shown in fig. 7, the block distribution apparatus 100 of the block chain further includes: a query module 105, a second block transmission module 106 and a third block transmission module 107.
The query module 105 is configured to query whether a cache block corresponding to the block read request exists in the temporary cache area if the block read request sent by the data node is received.
A second block sending module 106, configured to send the cache block to the data node if the cache block corresponding to the block read request exists in the temporary cache region.
A third block sending module 107, configured to, 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 send the block to the data node.
In some embodiments, as shown in fig. 8, the first block writing module 102 includes: a judgment sub-module 1021, a first writing sub-module 1022, a blocking wait sub-module 1023, a second writing sub-module 1024, a capacity increase sub-module 1025, and a third writing sub-module 1026.
The determining submodule 1021 is configured to determine whether the temporary cache area is full according to the number of the cache blocks already stored in the temporary cache area.
The first writing sub-module 1022 is configured to write the target block into the temporary cache area if the temporary cache area is not full, so as to obtain a cache block corresponding to the target block.
The block waiting sub-module 1023 is configured to wait for a block of the target block if the temporary buffer is full.
And a second write-in submodule 1024, configured to, if a cache block in the temporary cache area is written into the target disk, stop performing blocking waiting on the target block and write the target block into the temporary cache area, so as to obtain a cache block corresponding to the target block.
The capacity increasing sub-module 1025 is configured to increase the capacity of the temporary buffer if the temporary buffer is full and the number of target blocks to be subjected to blocking waiting is greater than a preset threshold.
And a third write-in submodule 1026, configured to stop performing blocking waiting on the target block and write the target block into the temporary buffer with the increased capacity, so as to obtain a buffer block corresponding to the target block.
In some embodiments, as shown in fig. 8, the block distribution apparatus 100 of the block chain further includes: a first verification module 108 and a block deletion module 109.
The first verification module 108 is configured to obtain a transaction verification result of the data node performing transaction verification on the received cache block.
A block deleting module 109, 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.
In some embodiments, as shown in fig. 8, the block distribution apparatus 100 of the block chain further includes: a second verification module 110 and a second block transmission sub-module 111.
The second verifying 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.
In some embodiments, as shown in fig. 8, the block distribution apparatus 100 of the block chain further includes: a third verification module 112 and a third block transmission submodule 113.
A third verification module 112, configured to obtain a verification result that the data node verifies the received block.
And a third block sending submodule 113, configured to send the block to the data node from the target disk again if it is determined that the block is erroneous according to the verification result.
It should be noted that, as will be clear to those skilled in the art, for convenience and brevity of description, the specific working processes of the apparatus, the modules and the units described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The methods, apparatus, and devices of the present application are operational with numerous general purpose or special purpose computing system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet-type devices, multiprocessor systems, microprocessor-based systems, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like.
The method and apparatus described above may be implemented in the form of a computer program that is executable on a computer device such as that shown in fig. 9.
Referring to fig. 9, fig. 9 is a schematic block diagram of a computer device according to an embodiment of the present disclosure. The computer device may be a terminal or a server. 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 servers may be independent servers or server clusters.
Referring to fig. 9, the computer device includes a processor and a memory connected by a system bus, wherein the memory may include a nonvolatile storage medium and an internal memory.
The processor is used for providing calculation and control capability and supporting the operation of the whole computer equipment.
The internal memory provides an environment for the execution of a computer program on a non-volatile storage medium, which when executed by the processor, causes the processor to perform any one of the methods of block distribution of the blockchain.
It should be understood that the Processor may be a Central Processing Unit (CPU), and the Processor may be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, etc. Wherein a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Wherein, in one embodiment, the processor is configured to execute a computer program stored in the memory to implement the steps of:
acquiring a target block to be written into a block chain; writing the target block into a temporary cache region to obtain a cache block corresponding to the target block, and sending a written notification for indicating that the target block is written into a block chain to a data node; if a block receiving request sent by the data node according to the written notification is received, sending a cache block corresponding to the block receiving request in the temporary cache region to the data node; and writing the cache block into a target disk so as to add the cache block into a block chain stored in the target disk.
In one embodiment, the processor is further configured to implement the steps of:
if a block reading request sent by the data node is received, inquiring whether a cache block corresponding to the block reading request exists in the temporary cache region; if a cache block corresponding to the block reading request exists in the temporary cache region, sending the cache block to the data node; and if the temporary cache area does not have the cache block corresponding to the block reading request, reading the block corresponding to the block reading request from the target disk, and sending the block to the data node.
In an embodiment, when the processor writes the target block into a temporary cache area to obtain a cache block corresponding to the target block, the processor is configured to:
if the temporary cache area is not full, writing the target block into the temporary cache area to obtain a cache block corresponding to the target block; if the temporary cache area is full, the target block is subjected to blocking waiting; if a cache block in the temporary cache area is written into the target disk, stopping blocking waiting for the target block and writing the target block into the temporary cache area to obtain the cache block corresponding to the target block.
In an embodiment, when the processor writes the target block into the temporary cache area to obtain the cache block corresponding to the target block, the processor is further configured to:
judging whether the temporary cache area is fully written according to the number of the stored cache blocks in the temporary cache area; if the temporary cache area is full and the number of target blocks for blocking waiting is larger than a preset threshold value, increasing the capacity of the temporary cache area; stopping blocking and waiting the target block, and writing the target block into the temporary cache area with increased capacity to obtain a cache block corresponding to the target block.
In one embodiment, the processor, when implementing writing the cache block to a target disk to add the cache block to a block chain stored in the target disk, is configured to implement:
and sequentially writing each cache block into a target disk according to the writing sequence of each cache block in the temporary cache region based on a first-in first-out rule so as to add each cache block into a block chain stored in the target disk.
In one embodiment, after the processor is configured to send the cache block corresponding to the block reception request in the temporary cache region to the data node, the processor is further configured to:
acquiring a transaction verification result of the data node performing transaction verification on the received cache block; and if the cache block comprises the wrong transaction according to the transaction verification result, deleting the cache block from the temporary cache region.
In one embodiment, after the processor performs sending the cache block to the data node, the processor is further configured to perform:
obtaining a verification result of the data node verifying the received cache block; and if the cache block is judged to be wrong according to the verification result, sending the cache block in the temporary cache area to the data node again.
In one embodiment, the processor, after enabling sending the block to the data node, is further configured to enable:
obtaining a verification result of the data node verifying the received block; and if the block is judged to be wrong according to the verification result, sending the block to the data node from the target disk again.
The embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, where the computer program includes program instructions, and the processor executes the program instructions to implement the block distribution method of any one of the block chains provided in the embodiment of the present application.
The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiment, for example, a hard disk or a 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), a Secure Digital Card (SD Card), a Flash memory Card (Flash Card), and the like provided on the computer device.
While the invention has been described with reference to specific embodiments, the scope of the invention is not limited thereto, and those skilled in the art can easily conceive various equivalent modifications or substitutions within the technical scope of the invention. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A method for block distribution of a blockchain, comprising:
acquiring a target block to be written into a block chain;
writing the target block into a temporary cache region to obtain a cache block corresponding to the target block, and sending a written notification for indicating that the target block is written into a block chain to a data node;
if a block receiving request sent by the data node according to the written notification is received, sending a cache block corresponding to the block receiving request in the temporary cache region to the data node;
and writing the cache block into a target disk so as to add the cache block into a block chain stored in the target disk.
2. A block distribution method of a block chain according to claim 1, characterized in that said block distribution method further comprises:
if a block reading request sent by the data node is received, inquiring whether a cache block corresponding to the block reading request exists in the temporary cache region;
if a cache block corresponding to the block reading request exists in the temporary cache region, sending the cache block to the data node;
and if the temporary cache area does not have the cache block corresponding to the block reading request, reading the block corresponding to the block reading request from the target disk, and sending the block to the data node.
3. The block distribution method of the block chain according to claim 1, wherein the writing the target block into a temporary buffer to obtain the buffer block corresponding to the target block comprises:
if the temporary cache area is not full, writing the target block into the temporary cache area to obtain a cache block corresponding to the target block;
if the temporary cache area is full, the target block is subjected to blocking waiting;
if a cache block in the temporary cache area is written into the target disk, stopping blocking waiting for the target block and writing the target block into the temporary cache area to obtain the cache block corresponding to the target block.
4. The block distribution method of the block chain according to claim 3, wherein the writing the target block into a temporary buffer to obtain a buffer block corresponding to the target block, further comprises:
if the temporary cache area is full and the number of target blocks for blocking waiting is larger than a preset threshold value, increasing the capacity of the temporary cache area;
stopping blocking and waiting the target block, and writing the target block into the temporary cache area with increased capacity to obtain a cache block corresponding to the target block.
5. The block distribution method for the block chain according to claim 1, wherein the writing the cache block to the target disk to add the cache block to the block chain stored in the target disk comprises:
and sequentially writing each cache block into a target disk according to the writing sequence of each cache block in the temporary cache region based on a first-in first-out rule so as to add each cache block into a block chain stored in the target disk.
6. The block distribution method of the block chain according to claim 1, wherein after sending the buffer block corresponding to the block reception request in the temporary buffer to the data node, the method further comprises:
acquiring a transaction verification result of the data node performing transaction verification on the received cache block;
and if the cache block comprises the wrong transaction according to the transaction verification result, deleting the cache block from the temporary cache region.
7. The method for block distribution of a blockchain of claim 2, wherein after sending the cache block to the data node, further comprising:
obtaining a verification result of the data node verifying the received cache block;
if the cache block is judged to be wrong according to the verification result, sending the cache block in the temporary cache area to the data node again;
after the sending the block to the data node, the method further includes:
obtaining a verification result of the data node verifying the received block;
and if the block is judged to be wrong according to the verification result, sending the block to the data node from the target disk again.
8. A block distribution apparatus for a blockchain, comprising:
the block acquisition module is used for acquiring a target block to be written into a block chain;
a first block writing module, configured to write the target block into a temporary cache area, obtain a cache block corresponding to the target block, and send a written notification indicating that the target block has been written into a block chain to a data node;
a first block sending module, configured to send, to the data node, a cache block in the temporary cache area corresponding to the block receiving request if a block receiving request sent by the data node according to the written notification is received;
and the second block writing module is used for writing the cache block into a target disk so as to add the cache block into a block chain stored in the target disk.
9. A computer device, wherein the computer device comprises a memory and a processor;
the memory for storing a computer program;
the processor for executing the computer program and implementing the method of block distribution of a blockchain according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which, when executed by a processor, causes the processor to implement the method of block distribution of a blockchain according to any one of claims 1 to 7.
CN201910969411.4A 2019-10-12 2019-10-12 Block distribution method and device of block chain, computer equipment and storage medium Active CN110995776B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201910969411.4A CN110995776B (en) 2019-10-12 2019-10-12 Block distribution method and device of block chain, computer equipment and storage medium
PCT/CN2020/099257 WO2021068567A1 (en) 2019-10-12 2020-06-30 Blockchain block distribution method, apparatus, computer device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910969411.4A CN110995776B (en) 2019-10-12 2019-10-12 Block distribution method and device of block chain, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110995776A true CN110995776A (en) 2020-04-10
CN110995776B CN110995776B (en) 2021-11-02

Family

ID=70081889

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910969411.4A Active CN110995776B (en) 2019-10-12 2019-10-12 Block distribution method and device of block chain, computer equipment and storage medium

Country Status (2)

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

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112291372A (en) * 2020-12-28 2021-01-29 腾讯科技(深圳)有限公司 Asynchronous posting method, device, medium and electronic equipment for block chain
WO2021068567A1 (en) * 2019-10-12 2021-04-15 平安科技(深圳)有限公司 Blockchain block distribution method, apparatus, computer device and storage medium
WO2022213697A1 (en) * 2021-04-07 2022-10-13 暗链科技(深圳)有限公司 Block distributed blockchain generation method, storage medium, and electronic device
EP4213038A4 (en) * 2021-02-19 2024-04-03 Tencent Tech Shenzhen Co Ltd Data processing method and apparatus based on distributed storage, device, and medium

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113590520B (en) * 2021-06-15 2024-05-03 珠海一微半导体股份有限公司 Control method for automatically writing data in SPI system and SPI system
CN113436015A (en) * 2021-06-30 2021-09-24 中元众诚(北京)科技有限公司 Block chain-based chained database and operation method
CN113596010B (en) * 2021-07-23 2023-04-28 腾讯科技(深圳)有限公司 Data processing method, device, node equipment and computer storage medium
CN113691611B (en) * 2021-08-23 2022-11-22 湖南大学 Block chain distributed high-concurrency transaction processing method, system, equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106649838A (en) * 2016-12-29 2017-05-10 先锋支付有限公司 Data transmission method, block chain node and distributed database
CN108764906A (en) * 2018-05-30 2018-11-06 深圳市元征科技股份有限公司 A kind of server and its block chain transaction confirmation method, device, storage medium
CN109032802A (en) * 2018-07-26 2018-12-18 国信优易数据有限公司 A kind of block catenary system and management method
CN109522499A (en) * 2018-11-20 2019-03-26 平安科技(深圳)有限公司 Method, apparatus, computer equipment and the storage medium of local loading page data
US20190199787A1 (en) * 2017-12-26 2019-06-27 Akamai Technologies, Inc. Distributed system of record transaction receipt handling in an overlay network
CN110019235A (en) * 2017-12-29 2019-07-16 百度在线网络技术(北京)有限公司 Data storage, restoration methods, device, equipment and medium based on block chain

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11769150B2 (en) * 2017-10-11 2023-09-26 International Business Machines Corporation Transaction scheduling for block space on a blockchain
CN109347935B (en) * 2018-09-30 2021-08-03 珠海信达九州科技有限公司 Method for realizing real-time communication message synchronization based on block chain
CN109684408A (en) * 2018-12-07 2019-04-26 深圳市智税链科技有限公司 Data managing method, device, medium and the electronic equipment of block catenary system
CN109816532B (en) * 2019-04-10 2021-05-18 北京一三链科技有限公司 Asset digital anchoring system based on block chain technology
CN110995776B (en) * 2019-10-12 2021-11-02 平安科技(深圳)有限公司 Block distribution method and device of block chain, computer equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106649838A (en) * 2016-12-29 2017-05-10 先锋支付有限公司 Data transmission method, block chain node and distributed database
US20190199787A1 (en) * 2017-12-26 2019-06-27 Akamai Technologies, Inc. Distributed system of record transaction receipt handling in an overlay network
CN110019235A (en) * 2017-12-29 2019-07-16 百度在线网络技术(北京)有限公司 Data storage, restoration methods, device, equipment and medium based on block chain
CN108764906A (en) * 2018-05-30 2018-11-06 深圳市元征科技股份有限公司 A kind of server and its block chain transaction confirmation method, device, storage medium
CN109032802A (en) * 2018-07-26 2018-12-18 国信优易数据有限公司 A kind of block catenary system and management method
CN109522499A (en) * 2018-11-20 2019-03-26 平安科技(深圳)有限公司 Method, apparatus, computer equipment and the storage medium of local loading page data

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021068567A1 (en) * 2019-10-12 2021-04-15 平安科技(深圳)有限公司 Blockchain block distribution method, apparatus, computer device and storage medium
CN112291372A (en) * 2020-12-28 2021-01-29 腾讯科技(深圳)有限公司 Asynchronous posting method, device, medium and electronic equipment for block chain
EP4207688A4 (en) * 2020-12-28 2024-03-27 Tencent Tech Shenzhen Co Ltd Asynchronous bookkeeping method and apparatus for blockchain, medium, and electronic device
EP4213038A4 (en) * 2021-02-19 2024-04-03 Tencent Tech Shenzhen Co Ltd Data processing method and apparatus based on distributed storage, device, and medium
WO2022213697A1 (en) * 2021-04-07 2022-10-13 暗链科技(深圳)有限公司 Block distributed blockchain generation method, storage medium, and electronic device

Also Published As

Publication number Publication date
WO2021068567A1 (en) 2021-04-15
CN110995776B (en) 2021-11-02

Similar Documents

Publication Publication Date Title
CN110995776B (en) Block distribution method and device of block chain, computer equipment and storage medium
US10942895B2 (en) Storage system with decrement protection of reference counts
US10242022B1 (en) Systems and methods for managing delayed allocation on clustered file systems
US9336224B2 (en) Systems and methods for providing increased scalability in deduplication storage systems
US20120102003A1 (en) Parallel data redundancy removal
CN105117351A (en) Method and apparatus for writing data into cache
WO2020093501A1 (en) File storage method and deletion method, server, and storage medium
CN107632781B (en) Method for rapidly checking consistency of distributed storage multi-copy and storage structure
CN111338688B (en) Data long-acting caching method and device, computer system and readable storage medium
CN111209257B (en) File system fragmentation method and device
EP3449372B1 (en) Fault-tolerant enterprise object storage system for small objects
CN115348222A (en) Message distribution method, device, server and storage medium
CN110955545B (en) Data integrity verification method, system and related equipment
CN110427394B (en) Data operation method and device
CN113568877A (en) File merging method and device, electronic equipment and storage medium
CN114218303B (en) Transaction data processing system, processing method, medium and equipment
CN109408496A (en) A kind of method and device reducing data redundancy
CN111290700A (en) Distributed data reading and writing method and system
CN113986833A (en) File merging method, system, computer system and storage medium
US10795596B1 (en) Delayed deduplication using precalculated hashes
CN108959405B (en) Strong consistency reading method of data and terminal equipment
CN111694801A (en) Data deduplication method and device applied to fault recovery
CN113986134B (en) Method for storing data, method and device for reading data
CN110784479B (en) Data verification method and device, electronic equipment and storage medium
CN115509763B (en) Fingerprint calculation method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant