CN109344630B - Block generation method, device, equipment and storage medium - Google Patents

Block generation method, device, equipment and storage medium Download PDF

Info

Publication number
CN109344630B
CN109344630B CN201811087577.5A CN201811087577A CN109344630B CN 109344630 B CN109344630 B CN 109344630B CN 201811087577 A CN201811087577 A CN 201811087577A CN 109344630 B CN109344630 B CN 109344630B
Authority
CN
China
Prior art keywords
block
node
time
initial
generation
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.)
Active
Application number
CN201811087577.5A
Other languages
Chinese (zh)
Other versions
CN109344630A (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.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology 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 Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201811087577.5A priority Critical patent/CN109344630B/en
Publication of CN109344630A publication Critical patent/CN109344630A/en
Application granted granted Critical
Publication of CN109344630B publication Critical patent/CN109344630B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/604Tools and structures for managing or administering access control systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Health & Medical Sciences (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Automation & Control Theory (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a block generation method, a block generation device, block generation equipment and a storage medium. The method comprises the following steps: acquiring the initial block output time of the local node in the current block generation period, wherein the initial block output time is determined according to the block generation period of the previous block generation node and the transition time between the nodes; and after the initial block output time reaching the local node is detected, generating a new block according to the node block output rule. In the embodiment of the invention, when the block generation node is switched, node transition time is added between adjacent switched nodes, so that even if the block output time in the node is shortened according to the block output rule in the node, sufficient time can be provided for the generation and the sending of the tail block in the previous block generation node to the block chain network, and under the condition that the block output time of the node is shortened and the confirmation speed of the block is improved, the probability of block chain branching is reduced, and the tail block in the previous block generation node is prevented from being discarded.

Description

Block generation method, device, equipment and storage medium
Technical Field
The present invention relates to the field of block chain technologies, and in particular, to a block generation method, apparatus, device, and storage medium.
Background
With the continuous development of internet technology, a decentralized and transparent block chain technology is developed. The block chain technology adopts the data block to break the dependence of the current internet on a central server, all data generated in the network are recorded by the block generating node, and a new block is formed and is linked to the tail part of the block chain through the broadcast of the data and the verification of other nodes. After the uplink block is confirmed, the new block is permanently recorded in the block chain; otherwise, rolling back the data in the block for the block which can not be confirmed.
In the prior art, from the viewpoint of generality, regardless of the adopted consensus mechanism and parameter deployment manner, the generally adopted uplink block acknowledgement manner is that if a block is successfully uplink for 6 blocks, it indicates that the block is acknowledged, and the block can be permanently recorded in the block chain.
Accordingly, the block out time of the block directly affects the uplink acknowledgement speed of the transaction data. If the block-out time is too slow, the uplink acknowledgement speed of the transaction data is slow, and the service performance is poor. However, if the block output time is too fast, block chain branching caused by block output failure exists, and then transaction data rollback is easy to occur, which causes trouble to the service layer.
Disclosure of Invention
Embodiments of the present invention provide a block generation method, apparatus, device, and storage medium, which can shorten the time for a node to go out of a block, improve the block confirmation speed, and reduce the probability of discarding the block.
In a first aspect, an embodiment of the present invention provides a block generation method, which is performed by a block generation node, where the method includes:
acquiring the initial block output time of the local node in the current block generation period, wherein the initial block output time is determined according to the block generation period of the previous block generation node and the transition time between the nodes;
and after the initial block output time reaching the local node is detected, generating a new block according to the node block output rule.
In a second aspect, an embodiment of the present invention provides a block generation apparatus, configured in a block generation node, where the apparatus includes:
the system comprises an initial block output time acquisition module, a block generation module and a block output module, wherein the initial block output time acquisition module is used for acquiring the initial block output time of a local node in a current block generation period, and the initial block output time is determined according to the block generation period of a previous block generation node and the transition time between nodes;
and the block generation module is used for generating a new block according to the rule of block output in the node after detecting the initial block output time of reaching the local node.
In a third aspect, an embodiment of the present invention provides an apparatus, including:
one or more processors;
a memory for storing one or more programs;
when the one or more programs are executed by the one or more processors, the one or more processors implement the block generation method according to any embodiment of the present invention.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the block generation method according to any embodiment of the present invention.
In the embodiment of the invention, when the local node is used as the current block generating node of the block chain network, the initial block output time of the local node in the current block generating period is obtained according to the block generating period of the previous block generating node and the transition time between the nodes, so that a new block is generated according to the rule of block output in the node after the initial block output time of the local node is detected. In the embodiment of the invention, when the block generation node is switched, node transition time is added between adjacent switched nodes, so that even if the block output time in the node is shortened according to the block output rule in the node, sufficient time can be provided for the generation and the sending of the tail block in the previous block generation node to the block chain network, and under the condition that the block output time of the node is shortened and the confirmation speed of the block is improved, the probability of block chain branching is reduced, and the tail block in the previous block generation node is prevented from being discarded.
Drawings
Fig. 1 is a flowchart of a block generation method according to an embodiment of the present invention;
fig. 2 is a flowchart of a block generation method according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of a block generating apparatus according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of an apparatus according to a fourth embodiment of the present invention.
Detailed Description
The embodiments of the present invention will be described in further detail with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the embodiments of the invention and that no limitation of the invention is intended. It should be further noted that, for convenience of description, only some structures, not all structures, relating to the embodiments of the present invention are shown in the drawings.
Example one
Fig. 1 is a flowchart of a block generation method according to an embodiment of the present invention, which is applicable to a case where at least two nodes alternately flow out a consensus mechanism of blocks according to a set rule. The method specifically comprises the following steps:
s110, acquiring the initial block output time of the local node in the current block generation period.
In the embodiment of the present invention, the blockchain network may enable at least two nodes in the blockchain network to share the transaction right by means of election and the like according to the consensus mechanism and the deployed parameters, and take the nodes as the current blockchain generation node in turn to process the transaction request in the blockchain network, and finally generate a new block according to the processed transaction data and record the new block in the blockchain. Each node has a block generation period during which at least two blocks are generated, typically on the order of tens or hundreds. Illustratively, a Delegated Proof of trust (DPOS) is a typical consensus mechanism for out-of-block taking, which pre-selects a number of candidate out-of-block nodes, which may be 21 in general, each of which takes turns to be out-of-block as a block generation node. For example, an EOS system, which uses DPOS as a consensus mechanism, during the process of generating a block of nodes, the accounting time period of each node in the EOS is 10 minutes.
In this embodiment, the blockchain consensus mechanism adopted by the node is a round-robin block consensus mechanism. The local node is a node which can be used as a block generation node in turn in the block chain network, namely one of at least two candidate block nodes which are selected in advance according to a consensus mechanism. The block generation period refers to a time range within which a node as a block generation node can perform transaction request processing according to a transaction right and generate a new block, and the block generation period may be determined for the block chain network according to a block generation period time length with equal length predefined in the consensus mechanism, or determined in real time according to a transaction request processing condition of the node and multidimensional threshold information such as time and/or space predefined in a node switching rule of the consensus mechanism. The block generation period of each node can be known in advance according to a block generation period predefined in the consensus mechanism, or the block generation period of the node can be determined by determining the block-out termination time of the node according to the transaction request processing condition of the node and the multi-dimensional threshold information. The starting block-out time refers to a time starting point when a node starts to serve as a current block generation node to generate a new block when a block generation node in a block chain network is switched.
Specifically, the starting block output time is determined according to the block generation period of the previous block generation node and the transition time between nodes. In this embodiment, the block generation period of the previous block generation node refers to a time point range corresponding to the starting block output time and the ending block output time of the previous block generation node, and may be known in advance, or may be determined immediately because the previous block generation node finishes outputting the ending block output time of the last block. It can be understood that, if the block generation cycle time lengths with equal lengths are predefined in the consensus mechanism in the blockchain network, the block generation cycle of the previous block generation node is the same as the block generation cycle of the current block generation node. The inter-node transition time is a time interval from the end of the previous block generation node to the start of the local node generating a new block when the block generation nodes in the block chain network are switched, that is, a time interval that the local node waits at the end of the block generation period of the previous block generation node. In order to ensure that the tail block of the previous block generation node is generated and transmitted into the blockchain network, the inter-node transition time in this embodiment is greater than the intra-node out-block time, where the intra-node out-block time is the out-block interval in the block generation period of a single node.
Correspondingly, in this embodiment, before the initial block output time of the local node in the current block generation cycle is obtained, the inter-node transition time is obtained from the consensus mechanism data deployed in the local node, and the sum of the end block output time of the block generation cycle of the previous block generation node and the inter-node transition time is used as the initial block output time of the local node in the current block generation cycle. It can be understood that, if the consensus mechanism in the blockchain network specifies the block generation cycle time length with equal length in advance, the block generation cycle of each node may be determined in advance according to the specified transaction time length with equal length, the transition time between nodes, and the rotation order of each candidate block node; or determining the ending block-out time of the block generation period of the previous block generation node at any time, and determining the starting block-out time of the local node in the current block generation period by summing the transition time between the nodes. If multi-dimensional threshold information such as time and/or space is preset in a node switching rule of a consensus mechanism in the block chain network, determining the ending block-out time of a block generation cycle of a previous block generation node according to the node switching rule, and determining the starting block-out time of the local node in the current block generation cycle by summing with the transition time between nodes.
For example, taking the intra-node block-out time as 10 minutes, that is, one block is out every 10 minutes, the current uplink block can be confirmed only after the next uplink 6 blocks, that is, 60 minutes, the block confirmation speed is slow, and the intra-block transaction data timeliness is poor. Therefore, in the embodiment, the block generation time is shortened, assuming that the block generation cycle time length with equal length predefined in the consensus mechanism is 10 minutes, the inter-node transition time is 3 seconds, and the intra-node block generation time is 0.1 second. While assuming the current node aiIs going out of the block and turns to node a after going outi+1And (6) discharging blocks. If node aiThe block generation period of (2) is from 00:00:00 to 00:10:00, and one block is generated every 0.1 second within the block generation period. Then the determination at node a may be made based on the parameter data obtained from the locally deployed consensus mechanismiWhen the last block is finished, the node ai+1Waiting for 3 seconds and then starting to output the block, namely the node ai+1The starting block output time of the current block generation period is 00:10:03, and the current block generation period of the local node is 00:10:03 to 00:20: 03. In this way, the block generation period of each candidate block node which is subsequently used as the block generation node in turn may be predetermined.
And S120, after the initial block output time of the local node is detected, generating a new block according to the rule of outputting the block in the node.
In the embodiment of the present invention, after the initial block output time of the local node in the current block generation cycle is obtained, the time can be detected in real time. If the initial block output time reaching the local node is detected, the local node can be used as a block generation node to generate a new block according to the block output rule in the node. The rule of the node out-of-block can be a predefined transaction request processing mode and a predefined block generation mode.
Specifically, in this embodiment, after detecting the initial block output time of reaching the local node, at least one block output processing thread may be used to process the transaction request in the blockchain network, and pack the transaction data to be packed at intervals of the block output time in the node to generate a new block. In this embodiment, the transaction request processing and the new block generation by packing may be divided into two types of threads for separate processing, that is, after the start block output time of the local node is detected, the transaction request is processed by at least one transaction type thread to generate transaction data, and the generated transaction data is packed by the packing thread at regular time with the block output time in the node as an interval to generate the new block. Or the transaction processing type thread can fully utilize the transition time among the nodes, the initial transaction processing time which is earlier than the initial block-out time is determined through the initial block-out time and the transition time among the nodes of the local node in the current block generation period, when the initial transaction processing time reaching the local node is detected, the transaction request is processed through at least one transaction processing type thread to generate transaction data, and after the initial block-out time is detected, the generated transaction data is packaged through the packaging thread at intervals of the block-out time in the nodes to generate a new block.
According to the technical scheme of the embodiment, when the local node is used as the current block generation node of the block chain network, the block generation period of the previous block generation node and the transition time between the nodes are taken as the basis, the initial block output time of the local node in the current block generation period is obtained, and therefore after the initial block output time of the local node is detected, a new block is generated according to the rule of outputting blocks in the node. In the embodiment of the invention, when the block generation node is switched, node transition time is added between adjacent switched nodes, so that even if the block output time in the node is shortened according to the block output rule in the node, sufficient time can be provided for the generation and the sending of the tail block in the previous block generation node to the block chain network, and under the condition that the block output time of the node is shortened and the confirmation speed of the block is improved, the probability of block chain branching is reduced, and the tail block in the previous block generation node is prevented from being discarded.
Example two
The present embodiment provides a preferred implementation of the block generation method based on the first embodiment, which can improve the timeliness of the block generation and the system performance of the block chain. Fig. 2 is a flowchart of a block generation method according to a second embodiment of the present invention, as shown in fig. 2, the method includes the following steps:
s210, acquiring transition time between nodes from the consensus mechanism data deployed by the local computer.
In the embodiment of the present invention, the blockchain network may enable at least two nodes in the blockchain network to share the transaction right by means of election and the like according to the consensus mechanism and the deployed parameters, and take transition time between the nodes as a time interval when the nodes are switched, and take the transition time as the current blockchain generation node in turn to process the transaction request in the blockchain network, and finally generate a new block according to the processed transaction data and record the new block in the blockchain.
Optionally, the block chain consensus mechanism adopted by the node is a round-robin block consensus mechanism.
In this embodiment, a round-robin block consensus mechanism is adopted, a block chain pre-elects a certain number of candidate block nodes according to the round-robin block consensus mechanism, each candidate block node is specified to have a block generation period, and each candidate block node is used as a block generation node in turn according to a sequence to process a transaction request in the block generation period and generate a new block. The consensus mechanism is pre-deployed in the blockchain network at the time of blockchain creation, wherein the blockchain generation period, the start out-of-block time, the inter-node transition time, and the intra-node out-of-block time may be pre-defined. Wherein, each deployment parameter can be a specific value stipulated in advance, and each candidate block output node can be switched and output blocks in turn according to the fixed and unchangeable parameters; or may be a predetermined determination rule for each deployment parameter, and each candidate block output node may dynamically determine the alternate switching mode and the block output mode according to the determination rule.
Optionally, the inter-node transition time is greater than the intra-node block output time, that is, the block output interval in the block generation period of a single node.
The inter-node transition time adopted in this embodiment is longer than the node block in/out time, so as to ensure that the tail block of the previous block generation node is generated and transmitted into the block chain network, and avoid the situation that after the block generation node is switched, the tail block of the previous block generation node is not generated or transmitted into the block chain network, so that the new block generated by the local node cannot completely follow the tail block of the previous block generation node to continue generating the new block, so that the block chain is forked, the tail block of the previous block generation node is discarded, and the transaction data is rolled back.
Accordingly, the local node may obtain the inter-node transition time from the co-recognition mechanism data of the local deployment, so as to determine the switching mode and the block output time of the local node when the previous block generation node finishes the block generation period.
Illustratively, the nodes adopt a round-robin block consensus mechanism, and assume that the time length of a block generation cycle with equal length specified in the consensus mechanism is 10 minutes, the transition time between nodes is 3 seconds, and the block-out time in a node is 0.1 second. Suppose that the current node aiIs going out of the block and turns to node a after going outi+1And (6) discharging blocks. If node ai+1And if the node is the native node, acquiring the inter-node transition time, namely 3 seconds, from the co-recognition mechanism data deployed in the native node.
And S220, taking the sum of the ending block-out time of the block generation period of the previous block generation node and the transition time between the nodes as the starting block-out time of the local node in the current block generation period.
In the embodiment of the present invention, the principle of determining the starting block output time of the local node in the current block generation cycle is to delay the ending block output time of the block generation cycle of the previous block generation node backward by one inter-node transition time, that is, when the block generation node is switched, the block to be output may wait for one inter-node transition time when the previous block generation node finishes outputting the last block, instead of taking the intra-node block output time as an interval, so that the previous block generation node finishes the tail block generation and the transmission to the block chain network as much as possible.
Specifically, if the consensus mechanism in the blockchain network specifies a block generation cycle time length with equal length in advance, the block generation cycle of each node may be determined in advance according to the specified block generation cycle, the transition time between nodes, and the rotation order of each candidate block node; or determining the ending block-out time of the block generation period of the previous block generation node, and determining the starting block-out time of the local node in the current block generation period by summing the transition time between the nodes. If multidimensional threshold information such as time and/or space is preset in a node switching rule of a consensus mechanism in a block chain network, determining the block output time of a block generation period of a previous block generation node according to information such as processing time, transaction request processing conditions or data volume of transaction data of the previous block generation node and the multidimensional threshold information such as time and/or space preset in the node switching rule, and determining the initial block output time of the local node in the block generation period by summing with transition time between nodes.
Illustratively, in the above example, assume node aiAfter the last block is generated, the block generation period is 00:00:00 to 00:10:00, the node aiThe end out-of-block time of (1) is 00:10: 00. And summing the block ending time and the transition time between the nodes, and determining that the starting block outputting time of the local node in the current block generating period is 00:10: 03.
And S230, after the initial block output time of the local node is detected, generating a new block according to the rule of outputting the block in the node.
In the embodiment of the present invention, after the initial block output time of the local node in the current block generation cycle is obtained, the time can be detected in real time. If the initial block output time reaching the local node is detected, the local node can be used as a block generation node to generate a new block according to the rule of block output in the node.
Optionally, after detecting the initial block-out time of reaching the local node, processing the transaction request by at least one transaction processing thread to generate transaction data; and packing the generated transaction data at regular time by using the packing thread with the block outgoing time in the node as an interval to generate a new block.
In this embodiment, the transaction request processing and the new block generated by packing may be divided into two types of threads for separate processing, that is, a transaction type thread for transaction request processing and a packing thread for generating a new block by packing may be started. The transaction processing type thread continuously processes the received transaction requests to form transaction data and cache the transaction data, wherein the number of the transaction data can be a plurality, and then the transaction requests in the block chain network are processed in series or in parallel; and after the packing thread reaches a set packing time point, namely the time of block output in the node, extracting transaction processing data meeting the packing requirement from the cache, packing to form a new block, sending the new block to a block chain network for verification and confirmation, wherein the number of the new block can be 1, and regularly packing to generate the new block by taking the time of block output in the node as an interval. And when the time reaches the initial block output time of the local node, processing the transaction request by using at least one transaction processing type thread to generate transaction data and caching the transaction data, and regularly packaging by using a packaging thread to generate a new block by taking the block output time in the node as an interval.
It is noted that transactions occurring in a blockchain network are generally sparse and not fully loaded, i.e. only one transaction request, or even no transaction request, may occur during the out-of-block time of a node. Therefore, the embodiment separately executes the tasks of the transaction request processing and the new block packing generation, is beneficial to packing and generating the new block at intervals of the block output time in the node, and can pack on time to form an empty block even if no transaction processing data meeting the requirements currently exists, thereby ensuring the stability of the output block. It can be understood that the transaction data is data formed after the transaction request has been processed, and if the packaging time point is reached but no transaction data exists in the cache, it indicates that the transaction request is not processed or no transaction request is to be processed, so that the packaging thread also packages on time to form an empty block, and the stability of the output block is ensured.
Illustratively, in the above example, the block output time of the local node at the beginning of the current block generation cycle is 00:10:03, and when the detection time reaches 00:10:03, the local node starts the transaction type thread to perform the transaction request processing, and generates a new block by regularly packing with the packing thread at the time interval of 0.1 second.
Optionally, after detecting the initial transaction processing time of reaching the local node, processing the transaction request by using at least one transaction processing thread to generate transaction data; and after the arrival of the initial block output time is detected, packaging the generated transaction data at the interval of the block output time in the node by a packaging thread to generate a new block.
In this embodiment, the transaction request may also be processed in advance, that is, the transaction request processing is performed by fully utilizing the waiting time, that is, the inter-node transition time. Therefore, when the initial block output time of the local node in the current block generation period is determined, the initial transaction processing time can be determined through the initial block output time and the inter-node transition time, that is, the initial transaction processing time is determined by subtracting one inter-node transition time from the initial block output time of the local node in the current block generation period. It is understood that the start transaction time is earlier than the start block-out time, i.e. the time when the last block is out of the previous block generation node from the perspective of the previous block generation node.
Specifically, in this embodiment, through two time detections, the transaction request processing task and the new block generating task by packaging of the local node are respectively started. After detecting the initial transaction processing time reaching the local node, processing the transaction request by utilizing at least one transaction processing class thread in the transition time between the nodes to generate transaction data and caching the transaction data. After the initial block output time is detected, the execution of the transaction processing type thread is not influenced, the packing thread is started, and the new blocks are generated by timing packing with the block output time in the node as an interval by using the packing thread. And furthermore, the problem that when the number of transaction requests in the block chain is large, the transaction requests are easy to accumulate and untimely to process is solved by a mode of processing the transaction requests in advance, and the block output efficiency and the timeliness of transaction data in the block are improved.
For example, in the above example, if the starting block-out time of the local node in the current block generation cycle is 00:10:03, it may be determined that the starting transaction processing time is 00:10: 00. And when the detection time reaches 00:10:00, the local node starts a transaction processing thread to process the transaction request and cache the transaction request. When the detection time reaches 00:10:03, the local node starts a packing thread and packs the thread at regular time to generate a new block at the time interval of 0.1 second.
Optionally, after the initial block output time is detected, the transaction request is processed by at least one block output processing thread to generate transaction data, and the transaction data to be packed is packed at regular time with the block output time in the node as an interval to generate a new block.
In this embodiment, a type of thread may be used to perform both transaction request processing and timing packing to generate a new block, which is referred to as a block output processing thread in this embodiment, and the number of the block output processing threads may be several, and a plurality of block output processing threads may perform processing in series or in parallel. Correspondingly, the threads of the class can not extract and process the transaction requests, so after the initial block output time is detected, at least one block output processing thread is used for processing the transaction requests to generate transaction data, and the transaction data to be packaged is packaged at intervals of block output time in the node to generate a new block.
For example, in the above example, the starting block output time of the local node in the current block generation cycle is 00:10:03, and when the detection time reaches 00:10:03, the local node starts the block output processing thread to process the transaction request and generate a new block in a packaging manner.
According to the technical scheme of the embodiment, the inter-node transition time is obtained from the consensus mechanism data deployed by the local computer, and the sum of the block output time of the block generation cycle of the previous block generation node and the inter-node transition time is used as the initial block output time of the local computer node in the current block generation cycle. Thus, after detecting the initial block-out time of reaching the local node, generating a new block in a multi-thread mode according to the in-node block-out rule. According to the embodiment of the invention, when the block generation node is switched, node transition time is added between adjacent switched nodes, so that even if the block output time in the node is shortened according to the block output rule in the node, sufficient time can be provided for the generation of the tail block in the previous block generation node and the sending to the block chain network, under the condition that the block output time of the node is shortened and the confirmation speed of the block is increased, the probability of block chain branching is reduced, the tail block in the previous block generation node is prevented from being discarded, and the block output efficiency and the timeliness of transaction data in the block are improved.
EXAMPLE III
Fig. 3 is a schematic structural diagram of a block generation apparatus according to a third embodiment of the present invention, which is applicable to a case where at least two nodes alternately flow out a consensus mechanism of blocks according to a set rule. The device specifically includes:
an initial block output time obtaining module 310, configured to obtain an initial block output time of a local node in a current block generation period, where the initial block output time is determined according to a block generation period of a previous block generation node and a transition time between nodes;
the block generating module 320 is configured to generate a new block according to the rule of intra-node block output after detecting the initial block output time of reaching the local node.
Optionally, the inter-node transition time is greater than the intra-node block output time, and the intra-node block output time is a block output interval in a block generation period of a single node.
Optionally, the starting block-out time obtaining module 310 is specifically configured to:
and taking the sum of the ending block-out time of the block generation period of the previous block generation node and the transition time between the nodes as the starting block-out time of the local node in the current block generation period.
Optionally, the block generating module 320 includes:
the transaction request processing unit is used for processing the transaction request through at least one transaction processing type thread to generate transaction data after detecting the initial block-out time of reaching the local node;
and the transaction data packing unit is used for regularly packing the generated transaction data to generate a new block by using the packing thread and taking the block-out time in the node as an interval.
Optionally, the block generating module 320 includes:
the transaction request processing unit is used for processing a transaction request through at least one transaction processing thread to generate transaction data after detecting initial transaction processing time reaching a local node, wherein the initial transaction processing time is determined by the initial block-out time and the inter-node transition time;
and the transaction data packing unit is used for packing the generated transaction data to generate a new block at intervals of the block output time in the node by using the packing thread after the initial block output time is detected.
Optionally, the block generating module 320 includes:
and the block output processing unit is used for processing the transaction request through at least one block output processing thread to generate transaction data after detecting the time of starting block output, and packaging the transaction data to be packaged at intervals of block output time in the node to generate a new block.
Optionally, the block chain consensus mechanism adopted by the node is a round-robin block consensus mechanism.
Further, the apparatus further comprises:
an inter-node transition time obtaining module 330, configured to obtain the inter-node transition time from the consensus mechanism data deployed by the local node before the obtaining of the initial block output time of the local node in the current block generation cycle.
According to the technical scheme of the embodiment, through mutual cooperation of all functional modules, functions of alternate switching of block generation nodes, acquisition of transition time between nodes, determination of block starting and outputting time, determination of starting transaction processing time, detection of time, starting of multiple threads, processing of transaction requests, packaging and generation of blocks and the like are achieved. According to the embodiment of the invention, when the block generation node is switched, node transition time is added between adjacent switched nodes, so that even if the block output time in the node is shortened according to the block output rule in the node, sufficient time can be provided for the generation of the tail block in the previous block generation node and the sending to the block chain network, under the condition that the block output time of the node is shortened and the confirmation speed of the block is increased, the probability of block chain branching is reduced, the tail block in the previous block generation node is prevented from being discarded, and the block output efficiency and the timeliness of transaction data in the block are improved.
Example four
Fig. 4 is a schematic structural diagram of an apparatus according to a fourth embodiment of the present invention, and fig. 4 shows a block diagram of an exemplary apparatus suitable for implementing the embodiment of the present invention. The device shown in fig. 4 is only an example and should not bring any limitation to the function and the scope of use of the embodiments of the present invention.
The device 12 shown in fig. 4 is only an example and should not bring any limitation to the function and scope of use of the embodiments of the present invention.
As shown in FIG. 4, device 12 is in the form of a general purpose computing device. The components of device 12 may include, but are not limited to: one or more processors 16, a system memory 28, and a bus 18 that connects the various system components (including the system memory 28 and the processors 16).
Bus 18 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Device 12 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by device 12 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)30 and/or cache memory 32. Device 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 4, and commonly referred to as a "hard drive"). Although not shown in FIG. 4, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 by one or more data media interfaces. System memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 42 generally carry out the functions and/or methodologies of embodiments described herein.
Device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), with one or more devices that enable a user to interact with device 12, and/or with any devices (e.g., network card, modem, etc.) that enable device 12 to communicate with one or more other computing devices. Such communication may be through an input/output (I/O) interface 22. Also, the device 12 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet) via the network adapter 20. As shown, the network adapter 20 communicates with the other modules of the device 12 via the bus 18. It should be understood that although not shown in the figures, other hardware and/or software modules may be used in conjunction with device 12, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processor 16 executes various functional applications and data processing by executing at least one program of the programs stored in the system memory 28, for example, to implement the block generation method provided by the embodiment of the present invention.
EXAMPLE five
An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program (or referred to as computer-executable instructions) is stored, where the computer program is used to execute a block generation method when executed by a processor, and the method includes:
acquiring the initial block output time of the local node in the current block generation period, wherein the initial block output time is determined according to the block generation period of the previous block generation node and the transition time between the nodes;
and after the initial block output time reaching the local node is detected, generating a new block according to the node block output rule.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for embodiments of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or device. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the embodiments of the present invention have been described in more detail through the above embodiments, the embodiments of the present invention are not limited to the above embodiments, and many other equivalent embodiments may be included without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (16)

1. A block generation method performed by a block generation node, the method comprising:
acquiring the initial block output time of the local node in the current block generation period, wherein the initial block output time is determined according to the block generation period of the previous block generation node and the transition time between the nodes; the inter-node transition time is longer than the intra-node block output time, and the intra-node block output time is the block output interval in the block generation period of a single node;
and after the initial block output time reaching the local node is detected, generating a new block according to the node block output rule.
2. The method of claim 1, wherein the local node determines the start block-out time of the current block generation cycle by:
and taking the sum of the ending block-out time of the block generation period of the previous block generation node and the transition time between the nodes as the starting block-out time of the local node in the current block generation period.
3. The method of claim 1, wherein generating a new block according to an intra-node out-block rule after detecting the start out-block time to reach a native node comprises:
after detecting the initial block-out time of reaching the local node, processing the transaction request by at least one transaction processing thread to generate transaction data;
and packing the generated transaction data at regular time by using the packing thread with the block outgoing time in the node as an interval to generate a new block.
4. The method of claim 1, wherein generating a new block according to an intra-node out-block rule after detecting the start out-block time to reach a native node comprises:
processing a transaction request by at least one transaction class thread to generate transaction data after detecting an initial transaction processing time reaching a local node, wherein the initial transaction processing time is determined by the initial out-of-block time and the inter-node transition time;
and after the initial block output time is detected, packaging the generated transaction data at intervals of the block output time in the node by a packaging thread to generate a new block.
5. The method of claim 1, wherein generating a new block according to an intra-node out-block rule after detecting the start out-block time to reach a native node comprises:
and after the initial block output time is detected, processing the transaction request through at least one block output processing thread to generate transaction data, and packaging the transaction data to be packaged at regular time by taking the block output time in the node as an interval to generate a new block.
6. The method of claim 1, wherein the blockchain consensus mechanism employed by the nodes is a round-robin block consensus mechanism.
7. The method according to claim 1, wherein before the obtaining the local node starts the block-out time at the beginning of the current block generation cycle, further comprising:
and acquiring the inter-node transition time from the co-recognition mechanism data of the local deployment.
8. A block generation apparatus arranged in a block generation node, comprising:
the system comprises an initial block output time acquisition module, a block generation module and a block output module, wherein the initial block output time acquisition module is used for acquiring the initial block output time of a local node in a current block generation period, and the initial block output time is determined according to the block generation period of a previous block generation node and the transition time between nodes; the inter-node transition time is longer than the intra-node block output time, and the intra-node block output time is the block output interval in the block generation period of a single node;
and the block generation module is used for generating a new block according to the rule of block output in the node after detecting the initial block output time of reaching the local node.
9. The apparatus of claim 8, wherein the start block-out time obtaining module is specifically configured to:
and taking the sum of the ending block-out time of the block generation period of the previous block generation node and the transition time between the nodes as the starting block-out time of the local node in the current block generation period.
10. The apparatus of claim 8, wherein the block generation module comprises:
the transaction request processing unit is used for processing the transaction request through at least one transaction processing type thread to generate transaction data after detecting the initial block-out time of reaching the local node;
and the transaction data packing unit is used for regularly packing the generated transaction data to generate a new block by using the packing thread and taking the block-out time in the node as an interval.
11. The apparatus of claim 8, wherein the block generation module comprises:
the transaction request processing unit is used for processing a transaction request through at least one transaction processing thread to generate transaction data after detecting initial transaction processing time reaching a local node, wherein the initial transaction processing time is determined by the initial block-out time and the inter-node transition time;
and the transaction data packing unit is used for packing the generated transaction data to generate a new block at intervals of the block output time in the node by using the packing thread after the initial block output time is detected.
12. The apparatus of claim 8, wherein the block generation module comprises:
and the block output processing unit is used for processing the transaction request through at least one block output processing thread to generate transaction data after detecting the time of starting block output, and packaging the transaction data to be packaged at intervals of block output time in the node to generate a new block.
13. The apparatus of claim 8, wherein the blockchain consensus mechanism employed by the nodes is a round-robin block consensus mechanism.
14. The apparatus of claim 8, further comprising:
and the inter-node transition time acquisition module is used for acquiring the inter-node transition time from the consensus mechanism data deployed by the local machine before the acquisition of the initial block output time of the local machine node in the current block generation cycle.
15. An electronic device, comprising:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement the tile generation method of any of claims 1-7.
16. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the block generation method according to any one of claims 1 to 7.
CN201811087577.5A 2018-09-18 2018-09-18 Block generation method, device, equipment and storage medium Active CN109344630B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811087577.5A CN109344630B (en) 2018-09-18 2018-09-18 Block generation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811087577.5A CN109344630B (en) 2018-09-18 2018-09-18 Block generation method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109344630A CN109344630A (en) 2019-02-15
CN109344630B true CN109344630B (en) 2021-07-02

Family

ID=65305462

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811087577.5A Active CN109344630B (en) 2018-09-18 2018-09-18 Block generation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109344630B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109787867B (en) * 2019-02-28 2020-10-20 矩阵元技术(深圳)有限公司 Block generation method and device, computer equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106453636A (en) * 2016-11-22 2017-02-22 深圳银链科技有限公司 Credible block generation method and system
CN107679857A (en) * 2017-10-10 2018-02-09 马晶瑶 Across the chain method of commerce and storage medium of block chain
CN108320155A (en) * 2017-12-21 2018-07-24 中国科学院信息工程研究所 A method of realizing block chain common recognition mechanism

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170116693A1 (en) * 2015-10-27 2017-04-27 Verimatrix, Inc. Systems and Methods for Decentralizing Commerce and Rights Management for Digital Assets Using a Blockchain Rights Ledger
US10438209B2 (en) * 2016-02-10 2019-10-08 Bank Of America Corporation System for secure routing of data to various networks from a process data network
CN106131048B (en) * 2016-08-13 2020-05-19 广州商品清算中心股份有限公司 Non-trust remote transaction file safe storage system for block chain
CN108270836B (en) * 2017-01-03 2020-04-03 华为技术有限公司 Data processing method, device and system based on block chain
CN110445619B (en) * 2017-03-30 2020-10-16 腾讯科技(深圳)有限公司 Block chain system, message processing method and storage medium
CN107341660B (en) * 2017-05-27 2021-06-29 唐盛(北京)物联技术有限公司 Block chain bottom layer consensus mechanism and block chain system based on same
CN107733651B (en) * 2017-09-11 2020-06-19 联动优势科技有限公司 Block chain generation method, node and system
CN108320160A (en) * 2018-02-02 2018-07-24 张超 Block catenary system, block common recognition method and apparatus
CN108509615B (en) * 2018-03-30 2022-04-19 深圳市元征科技股份有限公司 Consensus establishing method and device based on drawing mechanism and readable storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106453636A (en) * 2016-11-22 2017-02-22 深圳银链科技有限公司 Credible block generation method and system
CN107679857A (en) * 2017-10-10 2018-02-09 马晶瑶 Across the chain method of commerce and storage medium of block chain
CN108320155A (en) * 2017-12-21 2018-07-24 中国科学院信息工程研究所 A method of realizing block chain common recognition mechanism

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
A Blockchain based Peer-to-Peer Framework for Exchanging Leftover Foreign Currency;Rituparna Bhattacharya 等;《Computing Conference 2017》;20170720;第1431-1435页 *
区块链技术:架构及进展;邵奇峰 等;《计算机学报》;20171115;第41卷(第5期);第969-988页 *

Also Published As

Publication number Publication date
CN109344630A (en) 2019-02-15

Similar Documents

Publication Publication Date Title
CN109101662B (en) Block generation method, device, equipment and storage medium
CN110442560B (en) Log replay method, device, server and storage medium
CN108647104B (en) Request processing method, server and computer readable storage medium
CN109255057B (en) Block generation method, device, equipment and storage medium
US11593107B2 (en) Handling an input/output store instruction
WO2017167062A1 (en) Application program interface deadlock monitoring method and device
CN109213828B (en) Block generation method, device, equipment and storage medium
CN104731569B (en) A kind of data processing method and relevant device
US9400767B2 (en) Subgraph-based distributed graph processing
CN105045632A (en) Method and device for implementing lock free queue in multi-core environment
US11579874B2 (en) Handling an input/output store instruction
US20090070560A1 (en) Method and Apparatus for Accelerating the Access of a Multi-Core System to Critical Resources
CN111737022A (en) Interface calling method, system, equipment and medium based on micro-service
CN111416825A (en) Inter-thread lock-free log management method and system, terminal and storage medium
CN114398179B (en) Method and device for acquiring tracking identifier, server and storage medium
CN109344630B (en) Block generation method, device, equipment and storage medium
US20210397492A1 (en) Establishment of queue between threads in user space
US11740827B2 (en) Method, electronic device, and computer program product for recovering data
CN110955461B (en) Processing method, device, system, server and storage medium for computing task
CN110445874B (en) Session processing method, device, equipment and storage medium
CN109241362B (en) Block generation method, device, equipment and storage medium
US9509780B2 (en) Information processing system and control method of information processing system
CN114282968A (en) Serial number acquisition method, device, server and storage medium
CN110085237B (en) Recovery method, device and equipment of interactive process
CN114327854A (en) Method for processing service request by coroutine and related equipment

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