WO2020233054A1 - 基于区块链的区块生成方法、装置、设备及存储介质 - Google Patents

基于区块链的区块生成方法、装置、设备及存储介质 Download PDF

Info

Publication number
WO2020233054A1
WO2020233054A1 PCT/CN2019/120814 CN2019120814W WO2020233054A1 WO 2020233054 A1 WO2020233054 A1 WO 2020233054A1 CN 2019120814 W CN2019120814 W CN 2019120814W WO 2020233054 A1 WO2020233054 A1 WO 2020233054A1
Authority
WO
WIPO (PCT)
Prior art keywords
resource transfer
transfer data
data
packaged
thread
Prior art date
Application number
PCT/CN2019/120814
Other languages
English (en)
French (fr)
Inventor
张培培
褚镇飞
Original Assignee
深圳壹账通智能科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳壹账通智能科技有限公司 filed Critical 深圳壹账通智能科技有限公司
Publication of WO2020233054A1 publication Critical patent/WO2020233054A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/90Buffering arrangements
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees

Definitions

  • This application relates to the field of blockchain technology, in particular to a block generation method, device, equipment and storage medium based on blockchain.
  • Blockchain is a chained data structure that combines data blocks in sequence in chronological order, and is a distributed ledger that cannot be tampered with and is guaranteed by cryptography.
  • Blockchain technology refers to a technical solution to collectively maintain a reliable database through decentralization and trustlessness. Simply put, blockchain technology is a way for all people to participate in bookkeeping. There is a database behind all systems, which can be regarded as a big ledger. Currently, each system keeps its own account. But in the blockchain system, everyone can do bookkeeping (resource transfer), the system will choose the person with the fastest and best bookkeeping, write his recorded content to the ledger, and send the content of the ledger to the system everybody inside is backed up.
  • blocks are generated by consensus nodes.
  • consensus nodes use batch resource transfer data, which triggers the production of blocks by waiting for a fixed time or a fixed number of resource transfer data. But this will inevitably extend the confirmation time of each resource transfer data; but if the fixed waiting time or the number of transactions is reduced, the throughput rate of the resource transfer data will be reduced. Therefore, it is faced with the problem that the high throughput rate of resource transfer data and the low latency of resource transfer data cannot be achieved at the same time.
  • the inventor realized that the resource transfer frequency often changes dynamically, high frequencies should be high throughput, low frequencies should be low latency, but the current block generation strategy is difficult to adapt to such scenarios.
  • This application provides a block chain-based block generation method, device, equipment and storage medium, which are used to meet the high throughput requirements under high-frequency resource transfer and low-latency requirements under low-frequency resource transfer, and improve the generation of blocks. effectiveness.
  • the first aspect of the present application provides a block generation method based on a blockchain, including: creating a data cache queue and an atomic counter, the data cache queue including resource transfer data to be packaged; and caching the data
  • the queue is associated with the atomic counter, and the initial value of the atomic counter is determined; a first thread and a second thread are generated, and the first thread is used to increase the transfer data of the resource to be packaged in the data cache queue
  • the second thread is used to reduce the amount of the resource transfer data to be packaged in the data cache queue; the first thread and the second thread adjust the amount of the resource transfer data to be packaged, and
  • the initial value of the atomic counter is adjusted to a target value; the resource transfer data to be packaged is packaged and packaged according to a preset condition to generate a target block.
  • a second aspect of the present application provides a block generation device based on a blockchain, including: a creation unit for creating a data cache queue and an atomic counter, the data cache queue includes resource transfer data to be packaged; an association determination unit, Used to associate the data cache queue with the atomic counter and determine the initial value of the atomic counter; a generating unit is used to generate a first thread and a second thread, and the first thread is used to increase the The quantity of data to be transferred from the resource to be packaged in the data cache queue, the second thread is used to reduce the quantity of data to be transferred from the resource to be packaged in the data cache queue; the adjustment unit is used to pass the first thread and The second thread adjusts the quantity of the resource transfer data to be packaged, and adjusts the initial value of the atomic counter to the target value; the package generation unit packs and encapsulates the resource transfer data to be packaged according to a preset condition, Generate the target block.
  • a third aspect of the present application provides a block generation device based on a blockchain, including: a memory and at least one processor, the memory stores instructions, and the memory and the at least one processor are interconnected by wires; The at least one processor invokes the instructions in the memory, so that the block generation device based on blockchain executes the method described in the first aspect.
  • the fourth aspect of the present application provides a computer-readable storage medium, the computer-readable storage medium stores computer instructions, and when the computer instructions run on a computer, the computer executes the above-mentioned first aspect method.
  • a data cache queue and an atomic counter are created, the data cache queue includes the resource transfer data to be encapsulated; the data cache queue and the atomic counter are associated, and the initial value of the atomic counter is determined Value; generate a first thread and a second thread, the first thread is used to increase the amount of data to be encapsulated in the data cache queue, the second thread is used to reduce the data cache queue
  • the quantity of the resource transfer data to be packaged; the quantity of the resource transfer data to be packaged is adjusted through the first thread and the second thread, and the initial value of the atomic counter is adjusted to the target value; according to preset conditions Package and package the resource transfer data to be packaged to generate a target block.
  • the resource transfer data is cached through the data cache queue, different processes are called to extract the cached resource transfer data to generate blocks, and the atomic counter is adjusted to meet the high throughput requirements and low frequency resources under high frequency resource transfer.
  • the low latency requirement under transfer improves the efficiency of generating blocks.
  • FIG. 1 is a schematic diagram of an embodiment of a block generation method based on blockchain in an embodiment of the application
  • FIG. 2 is a schematic diagram of another embodiment of a block generation method based on blockchain in an embodiment of the application;
  • FIG. 3 is a schematic diagram of an embodiment of a block generation device based on blockchain in an embodiment of the application
  • FIG. 4 is a schematic diagram of another embodiment of a block generation device based on blockchain in an embodiment of the application.
  • Figure 5 is a schematic diagram of an embodiment of a block generation device based on blockchain in an embodiment of the application.
  • This application provides a block chain-based block generation method, device, equipment and storage medium, which are used to meet the high throughput requirements under high-frequency resource transfer and low-latency requirements under low-frequency resource transfer, and improve the generation of blocks. effectiveness.
  • FIG. 1 a flowchart of a block generation method based on a blockchain provided in an embodiment of the present application, which specifically includes:
  • the data cache queue includes data to be encapsulated for resource transfer.
  • the ordering node creates a data cache queue and an atomic counter. Specifically, the ordering node creates a data cache queue to cache the pre-processed resource transfer data to be encapsulated, and generates an atomic counter.
  • the orderer is mainly used to implement the consensus mechanism of the blockchain network, provide a unified resource transfer data sorting and block service for all application clients, and distribute the block to all peer nodes and peer nodes. Undertake the role of processing resource transfer data and storing blocks in the blockchain network.
  • the resource transfer data to be encapsulated refers to the resource transfer data that has been processed by the peer node and has not been added to the block.
  • blockchain is a decentralized system and may carry a large number of financial assets, so it may face a large number of Byzantine failures instead of general failures, while a centralized distributed system Byzantine failure is rarely encountered.
  • the Byzantine fault can refer to the prior art, which will not be repeated here.
  • the execution subject of this application is an ordering node
  • the ordering node may be a block generation device based on a blockchain, or a terminal or a server, which is not specifically limited here.
  • the ordering node associates the data cache queue with the atomic counter, and determines the initial value of the atomic counter according to the specific amount of data to be encapsulated for resource transfer in the data cache queue. Specifically, the ordering node determines the initial quantity of data to be encapsulated for resource transfer in the data cache queue; sets the initial quantity to the initial value of the atomic counter; sets the change rate of the data cache queue to be the same as the value change rate of the atomic counter, where, When the initial number of resource transfer data to be packaged is increased by N, the initial value of the atomic counter is increased by N, or when the initial number of resource transfer data to be packaged is subtracted by N, the initial value of the atomic counter is subtracted by N, where N is an integer.
  • the main function of the atomic counter is to count the data buffer queue.
  • the value of the atomic counter is set to 100.
  • the value of the atomic counter corresponds to the number of transactions to be packaged in the transaction cache queue.
  • the value of the atomic counter changes synchronously. For example, when the number of transactions to be packaged decreases by 20 to 80, then the value of the atomic counter also decreases by 20 to become 80; when the number of transactions to be packaged increases by 15 to become 95, then the value of the atomic counter Also increase by 15 to 95. It can also be a change in the magnitude of other values, which is not specifically limited here.
  • the first thread is used to increase the amount of resource transfer data to be packaged in the data cache queue
  • the second thread is used to reduce the amount of resource transfer data to be packaged in the data cache queue.
  • the ordering node generates a first thread and a second thread.
  • the first thread is used to increase the amount of resource transfer data to be packaged in the data cache queue
  • the second thread is used to reduce the amount of resource transfer data to be packaged in the data cache queue.
  • the first thread may add the data to be encapsulated for resource transfer to the data cache queue
  • the second thread may extract the to-be-encapsulated resource transfer data from the data cache queue. After the first thread and the second thread adjust the data cache queue It is also necessary to synchronize the atomic counter.
  • the first thread and the second thread can modify the atomic counter at the same time, and both can be modified successfully without affecting each other.
  • the ordering node adjusts the amount of data to be encapsulated for resource transfer through the first thread and the second thread, and adjusts the initial value of the atomic counter to the target value. Specifically, the ordering node transfers data by adding P resources to be encapsulated to the data cache queue through the first thread, and increases the initial value W of the atomic counter by P, where W and P are integers; and extracts data from the data cache queue through the second thread.
  • the resource transfer data is put into the block cache module.
  • the initial value W of the atomic counter is 80, that is, there are 80 transactions to be packaged (that is, resource transfer data to be packaged) in the transaction cache queue (ie, data cache queue), and the ordering node according to the preset parameters P, Q, P is 10 and Q is 20.
  • the initial value 80 is adjusted to the target value 70, and the values of P and Q can be set according to the actual situation to obtain different K values, which are not specifically limited here.
  • the atomic counter is a multi-threaded counter, and the multi-line counter is called by an atomic operation. The specific principle can be referred to the prior art, which will not be repeated here.
  • the sorting node packs and encapsulates the resource transfer data to be packaged according to preset conditions, and generates a target block.
  • the ordering node first judges the production rate and the consumption rate; when the production rate of the data cache queue is greater than or equal to the consumption rate, the ordering node judges whether the time interval for generating blocks is equal to the preset duration, or judges the target of the atomic counter Whether the value K is greater than or equal to the preset size; if the time interval for generating blocks is equal to the preset duration, the sorting node will package and cut all the resource transfer data to be packaged in the dicing cache module, and generate the target block, target
  • the block includes the first preset number of resource transfer data to be packaged; if the target value K in the data cache queue is greater than or equal to the preset size, the ordering node packs all the resource transfer data to be packaged in the block cache module Block and generate a target block.
  • the target block includes a second preset number of resource transfer data to be packaged.
  • the ordering node judges whether the target value K of the atomic counter is zero; if the target value K of the atomic counter is zero, the ordering node transfers all the resources to be encapsulated in the block cache module
  • the data is packaged and cut into blocks, and a target block is generated.
  • the target block includes a third preset number of resource transfer data to be packaged.
  • the “rate” in the “production rate” and “consumption rate” refers to the average rate over a period of time.
  • the resource transfer data (ie transactions) consumed is simply entered into the above Speaking of the block cache module, during this period, the consumption rate and the production rate are larger or smaller depends on the rate of the resource transfer request.
  • the consumption rate mainly depends on the processing capabilities of computing hash, signature, IO storage, etc.
  • the production rate mainly depends on the frequency of resource transfer.
  • the production rate is less than the consumption rate, and the counter quickly becomes 0, which will trigger the block; in the high-frequency resource transfer scenario, the production rate is greater than or equal to the consumption rate, and the counter is greater than 0, passing a fixed time or fixed transaction The number triggers dicing.
  • the resource transfer data is cached through the data cache queue, different processes are called to extract the cached resource transfer data to generate blocks, and the atomic counter is adjusted to meet the high throughput requirements and low frequency resources under high frequency resource transfer.
  • the low latency requirement under transfer improves the efficiency of generating blocks.
  • the data cache queue includes data to be encapsulated for resource transfer.
  • the ordering node creates a data cache queue and an atomic counter. Specifically, the ordering node creates a data cache queue to cache the pre-processed resource transfer data to be encapsulated, and generates an atomic counter.
  • the orderer is mainly used to implement the consensus mechanism of the blockchain network, provide a unified resource transfer data sorting and block service for all application clients, and distribute the block to all peer nodes and peer nodes. Undertake the role of processing resource transfer data and storing blocks in the blockchain network.
  • the resource transfer data to be encapsulated refers to the resource transfer data that has been processed by the peer node and has not been added to the block.
  • blockchain is a decentralized system and may carry a large number of financial assets, so it may face a large number of Byzantine failures instead of general failures, while a centralized distributed system Byzantine failure is rarely encountered.
  • the Byzantine fault can refer to the prior art, which will not be repeated here.
  • the execution subject of this application is an ordering node
  • the ordering node may be a block generation device based on a blockchain, or a terminal or a server, which is not specifically limited here.
  • the ordering node obtains a resource transfer data sequence to be packaged, and the resource transfer data sequence to be packaged includes a plurality of resource transfer data to be packaged sequentially arranged in chronological order. Specifically, obtain multiple resource transfer data sent by the client; check multiple resource transfer data to determine whether there is wrong resource transfer data in the multiple resource transfer data; if there are wrong resources in the multiple resource transfer data To transfer data, delete the wrong resource transfer data to obtain multiple resource transfer data after error correction; determine whether the same resource transfer data exists in the multiple resource transfer data after error correction; if there are multiple resources after error correction If there is the same resource transfer data in the transferred data, randomly select one of the same resource transfer data to keep and delete other resource transfer data to obtain multiple resource transfer data after deduplication; transfer multiple resources after deduplication
  • the data is encapsulated to obtain multiple resource transfer data to be packaged; the multiple resource transfer data to be packaged are sorted in chronological order to obtain the resource transfer data sequence to be packaged.
  • Request phase Client C sends a transaction request (ie resource transfer request) to any node, here is the node 0;
  • Preparation stage Node 0 broadcasts after receiving client C's transaction request, and spreads to nodes 1, 2, 3;
  • Preparation stage Nodes 1, 2, 3 receive it and record and broadcast again, that is, node 1 to node 0, 2, 3 broadcast, node 2 broadcasts to nodes 0, 1, 3, node 3 cannot broadcast due to failure;
  • completion stage nodes 0, 1, 2, and 3 are in the preparation stage, if more than a certain number of identical Request, enter the completion stage, broadcast the completion request;
  • feedback stage Nodes 0, 1, 2, and 3 are in the completion stage, and if they receive more than a certain number of identical requests, they will feedback to the client C.
  • the ordering node associates the data buffer queue with the atomic counter, and determines the initial value of the atomic counter according to the specific amount of resource transfer data to be packaged in the resource transfer data sequence to be packaged. Specifically, the ordering node determines the initial quantity of resource transfer data to be packaged in the resource transfer data sequence to be packaged; sets the initial quantity to the initial value of the atomic counter; sets the change rate of the data buffer queue to be the same as the value change rate of the atomic counter , Where, when the initial number of resource transfer data to be packaged adds N, the initial value of the atomic counter is added to N, or when the initial number of resource transfer data to be packaged is subtracted by N, the initial value of the atomic counter is reduced by N, where N is an integer .
  • the main function of the atomic counter is to count the data buffer queue.
  • the value of the atomic counter is set to 100.
  • the value of the atomic counter corresponds to the number of transactions to be packaged in the transaction cache queue.
  • the value of the atomic counter changes synchronously. For example, when the number of transactions to be packaged decreases by 20 to 80, then the value of the atomic counter also decreases by 20 to become 80; when the number of transactions to be packaged increases by 15 to become 95, then the value of the atomic counter Also increase by 15 to 95. It can also be a change in the magnitude of other values, which is not limited here.
  • the first thread is used to increase the amount of resource transfer data to be packaged in the data cache queue
  • the second thread is used to reduce the amount of resource transfer data to be packaged in the data cache queue.
  • the ordering node generates a first thread and a second thread.
  • the first thread is used to increase the amount of resource transfer data to be packaged in the data cache queue
  • the second thread is used to reduce the amount of resource transfer data to be packaged in the data cache queue.
  • the first thread may add the data to be encapsulated for resource transfer to the data cache queue
  • the second thread may extract the to-be-encapsulated resource transfer data from the data cache queue.
  • After the first thread and the second thread adjust the data cache queue It is also necessary to synchronize the atomic counter.
  • the added resource transfer data to be packaged is obtained from the resource transfer data sequence to be packaged.
  • the first thread and the second thread can modify the atomic counter at the same time, and both can be modified successfully without affecting each other.
  • the ordering node adjusts the amount of data to be encapsulated for resource transfer through the first thread and the second thread, and adjusts the initial value of the atomic counter to the target value.
  • the sorting node transfers data by adding P resources to be encapsulated to the data cache queue through the first thread, and increases the initial value W of the atomic counter by P, where W and P are integers; and extracts Q data from the data cache queue through the second thread.
  • the initial value W of the atomic counter is 80, that is, there are 80 transactions to be packaged (that is, resource transfer data to be packaged) in the transaction cache queue (ie, data cache queue), and the ordering node according to the preset parameters P, Q, P is 10 and Q is 20.
  • the first thread can cache 10 transactions to be packaged in the transaction cache queue each time, and the second thread can extract 20 transactions to be packaged from the transaction cache queue each time.
  • the atomic counter is a multi-threaded counter, and the multi-line counter is called by an atomic operation.
  • the specific principle can be referred to the prior art, which will not be repeated here.
  • the sorting node packs and encapsulates the resource transfer data to be packaged according to preset conditions, and generates a target block.
  • the ordering node first judges the production rate and the consumption rate; when the production rate of the data cache queue is greater than or equal to the consumption rate, the ordering node judges whether the time interval for generating blocks is equal to the preset duration, or judges the target of the atomic counter Whether the value K is greater than or equal to the preset size; if the time interval for generating blocks is equal to the preset duration, the sorting node will package and cut all the resource transfer data to be packaged in the dicing cache module, and generate the target block, target
  • the block includes the first preset number of resource transfer data to be packaged; if the target value K in the data cache queue is greater than or equal to the preset size, the ordering node packs all the resource transfer data to be packaged in the block cache module Block and generate a target block.
  • the target block includes a second preset number of resource transfer data to be packaged.
  • the ordering node judges whether the target value K of the atomic counter is zero; if the target value K of the atomic counter is zero, the ordering node transfers all the resources to be encapsulated in the block cache module
  • the data is packaged and cut into blocks, and a target block is generated.
  • the target block includes a third preset number of resource transfer data to be packaged.
  • the “rate” in the “production rate” and “consumption rate” refers to the average rate over a period of time.
  • the resource transfer data (ie transactions) consumed is simply entered into the above Speaking of the block cache module, during this period, the consumption rate and the production rate are larger or smaller depends on the rate of the resource transfer request.
  • the consumption rate mainly depends on the processing capabilities of computing hash, signature, IO storage, etc.
  • the production rate mainly depends on the frequency of resource transfer.
  • the production rate is less than the consumption rate, and the counter quickly becomes 0, which will trigger the block; in the high-frequency resource transfer scenario, the production rate is greater than or equal to the consumption rate, and the counter is greater than 0, passing a fixed time or fixed transaction The number triggers dicing.
  • the resource transfer data is cached through the data cache queue, different processes are called to extract the cached resource transfer data to generate blocks, and the atomic counter is adjusted to meet the high throughput requirements and low frequency resources under high frequency resource transfer.
  • the low latency requirement under transfer improves the efficiency of generating blocks.
  • An embodiment of the block generation device of the chain includes:
  • the creating unit 301 is used to create a data cache queue and an atomic counter, and the data cache queue includes resource transfer data to be encapsulated;
  • the association determination unit 302 is configured to associate the data buffer queue with the atomic counter and determine the initial value of the atomic counter;
  • the generating unit 303 is used to generate a first thread and a second thread.
  • the first thread is used to increase the amount of resource transfer data to be packaged in the data buffer queue
  • the second thread is used to reduce the amount of resource transfer data to be packaged in the data buffer queue ;
  • the adjustment unit 304 is configured to adjust the amount of resource transfer data to be encapsulated through the first thread and the second thread, and adjust the initial value of the atomic counter to the target value;
  • the encapsulation generating unit 305 packages and encapsulates the resource transfer data to be encapsulated according to preset conditions to generate a target block.
  • the resource transfer data is cached through the data cache queue, different processes are called to extract the cached resource transfer data to generate blocks, and the atomic counter is adjusted to meet the high throughput requirements and low frequency resources under high frequency resource transfer.
  • the low latency requirement under transfer improves the efficiency of generating blocks.
  • FIG. 4 another embodiment of the block generation device based on the block chain in the embodiment of the present application includes:
  • the creating unit 301 is used to create a data cache queue and an atomic counter, and the data cache queue includes resource transfer data to be encapsulated;
  • the association determination unit 302 is configured to associate the data buffer queue with the atomic counter and determine the initial value of the atomic counter;
  • the generating unit 303 is used to generate a first thread and a second thread.
  • the first thread is used to increase the amount of resource transfer data to be packaged in the data buffer queue
  • the second thread is used to reduce the amount of resource transfer data to be packaged in the data buffer queue ;
  • the adjustment unit 304 is configured to adjust the amount of resource transfer data to be encapsulated through the first thread and the second thread, and adjust the initial value of the atomic counter to the target value;
  • the encapsulation generating unit 305 packages and encapsulates the resource transfer data to be encapsulated according to preset conditions to generate a target block.
  • association determining unit 302 is specifically configured to:
  • the adjustment unit 304 is specifically configured to:
  • the package generation unit 305 is specifically used to:
  • the time interval of generating blocks is equal to the preset time length; if the time interval of generating blocks is equal to the preset time length, all the blocks to be packaged in the block cache module are cut. The resource transfer data is packaged and cut into blocks, and a target block is generated.
  • the target block includes a first preset number of resource transfer data to be packaged; or, when the production rate of the data cache queue is greater than or equal to the consumption rate, the atomic counter is determined Whether the target value K is greater than or equal to the preset size; if the target value K in the data cache queue is greater than or equal to the preset size, then all the resource transfer data to be packaged in the dicing cache module is packaged and diced, and the target area is generated Block, the target block includes a second preset number of resource transfer data to be encapsulated; or, when the production rate of the data cache queue is less than the consumption rate, determine whether the target value K of the atomic counter is zero; if the target value K of the atomic counter If it is zero, all the resource transfer data to be encapsulated in the dicing cache module is packaged and diced, and a target block is generated.
  • the target block includes a third preset number of resource transfer data to be packaged.
  • the block generation device based on blockchain further includes:
  • the obtaining unit 306 is configured to obtain a resource transfer data sequence to be packaged, and the resource transfer data sequence to be packaged includes a plurality of resource transfer data to be packaged sequentially arranged in chronological order.
  • the acquiring unit 306 includes:
  • the obtaining subunit 3061 is used to obtain multiple resource transfer data sent by the client;
  • the first judging subunit 3062 is configured to check multiple resource transfer data and judge whether there is wrong resource transfer data in the multiple resource transfer data;
  • the deleting subunit 3063 if there is wrong resource transfer data in the multiple resource transfer data, it is used to delete the wrong resource transfer data to obtain multiple resource transfer data after error correction;
  • the second judging subunit 3064 is used to judge whether the same resource transfer data exists in the multiple resource transfer data after error correction;
  • the saving and deleting sub-unit 3065 if the same resource transfer data exists in the multiple resource transfer data after error correction, it is used to randomly select one of the same resource transfer data to retain and delete other resource transfer data, after the duplicate is obtained Transfer data from multiple resources;
  • the encapsulation subunit 3066 is configured to encapsulate multiple resource transfer data after deduplication to obtain multiple resource transfer data to be packaged;
  • the sorting subunit 3067 is used for sorting a plurality of resource transfer data to be packaged in chronological order to obtain a resource transfer data sequence to be packaged.
  • the first judging subunit 3062 is specifically configured to:
  • the resource transfer data is cached through the data cache queue, different processes are called to extract the cached resource transfer data to generate blocks, and the atomic counter is adjusted to meet the high throughput requirements and low frequency resources under high frequency resource transfer.
  • the low latency requirement under transfer improves the efficiency of generating blocks.
  • FIG. 5 is a schematic structural diagram of a block generation device based on a blockchain provided by an embodiment of the present application.
  • the block generation device 500 based on a blockchain may have relatively large differences due to different configurations or performances, and may include One or more processors (central processing units, CPU) 501 (for example, one or more processors) and memory 509, and one or more storage media 508 for storing application programs 507 or data 506 (for example, one or more data storage Storage device).
  • the memory 509 and the storage medium 508 may be short-term storage or persistent storage.
  • the program stored in the storage medium 508 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the block generation device based on the blockchain.
  • the processor 501 may be configured to communicate with the storage medium 508, and execute a series of instruction operations in the storage medium 508 on the block generation device 500 based on the blockchain.
  • Blockchain-based block generation device 500 may also include one or more power supplies 502, one or more wired or wireless network interfaces 503, one or more input and output interfaces 504, and/or, one or more operating systems 505, such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD, etc.
  • operating systems 505 such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD, etc.
  • the processor 501 can execute the functions of the creation unit 301, the association determination unit 302, the generation unit 303, the adjustment unit 304, the package generation unit 305, and the acquisition unit 306 in the foregoing embodiment.
  • the present application also provides a computer-readable storage medium.
  • the computer-readable storage medium may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium.
  • the computer-readable storage medium stores computer instructions, and when the computer instructions are executed on the computer, the computer executes the following steps:
  • the data cache queue includes the transfer data of the resource to be packaged
  • the first thread is used to increase the amount of resource transfer data to be encapsulated in the data cache queue
  • the second thread is used to reduce the amount of resource transfer data to be encapsulated in the data cache queue
  • the resource transfer data to be packaged is packaged and packaged according to preset conditions to generate a target block.
  • the disclosed system, device, and method may be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components can be combined or It can be integrated into another system, or some features can be ignored or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

一种基于区块链的区块生成方法、装置、设备及存储介质,涉及区块链技术领域,用于满足高频资源转移下的高吞吐要求和低频资源转移下的低延时要求,提高了生成区块的效率。该方法包括:创建数据缓存队列和原子计数器,数据缓存队列包括待封装资源转移数据(101,201);将数据缓存队列和原子计数器进行关联,并确定原子计数器的初始值(102,203);生成第一线程和第二线程,第一线程用于增加数据缓存队列中待封装资源转移数据的数量,第二线程用于减少数据缓存队列中待封装资源转移数据的数量(103,204);通过第一线程和第二线程调整待封装资源转移数据的数量,并将原子计数器的初始值调整为目标值(104,205);根据预置条件将待封装资源转移数据进行打包封装,生成目标区块(105,206)。

Description

基于区块链的区块生成方法、装置、设备及存储介质
本申请要求于2019年5月22日提交中国专利局、申请号为201910426729.8、发明名称为“基于区块链的区块生成方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在申请中。
技术领域
本申请涉及区块链技术领域,尤其涉及基于区块链的区块生成方法、装置、设备及存储介质。
背景技术
区块链是一种按照时间顺序将数据区块以顺序相连的方式组合成的一种链式数据结构,并以密码学方式保证的不可篡改和不可伪造的分布式账本。区块链技术是指通过去中心化和去信任的方式集体维护一个可靠数据库的技术方案。简单来说,区块链技术是一种全民参与记账的方式。所有系统的背后都有一个数据库,可以把数据库看成一个大账本,目前是各自记各自的账。但是在区块链系统中,每个人都可以来进行记账(资源转移),系统会选择记账最快最好的人,把他记录的内容写到账本,并将者账本内容发给系统内所有人备份。
在区块链中,通过共识节点产生区块,为了提升资源转移的吞吐率,共识节点采用批处理资源转移数据的方式,通过等待固定时间或者固定个数的资源转移数据来触发生产区块,但这势必延长了每笔资源转移数据的确认时间;但如果减少等待的固定时间或交易数,又会降低资源转移数据的吞吐率。因此,面临了资源转移数据高吞吐率和资源转移数据低延时不可兼得的难题。
在实际应用场景中,发明人意识到,资源转移频率往往是动态变化的,高频应该高吞吐,低频应该低延时,但目前这种区块生成策略却很难自适应这样的场景。
发明内容
本申请提供了基于区块链的区块生成方法、装置、设备及存储介质,用于满足高频资源转移下的高吞吐要求和低频资源转移下的低延时要求,提高了生成区块的效率。
为实现上述目的,本申请第一方面提供一种基于区块链的区块生成方法,包括:创建数据缓存队列和原子计数器,所述数据缓存队列包括待封装资源转移数据;将所述数据缓存队列和所述原子计数器进行关联,并确定所述原子计数器的初始值;生成第一线程和第二线程,所述第一线程用于增加所述数据缓存队列中所述待封装资源转移数据的数量,所述第二线程用于减少所述数据缓存队列中所述待封装资源转移数据的数量;通过所述第一线程和所述第二线程 调整所述待封装资源转移数据的数量,并将所述原子计数器的初始值调整为目标值;根据预置条件将所述待封装资源转移数据进行打包封装,生成目标区块。
本申请第二方面提供了一种基于区块链的区块生成装置,包括:创建单元,用于创建数据缓存队列和原子计数器,所述数据缓存队列包括待封装资源转移数据;关联确定单元,用于将所述数据缓存队列和所述原子计数器进行关联,并确定所述原子计数器的初始值;生成单元,用于生成第一线程和第二线程,所述第一线程用于增加所述数据缓存队列中所述待封装资源转移数据的数量,所述第二线程用于减少所述数据缓存队列中所述待封装资源转移数据的数量;调整单元,用于通过所述第一线程和所述第二线程调整所述待封装资源转移数据的数量,并将所述原子计数器的初始值调整为目标值;封装生成单元,根据预置条件将所述待封装资源转移数据进行打包封装,生成目标区块。
本申请第三方面提供了一种基于区块链的区块生成设备,包括:存储器和至少一个处理器,所述存储器中存储有指令,所述存储器和所述至少一个处理器通过线路互联;所述至少一个处理器调用所述存储器中的所述指令,以使得所述一种基于区块链的区块生成设备执行上述第一方面所述的方法。
本申请的第四方面提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机指令,当所述计算机指令在计算机上运行时,使得计算机执行上述第一方面所述的方法。
本申请提供的技术方案中,创建数据缓存队列和原子计数器,所述数据缓存队列包括待封装资源转移数据;将所述数据缓存队列和所述原子计数器进行关联,并确定所述原子计数器的初始值;生成第一线程和第二线程,所述第一线程用于增加所述数据缓存队列中所述待封装资源转移数据的数量,所述第二线程用于减少所述数据缓存队列中所述待封装资源转移数据的数量;通过所述第一线程和所述第二线程调整所述待封装资源转移数据的数量,并将所述原子计数器的初始值调整为目标值;根据预置条件将所述待封装资源转移数据进行打包封装,生成目标区块。本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征和优点将从说明书、附图以及权利要求书变得明显。本申请实施例,通过数据缓存队列缓存资源转移数据,调用不同的进程对缓存的资源转移数据进行提取生成区块,并对原子计数器进行调整,满足高频资源转移下的高吞吐要求和低频资源转移下的低延时要求,提高了生成区块的效率。
附图说明
图1为本申请实施例中基于区块链的区块生成方法的一个实施例示意图;
图2为本申请实施例中基于区块链的区块生成方法的另一个实施例示意图;
图3为本申请实施例中基于区块链的区块生成装置的一个实施例示意图;
图4为本申请实施例中基于区块链的区块生成装置的另一个实施例示意图;
图5为本申请实施例中基于区块链的区块生成设备的一个实施例示意图。
具体实施方式
本申请提供了基于区块链的区块生成方法、装置、设备及存储介质,用于满足高频资源转移下的高吞吐要求和低频资源转移下的低延时要求,提高了生成区块的效率。
为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例进行描述。
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的实施例能够以除了在这里图示或描述的内容以外的顺序实施。此外,术语“包括”或“具有”及其任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
请参阅图1,本申请实施例提供的基于区块链的区块生成方法的流程图,具体包括:
101、创建数据缓存队列和原子计数器,数据缓存队列包括待封装资源转移数据。
排序节点创建数据缓存队列和原子计数器。具体的,排序节点创建一个数据缓存队列,用来缓存预处理后的待封装资源转移数据,并生成一个原子计数器。其中,排序节点(orderer)主要用来实现区块链网络的共识机制,为所有的应用客户端提供统一的资源转移数据排序及切块服务,并将区块分发到所有的peer节点,peer节点在区块链网络中承担处理资源转移数据、存储区块的角色。其中,待封装资源转移数据是指已经过peer节点处理过,且还未加入到区块中的资源转移数据。
需要说明的是,共识机制是区块链的核心算法,因为分布式系统的数据分散在各个参与节点中,这些分散的数据必须通过一种算法来保持一致性,否则系统将无法正常工作。与传统的分布式系统不同,区块链是一个去中心化的系统,并且可能会承载大量的金融资产,所以它可能会面临大量的拜占庭故障而非一般性故障,而中心化的分布式系统则很少遇到拜占庭故障。拜占庭故障可以参照现有技术,此处不再赘述。
可以理解的是,本申请的执行主体为排序节点,排序节点可以为基于区块链的区块生成装置,还可以是终端或者服务器,具体此处不做限定。
102、将数据缓存队列和原子计数器进行关联,并确定原子计数器的初始值。
排序节点将数据缓存队列和原子计数器进行关联,并根据数据缓存队列中的待封装资源转移数据的具体数量确定原子计数器的初始值。具体的,排序节点确定数据缓存队列中的待封装资源转移数据的初始数量;将初始数量设置为原子计数器的初始值;设置数据缓存队列的数量变化速率与原子计数器的值变化速率相同,其中,当待封装资源转移数据的初始数量加N时,原子计数器的初始值加N,或者,当待封装资源转移数据的初始数量减N时,原子计数器的初始值减N,N为整数。原子计数器主要作用就是对数据缓存队列进行计数。
例如,当交易缓存队列(即数据缓存队列)中存在100个待封装交易(即待封装资源转移数据)时,则将原子计数器的值设置为100。原子计数器的值与交易缓存队列中的待封装交易的数量对应,当交易缓存队列中的待封装交易的数量发生变化时,原子计数器的值进行同步变化。例如,当待封装交易的数量减少了20,变为80,那么原子计数器的值也要减少20,变为80;当待封装交易的数量又增加了15,变为95,那么原子计数器的值也要增加15,变为95。还可以是其他数值大小的变化,具体此处不做限定。
103、生成第一线程和第二线程,第一线程用于增加数据缓存队列中待封装资源转移数据的数量,第二线程用于减少数据缓存队列中待封装资源转移数据的数量。
排序节点生成第一线程和第二线程,第一线程用于增加数据缓存队列中待封装资源转移数据的数量,第二线程用于减少数据缓存队列中待封装资源转移数据的数量。具体的,第一线程可以向数据缓存队列中添加待封装资源转移数据,第二线程可以从数据缓存队列中提取待封装资源转移数据,第一线程和第二线程在对数据缓存队列进行调整后也需要对原子计数器进行同步调整。
需要说明的是,因为是原子计数器,第一线程和第二线程可以同时修改此原子计数器,且都能修改成功,不会互相影响。
104、通过第一线程和第二线程调整待封装资源转移数据的数量,并将原子计数器的初始值调整为目标值。
排序节点通过第一线程和第二线程调整待封装资源转移数据的数量,并将原子计数器的初始值调整为目标值。具体的,排序节点通过第一线程向数据缓存队列中增加P个的待封装资源转移数据,并将原子计数器的初始值W增加P,W、P为整数;通过第二线程从数据缓存队列提取Q个的待封装资源转移数据,并将原子计数器的初始值W减少Q,Q为整数;得到原子计数器的目标值K,其中,K=W+P-Q,K为整数;将Q个的待封装资源转移数据放入切块缓存模块中。
例如,当原子计数器的初始值W为80时,即交易缓存队列(即数据缓存队列)中存在80个待封装交易(即待封装资源转移数据),排序节点根据预先 设置的参数P、Q,P为10,Q为20,第一线程每次可以向交易缓存队列中缓存10个待封装交易,而第而线程每次可以从交易缓存队列中提取20个待封装交易,那么,在第一线程和第二线程执行完一次后,通过K=W+P-Q计算得到,80+10-20=70,交易缓存队列中存在70个待封装的交易。即将初始值80调整为目标值70,P、Q的取值可以根据实际情况进行设置,从而得到不同的K值,具体此处不做限定。其中,原子计数器为多线程计数器,该多线计数器通过原子操作进行调用,具体原理可以参照现有技术,此处不再赘述。
105、根据预置条件将待封装资源转移数据进行打包封装,生成目标区块。
排序节点根据预置条件将待封装资源转移数据进行打包封装,生成目标区块。具体的,首先排序节点判断生产速率和消费速率的大小;当数据缓存队列的生产速率大于或等于消费速率时,排序节点判断生成区块的时间间隔是否等于预置时长,或判断原子计数器的目标值K是否大于或等于预置大小;若生成区块的时间间隔等于预置时长,则排序节点将切块缓存模块中所有的待封装资源转移数据进行打包切块,并生成目标区块,目标区块包括第一预置数目的待封装资源转移数据;若数据缓存队列中的目标值K大于或等于预置大小,则排序节点将切块缓存模块中所有的待封装资源转移数据进行打包切块,并生成目标区块,目标区块包括第二预置数目的待封装资源转移数据。
当数据缓存队列的生产速率小于消费速率时,排序节点判断原子计数器的目标值K是否为零;若原子计数器的目标值K为零,则排序节点将切块缓存模块中所有的待封装资源转移数据进行打包切块,并生成目标区块,目标区块包括第三预置数目的待封装资源转移数据。
可以理解的是,判断生成区块的时间间隔是否等于预置时长和判断原子计数器的目标值K是否大于或等于预置大小之间没有特定的先后顺序,可以同时判断,也可以依次判断,具体此处不做限定。
需要说明的是,“生产速率”和“消费速率”中的“速率”指的是一段时间的平均速率,在生产区块之前,消费出来的资源转移数据(即交易)只是简单的进入上面所说的切块缓存模块,这期间消费速率和生产速率孰大孰小取决于资源转移请求的速率,其中,消费速率主要取决于:计算Hash、签名、IO存储等处理能力。而生产速率主要取决于资源转移频率。在低频资源转移场景下,生产速率小于消费速率,计数器很快为0,会触发切块;在高频资源转移场景下,生产速率大于或等于消费速率,计数器大于0,通过固定时间或固定交易个数触发切块。
本申请实施例,通过数据缓存队列缓存资源转移数据,调用不同的进程对缓存的资源转移数据进行提取生成区块,并对原子计数器进行调整,满足高频资源转移下的高吞吐要求和低频资源转移下的低延时要求,提高了生成区块的效率。
请参阅图2,本申请实施例提供的基于区块链的区块生成方法的另一个流 程图,具体包括:
201、创建数据缓存队列和原子计数器,数据缓存队列包括待封装资源转移数据。
排序节点创建数据缓存队列和原子计数器。具体的,排序节点创建一个数据缓存队列,用来缓存预处理后的待封装资源转移数据,并生成一个原子计数器。其中,排序节点(orderer)主要用来实现区块链网络的共识机制,为所有的应用客户端提供统一的资源转移数据排序及切块服务,并将区块分发到所有的peer节点,peer节点在区块链网络中承担处理资源转移数据、存储区块的角色。其中,待封装资源转移数据是指已经过peer节点处理过,且还未加入到区块中的资源转移数据。
需要说明的是,共识机制是区块链的核心算法,因为分布式系统的数据分散在各个参与节点中,这些分散的数据必须通过一种算法来保持一致性,否则系统将无法正常工作。与传统的分布式系统不同,区块链是一个去中心化的系统,并且可能会承载大量的金融资产,所以它可能会面临大量的拜占庭故障而非一般性故障,而中心化的分布式系统则很少遇到拜占庭故障。拜占庭故障可以参照现有技术,此处不再赘述。
可以理解的是,本申请的执行主体为排序节点,排序节点可以为基于区块链的区块生成装置,还可以是终端或者服务器,具体此处不做限定。
202、获取待封装资源转移数据序列。
排序节点获取待封装资源转移数据序列,该待封装资源转移数据序列中包括按照时间顺序依次排列的多个待封装资源转移数据。具体的,获取客户端发送的多个资源转移数据;对多个资源转移数据进行校验,判断多个资源转移数据中是否存在错误的资源转移数据;若多个资源转移数据中存在错误的资源转移数据,则将错误的资源转移数据删除,得到纠错后的多个资源转移数据;判断纠错后的多个资源转移数据中是否存在相同的资源转移数据;若纠错后的多个资源转移数据中存在相同的资源转移数据,则在相同的资源转移数据中随机选择一个进行保留并删除其他资源转移数据,得到去重后的多个资源转移数据;将去重后的多个资源转移数据进行封装,得到多个待封装资源转移数据;对多个待封装资源转移数据按照时间顺序进行排序,得到待封装资源转移数据序列。
其中,判断多个资源转移数据中是否存在错误的资源转移数据的过程包括:在多个资源转移数据中确定目标资源转移数据;将目标资源转移数据的资源转移请求向网络中其他节点进行广播,网络中节点总数为X;重新获取各个其他节点转发的目标资源转移数据的资源转移请求,确定接收到的目标资源转移数据的资源转移请求的总数量Y;确定故障节点数量Z,其中,Z=X-Y-1;判断X是否满足条件X≥3Z+1;若X不满足条件X≥3Z+1,确定多个资源转移数据中存在错误的资源转移数据;若X满足条件X≥3Z+1,则确定多个资源转移 数据中不存在错误的资源转移数据。
例如,假设C为发送请求的客户端,0123为网络中的节点,3为故障节点,具体步骤如下:请求阶段:客户端C发送交易请求(即资源转移请求)到任意一节点,这里是节点0;预备阶段:节点0收到客户端C的交易请求后进行广播,扩散至节点1、2、3;准备阶段:节点1、2、3收到后记录并再次广播,即节点1向节点0、2、3进行广播,节点2向节点0、1、3进行广播,节点3因为故障无法广播;完成阶段:节点0、1、2、3在准备阶段,若收到超过一定数量的相同请求,则进入完成阶段,广播完成请求;反馈阶段:节点0、1、2、3在完成阶段,若收到超过一定数量的相同请求,则对客户端C进行反馈。可以看出,在X≥3Z+1的情況下可以确保交易(即资源转移数据)的一致性,X为节点的总数,Z为故障节点的总数。而不满足X≥3Z+1的情况下,会产生错误的交易。
203、将数据缓存队列和原子计数器进行关联,并根据待封装资源转移数据序列确定原子计数器的初始值。
排序节点将数据缓存队列和原子计数器进行关联,并根据待封装资源转移数据序列中的待封装资源转移数据的具体数量确定原子计数器的初始值。具体的,排序节点确定待封装资源转移数据序列中的待封装资源转移数据的初始数量;将初始数量设置为原子计数器的初始值;设置数据缓存队列的数量变化速率与原子计数器的值变化速率相同,其中,当待封装资源转移数据的初始数量加N时,原子计数器的初始值加N,或者,当待封装资源转移数据的初始数量减N时,原子计数器的初始值减N,N为整数。原子计数器主要作用就是对数据缓存队列进行计数。
例如,当待封装交易序列(即数据缓存队列)中存在100个待封装交易(即待封装资源转移数据)时,则将原子计数器的值设置为100。原子计数器的值与交易缓存队列中的待封装交易的数量对应,当交易缓存队列中的待封装交易的数量发生变化时,原子计数器的值进行同步变化。例如,当待封装交易的数量减少了20,变为80,那么原子计数器的值也要减少20,变为80;当待封装交易的数量又增加了15,变为95,那么原子计数器的值也要增加15,变为95。还可以是其他数值大小的变化,具体此处不做限定。
204、生成第一线程和第二线程,第一线程用于增加数据缓存队列中待封装资源转移数据的数量,第二线程用于减少数据缓存队列中待封装资源转移数据的数量。
排序节点生成第一线程和第二线程,第一线程用于增加数据缓存队列中待封装资源转移数据的数量,第二线程用于减少数据缓存队列中待封装资源转移数据的数量。具体的,第一线程可以向数据缓存队列中添加待封装资源转移数据,第二线程可以从数据缓存队列中提取待封装资源转移数据,第一线程和第二线程在对数据缓存队列进行调整后也需要对原子计数器进行同步调整。添加 的待封装资源转移数据从待封装资源转移数据序列中得到。
需要说明的是,因为是原子计数器,第一线程和第二线程可以同时修改此原子计数器,且都能修改成功,不会互相影响。
205、通过第一线程和第二线程调整待封装资源转移数据的数量,并将原子计数器的初始值调整为目标值。
排序节点通过第一线程和第二线程调整待封装资源转移数据的数量,并将原子计数器的初始值调整为目标值。排序节点通过第一线程向数据缓存队列中增加P个的待封装资源转移数据,并将原子计数器的初始值W增加P,W、P为整数;通过第二线程从数据缓存队列提取Q个的待封装资源转移数据,并将原子计数器的初始值W减少Q,Q为整数;得到原子计数器的目标值K,其中,K=W+P-Q,K为整数;将Q个的待封装资源转移数据放入切块缓存模块中。
例如,当原子计数器的初始值W为80时,即交易缓存队列(即数据缓存队列)中存在80个待封装交易(即待封装资源转移数据),排序节点根据预先设置的参数P、Q,P为10,Q为20,第一线程每次可以向交易缓存队列中缓存10个待封装交易,而第而线程每次可以从交易缓存队列中提取20个待封装交易,那么,在第一线程和第二线程执行完一次后,通过K=W+P-Q计算得到,80+10-20=70,交易缓存队列中存在70个待封装的交易。即将初始值80调整为目标值70,P、Q的取值可以根据实际情况进行设置,从而得到不同的K值,具体此处不做限定。
其中,原子计数器为多线程计数器,该多线计数器通过原子操作进行调用,具体原理可以参照现有技术,此处不再赘述。
206、根据预置条件将待封装资源转移数据进行打包封装,生成目标区块。
排序节点根据预置条件将待封装资源转移数据进行打包封装,生成目标区块。具体的,首先排序节点判断生产速率和消费速率的大小;当数据缓存队列的生产速率大于或等于消费速率时,排序节点判断生成区块的时间间隔是否等于预置时长,或判断原子计数器的目标值K是否大于或等于预置大小;若生成区块的时间间隔等于预置时长,则排序节点将切块缓存模块中所有的待封装资源转移数据进行打包切块,并生成目标区块,目标区块包括第一预置数目的待封装资源转移数据;若数据缓存队列中的目标值K大于或等于预置大小,则排序节点将切块缓存模块中所有的待封装资源转移数据进行打包切块,并生成目标区块,目标区块包括第二预置数目的待封装资源转移数据。
当数据缓存队列的生产速率小于消费速率时,排序节点判断原子计数器的目标值K是否为零;若原子计数器的目标值K为零,则排序节点将切块缓存模块中所有的待封装资源转移数据进行打包切块,并生成目标区块,目标区块包括第三预置数目的待封装资源转移数据。
可以理解的是,判断生成区块的时间间隔是否等于预置时长和判断原子计数器的目标值K是否大于或等于预置大小之间没有特定的先后顺序,可以同时 判断,也可以依次判断,具体此处不做限定。
需要说明的是,“生产速率”和“消费速率”中的“速率”指的是一段时间的平均速率,在生产区块之前,消费出来的资源转移数据(即交易)只是简单的进入上面所说的切块缓存模块,这期间消费速率和生产速率孰大孰小取决于资源转移请求的速率,其中,消费速率主要取决于:计算Hash、签名、IO存储等处理能力。而生产速率主要取决于资源转移频率。在低频资源转移场景下,生产速率小于消费速率,计数器很快为0,会触发切块;在高频资源转移场景下,生产速率大于或等于消费速率,计数器大于0,通过固定时间或固定交易个数触发切块。
本申请实施例,通过数据缓存队列缓存资源转移数据,调用不同的进程对缓存的资源转移数据进行提取生成区块,并对原子计数器进行调整,满足高频资源转移下的高吞吐要求和低频资源转移下的低延时要求,提高了生成区块的效率。
上面对本申请实施例中基于区块链的区块生成方法进行了描述,下面对本申请实施例中基于区块链的区块生成装置进行描述,请参阅图3,本申请实施例中基于区块链的区块生成装置的一个实施例包括:
创建单元301,用于创建数据缓存队列和原子计数器,数据缓存队列包括待封装资源转移数据;
关联确定单元302,用于将数据缓存队列和原子计数器进行关联,并确定原子计数器的初始值;
生成单元303,用于生成第一线程和第二线程,第一线程用于增加数据缓存队列中待封装资源转移数据的数量,第二线程用于减少数据缓存队列中待封装资源转移数据的数量;
调整单元304,用于通过第一线程和第二线程调整待封装资源转移数据的数量,并将原子计数器的初始值调整为目标值;
封装生成单元305,根据预置条件将待封装资源转移数据进行打包封装,生成目标区块。
本申请实施例,通过数据缓存队列缓存资源转移数据,调用不同的进程对缓存的资源转移数据进行提取生成区块,并对原子计数器进行调整,满足高频资源转移下的高吞吐要求和低频资源转移下的低延时要求,提高了生成区块的效率。
请参阅图4,本申请实施例中基于区块链的区块生成装置的另一个实施例包括:
创建单元301,用于创建数据缓存队列和原子计数器,数据缓存队列包括待封装资源转移数据;
关联确定单元302,用于将数据缓存队列和原子计数器进行关联,并确定原子计数器的初始值;
生成单元303,用于生成第一线程和第二线程,第一线程用于增加数据缓存队列中待封装资源转移数据的数量,第二线程用于减少数据缓存队列中待封装资源转移数据的数量;
调整单元304,用于通过第一线程和第二线程调整待封装资源转移数据的数量,并将原子计数器的初始值调整为目标值;
封装生成单元305,根据预置条件将待封装资源转移数据进行打包封装,生成目标区块。
可选的,关联确定单元302具体用于:
确定数据缓存队列中的待封装资源转移数据的初始数量;将初始数量设置为原子计数器的初始值;设置数据缓存队列的数量变化速率与原子计数器的值变化速率相同,其中,当待封装资源转移数据的初始数量加N时,原子计数器的初始值加N,或者,当待封装资源转移数据的初始数量减N时,原子计数器的初始值减N,N为整数。
可选的,调整单元304具体用于:
确定数据缓存队列中的待封装资源转移数据的初始数量;通过第一线程向数据缓存队列中增加P个的待封装资源转移数据,并将原子计数器的初始值W增加P,W、P为整数;通过第二线程从数据缓存队列提取Q个的待封装资源转移数据,并将原子计数器的初始值W减少Q,Q为整数;得到原子计数器的目标值K,其中,K=W+P-Q,K为整数;将Q个的待封装资源转移数据放入切块缓存模块中。
可选的,封装生成单元305具体还用于:
当数据缓存队列的生产速率大于或等于消费速率时,判断生成区块的时间间隔是否等于预置时长;若生成区块的时间间隔等于预置时长,则将切块缓存模块中所有的待封装资源转移数据进行打包切块,并生成目标区块,目标区块包括第一预置数目的待封装资源转移数据;或者,当数据缓存队列的生产速率大于或等于消费速率时,判断原子计数器的目标值K是否大于或等于预置大小;若数据缓存队列中的目标值K大于或等于预置大小,则将切块缓存模块中所有的待封装资源转移数据进行打包切块,并生成目标区块,目标区块包括第二预置数目的待封装资源转移数据;或者,当数据缓存队列的生产速率小于消费速率时,判断原子计数器的目标值K是否为零;若原子计数器的目标值K为零,则将切块缓存模块中所有的待封装资源转移数据进行打包切块,并生成目标区块,目标区块包括第三预置数目的待封装资源转移数据。
可选的,基于区块链的区块生成装置还包括:
获取单元306,用于获取待封装资源转移数据序列,待封装资源转移数据序列中包括按照时间顺序依次排列的多个待封装资源转移数据。
可选的,获取单元306包括:
获取子单元3061,用于获取客户端发送的多个资源转移数据;
第一判断子单元3062,用于对多个资源转移数据进行校验,判断多个资源转移数据中是否存在错误的资源转移数据;
删除子单元3063,若多个资源转移数据中存在错误的资源转移数据,则用于将错误的资源转移数据删除,得到纠错后的多个资源转移数据;
第二判断子单元3064,用于判断纠错后的多个资源转移数据中是否存在相同的资源转移数据;
保存删除子单元3065,若纠错后的多个资源转移数据中存在相同的资源转移数据,则用于在相同的资源转移数据中随机选择一个进行保留并删除其他资源转移数据,得到去重后的多个资源转移数据;
封装子单元3066,用于将去重后的多个资源转移数据进行封装,得到多个待封装资源转移数据;
排序子单元3067,用于对多个待封装资源转移数据按照时间顺序进行排序,得到待封装资源转移数据序列。
可选的,第一判断子单元3062具体用于:
在多个资源转移数据中确定目标资源转移数据;将目标资源转移数据的资源转移请求向网络中其他节点进行广播,网络中节点总数为X;重新获取各个其他节点转发的目标资源转移数据的资源转移请求,确定接收到的目标资源转移数据的资源转移请求的总数量Y;确定故障节点数量Z,其中,Z=X-Y-1;判断X是否满足条件X≥3Z+1;若X不满足条件X≥3Z+1,则确定多个资源转移数据中存在错误的资源转移数据;若X满足条件X≥3Z+1,则确定多个资源转移数据中不存在错误的资源转移数据。
本申请实施例,通过数据缓存队列缓存资源转移数据,调用不同的进程对缓存的资源转移数据进行提取生成区块,并对原子计数器进行调整,满足高频资源转移下的高吞吐要求和低频资源转移下的低延时要求,提高了生成区块的效率。
上面图3至图4从模块化功能实体的角度对本申请实施例中的基于区块链的区块生成装置进行详细描述,下面从硬件处理的角度对本申请实施例中基于区块链的区块生成设备进行详细描述。
图5是本申请实施例提供的一种基于区块链的区块生成设备的结构示意图,该基于区块链的区块生成设备500可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上处理器(central processing units,CPU)501(例如,一个或一个以上处理器)和存储器509,一个或一个以上存储应用程序507或数据506的存储介质508(例如一个或一个以上海量存储设备)。其中,存储器509和存储介质508可以是短暂存储或持久存储。存储在存储介质508的程序可以包括一个或一个以上模块(图示没标出),每个模块可以包括对基于区块链的区块生成设备中的一系列指令操作。更进一步地,处理器501可以设置为与存储介质508通信,在基于区块链的区块生成设备500上执行存 储介质508中的一系列指令操作。
基于区块链的区块生成设备500还可以包括一个或一个以上电源502,一个或一个以上有线或无线网络接口503,一个或一个以上输入输出接口504,和/或,一个或一个以上操作系统505,例如Windows Serve,Mac OS X,Unix,Linux,FreeBSD等等。本领域技术人员可以理解,图5中示出的基于区块链的区块生成设备结构并不构成对基于区块链的区块生成设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。处理器501可以执行上述实施例中创建单元301、关联确定单元302、生成单元303、调整单元304、封装生成单元305和获取单元306的功能。
本申请还提供一种计算机可读存储介质,该计算机可读存储介质可以为非易失性计算机可读存储介质,也可以为易失性计算机可读存储介质。计算机可读存储介质存储有计算机指令,当所述计算机指令在计算机上运行时,使得计算机执行如下步骤:
创建数据缓存队列和原子计数器,数据缓存队列包括待封装资源转移数据;
将数据缓存队列和原子计数器进行关联,并确定原子计数器的初始值;
生成第一线程和第二线程,第一线程用于增加数据缓存队列中待封装资源转移数据的数量,第二线程用于减少数据缓存队列中待封装资源转移数据的数量;
通过第一线程和第二线程调整待封装资源转移数据的数量,并将原子计数器的初始值调整为目标值;
根据预置条件将待封装资源转移数据进行打包封装,生成目标区块。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
以上所述,以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。

Claims (20)

  1. 一种基于区块链的区块生成方法,包括:
    创建数据缓存队列和原子计数器,所述数据缓存队列包括待封装资源转移数据;
    将所述数据缓存队列和所述原子计数器进行关联,并确定所述原子计数器的初始值;
    生成第一线程和第二线程,所述第一线程用于增加所述数据缓存队列中所述待封装资源转移数据的数量,所述第二线程用于减少所述数据缓存队列中所述待封装资源转移数据的数量;
    通过所述第一线程和所述第二线程调整所述待封装资源转移数据的数量,并将所述原子计数器的初始值调整为目标值;
    根据预置条件将所述待封装资源转移数据进行打包封装,生成目标区块。
  2. 根据权利要求1所述的基于区块链的区块生成方法,所述将所述数据缓存队列和所述原子计数器进行关联,并确定所述原子计数器的初始值包括:
    确定所述数据缓存队列中的所述待封装资源转移数据的初始数量;
    将所述初始数量设置为所述原子计数器的初始值;
    设置所述数据缓存队列的数量变化速率与所述原子计数器的值变化速率相同,其中,当所述待封装资源转移数据的初始数量加N时,所述原子计数器的初始值加N,或者,当所述待封装资源转移数据的初始数量减N时,所述原子计数器的初始值减N,所述N为整数。
  3. 根据权利要求1所述的基于区块链的区块生成方法,所述通过所述第一线程和所述第二线程调整所述待封装资源转移数据的数量,并将所述原子计数器的初始值调整为目标值包括:
    通过所述第一线程向所述数据缓存队列中增加P个的待封装资源转移数据,并将所述原子计数器的初始值W增加P,所述W、P为整数;
    通过所述第二线程从所述数据缓存队列提取Q个的待封装资源转移数据,并将所述原子计数器的初始值W减少Q,所述Q为整数;
    得到所述原子计数器的目标值K,其中,K=W+P-Q,所述K为整数;
    将所述Q个的待封装资源转移数据放入切块缓存模块中。
  4. 根据权利要求1所述的基于区块链的区块生成方法,所述根据预置条件将所述待封装资源转移数据进行打包封装,生成目标区块包括:
    当所述数据缓存队列的生产速率大于或等于消费速率时,判断生成区块的时间间隔是否等于预置时长;
    若所述生成区块的时间间隔等于所述预置时长,则将所述切块缓存模块中 所有的待封装资源转移数据进行打包切块,并生成所述目标区块,所述目标区块包括第一预置数目的所述待封装资源转移数据;
    或者,当所述数据缓存队列的生产速率大于或等于消费速率时,判断所述原子计数器的目标值K是否大于或等于预置大小;
    若所述数据缓存队列中的目标值K大于或等于所述预置大小,则将所述切块缓存模块中所有的待封装资源转移数据进行打包切块,并生成所述目标区块,所述目标区块包括第二预置数目的所述待封装资源转移数据;
    或者,当所述数据缓存队列的生产速率小于消费速率时,判断所述原子计数器的目标值K是否为零;
    若所述原子计数器的目标值K为零,则将所述切块缓存模块中所有的待封装资源转移数据进行打包切块,并生成所述目标区块,所述目标区块包括第三预置数目的所述待封装资源转移数据。
  5. 根据权利要求1-4任一所述的基于区块链的区块生成方法,在所述创建数据缓存队列和原子计数器,所述数据缓存队列包括待封装资源转移数据之后,在所述将所述数据缓存队列和所述原子计数器进行关联之前,所述方法还包括:
    获取待封装资源转移数据序列,所述待封装资源转移数据序列中包括按照时间顺序依次排列的多个待封装资源转移数据。
  6. 根据权利要求5所述的基于区块链的区块生成方法,所述获取待封装资源转移数据序列,所述待封装资源转移数据序列中包括按照时间顺序依次排列的多个待封装资源转移数据包括:
    获取客户端发送的多个资源转移数据;
    对所述多个资源转移数据进行校验,判断所述多个资源转移数据中是否存在错误的资源转移数据;
    若所述多个资源转移数据中存在错误的资源转移数据,则将所述错误的资源转移数据删除,得到纠错后的多个资源转移数据;
    判断所述纠错后的多个资源转移数据中是否存在相同的资源转移数据;
    若所述纠错后的多个资源转移数据中存在相同的资源转移数据,则在所述相同的资源转移数据中随机选择一个进行保留并删除其他资源转移数据,得到去重后的多个资源转移数据;
    将所述去重后的多个资源转移数据进行封装,得到多个待封装资源转移数据;
    对所述多个待封装资源转移数据按照时间顺序进行排序,得到待封装资源转移数据序列。
  7. 根据权利要求6所述的基于区块链的区块生成方法,所述判断所述多个资源转移数据中是否存在错误的资源转移数据包括:
    在所述多个资源转移数据中确定目标资源转移数据;
    将所述目标资源转移数据的资源转移请求向网络中其他节点进行广播,网络中节点总数为X;
    重新获取各个其他节点转发的所述目标资源转移数据的资源转移请求,确定接收到的所述目标资源转移数据的资源转移请求的总数量Y;
    确定故障节点数量Z,其中,Z=X-Y-1;
    判断所述X是否满足条件X≥3Z+1;
    若所述X不满足条件X≥3Z+1,则确定所述多个资源转移数据中存在错误的资源转移数据;
    若所述X满足条件X≥3Z+1,则确定所述多个资源转移数据中不存在错误的资源转移数据。
  8. 一种基于区块链的区块生成装置,所述区块生成装置包括:
    创建单元,用于创建数据缓存队列和原子计数器,所述数据缓存队列包括待封装资源转移数据;
    关联确定单元,用于将所述数据缓存队列和所述原子计数器进行关联,并确定所述原子计数器的初始值;
    生成单元,用于生成第一线程和第二线程,所述第一线程用于增加所述数据缓存队列中所述待封装资源转移数据的数量,所述第二线程用于减少所述数据缓存队列中所述待封装资源转移数据的数量;
    调整单元,用于通过所述第一线程和所述第二线程调整所述待封装资源转移数据的数量,并将所述原子计数器的初始值调整为目标值;
    封装生成单元,根据预置条件将所述待封装资源转移数据进行打包封装,生成目标区块。
  9. 根据权利要求8所述的基于区块链的区块生成装置,所述关联确定单元具体用于:
    确定所述数据缓存队列中的所述待封装资源转移数据的初始数量;
    将所述初始数量设置为所述原子计数器的初始值;
    设置所述数据缓存队列的数量变化速率与所述原子计数器的值变化速率相同,其中,当所述待封装资源转移数据的初始数量加N时,所述原子计数器的初始值加N,或者,当所述待封装资源转移数据的初始数量减N时,所述原子计数器的初始值减N,所述N为整数。
  10. 根据权利要求8所述的基于区块链的区块生成装置,所述调整单元具 体用于:
    通过所述第一线程向所述数据缓存队列中增加P个的待封装资源转移数据,并将所述原子计数器的初始值W增加P,所述W、P为整数;
    通过所述第二线程从所述数据缓存队列提取Q个的待封装资源转移数据,并将所述原子计数器的初始值W减少Q,所述Q为整数;
    得到所述原子计数器的目标值K,其中,K=W+P-Q,所述K为整数;
    将所述Q个的待封装资源转移数据放入切块缓存模块中。
  11. 根据权利要求8所述的基于区块链的区块生成装置,所述封装生成单元具体用于:
    当所述数据缓存队列的生产速率大于或等于消费速率时,判断生成区块的时间间隔是否等于预置时长;
    若所述生成区块的时间间隔等于所述预置时长,则将所述切块缓存模块中所有的待封装资源转移数据进行打包切块,并生成所述目标区块,所述目标区块包括第一预置数目的所述待封装资源转移数据;
    或者,当所述数据缓存队列的生产速率大于或等于消费速率时,判断所述原子计数器的目标值K是否大于或等于预置大小;
    若所述数据缓存队列中的目标值K大于或等于所述预置大小,则将所述切块缓存模块中所有的待封装资源转移数据进行打包切块,并生成所述目标区块,所述目标区块包括第二预置数目的所述待封装资源转移数据;
    或者,当所述数据缓存队列的生产速率小于消费速率时,判断所述原子计数器的目标值K是否为零;
    若所述原子计数器的目标值K为零,则将所述切块缓存模块中所有的待封装资源转移数据进行打包切块,并生成所述目标区块,所述目标区块包括第三预置数目的所述待封装资源转移数据。
  12. 根据权利要求8-11任一所述的基于区块链的区块生成装置,所述区块生成装置还包括:
    获取单元,用于获取待封装资源转移数据序列,所述待封装资源转移数据序列中包括按照时间顺序依次排列的多个待封装资源转移数据。
  13. 根据权利要求12所述的基于区块链的区块生成装置,所述获取单元包括:
    获取子单元,用于获取客户端发送的多个资源转移数据;
    第一判断子单元,用于对所述多个资源转移数据进行校验,判断所述多个资源转移数据中是否存在错误的资源转移数据;
    删除子单元,用于若所述多个资源转移数据中存在错误的资源转移数据, 则将所述错误的资源转移数据删除,得到纠错后的多个资源转移数据;
    第二判断子单元,用于判断所述纠错后的多个资源转移数据中是否存在相同的资源转移数据;
    保存删除子单元,用于若所述纠错后的多个资源转移数据中存在相同的资源转移数据,则在所述相同的资源转移数据中随机选择一个进行保留并删除其他资源转移数据,得到去重后的多个资源转移数据;
    封装子单元,用于将所述去重后的多个资源转移数据进行封装,得到多个待封装资源转移数据;
    排序子单元,用于对所述多个待封装资源转移数据按照时间顺序进行排序,得到待封装资源转移数据序列。
  14. 根据权利要求13所述的基于区块链的区块生成装置,所述第一判断子单元具体用于:
    在所述多个资源转移数据中确定目标资源转移数据;
    将所述目标资源转移数据的资源转移请求向网络中其他节点进行广播,网络中节点总数为X;
    重新获取各个其他节点转发的所述目标资源转移数据的资源转移请求,确定接收到的所述目标资源转移数据的资源转移请求的总数量Y;
    确定故障节点数量Z,其中,Z=X-Y-1;
    判断所述X是否满足条件X≥3Z+1;
    若所述X不满足条件X≥3Z+1,则确定所述多个资源转移数据中存在错误的资源转移数据;
    若所述X满足条件X≥3Z+1,则确定所述多个资源转移数据中不存在错误的资源转移数据。
  15. 一种基于区块链的区块生成设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现如下步骤:
    创建数据缓存队列和原子计数器,所述数据缓存队列包括待封装资源转移数据;
    将所述数据缓存队列和所述原子计数器进行关联,并确定所述原子计数器的初始值;
    生成第一线程和第二线程,所述第一线程用于增加所述数据缓存队列中所述待封装资源转移数据的数量,所述第二线程用于减少所述数据缓存队列中所述待封装资源转移数据的数量;
    通过所述第一线程和所述第二线程调整所述待封装资源转移数据的数量,并将所述原子计数器的初始值调整为目标值;
    根据预置条件将所述待封装资源转移数据进行打包封装,生成目标区块。
  16. 根据权利要求15所述的基于区块链的区块生成设备,所述处理器执行所述计算机程序实现所述将所述数据缓存队列和所述原子计数器进行关联,并确定所述原子计数器的初始值时,包括以下步骤:
    确定所述数据缓存队列中的所述待封装资源转移数据的初始数量;
    将所述初始数量设置为所述原子计数器的初始值;
    设置所述数据缓存队列的数量变化速率与所述原子计数器的值变化速率相同,其中,当所述待封装资源转移数据的初始数量加N时,所述原子计数器的初始值加N,或者,当所述待封装资源转移数据的初始数量减N时,所述原子计数器的初始值减N,所述N为整数。
  17. 根据权利要求15所述的基于区块链的区块生成设备,所述处理器执行所述计算机程序实现所述通过所述第一线程和所述第二线程调整所述待封装资源转移数据的数量,并将所述原子计数器的初始值调整为目标值时,包括以下步骤:
    通过所述第一线程向所述数据缓存队列中增加P个的待封装资源转移数据,并将所述原子计数器的初始值W增加P,所述W、P为整数;
    通过所述第二线程从所述数据缓存队列提取Q个的待封装资源转移数据,并将所述原子计数器的初始值W减少Q,所述Q为整数;
    得到所述原子计数器的目标值K,其中,K=W+P-Q,所述K为整数;
    将所述Q个的待封装资源转移数据放入切块缓存模块中。
  18. 根据权利要求15所述的基于区块链的区块生成设备,所述处理器执行所述计算机程序实现所述根据预置条件将所述待封装资源转移数据进行打包封装,生成目标区块时,包括以下步骤:
    当所述数据缓存队列的生产速率大于或等于消费速率时,判断生成区块的时间间隔是否等于预置时长;
    若所述生成区块的时间间隔等于所述预置时长,则将所述切块缓存模块中所有的待封装资源转移数据进行打包切块,并生成所述目标区块,所述目标区块包括第一预置数目的所述待封装资源转移数据;
    或者,当所述数据缓存队列的生产速率大于或等于消费速率时,判断所述原子计数器的目标值K是否大于或等于预置大小;
    若所述数据缓存队列中的目标值K大于或等于所述预置大小,则将所述切块缓存模块中所有的待封装资源转移数据进行打包切块,并生成所述目标区块,所述目标区块包括第二预置数目的所述待封装资源转移数据;
    或者,当所述数据缓存队列的生产速率小于消费速率时,判断所述原子计 数器的目标值K是否为零;
    若所述原子计数器的目标值K为零,则将所述切块缓存模块中所有的待封装资源转移数据进行打包切块,并生成所述目标区块,所述目标区块包括第三预置数目的所述待封装资源转移数据。
  19. 根据权利要求15-18任一所述的基于区块链的区块生成设备,所述处理器执行所述计算机程序实现在所述创建数据缓存队列和原子计数器,所述数据缓存队列包括待封装资源转移数据之后,在所述将所述数据缓存队列和所述原子计数器进行关联之前,包括以下步骤:
    获取待封装资源转移数据序列,所述待封装资源转移数据序列中包括按照时间顺序依次排列的多个待封装资源转移数据。
  20. 一种计算机可读存储介质,所述计算机可读存储介质中存储计算机指令,当所述计算机指令在计算机上运行时,使得计算机执行如下步骤:
    创建数据缓存队列和原子计数器,所述数据缓存队列包括待封装资源转移数据;
    将所述数据缓存队列和所述原子计数器进行关联,并确定所述原子计数器的初始值;
    生成第一线程和第二线程,所述第一线程用于增加所述数据缓存队列中所述待封装资源转移数据的数量,所述第二线程用于减少所述数据缓存队列中所述待封装资源转移数据的数量;
    通过所述第一线程和所述第二线程调整所述待封装资源转移数据的数量,并将所述原子计数器的初始值调整为目标值;
    根据预置条件将所述待封装资源转移数据进行打包封装,生成目标区块。
PCT/CN2019/120814 2019-05-22 2019-11-26 基于区块链的区块生成方法、装置、设备及存储介质 WO2020233054A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910426729.8 2019-05-22
CN201910426729.8A CN110309230A (zh) 2019-05-22 2019-05-22 基于区块链的区块生成方法、装置、设备及存储介质

Publications (1)

Publication Number Publication Date
WO2020233054A1 true WO2020233054A1 (zh) 2020-11-26

Family

ID=68074990

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/120814 WO2020233054A1 (zh) 2019-05-22 2019-11-26 基于区块链的区块生成方法、装置、设备及存储介质

Country Status (2)

Country Link
CN (1) CN110309230A (zh)
WO (1) WO2020233054A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112540985A (zh) * 2020-12-07 2021-03-23 江苏赛融科技股份有限公司 基于分布式计算框架的全局排序输出系统及其方法
CN113656499A (zh) * 2021-08-16 2021-11-16 工银科技有限公司 基于区块链的价值转移方法及装置
US11922026B2 (en) 2022-02-16 2024-03-05 T-Mobile Usa, Inc. Preventing data loss in a filesystem by creating duplicates of data in parallel, such as charging data in a wireless telecommunications network

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110309230A (zh) * 2019-05-22 2019-10-08 深圳壹账通智能科技有限公司 基于区块链的区块生成方法、装置、设备及存储介质
CN112039987B (zh) * 2020-08-28 2022-05-20 平安科技(深圳)有限公司 区块链中区块的处理方法、装置、节点设备及存储介质
CN112070610B (zh) * 2020-09-01 2023-08-29 中国联合网络通信集团有限公司 验证区块合法性的方法及节点、系统、电子设备、介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106651332A (zh) * 2016-12-29 2017-05-10 先锋支付有限公司 一种区块链中新区快的生成方法及区块链
CN107067242A (zh) * 2017-03-24 2017-08-18 钱德君 一种区块链生成过程中难度值创建方法
CN108270821A (zh) * 2016-12-30 2018-07-10 深圳瀚德创客金融投资有限公司 用于区块链网络中的区块生成方法和网络节点
US20180294955A1 (en) * 2017-04-05 2018-10-11 Samsung Sds Co., Ltd. System for processing data based on blockchain and operating method thereof
CN110309230A (zh) * 2019-05-22 2019-10-08 深圳壹账通智能科技有限公司 基于区块链的区块生成方法、装置、设备及存储介质

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
BR112012001629B1 (pt) * 2009-07-28 2019-10-22 Ericsson Telefon Ab L M método de sincronizar o processamento de eventos associados com sessões de aplicação em uma plataforma de processamento de telecomunicações, adaptador de recursos, e, agrupamento de java enterprise edition
CN106598760B (zh) * 2016-12-19 2020-07-10 北京奇虎科技有限公司 消息队列的消费方法及装置
KR102414732B1 (ko) * 2017-04-05 2022-06-28 삼성에스디에스 주식회사 블록체인 기반 디지털 아이덴티티 관리 방법
CN107241279A (zh) * 2017-06-22 2017-10-10 北京天德科技有限公司 一种基于多级缓冲队列的区块链交易限流方法
CN107508863A (zh) * 2017-07-27 2017-12-22 北京瑞卓喜投科技发展有限公司 应用于区块链的信息处理方法和装置
CN109445955B (zh) * 2018-09-13 2020-09-04 武汉斗鱼网络科技有限公司 一种计数方法及计数系统

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106651332A (zh) * 2016-12-29 2017-05-10 先锋支付有限公司 一种区块链中新区快的生成方法及区块链
CN108270821A (zh) * 2016-12-30 2018-07-10 深圳瀚德创客金融投资有限公司 用于区块链网络中的区块生成方法和网络节点
CN107067242A (zh) * 2017-03-24 2017-08-18 钱德君 一种区块链生成过程中难度值创建方法
US20180294955A1 (en) * 2017-04-05 2018-10-11 Samsung Sds Co., Ltd. System for processing data based on blockchain and operating method thereof
CN110309230A (zh) * 2019-05-22 2019-10-08 深圳壹账通智能科技有限公司 基于区块链的区块生成方法、装置、设备及存储介质

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112540985A (zh) * 2020-12-07 2021-03-23 江苏赛融科技股份有限公司 基于分布式计算框架的全局排序输出系统及其方法
CN112540985B (zh) * 2020-12-07 2023-09-26 江苏赛融科技股份有限公司 基于分布式计算框架的全局排序输出系统及其方法
CN113656499A (zh) * 2021-08-16 2021-11-16 工银科技有限公司 基于区块链的价值转移方法及装置
CN113656499B (zh) * 2021-08-16 2024-04-02 工银科技有限公司 基于区块链的价值转移方法及装置
US11922026B2 (en) 2022-02-16 2024-03-05 T-Mobile Usa, Inc. Preventing data loss in a filesystem by creating duplicates of data in parallel, such as charging data in a wireless telecommunications network

Also Published As

Publication number Publication date
CN110309230A (zh) 2019-10-08

Similar Documents

Publication Publication Date Title
WO2020233054A1 (zh) 基于区块链的区块生成方法、装置、设备及存储介质
JP6276273B2 (ja) 分散型データグリッドクラスタにおけるメッセージ前処理をサポートするシステムおよび方法
CN110636130B (zh) 延时消息处理方法、装置、计算机设备和存储介质
US10116574B2 (en) System and method for improving TCP performance in virtualized environments
Dean et al. The tail at scale
TW201539326A (zh) 用於即時串流式計算的計算資源擴容、釋放方法及其裝置
US8639809B2 (en) Predictive removal of runtime data using attribute characterizing
US7529855B2 (en) Dynamic modification of fragmentation size cluster communication parameter in clustered computer system
US10355997B2 (en) System and method for improving TCP performance in virtualized environments
WO2023050901A1 (zh) 一种负载均衡方法、装置、设备、计算机存储介质和程序
CN106354865B (zh) 一种同步主从数据库的方法、装置和系统
CN103957237A (zh) 一种弹性云的体系结构
WO2020019743A1 (zh) 流量控制方法及装置
CN103049336A (zh) 一种基于哈希的网卡软中断负载均衡方法
US20190278749A1 (en) Profiling performance in a networked, clustered, hybrid storage system
CN111641563B (zh) 基于分布式场景的流量自适应方法与系统
WO2021036330A1 (zh) 备份处理方法及服务器
Zhang et al. Efficient TCP connection failover in web server clusters
WO2011127865A2 (zh) 内存转储处理方法和装置及内存转储系统
WO2019153880A1 (zh) 集群中镜像文件下载的方法、节点、查询服务器
WO2017096787A1 (zh) 图片处理方法及装置
WO2018196459A1 (zh) 一种下载请求处理方法、装置、处理设备及介质
Chen et al. Dynamic replication scheduling for cloud datacenters based on workload statistics
US20060085695A1 (en) Use of incarnation number for resource state cycling
Hoang et al. RocketBufs: a framework for building efficient, in-memory, message-oriented middleware

Legal Events

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

Ref document number: 19930078

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19930078

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 18/03/2022)

122 Ep: pct application non-entry in european phase

Ref document number: 19930078

Country of ref document: EP

Kind code of ref document: A1