CN110309230A - Block generation method, device, equipment and storage medium based on block chain - Google Patents
Block generation method, device, equipment and storage medium based on block chain Download PDFInfo
- Publication number
- CN110309230A CN110309230A CN201910426729.8A CN201910426729A CN110309230A CN 110309230 A CN110309230 A CN 110309230A CN 201910426729 A CN201910426729 A CN 201910426729A CN 110309230 A CN110309230 A CN 110309230A
- Authority
- CN
- China
- Prior art keywords
- resource transfers
- data
- packaged
- transfers data
- block
- 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.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/546—Message passing systems or structures, e.g. queues
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L49/00—Packet switching elements
- H04L49/90—Buffering arrangements
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/54—Indexing scheme relating to G06F9/54
- G06F2209/548—Queue
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/50—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees
Abstract
The present invention relates to block chain technical fields, disclose block generation method, device, equipment and storage medium based on block chain, the low delay requirement handled up under requirement and low-frequency resources transfer for meeting the height under high frequency resources transfer, improves the efficiency for generating block.The method of the present invention includes: creation data buffer storage queue and atomic counters, data buffer storage queue include resource transfers data to be packaged;Data buffer storage queue and atomic counters are associated, and determine the initial value of atomic counters;Generate first thread and the second thread, first thread is used to increase the quantity of resource transfers data to be packaged in data buffer storage queue, and the second thread is used to reduce the quantity of resource transfers data to be packaged in data buffer storage queue;The quantity of resource transfers data to be packaged is adjusted by first thread and the second thread, and the initial value of atomic counters is adjusted to target value;Resource transfers data to be packaged are subjected to packing encapsulation according to prerequisite, generate target block.
Description
Technical field
The present invention relates to block chain technical fields, more particularly to the block generation method based on block chain, device, equipment and
Storage medium.
Background technique
Block chain is a kind of a kind of chain type number for being sequentially in time combined into data block in such a way that sequence is connected
According to structure, and the distributed account book that can not be distorted He can not forge guaranteed in a manner of cryptography.Block chain technology, which refers to, to be passed through
Decentralization and the technical solution for going to one authentic data library of the mode collective trusted maintenance.In simple terms, block chain technology is
A kind of whole people participate in the mode of book keeping operation.There is a database in the systematic behind of institute, database can be regarded as a big account
This, is currently respectively to remember respective account.But in block catenary system, everyone can come kept accounts (resource transfers),
System can select the most fast best of book keeping operation, the content that he records be write account book, and person's account book content is issued institute in system
Someone's backup.
In block chain, block is generated by common recognition node, in order to promote the throughput of resource transfers, common recognition node is used
The mode of batch processing resource transfers data triggers production by waiting the resource transfers data of set time or fixed number
Block, but this certainly will extend the acknowledging time of every resource transfers data;But if reducing the set time waited or transaction
Number, and the throughput of resource transfers data can be reduced.Therefore, resource transfers data high-throughput and resource transfers data are encountered by
The problem that low delay can not get both.
In practical application scene, resource transfers frequency is often dynamic change, high frequency should height handle up, low frequency should
Low delay, but this block generation strategy is difficult adaptive such scene at present.
Summary of the invention
The present invention provides block generation method, device, equipment and storage mediums based on block chain, for meeting high frequency
The low delay requirement that height under resource transfers is handled up under requirement and low-frequency resources transfer, improves the efficiency for generating block.
The first aspect of the embodiment of the present invention provides a kind of block generation method based on block chain, comprising: creation data
Buffer queue and atomic counters, the data buffer storage queue include resource transfers data to be packaged;By the data buffer storage team
Column and the atomic counters are associated, and determine the initial value of the atomic counters;Generate first thread and the second line
Journey, the first thread are used to increase the quantity of resource transfers data to be packaged described in the data buffer storage queue, and described the
Two threads are used to reduce the quantity of resource transfers data to be packaged described in the data buffer storage queue;Pass through the first thread
The quantity of the resource transfers data to be packaged is adjusted with second thread, and the initial value of the atomic counters is adjusted
For target value;The resource transfers data to be packaged are subjected to packing encapsulation according to prerequisite, generate target block.
Optionally, described by the data buffer storage team in the first implementation of first aspect of the embodiment of the present invention
Column and the atomic counters are associated, and determine that the initial value of the atomic counters comprises determining that the data buffer storage
The initial number of the resource transfers data to be packaged in queue;The atomic counters are set by the initial number
Initial value;The quantity rate of change that the data buffer storage queue is arranged is identical as the value rate of change of the atomic counters,
In, when the initial number of the resource transfers data to be packaged adds N, the initial value of the atomic counters adds N, alternatively, working as
When the initial number of the resource transfers data to be packaged subtracts N, the initial value of the atomic counters subtracts N, and the N is integer.
Optionally, described to pass through the first thread in second of implementation of first aspect of the embodiment of the present invention
The quantity of the resource transfers data to be packaged is adjusted with second thread, and the initial value of the atomic counters is adjusted
It include: the resource transfers data to be packaged for increasing P into the data buffer storage queue by the first thread for target value,
And the initial value W of the atomic counters is increased into P, described W, P are integer;By second thread from the data buffer storage
Q resource transfers data to be packaged are extracted in queue, and the initial value W of the atomic counters is reduced Q, and the Q is integer;
Obtain the target value K of the atomic counters, wherein K=W+P-Q, the K are integer;The Q resources to be packaged are turned
Data are moved to be put into stripping and slicing cache module.
Optionally, in the third implementation of first aspect of the embodiment of the present invention, it is described according to prerequisite by institute
It states resource transfers data to be packaged and carries out packing encapsulation, generating target block includes: the production speed when the data buffer storage queue
When rate is greater than or equal to Consumption rate, judge whether the time interval for generating block is equal to preset time period;If the generation block
Time interval be equal to the preset time period, then all resource transfers data to be packaged in the stripping and slicing cache module are carried out
It is packaged stripping and slicing, and generates the target block, the target block includes the resource transfers to be packaged of the first preset number
Data;Alternatively, judging the atomic counters when the throughput rate of the data buffer storage queue is greater than or equal to Consumption rate
Target value K whether be greater than or equal to preset size;If the target value K in the data buffer storage queue is greater than or equal to described pre-
Size is set, then resource transfers data to be packaged all in the stripping and slicing cache module are subjected to packing stripping and slicing, and described in generation
Target block, the target block include the resource transfers data to be packaged of the second preset number;Alternatively, working as the data
When the throughput rate of buffer queue is less than Consumption rate, judge whether the target value K of the atomic counters is zero;If the original
The target value K of sub-count device is zero, then is packaged resource transfers data to be packaged all in the stripping and slicing cache module
Stripping and slicing, and the target block is generated, the target block includes the resource transfers data to be packaged of third preset number.
Optionally, in the 4th kind of implementation of first aspect of the embodiment of the present invention, in the creation data buffer storage team
Column and atomic counters delay the data described after the data buffer storage queue includes resource transfers data to be packaged
Deposit queue and before the atomic counters are associated, the method also includes: resource transfers data sequence to be packaged is obtained,
It include the multiple resource transfers data to be packaged being arranged successively sequentially in time in the resource transfers data sequence to be packaged.
Optionally, described to obtain resource turn to be packaged in the 5th kind of implementation of first aspect of the embodiment of the present invention
Data sequence is moved, includes the multiple moneys to be packaged being arranged successively sequentially in time in the resource transfers data sequence to be packaged
Source transfer data include: the multiple resource transfers data for obtaining client and sending;School is carried out to the multiple resource transfers data
It tests, judges in the multiple resource transfers data with the presence or absence of the resource transfers data of mistake;If the multiple resource transfers number
According to the middle resource transfers data that there is mistake, then the resource transfers data of the mistake are deleted, multiple moneys after obtaining error correction
Shift data in source;It whether there is identical resource transfers data in multiple resource transfers data after judging the error correction;If institute
There are identical resource transfers data in multiple resource transfers data after stating error correction, then in the identical resource transfers data
Middle random selection one is retained and is deleted other resource transfers data, multiple resource transfers data after obtaining duplicate removal;It will
Multiple resource transfers data after the duplicate removal are packaged, and obtain multiple resource transfers data to be packaged;To it is the multiple to
Encapsulation resource transfer data are ranked up sequentially in time, obtain resource transfers data sequence to be packaged.
Optionally, in the 6th kind of implementation of first aspect of the embodiment of the present invention, the multiple resource of judgement
Resource transfers data in transfer data with the presence or absence of mistake include: that target resource is determined in the multiple resource transfers data
Shift data;Other nodes into network are requested to be broadcasted the resource transfers of target resource transfer data, in network
Node total number is X;The resource transfers request for reacquiring the target resource transfer data of each other nodes forwarding, determines
The total quantity Y of the resource transfers request of the target resource transfer data received;Determine malfunctioning node quantity Z, wherein Z
=X-Y-1;Judge whether the X meets condition X >=3Z+1;If the X is unsatisfactory for condition X >=3Z+1, it is determined that the multiple
There are the resource transfers data of mistake in resource transfers data;If the X meets condition X >=3Z+1, it is determined that the multiple money
Shift the resource transfers data that mistake is not present in data in source.
The second aspect of the embodiment of the present invention provides a kind of block generating means based on block chain, comprising: creation is single
Member, for creating data buffer storage queue and atomic counters, the data buffer storage queue includes resource transfers data to be packaged;It closes
Join determination unit, for the data buffer storage queue and the atomic counters to be associated, and determines that the atom counts
The initial value of device;Generation unit, for generating first thread and the second thread, the first thread is slow for increasing the data
The quantity of resource transfers data to be packaged described in queue is deposited, second thread is for reducing institute in the data buffer storage queue
State the quantity of resource transfers data to be packaged;Adjustment unit, for adjusting institute by the first thread and second thread
The quantity of resource transfers data to be packaged is stated, and the initial value of the atomic counters is adjusted to target value;Encapsulation generates single
The resource transfers data to be packaged are carried out packing encapsulation according to prerequisite, generate target block by member.
Optionally, in the first implementation of second aspect of the embodiment of the present invention, association determination unit is specifically used for:
Determine the initial number of the resource transfers data to be packaged in the data buffer storage queue;It sets the initial number to
The initial value of the atomic counters;The quantity rate of change of the data buffer storage queue and the value of the atomic counters are set
Rate of change is identical, wherein when the initial number of the resource transfers data to be packaged adds N, at the beginning of the atomic counters
Initial value adds N, alternatively, the initial value of the atomic counters subtracts when the initial number of the resource transfers data to be packaged subtracts N
N, the N are integer.
Optionally, in second of implementation of second aspect of the embodiment of the present invention, adjustment unit is specifically used for: determining
The initial number of the resource transfers data to be packaged in the data buffer storage queue;By the first thread to the number
Increase P according to the resource transfers data to be packaged for increasing P in buffer queue, and by the initial value W of the atomic counters, it is described
W, P is integer;A resource transfers data to be packaged of Q are extracted from the data buffer storage queue by second thread, and will
The initial value W of the atomic counters reduces Q, and the Q is integer;Obtain the target value K of the atomic counters, wherein K=
W+P-Q, the K are integer;The Q resource transfers data to be packaged are put into stripping and slicing cache module.
Optionally, in the third implementation of second aspect of the embodiment of the present invention, encapsulation generation unit is specifically used for:
When the throughput rate of the data buffer storage queue be greater than or equal to Consumption rate when, judge generate block time interval whether etc.
In preset time period;If the time interval for generating block is equal to the preset time period, by institute in the stripping and slicing cache module
The resource transfers data to be packaged having carry out packing stripping and slicing, and generate the target block, and the target block includes first pre-
Set the resource transfers data to be packaged of number;Alternatively, disappearing when the throughput rate of the data buffer storage queue is greater than or equal to
When taking rate, judge whether the target value K of the atomic counters is greater than or equal to preset size;If the data buffer storage queue
In target value K be greater than or equal to the preset size, then by resource transfers to be packaged all in the stripping and slicing cache module
Data carry out packing stripping and slicing, and generate the target block, and the target block includes the described to be packaged of the second preset number
Resource transfers data;Alternatively, judging that the atom counts when the throughput rate of the data buffer storage queue is less than Consumption rate
Whether the target value K of device is zero;If the target value K of the atomic counters is zero, will own in the stripping and slicing cache module
Resource transfers data to be packaged carry out packing stripping and slicing, and generate the target block, the target block includes that third is preset
The resource transfers data to be packaged of number.
Optionally, in the 4th kind of implementation of second aspect of the embodiment of the present invention, the block based on block chain is generated
Device further include: acquiring unit, for obtaining resource transfers data sequence to be packaged, the resource transfers data sequence to be packaged
In include the multiple resource transfers data to be packaged being arranged successively according to exchange hour sequence.
Optionally, in the 5th kind of implementation of second aspect of the embodiment of the present invention, acquiring unit includes: to obtain son list
Member, for obtaining multiple resource transfers data of client transmission;First judgment sub-unit, for the multiple resource transfers
Data are verified, and are judged in the multiple resource transfers data with the presence or absence of the resource transfers data of mistake;Subelement is deleted,
If there are the resource transfers data of mistake in the multiple resource transfers data, it is used for the resource transfers data of the mistake
It deletes, multiple resource transfers data after obtaining error correction;Second judgment sub-unit, for judging multiple resources after the error correction
It shifts and whether there is identical resource transfers data in data;It saves and deletes subelement, if multiple resources after the error correction turn
Move data in there are identical resource transfers data, then in the identical resource transfers data randomly choose one into
Row retains and deletes other resource transfers data, multiple resource transfers data after obtaining duplicate removal;Subelement is encapsulated, is used for institute
Multiple resource transfers data after stating duplicate removal are packaged, and obtain multiple resource transfers data to be packaged;Sorting subunit is used for
The multiple resource transfers data to be packaged are ranked up sequentially in time, obtain resource transfers data sequence to be packaged.
Optionally, in the 6th kind of implementation of second aspect of the embodiment of the present invention, the first judgment sub-unit is specifically used
In: target resource transfer data are determined in the multiple resource transfers data;By the resource of target resource transfer data
Transfer request other nodes into network are broadcasted, and nodes sum is X;Reacquire each other nodes forwarding
The resource transfers request of the target resource transfer data determines the resource transfers of the target resource transfer data received
The total quantity Y of request;Determine malfunctioning node quantity Z, wherein Z=X-Y-1;Judge whether the X meets condition X >=3Z+1;If
The X is unsatisfactory for condition X >=3Z+1, it is determined that there are the resource transfers data of mistake in the multiple resource transfers data;If
The X meets condition X >=3Z+1, it is determined that there is no the resource transfers data of mistake in the multiple resource transfers data.
The third aspect of the embodiment of the present invention provides a kind of block generating device based on block chain, including memory,
Processor and it is stored in the computer program that can be run on the memory and on the processor, the processor executes institute
The block generation method described in any of the above-described embodiment based on block chain is realized when stating computer program.
The fourth aspect of the embodiment of the present invention provides a kind of computer readable storage medium, including instruction, when the finger
When order is run on computers, so that computer executes the block generation side described in any of the above-described embodiment based on block chain
The step of method.
In technical solution provided in an embodiment of the present invention, data buffer storage queue and atomic counters are created, the data are slow
Depositing queue includes resource transfers data to be packaged;The data buffer storage queue and the atomic counters are associated, and really
The initial value of the fixed atomic counters;First thread and the second thread are generated, the first thread is for increasing the data
The quantity of resource transfers data to be packaged described in buffer queue, second thread is for reducing in the data buffer storage queue
The quantity of the resource transfers data to be packaged;The resource to be packaged is adjusted by the first thread and second thread
The quantity of data is shifted, and the initial value of the atomic counters is adjusted to target value;According to prerequisite by described wait seal
Dress resource transfers data carry out packing encapsulation, generate target block.The embodiment of the present invention passes through data buffer storage queue cache resources
Shift data, different processes called to extract generation block to the resource transfers data of caching, and to atomic counters into
Row adjustment meets the low delay requirement that the height under high frequency resources transfer is handled up under requirement and low-frequency resources transfer, improves generation
The efficiency of block.
Detailed description of the invention
Fig. 1 is one embodiment schematic diagram of the block generation method based on block chain in the embodiment of the present invention;
Fig. 2 is another embodiment schematic diagram of the block generation method based on block chain in the embodiment of the present invention;
Fig. 3 is one embodiment schematic diagram of the block generating means based on block chain in the embodiment of the present invention;
Fig. 4 is another embodiment schematic diagram of the block generating means based on block chain in the embodiment of the present invention;
Fig. 5 is one embodiment schematic diagram of the block generating device based on block chain in the embodiment of the present invention.
Specific embodiment
The present invention provides block generation method, device, equipment and storage mediums based on block chain, for meeting high frequency
The low delay requirement that height under resource transfers is handled up under requirement and low-frequency resources transfer, improves the efficiency for generating block.
In order to enable those skilled in the art to better understand the solution of the present invention, below in conjunction in the embodiment of the present invention
The embodiment of the present invention is described in attached drawing.
Description and claims of this specification and term " first ", " second ", " third ", " in above-mentioned attached drawing
The (if present)s such as four " are to be used to distinguish similar objects, without being used to describe a particular order or precedence order.It should manage
The data that solution uses in this way are interchangeable under appropriate circumstances, so that the embodiments described herein can be in addition to illustrating herein
Or the sequence other than the content of description is implemented.In addition, term " includes " or " having " and its any deformation, it is intended that covering is not
Exclusive includes, for example, the process, method, system, product or equipment for containing a series of steps or units be not necessarily limited to it is clear
Step or unit those of is listed on ground, but is not clearly listed or for these process, methods, product or is set
Standby intrinsic other step or units.
Referring to Fig. 1, the flow chart of the block generation method provided in an embodiment of the present invention based on block chain, specific to wrap
It includes:
101, it creates data buffer storage queue and atomic counters, data buffer storage queue includes resource transfers data to be packaged.
Ordering joint creates data buffer storage queue and atomic counters.Specifically, ordering joint creates a data buffer storage
Queue for caching pretreated resource transfers data to be packaged, and generates an atomic counters.Wherein, ordering joint
(orderer) it is mainly used to realize the common recognition mechanism of block chain network, provides unified resource for all applications clients and turn
Data sorting and stripping and slicing service are moved, and block is distributed to all peer nodes, peer node undertakes in block chain network
Process resource shifts the role of data, memory block.Wherein, resource transfers data to be packaged, which refer to, has been subjected to peer node processing
The resource transfers data crossed, and be not added to also in block.
It should be noted that common recognition mechanism is the core algorithm of block chain, because the data of distributed system are dispersed in respectively
In a participation node, the data of these dispersions must be by a kind of algorithm come being consistent property, and otherwise system will be unable to normal work
Make.Different from traditional distributed system, block chain is the system of a decentralization, and may carry a large amount of finance
Assets, so it may face a large amount of Byzantine faults rather than total generic failure, and the distributed system of centralization is then very
Byzantine faults are encountered less.Byzantine faults are referred to the prior art, and details are not described herein again.
It is understood that executing subject of the invention is ordering joint, ordering joint can be the area based on block chain
Block generating means can also be terminal or server, specifically herein without limitation.
102, data buffer storage queue and atomic counters are associated, and determine the initial value of atomic counters.
Data buffer storage queue and atomic counters are associated by ordering joint, and according in data buffer storage queue wait seal
The particular number of dress resource transfers data determines the initial value of atomic counters.Specifically, ordering joint determines data buffer storage team
The initial number of resource transfers data to be packaged in column;Set initial number to the initial value of atomic counters;Number is set
It is identical according to the quantity rate of change of buffer queue and the value rate of change of atomic counters, wherein when resource transfers number to be packaged
According to initial number add N when, the initial value of atomic counters adds N, alternatively, when the initial numbers of resource transfers data to be packaged subtracts
When N, the initial value of atomic counters subtracts N, and N is integer.Atomic counters main function is exactly to count to data buffer queue
Number.
For example, when there are 100 transaction (resources i.e. to be packaged to be packaged in transaction buffer queue (i.e. data buffer storage queue)
Shift data) when, then 100 are set by the value of atomic counters.The value of atomic counters with transaction buffer queue in wait seal
The quantity of dress transaction is corresponding, when the quantity of the transaction to be packaged in buffer queue of trading changes, the value of atomic counters
Synchronize variation.For example, the quantity when transaction to be packaged reduces 20, become 80, then the value of atomic counters will also subtract
Few 20, become 80;When the quantity of transaction to be packaged increases 15 again, become 95, then the value of atomic counters will also increase by 15,
Become 95.It can also be the variation of other numerical values reciteds, specifically herein without limitation.
103, first thread and the second thread are generated, first thread is for increasing resource turn to be packaged in data buffer storage queue
The quantity of data is moved, the second thread is used to reduce the quantity of resource transfers data to be packaged in data buffer storage queue.
Ordering joint generates first thread and the second thread, and first thread is for increasing money to be packaged in data buffer storage queue
The quantity of data is shifted in source, and the second thread is used to reduce the quantity of resource transfers data to be packaged in data buffer storage queue.Specifically
, first thread can add resource transfers data to be packaged into data buffer storage queue, and the second thread can be from data buffer storage
Resource transfers data to be packaged are extracted in queue, first thread and the second thread also need after being adjusted to data buffer queue
Atomic counters are synchronized with adjustment.
It should be noted that first thread and the second thread can modify this atom meter simultaneously because being atomic counters
Number device, and can be successfully modified, it will not interact.
104, the quantity of resource transfers data to be packaged is adjusted by first thread and the second thread, and by atomic counters
Initial value be adjusted to target value.
Ordering joint adjusts the quantity of resource transfers data to be packaged by first thread and the second thread, and by atom meter
The initial value of number device is adjusted to target value.Specifically, ordering joint increases P into data buffer storage queue by first thread
Resource transfers data to be packaged, and the initial value W of atomic counters is increased into P, W, P are integer;By the second thread from data
Buffer queue extracts Q resource transfers data to be packaged, and the initial value W of atomic counters is reduced Q, and Q is integer;It obtains
The target value K of atomic counters, wherein K=W+P-Q, K are integer;Q resource transfers data to be packaged are put into stripping and slicing to delay
In storing module.
For example, existing in transaction buffer queue (i.e. data buffer storage queue) when the initial value W of atomic counters is 80
80 transaction (resource transfers data i.e. to be packaged) to be packaged, ordering joint is according to pre-set parameter P, Q, P 10, Q
20, first thread can cache 10 transaction to be packaged into transaction buffer queue every time, and the and thread every time can be from friendship
20 transaction to be packaged are extracted in easy buffer queue, then, after first thread and the second thread have executed once, pass through K=W
+ P-Q is calculated, 80+10-20=70, and there are 70 transaction to be packaged in buffer queue of trading.Initial value 80 is adjusted
Value for target value 70, P, Q can be configured according to the actual situation, to obtain different K values, not limited herein specifically
It is fixed.
Wherein, atomic counters are multithreading counter, which is called by atomic operation, specific former
Reason is referred to the prior art, and details are not described herein again.
105, resource transfers data to be packaged are carried out by packing encapsulation according to prerequisite, generates target block.
Resource transfers data to be packaged are carried out packing encapsulation according to prerequisite by ordering joint, generate target block.Tool
Body, the ordering joint size that judges throughput rate and Consumption rate first;Be greater than when the throughput rate of data buffer storage queue or
When equal to Consumption rate, ordering joint judges whether the time interval for generating block is equal to preset time period, or judges that atom counts
Whether the target value K of device is greater than or equal to preset size;If the time interval for generating block is equal to preset time period, ordering joint
Resource transfers data to be packaged all in stripping and slicing cache module are subjected to packing stripping and slicing, and generate target block, target block
Resource transfers data to be packaged including the first preset number;If the target value K in data buffer storage queue is greater than or equal to preset
Size, then resource transfers data to be packaged all in stripping and slicing cache module are carried out packing stripping and slicing by ordering joint, and generate mesh
Block is marked, target block includes the resource transfers data to be packaged of the second preset number.
When the throughput rate of data buffer storage queue is less than Consumption rate, ordering joint judges the target value of atomic counters
Whether K is zero;If the target value K of atomic counters is zero, ordering joint is by money to be packaged all in stripping and slicing cache module
Source transfer data carry out packing stripping and slicing, and generate target block, and target block includes that the resource to be packaged of third preset number turns
Move data.
It is understood that judging whether the time interval for generating block is equal to preset time period and judges atomic counters
Whether target value K is greater than or equal between preset size without specific sequencing, can judge simultaneously, can also successively sentence
It is disconnected, specifically herein without limitation.
It should be noted that " rate " in " throughput rate " and " Consumption rate " refers to the average speed of a period of time
Rate, before producing block, the resource transfers data (trading) for consuming out only simply enter stripping and slicing described above
Cache module, who who big small rate depending on resource transfers request of Consumption rate and throughput rate during this, wherein consumption speed
Rate depends primarily on: calculating the processing capacities such as Hash, signature, I O storage.And throughput rate depends primarily on resource transfers frequency.
In the case where low-frequency resources shift scene, throughput rate is less than Consumption rate, and counter is 0 quickly, can trigger stripping and slicing;In high frequency resources
It shifts under scene, throughput rate is greater than or equal to Consumption rate, and counter is greater than 0, passes through set time or fixed transaction number
Trigger stripping and slicing.
The embodiment of the present invention shifts data by data buffer storage queue cache resources, calls different processes to caching
Resource transfers data extract generation block, and are adjusted to atomic counters, and the height met under high frequency resources transfer gulps down
The low delay requirement under requirement and low-frequency resources transfer is spat, the efficiency for generating block is improved.
Referring to Fig. 2, another flow chart of the block generation method provided in an embodiment of the present invention based on block chain, tool
Body includes:
201, it creates data buffer storage queue and atomic counters, data buffer storage queue includes resource transfers data to be packaged.
Ordering joint creates data buffer storage queue and atomic counters.Specifically, ordering joint creates a data buffer storage
Queue for caching pretreated resource transfers data to be packaged, and generates an atomic counters.Wherein, ordering joint
(orderer) it is mainly used to realize the common recognition mechanism of block chain network, provides unified resource for all applications clients and turn
Data sorting and stripping and slicing service are moved, and block is distributed to all peer nodes, peer node undertakes in block chain network
Process resource shifts the role of data, memory block.Wherein, resource transfers data to be packaged, which refer to, has been subjected to peer node processing
The resource transfers data crossed, and be not added to also in block.
It should be noted that common recognition mechanism is the core algorithm of block chain, because the data of distributed system are dispersed in respectively
In a participation node, the data of these dispersions must be by a kind of algorithm come being consistent property, and otherwise system will be unable to normal work
Make.Different from traditional distributed system, block chain is the system of a decentralization, and may carry a large amount of finance
Assets, so it may face a large amount of Byzantine faults rather than total generic failure, and the distributed system of centralization is then very
Byzantine faults are encountered less.Byzantine faults are referred to the prior art, and details are not described herein again.
It is understood that executing subject of the invention is ordering joint, ordering joint can be the area based on block chain
Block generating means can also be terminal or server, specifically herein without limitation.
202, resource transfers data sequence to be packaged is obtained.
Ordering joint obtains resource transfers data sequence to be packaged, include in the resource transfers data sequence to be packaged according to
Multiple resource transfers data to be packaged that time sequencing is arranged successively.Specifically, obtaining multiple resource transfers that client is sent
Data;Multiple resource transfers data are verified, are judged in multiple resource transfers data with the presence or absence of the resource transfers of mistake
Data;If there are the resource transfers data of mistake in multiple resource transfers data, the resource transfers data of mistake are deleted, are obtained
Multiple resource transfers data after to error correction;Turn in multiple resource transfers data after judging error correction with the presence or absence of identical resource
Move data;If in multiple resource transfers data after error correction, there are identical resource transfers data, in identical resource transfers
One, which is randomly choosed, in data is retained and deleted other resource transfers data, multiple resource transfers numbers after obtaining duplicate removal
According to;Multiple resource transfers data after duplicate removal are packaged, multiple resource transfers data to be packaged are obtained;To multiple to be packaged
Resource transfers data are ranked up sequentially in time, obtain resource transfers data sequence to be packaged.
Wherein, judge that the process that whether there is the resource transfers data of mistake in multiple resource transfers data includes:
Determine that target resource shifts data in multiple resource transfers data;By the resource transfers of target resource transfer data
Other nodes into network are requested to be broadcasted, nodes sum is X;Reacquire the target of each other nodes forwarding
The resource transfers of resource transfers data are requested, and determine the total quantity of the resource transfers request of the target resource transfer data received
Y;Determine malfunctioning node quantity Z, wherein Z=X-Y-1;Judge whether X meets condition X >=3Z+1;If X is unsatisfactory for condition X >=3Z
+ 1, determine there are the resource transfers data of mistake in multiple resource transfers data;If X meets condition X >=3Z+1, it is determined that multiple
There is no the resource transfers data of mistake in resource transfers data.
For example, it is assumed that C is the client for sending request, 0123 is the node in network, and 3 be malfunctioning node, specific steps
As follows: request stage: client C sends transaction request (i.e. resource transfers request) and arrives any one node, is node 0 here;In advance
The standby stage: node 0 is broadcasted after receiving the transaction request of client C, diffuses to node 1,2,3;Preparation stage: node 1,2,
3 receive after record and broadcast again, i.e., node 1 is broadcasted to node 0,2,3, and node 2 is broadcasted to node 0,1,3, section
Point 3 is because failure can not be broadcasted;The completion stage: node 0,1,2,3 identical is asked if receiving more than a certain number of in the preparation stage
It asks, then enters the completion stage, request is completed in broadcast;Feedback stage: node 0,1,2,3 is in the stage of completion, if it is more than certain for receiving
The same request of quantity then feeds back client C.As can be seen that may insure transaction in the case where X >=3Z+1 (i.e.
Resource transfers data) consistency, X be node sum, Z be malfunctioning node sum.And the case where being unsatisfactory for X >=3Z+1
Under, the transaction of mistake can be generated.
203, data buffer storage queue and atomic counters are associated, and true according to resource transfers data sequence to be packaged
Determine the initial value of atomic counters.
Data buffer storage queue and atomic counters are associated by ordering joint, and according to resource transfers data sequence to be packaged
The particular number of resource transfers data to be packaged in column determines the initial value of atomic counters.Specifically, ordering joint determines
The initial number of resource transfers data to be packaged in resource transfers data sequence to be packaged;Atom meter is set by initial number
The initial value of number device;The quantity rate of change that data buffer storage queue is arranged is identical as the value rate of change of atomic counters, wherein
When the initial number of resource transfers data to be packaged adds N, the initial value of atomic counters adds N, alternatively, when resource to be packaged turns
When the initial number of shifting data subtracts N, the initial value of atomic counters subtracts N, and N is integer.Atomic counters main function is exactly pair
Data buffer storage queue is counted.
For example, when there are 100 transaction (moneys i.e. to be packaged to be packaged in transaction sequence to be packaged (i.e. data buffer storage queue)
Shift data in source) when, then 100 are set by the value of atomic counters.In the values of atomic counters and transaction buffer queue to
The quantity of encapsulation transaction is corresponding, when the quantity of the transaction to be packaged in buffer queue of trading changes, atomic counters
Value synchronizes variation.For example, the quantity when transaction to be packaged reduces 20, become 80, then the value of atomic counters is also wanted
20 are reduced, becomes 80;When the quantity of transaction to be packaged increases 15 again, become 95, then the value of atomic counters will also increase
15, become 95.It can also be the variation of other numerical values reciteds, specifically herein without limitation.
204, first thread and the second thread are generated, first thread is for increasing resource turn to be packaged in data buffer storage queue
The quantity of data is moved, the second thread is used to reduce the quantity of resource transfers data to be packaged in data buffer storage queue.
Ordering joint generates first thread and the second thread, and first thread is for increasing money to be packaged in data buffer storage queue
The quantity of data is shifted in source, and the second thread is used to reduce the quantity of resource transfers data to be packaged in data buffer storage queue.Specifically
, first thread can add resource transfers data to be packaged into data buffer storage queue, and the second thread can be from data buffer storage
Resource transfers data to be packaged are extracted in queue, first thread and the second thread also need after being adjusted to data buffer queue
Atomic counters are synchronized with adjustment.The resource transfers data to be packaged of addition are from resource transfers data sequence to be packaged
It obtains.
It should be noted that first thread and the second thread can modify this atom meter simultaneously because being atomic counters
Number device, and can be successfully modified, it will not interact.
205, the quantity of resource transfers data to be packaged is adjusted by first thread and the second thread, and by atomic counters
Initial value be adjusted to target value.
Ordering joint adjusts the quantity of resource transfers data to be packaged by first thread and the second thread, and by atom meter
The initial value of number device is adjusted to target value.Specifically, ordering joint increases P into data buffer storage queue by first thread
Resource transfers data to be packaged, and the initial value W of atomic counters is increased into P, W, P are integer;By the second thread from data
Buffer queue extracts Q resource transfers data to be packaged, and the initial value W of atomic counters is reduced Q, and Q is integer;It obtains
The target value K of atomic counters, wherein K=W+P-Q, K are integer;Q resource transfers data to be packaged are put into stripping and slicing to delay
In storing module.
For example, existing in transaction buffer queue (i.e. data buffer storage queue) when the initial value W of atomic counters is 80
80 transaction (resource transfers data i.e. to be packaged) to be packaged, ordering joint is according to pre-set parameter P, Q, P 10, Q
20, first thread can cache 10 transaction to be packaged into transaction buffer queue every time, and the and thread every time can be from friendship
20 transaction to be packaged are extracted in easy buffer queue, then, after first thread and the second thread have executed once, pass through K=W
+ P-Q is calculated, 80+10-20=70, and there are 70 transaction to be packaged in buffer queue of trading.Initial value 80 is adjusted
Value for target value 70, P, Q can be configured according to the actual situation, to obtain different K values, not limited herein specifically
It is fixed.
Wherein, atomic counters are multithreading counter, which is called by atomic operation, specific former
Reason is referred to the prior art, and details are not described herein again.
206, resource transfers data to be packaged are carried out by packing encapsulation according to prerequisite, generates target block.
Resource transfers data to be packaged are carried out packing encapsulation according to prerequisite by ordering joint, generate target block.Tool
Body, the ordering joint size that judges throughput rate and Consumption rate first;Be greater than when the throughput rate of data buffer storage queue or
When equal to Consumption rate, ordering joint judges whether the time interval for generating block is equal to preset time period, or judges that atom counts
Whether the target value K of device is greater than or equal to preset size;If the time interval for generating block is equal to preset time period, ordering joint
Resource transfers data to be packaged all in stripping and slicing cache module are subjected to packing stripping and slicing, and generate target block, target block
Resource transfers data to be packaged including the first preset number;If the target value K in data buffer storage queue is greater than or equal to preset
Size, then resource transfers data to be packaged all in stripping and slicing cache module are carried out packing stripping and slicing by ordering joint, and generate mesh
Block is marked, target block includes the resource transfers data to be packaged of the second preset number.
When the throughput rate of data buffer storage queue is less than Consumption rate, ordering joint judges the target value of atomic counters
Whether K is zero;If the target value K of atomic counters is zero, ordering joint is by money to be packaged all in stripping and slicing cache module
Source transfer data carry out packing stripping and slicing, and generate target block, and target block includes that the resource to be packaged of third preset number turns
Move data.
It is understood that judging whether the time interval for generating block is equal to preset time period and judges atomic counters
Whether target value K is greater than or equal between preset size without specific sequencing, can judge simultaneously, can also successively sentence
It is disconnected, specifically herein without limitation.
It should be noted that " rate " in " throughput rate " and " Consumption rate " refers to the average speed of a period of time
Rate, before producing block, the resource transfers data (trading) for consuming out only simply enter stripping and slicing described above
Cache module, who who big small rate depending on resource transfers request of Consumption rate and throughput rate during this, wherein consumption speed
Rate depends primarily on: calculating the processing capacities such as Hash, signature, I O storage.And throughput rate depends primarily on resource transfers frequency.
In the case where low-frequency resources shift scene, throughput rate is less than Consumption rate, and counter is 0 quickly, can trigger stripping and slicing;In high frequency resources
It shifts under scene, throughput rate is greater than or equal to Consumption rate, and counter is greater than 0, passes through set time or fixed transaction number
Trigger stripping and slicing.
The embodiment of the present invention shifts data by data buffer storage queue cache resources, calls different processes to caching
Resource transfers data extract generation block, and are adjusted to atomic counters, and the height met under high frequency resources transfer gulps down
The low delay requirement under requirement and low-frequency resources transfer is spat, the efficiency for generating block is improved.
The block generation method in the embodiment of the present invention based on block chain is described above, below to of the invention real
It applies the block generating means in example based on block chain to be described, referring to Fig. 3, the area based on block chain in the embodiment of the present invention
One embodiment of block generating means includes:
Creating unit 301, for creating data buffer storage queue and atomic counters, the data buffer storage queue includes wait seal
Fill resource transfers data;
It is associated with determination unit 302, for the data buffer storage queue and the atomic counters to be associated, and is determined
The initial value of the atomic counters;
Generation unit 303, for generating first thread and the second thread, the first thread is slow for increasing the data
The quantity of resource transfers data to be packaged described in queue is deposited, second thread is for reducing institute in the data buffer storage queue
State the quantity of resource transfers data to be packaged;
Adjustment unit 304, for adjusting the resource transfers to be packaged by the first thread and second thread
The quantity of data, and the initial value of the atomic counters is adjusted to target value;
Generation unit 305 is encapsulated, the resource transfers data to be packaged are carried out by packing encapsulation according to prerequisite, is generated
Target block.
The embodiment of the present invention shifts data by data buffer storage queue cache resources, calls different processes to caching
Resource transfers data extract generation block, and are adjusted to atomic counters, and the height met under high frequency resources transfer gulps down
The low delay requirement under requirement and low-frequency resources transfer is spat, the efficiency for generating block is improved.
Referring to Fig. 4, another embodiment of the block generating means in the embodiment of the present invention based on block chain includes:
Creating unit 301, for creating data buffer storage queue and atomic counters, the data buffer storage queue includes wait seal
Fill resource transfers data;
It is associated with determination unit 302, for the data buffer storage queue and the atomic counters to be associated, and is determined
The initial value of the atomic counters;
Generation unit 303, for generating first thread and the second thread, the first thread is slow for increasing the data
The quantity of resource transfers data to be packaged described in queue is deposited, second thread is for reducing institute in the data buffer storage queue
State the quantity of resource transfers data to be packaged;
Adjustment unit 304, for adjusting the resource transfers to be packaged by the first thread and second thread
The quantity of data, and the initial value of the atomic counters is adjusted to target value;
Generation unit 305 is encapsulated, the resource transfers data to be packaged are carried out by packing encapsulation according to prerequisite, is generated
Target block.
Optionally, association determination unit 302 is specifically used for:
Determine the initial number of the resource transfers data to be packaged in the data buffer storage queue;By the initial number
Amount is set as the initial value of the atomic counters;The quantity rate of change and the atom meter of the data buffer storage queue are set
The value rate of change of number device is identical, wherein when the initial number of the resource transfers data to be packaged adds N, the atom meter
The initial value of number device adds N, alternatively, when the initial number of the resource transfers data to be packaged subtracts N, the atomic counters
Initial value subtracts N, and the N is integer.
Optionally, adjustment unit 304 is specifically used for:
Determine the initial number of the resource transfers data to be packaged in the data buffer storage queue;Pass through described first
Thread increases the resource transfers data to be packaged of P into the data buffer storage queue, and by the initial of the atomic counters
Value W increases P, and described W, P are integer;A resource to be packaged of Q is extracted from the data buffer storage queue by second thread
Data are shifted, and the initial value W of the atomic counters is reduced into Q, the Q is integer;Obtain the mesh of the atomic counters
Scale value K, wherein K=W+P-Q, the K are integer;The Q resource transfers data to be packaged are put into stripping and slicing cache module
In.
Optionally, encapsulation generation unit 305 is specifically also used to:
When the throughput rate of the data buffer storage queue is greater than or equal to Consumption rate, between the time for judging generation block
Every whether equal to preset time period;If the time interval for generating block is equal to the preset time period, the stripping and slicing is cached
All resource transfers data to be packaged carry out packing stripping and slicing in module, and generate the target block, the target block packet
Include the resource transfers data to be packaged of the first preset number;Alternatively, the throughput rate when the data buffer storage queue is greater than
Or when being equal to Consumption rate, judge whether the target value K of the atomic counters is greater than or equal to preset size;If the data
Target value K in buffer queue is greater than or equal to the preset size, then will be all to be packaged in the stripping and slicing cache module
Resource transfers data carry out packing stripping and slicing, and generate the target block, and the target block includes the institute of the second preset number
State resource transfers data to be packaged;Alternatively, when the throughput rate of the data buffer storage queue is less than Consumption rate, described in judgement
Whether the target value K of atomic counters is zero;If the target value K of the atomic counters is zero, the stripping and slicing is cached into mould
All resource transfers data to be packaged carry out packing stripping and slicing in block, and generate the target block, and the target block includes
The resource transfers data to be packaged of third preset number.
Optionally, based on the block generating means of block chain further include:
Acquiring unit 306, for obtaining resource transfers data sequence to be packaged, the resource transfers data sequence to be packaged
In include multiple resource transfers data to be packaged for being arranged successively sequentially in time.
Optionally, acquiring unit 306 includes:
Subelement 3061 is obtained, for obtaining multiple resource transfers data of client transmission;
First judgment sub-unit 3062 judges the multiple money for verifying to the multiple resource transfers data
It shifts in data with the presence or absence of the resource transfers data of mistake in source;
Subelement 3063 is deleted, if there are the resource transfers data of mistake in the multiple resource transfers data, is used for
The resource transfers data of the mistake are deleted, multiple resource transfers data after obtaining error correction;
Second judgment sub-unit 3064, for judging in multiple resource transfers data after the error correction with the presence or absence of identical
Resource transfers data;
It saves and deletes subelement 3065, if there are identical resource transfers in multiple resource transfers data after the error correction
Data are then retained and are deleted other resource transfers numbers for randomly choosing one in the identical resource transfers data
According to multiple resource transfers data after obtaining duplicate removal;
Encapsulate subelement 3066, for multiple resource transfers data after the duplicate removal to be packaged, obtain it is multiple to
Encapsulation resource shifts data;
Sorting subunit 3067, for being ranked up sequentially in time to the multiple resource transfers data to be packaged,
Obtain resource transfers data sequence to be packaged.
Optionally, the first judgment sub-unit 3062 is specifically used for:
Determine that target resource shifts data in the multiple resource transfers data;By target resource transfer data
Resource transfers request other nodes into network to be broadcasted, and nodes sum is X;Other each nodes are reacquired to turn
The resource transfers request of the target resource transfer data of hair determines the resource of the target resource transfer data received
The total quantity Y of transfer request;Determine malfunctioning node quantity Z, wherein Z=X-Y-1;Judge whether the X meets condition X >=3Z+
1;If the X is unsatisfactory for condition X >=3Z+1, it is determined that there is the resource transfers number of mistake in the multiple resource transfers data
According to;If the X meets condition X >=3Z+1, it is determined that there is no the resource transfers numbers of mistake in the multiple resource transfers data
According to.
The embodiment of the present invention shifts data by data buffer storage queue cache resources, calls different processes to caching
Resource transfers data extract generation block, and are adjusted to atomic counters, and the height met under high frequency resources transfer gulps down
The low delay requirement under requirement and low-frequency resources transfer is spat, the efficiency for generating block is improved.
Angle of the above figure 3 to Fig. 4 from modular functionality entity is to the block based on block chain in the embodiment of the present invention
Generating means are described in detail, and generate below from the angle of hardware handles to the block in the embodiment of the present invention based on block chain
Equipment is described in detail.
Fig. 5 is a kind of structural schematic diagram of block generating device based on block chain provided in an embodiment of the present invention, the base
Bigger difference can be generated because configuration or performance are different in the block generating device 500 of block chain, may include one or
More than one processor (central processing units, CPU) 501 (for example, one or more processors) and
Storage medium 508 (such as one or one of memory 509, one or more storage application programs 507 or data 506
The above mass memory unit).Wherein, memory 509 and storage medium 508 can be of short duration storage or persistent storage.It is stored in
The program of storage medium 508 may include one or more modules (diagram does not mark), and each module may include to base
Series of instructions operation in the block generating device of block chain.Further, processor 501 can be set to and store
Medium 508 communicates, and the series of instructions operation in storage medium 508 is executed in the block generating device 500 based on block chain.
Block generating device 500 based on block chain can also include one or more power supplys 502, one or one
The above wired or wireless network interface 503, one or more input/output interfaces 504, and/or, one or more
Operating system 505, such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD etc..Those skilled in the art
It is appreciated that the block generating device structure shown in Fig. 5 based on block chain is not constituted to the block life based on block chain
The restriction of forming apparatus may include perhaps combining certain components or different component cloth than illustrating more or fewer components
It sets.Processor 501 can execute creating unit 301 in above-described embodiment, association determination unit 302, generation unit 303, adjustment
Unit 304, the function of encapsulating generation unit 305 and acquiring unit 306.
It is specifically introduced below with reference to each component parts of the Fig. 5 to the block generating device based on block chain:
Processor 501 is the control centre of the block generating device based on block chain, can be according to setting based on block
The block generation method of chain is handled.Block of the processor 501 using various interfaces and connection entirely based on block chain
The various pieces of generating device, by running or executing the software program and/or module that are stored in memory 509, and tune
With the data being stored in memory 509, the various functions and processing data of the block generating device based on block chain are executed, it is full
The low delay requirement that height under sufficient high frequency transaction is handled up under requirement and low frequency transaction, improves the efficiency for generating block.Storage is situated between
Matter 508 and memory 509 are all the carriers of storing data, and in the embodiment of the present invention, storage medium 508 can refer to storage volume
It is smaller, but fireballing built-in storage, and memory 509 can be that storage volume is big, but the external memory that storage speed is slow.
Memory 509 can be used for storing software program and module, and processor 501 is stored in memory 509 by operation
Software program and module, thereby executing the various function application and data of the block generating device 500 based on block chain
Processing.Memory 509 can mainly include storing program area and storage data area, wherein storing program area can storage program area,
Application program needed at least one function (it is associated than data buffer storage queue as will be described and the atomic counters, and
Determine the initial value of the atomic counters) etc.;Storage data area can be stored according to the block generating device based on block chain
Use created data (such as data buffer storage queue and atomic counters) etc..In addition, memory 509 may include high speed with
Machine access memory, can also include nonvolatile memory, a for example, at least disk memory, flush memory device or its
His volatile solid-state part.There is provided in embodiments of the present invention based on the block generation method program of block chain and reception
In memory, when it is desired to be used, processor 501 is called from memory 509 for the data flow storage arrived.
When loading on computers and executing the computer program instructions, entirely or partly generate according to of the invention real
Apply process described in example or function.The computer can be general purpose computer, special purpose computer, computer network or its
His programmable device.The computer instruction may be stored in a computer readable storage medium, or can from a computer
Read storage medium transmitted to another computer readable storage medium, for example, the computer instruction can from a web-site,
Computer, server or data center pass through wired (such as coaxial cable, optical fiber, twisted pair) or wireless (such as infrared, nothing
Line, microwave etc.) mode transmitted to another web-site, computer, server or data center.It is described computer-readable
Storage medium can be any usable medium that computer can store or include that one or more usable mediums are integrated
The data storage devices such as server, data center.The usable medium can be magnetic medium, (for example, floppy disk, hard disk, magnetic
Band), optical medium (for example, CD) or semiconductor medium (such as solid state hard disk (solid state disk, SSD)) etc..
It is apparent to those skilled in the art that for convenience and simplicity of description, the system of foregoing description,
The specific work process of device and unit, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
In several embodiments provided by the present invention, it should be understood that disclosed system, device and method can be with
It realizes by another way.For example, the apparatus embodiments described above are merely exemplary, for example, the unit
It divides, only a kind of logical function partition, there may be another division manner in actual implementation, such as multiple units or components
It can be combined or can be integrated into another system, or some features can be ignored or not executed.Another point, it is shown or
The mutual coupling, direct-coupling or communication connection discussed can be through some interfaces, the indirect coupling of device or unit
It closes or communicates to connect, can be electrical property, mechanical or other forms.
The unit as illustrated by the separation member may or may not be physically separated, aobvious as unit
The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple
In network unit.It can select some or all of unit therein according to the actual needs to realize the mesh of this embodiment scheme
's.
In addition, each functional unit in embodiments of the present invention can integrate in one processing unit, it is also possible to each
A unit physically exists alone, and can also be integrated in one unit with two or more units.Above-mentioned integrated unit was both
It can take the form of hardware realization, can also realize in the form of software functional units.
If the integrated unit is realized in the form of SFU software functional unit and sells or use as independent product
When, it can store in a computer readable storage medium.Based on this understanding, technical solution of the present invention is substantially
The all or part of the part that contributes to existing technology or the technical solution can be in the form of software products in other words
It embodies, which is stored in a storage medium, including some instructions are used so that a computer
Equipment (can be personal computer, server or the network equipment etc.) executes the complete of each embodiment the method for the present invention
Portion or part steps.And storage medium above-mentioned include: USB flash disk, mobile hard disk, read-only memory (read-only memory,
ROM), random access memory (random access memory, RAM), magnetic or disk etc. are various can store program
The medium of code.
The above, the above embodiments are merely illustrative of the technical solutions of the present invention, rather than its limitations;Although referring to before
Stating embodiment, invention is explained in detail, those skilled in the art should understand that: it still can be to preceding
Technical solution documented by each embodiment is stated to modify or equivalent replacement of some of the technical features;And these
It modifies or replaces, the spirit and scope for technical solution of various embodiments of the present invention that it does not separate the essence of the corresponding technical solution.
Claims (10)
1. a kind of block generation method based on block chain characterized by comprising
It creates data buffer storage queue and atomic counters, the data buffer storage queue includes resource transfers data to be packaged;
The data buffer storage queue and the atomic counters are associated, and determine the initial value of the atomic counters;
First thread and the second thread are generated, the first thread is for increasing money to be packaged described in the data buffer storage queue
The quantity of data is shifted in source, and second thread is for reducing resource transfers data to be packaged described in the data buffer storage queue
Quantity;
Adjust the quantity of the resource transfers data to be packaged by the first thread and second thread, and by the original
The initial value of sub-count device is adjusted to target value;
The resource transfers data to be packaged are subjected to packing encapsulation according to prerequisite, generate target block.
2. the block generation method according to claim 1 based on block chain, which is characterized in that described to delay the data
It deposits queue and the atomic counters is associated, and the initial value of the determining atomic counters includes:
Determine the initial number of the resource transfers data to be packaged in the data buffer storage queue;
Set the initial number to the initial value of the atomic counters;
The quantity rate of change that the data buffer storage queue is arranged is identical as the value rate of change of the atomic counters, wherein
When the initial number of the resource transfers data to be packaged adds N, the initial value of the atomic counters adds N, alternatively, when described
When the initial number of resource transfers data to be packaged subtracts N, the initial value of the atomic counters subtracts N, and the N is integer.
3. the block generation method according to claim 1 based on block chain, which is characterized in that described to pass through described first
Thread and second thread adjust the quantity of the resource transfers data to be packaged, and by the initial value of the atomic counters
Being adjusted to target value includes:
Increase P resource transfers data to be packaged into the data buffer storage queue by the first thread, and will be described
The initial value W of atomic counters increases P, and described W, P are integer;
Extract the resource transfers data to be packaged of Q from the data buffer storage queue by second thread, and by the original
The initial value W of sub-count device reduces Q, and the Q is integer;
Obtain the target value K of the atomic counters, wherein K=W+P-Q, the K are integer;
The Q resource transfers data to be packaged are put into stripping and slicing cache module.
4. the block generation method according to claim 1 based on block chain, which is characterized in that described according to prerequisite
The resource transfers data to be packaged are subjected to packing encapsulation, generating target block includes:
When the throughput rate of the data buffer storage queue is greater than or equal to Consumption rate, judge that the time interval for generating block is
It is no to be equal to preset time period;
If the time interval for generating block is equal to the preset time period, will be all wait seal in the stripping and slicing cache module
Dress resource transfers data carry out packing stripping and slicing, and generate the target block, and the target block includes the first preset number
The resource transfers data to be packaged;
Alternatively, judging the atomic counters when the throughput rate of the data buffer storage queue is greater than or equal to Consumption rate
Target value K whether be greater than or equal to preset size;
If the target value K in the data buffer storage queue is greater than or equal to the preset size, by the stripping and slicing cache module
In all resource transfers data to be packaged carry out packing stripping and slicing, and generate the target block, the target block includes the
The resource transfers data to be packaged of two preset numbers;
Alternatively, judging the target of the atomic counters when the throughput rate of the data buffer storage queue is less than Consumption rate
Whether value K is zero;
If the target value K of the atomic counters is zero, by resource transfers to be packaged all in the stripping and slicing cache module
Data carry out packing stripping and slicing, and generate the target block, and the target block includes the described to be packaged of third preset number
Resource transfers data.
5. the block generation method according to claim 1 to 4 based on block chain, which is characterized in that in the creation
Data buffer storage queue and atomic counters, after the data buffer storage queue includes resource transfers data to be packaged, it is described will
Before the data buffer storage queue and the atomic counters are associated, the method also includes:
Obtain resource transfers data sequence to be packaged, include in the resource transfers data sequence to be packaged sequentially in time according to
Multiple resource transfers data to be packaged of secondary arrangement.
6. the block generation method according to claim 5 based on block chain, which is characterized in that described to obtain money to be packaged
Data sequence is shifted in source, include in the resource transfers data sequence to be packaged be arranged successively sequentially in time it is multiple wait seal
Filling resource transfers data includes:
Obtain multiple resource transfers data that client is sent;
The multiple resource transfers data are verified, are judged in the multiple resource transfers data with the presence or absence of the money of mistake
Shift data in source;
If there are the resource transfers data of mistake in the multiple resource transfers data, by the resource transfers data of the mistake
It deletes, multiple resource transfers data after obtaining error correction;
It whether there is identical resource transfers data in multiple resource transfers data after judging the error correction;
If there are identical resource transfers data in multiple resource transfers data after the error correction, in the identical resource
Random selection one is retained and is deleted other resource transfers data, multiple resource transfers after obtaining duplicate removal in transfer data
Data;
Multiple resource transfers data after the duplicate removal are packaged, multiple resource transfers data to be packaged are obtained;
The multiple resource transfers data to be packaged are ranked up sequentially in time, obtain resource transfers data sequence to be packaged
Column.
7. the block generation method according to claim 6 based on block chain, which is characterized in that the judgement is the multiple
Include: with the presence or absence of wrong resource transfers data in resource transfers data
Determine that target resource shifts data in the multiple resource transfers data;
Other nodes into network are requested to be broadcasted the resource transfers of target resource transfer data, nodes are total
Number is X;
The resource transfers request of the target resource transfer data of each other nodes forwarding is reacquired, what determination received
The total quantity Y of the resource transfers request of the target resource transfer data;
Determine malfunctioning node quantity Z, wherein Z=X-Y-1;
Judge whether the X meets condition X >=3Z+1;
If the X is unsatisfactory for condition X >=3Z+1, it is determined that there is the resource transfers number of mistake in the multiple resource transfers data
According to;
If the X meets condition X >=3Z+1, it is determined that there is no the resource transfers numbers of mistake in the multiple resource transfers data
According to.
8. a kind of block generating means based on block chain characterized by comprising
Creating unit, for creating data buffer storage queue and atomic counters, the data buffer storage queue includes resource to be packaged
Shift data;
It is associated with determination unit, for the data buffer storage queue and the atomic counters to be associated, and determines the original
The initial value of sub-count device;
Generation unit, for generating first thread and the second thread, the first thread is for increasing the data buffer storage queue
Described in resource transfers data to be packaged quantity, second thread is for reducing described in the data buffer storage queue wait seal
Fill the quantity of resource transfers data;
Adjustment unit, for adjusting the number of the resource transfers data to be packaged by the first thread and second thread
Amount, and the initial value of the atomic counters is adjusted to target value;
Generation unit is encapsulated, the resource transfers data to be packaged are carried out by packing encapsulation according to prerequisite, generate target area
Block.
9. a kind of block generating device based on block chain, which is characterized in that including memory, processor and be stored in described deposit
On reservoir and the computer program that can run on the processor, the processor are realized such as when executing the computer program
Based on the block generation method of block chain described in any one of claim 1-7.
10. a kind of computer readable storage medium, which is characterized in that including instruction, when described instruction is run on computers,
So that computer executes the block generation method based on block chain as described in any one of claim 1-7.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910426729.8A CN110309230A (en) | 2019-05-22 | 2019-05-22 | Block generation method, device, equipment and storage medium based on block chain |
PCT/CN2019/120814 WO2020233054A1 (en) | 2019-05-22 | 2019-11-26 | Blockchain-based block generation method, apparatus and device, and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910426729.8A CN110309230A (en) | 2019-05-22 | 2019-05-22 | Block generation method, device, equipment and storage medium based on block chain |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110309230A true CN110309230A (en) | 2019-10-08 |
Family
ID=68074990
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910426729.8A Pending CN110309230A (en) | 2019-05-22 | 2019-05-22 | Block generation method, device, equipment and storage medium based on block chain |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN110309230A (en) |
WO (1) | WO2020233054A1 (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2020233054A1 (en) * | 2019-05-22 | 2020-11-26 | 深圳壹账通智能科技有限公司 | Blockchain-based block generation method, apparatus and device, and storage medium |
CN112039987A (en) * | 2020-08-28 | 2020-12-04 | 平安科技(深圳)有限公司 | Method and device for processing blocks in block chain, node equipment and storage medium |
CN112070610A (en) * | 2020-09-01 | 2020-12-11 | 中国联合网络通信集团有限公司 | Method, node, system, electronic device and medium for verifying block validity |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112540985B (en) * | 2020-12-07 | 2023-09-26 | 江苏赛融科技股份有限公司 | Global ordering output system and method based on distributed computing framework |
CN113656499B (en) * | 2021-08-16 | 2024-04-02 | 工银科技有限公司 | Value transfer method and device based on block chain |
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 |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102473107A (en) * | 2009-07-28 | 2012-05-23 | 瑞典爱立信有限公司 | Apparatus and method for processing events in a telecommunications network |
CN106598760A (en) * | 2016-12-19 | 2017-04-26 | 北京奇虎科技有限公司 | Message queue consumption method and apparatus |
CN107241279A (en) * | 2017-06-22 | 2017-10-10 | 北京天德科技有限公司 | A kind of block chain transaction current-limiting method based on multi-buffer queue |
CN107508863A (en) * | 2017-07-27 | 2017-12-22 | 北京瑞卓喜投科技发展有限公司 | Information processing method and device applied to block chain |
US20180294966A1 (en) * | 2017-04-05 | 2018-10-11 | Samsung Sds Co., Ltd. | Blockchain-based digital identity management method |
CN109445955A (en) * | 2018-09-13 | 2019-03-08 | 武汉斗鱼网络科技有限公司 | A kind of method of counting and number system |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106651332B (en) * | 2016-12-29 | 2020-11-06 | 成都质数斯达克科技有限公司 | Method for generating new block in block chain and block chain |
CN108270821A (en) * | 2016-12-30 | 2018-07-10 | 深圳瀚德创客金融投资有限公司 | For the block generation method and network node in block chain network |
CN107067242A (en) * | 2017-03-24 | 2017-08-18 | 钱德君 | Difficulty value creation method in a kind of block chain generating process |
US11095432B2 (en) * | 2017-04-05 | 2021-08-17 | Samsung Sds Co., Ltd. | System for processing data based on blockchain and operating method thereof |
CN110309230A (en) * | 2019-05-22 | 2019-10-08 | 深圳壹账通智能科技有限公司 | Block generation method, device, equipment and storage medium based on block chain |
-
2019
- 2019-05-22 CN CN201910426729.8A patent/CN110309230A/en active Pending
- 2019-11-26 WO PCT/CN2019/120814 patent/WO2020233054A1/en active Application Filing
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102473107A (en) * | 2009-07-28 | 2012-05-23 | 瑞典爱立信有限公司 | Apparatus and method for processing events in a telecommunications network |
CN106598760A (en) * | 2016-12-19 | 2017-04-26 | 北京奇虎科技有限公司 | Message queue consumption method and apparatus |
US20180294966A1 (en) * | 2017-04-05 | 2018-10-11 | Samsung Sds Co., Ltd. | Blockchain-based digital identity management method |
CN107241279A (en) * | 2017-06-22 | 2017-10-10 | 北京天德科技有限公司 | A kind of block chain transaction current-limiting method based on multi-buffer queue |
CN107508863A (en) * | 2017-07-27 | 2017-12-22 | 北京瑞卓喜投科技发展有限公司 | Information processing method and device applied to block chain |
CN109445955A (en) * | 2018-09-13 | 2019-03-08 | 武汉斗鱼网络科技有限公司 | A kind of method of counting and number system |
Non-Patent Citations (1)
Title |
---|
袁勇;倪晓春;曾帅;王飞跃;: "区块链共识算法的发展现状与展望", 自动化学报, no. 11 * |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2020233054A1 (en) * | 2019-05-22 | 2020-11-26 | 深圳壹账通智能科技有限公司 | Blockchain-based block generation method, apparatus and device, and storage medium |
CN112039987A (en) * | 2020-08-28 | 2020-12-04 | 平安科技(深圳)有限公司 | Method and device for processing blocks in block chain, node equipment and storage medium |
WO2022041899A1 (en) * | 2020-08-28 | 2022-03-03 | 平安科技(深圳)有限公司 | Block processing method and apparatus for blockchain, node device, and storage medium |
CN112039987B (en) * | 2020-08-28 | 2022-05-20 | 平安科技(深圳)有限公司 | Method and device for processing blocks in block chain, node equipment and storage medium |
CN112070610A (en) * | 2020-09-01 | 2020-12-11 | 中国联合网络通信集团有限公司 | Method, node, system, electronic device and medium for verifying block validity |
CN112070610B (en) * | 2020-09-01 | 2023-08-29 | 中国联合网络通信集团有限公司 | Method, node, system, electronic device and medium for verifying validity of block |
Also Published As
Publication number | Publication date |
---|---|
WO2020233054A1 (en) | 2020-11-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110309230A (en) | Block generation method, device, equipment and storage medium based on block chain | |
Dogar et al. | Decentralized task-aware scheduling for data center networks | |
CN107172187B (en) | A kind of SiteServer LBS and method | |
JP5230645B2 (en) | System and method for optimizing data set changes | |
CN106126407A (en) | A kind of performance monitoring Operation Optimization Systerm for distributed memory system and method | |
CN104092756B (en) | A kind of resource dynamic distributing method of the cloud storage system based on DHT mechanism | |
CN103747274B (en) | A kind of video data center setting up cache cluster and cache resources dispatching method thereof | |
CN104866339B (en) | Distributed persistence management method, system and the device of FOTA data | |
CN107291928A (en) | A kind of daily record storage system and method | |
CN108632063A (en) | Manage the methods, devices and systems of network slice example | |
CN106101290A (en) | A kind of method and system of server cluster management | |
CN106713391A (en) | Session information sharing method and sharing system | |
CN109643310A (en) | System and method for fast resampling in database | |
CN106790563A (en) | Distributed memory system and method | |
CN107872517A (en) | A kind of data processing method and device | |
CN106713377A (en) | Distributed database load leveling method and device | |
CN105827678A (en) | High-availability framework based communication method and node | |
CN106844694B (en) | Method and apparatus for synchrodata | |
CN109241194A (en) | The load-balancing method and device of Database Systems based on High-Performance Computing Cluster distribution | |
CN108875035A (en) | The date storage method and relevant device of distributed file system | |
CN105262842B (en) | Cloud based on rendering characteristics renders file high speed transmission method | |
CN109684048A (en) | The method and device of affairs is handled in affairs submission system | |
CN107204998B (en) | Method and device for processing data | |
CN103577424B (en) | The realization method and system of distributed data base view | |
CN104572276B (en) | A kind of concurrent data processing method based on cloud computing |
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 |