Invention content
It is too low it is a primary object of the present invention to solve existing block chain TPS, at the transaction of the serious whole block chain of limitation
The problem of managing speed.
To achieve the above object, a kind of transaction buffer/accelerated method based on block chain proposed by the present invention, this method packet
Include following steps:
When user initiates a friendship for carrying parameter transaction by one block chain node of block link network network layers in application layer
When easily asking, the intelligent contract on the block chain carries out parameter legitimacy verifies to the parameter transaction of the transaction request;
When by parameter legitimacy verifies, then the transaction request is sent to transaction buffer/acceleration subsystem by the intelligence contract
System is traded processing, and trading processing result is written block chain by asynchronous system and deposited by the transaction buffer/acceleration subsystem
Memory block in reservoir.
The storage of block chain is written by asynchronous system in trading processing result by preferably described transaction buffer/acceleration subsystem
Layer in memory block the step of include:
The trading processing result for needing to be stored into chain is ranked up by timing according to the sequencing of generated time;
When the quantity for the trading processing result for needing to be stored into chain is less than or equal to first threshold quantity, press
According to clooating sequence, the memory block in the block chain accumulation layer is written into the trading processing result that chain to be entered stores;
When the quantity for the trading processing result for needing to be stored into chain is more than first threshold quantity, will sort preceding
First threshold quantity chain to be entered storage the trading processing as a result, the block chain accumulation layer is written according to clooating sequence
In memory block, the trading processing result of remaining chain to be entered storage is cached.
Preferably, trading processing result is written block chain by asynchronous system and deposited by the transaction buffer/acceleration subsystem
The step of memory block in reservoir includes:
When the transaction buffer/acceleration subsystem generates a trading processing as a result, then the trading processing result is added
One be generated in advance enter chain storage result queue, this enter chain storage result queue for cache need to be stored into chain it is described
Trading processing is as a result, when this enters the trading processing result for needing to be stored into chain in chain storage result queue according to generating
Between sequencing be ranked up;
The trading processing result that timing enters this storage of chain to be entered in chain storage result queue starts into chain storage
Operation, and after entering described in startup chain storage operation, judge that this enters the institute for needing to be stored into chain in chain storage result queue
Whether the quantity for stating trading processing result is less than first threshold quantity;
When the quantity for the trading processing result for needing to be stored into chain is less than or equal to first threshold quantity, press
According to clooating sequence, the memory block in the block chain accumulation layer is written into the trading processing result that chain to be entered stores;
When the quantity for the trading processing result for needing to be stored into chain is more than first threshold quantity, will sort preceding
First threshold quantity chain to be entered storage the trading processing as a result, the block chain accumulation layer is written according to clooating sequence
In memory block, the trading processing result of remaining chain to be entered storage is continued to cache.
Preferably, the transaction buffer/acceleration subsystem includes multiple database groups, is included in the intelligent contract
And in the data operating interface communicated with each database group, and the control that is communicated with the data operating interface
The heart, wherein:
Each described database group respectively includes the cluster load balance device communicated with the data operating interface, with
The proxy server group of cluster load balance device communication, with the first of the proxy server group communication for database
With primary database load equalizer, the primary database communicated with the primary database load equalizer, and with the primary database
The second of communication for database, a database group first for database and another database group second for data
Library communicates;
The control centre is used to issue groups of users fragment rule to the intelligent contract;
The intelligence contract initiates to preset identification information with counterparty for a node on the block chain
After data trade request, the data operating interface is called, with the groups of users fragment issued according to the control centre
Rule determines that the counterparty presets database group corresponding to identification information and the data trade asks corresponding database group
Under database, and the data trade is asked to be sent to really via the proxy server group of the determining database group
The fixed database carries out data reading operation or write operation.
Preferably, the groups of users fragment rule includes:
Predefine the mapping relations that each database group presets identification information with each counterparty;
The mapping that identification information is preset according to predetermined each database group and each counterparty is closed
System determines that the counterparty of the data trade request presets database group corresponding to identification information;
According to the mapping relations of predetermined the data trade request type and the database, the data are determined
The corresponding database of transaction request.
Preferably, the control centre is additionally operable to:
When a database group is abnormal, by the database group under data trade is asked in service queue
Line will adjust for second in another database group of database communication for database with first in the database group
For primary database, responded on behalf of to the request of the database group corresponding data trade;
It is when the database group restores normal, second in another database group is same for the data in database
It walks to first in the database group for database, second for database and primary database, and the database group is added
It asks to reach the standard grade in service queue to the data trade.
Preferably, the primary database load equalizer is additionally operable to:
When the primary database of a database group is abnormal, the original second of the database group is cut for database
It is changed to the primary database of the database group, is responded on behalf of to the request of the primary database corresponding data trade;
When the primary database restores normal, using the primary database as new second for database, it is standby to be switched to original second
The standby database of database, and original second is synchronized to new second for database for the data of database.
In addition, to achieve the above object, the present invention provides a kind of block chain transaction processing system, the block chain trading processing
System is suitable for transaction buffer/accelerated method based on block chain, the block chain transaction processing system include intelligent contract and
Transaction buffer/acceleration subsystem;Wherein:
The intelligence contract, for initiating one in application layer by one block chain node of block link network network layers as user
When transaction request with parameter transaction, parameter legitimacy verifies are carried out to the parameter transaction of the transaction request;When passing through parameter
The transaction request is then sent to transaction buffer/acceleration subsystem and is traded processing by legitimacy verifies;
The transaction buffer/acceleration subsystem, the transaction request sent for receiving the intelligent contract, and according to reception
The transaction request be traded processing, and trading processing result is passed through into asynchronous system, depositing in block chain accumulation layer is written
Storage area block.
Preferably, the transaction buffer/acceleration subsystem is additionally operable to:
The trading processing result for needing to be stored into chain is ranked up by timing according to the sequencing of generated time;
When the quantity for the trading processing result for needing to be stored into chain is less than or equal to first threshold quantity, press
According to clooating sequence, the memory block in the block chain accumulation layer is written into the trading processing result that chain to be entered stores;
When the quantity for the trading processing result for needing to be stored into chain is more than first threshold quantity, will sort preceding
First threshold quantity chain to be entered storage the trading processing as a result, the block chain accumulation layer is written according to clooating sequence
In memory block, the trading processing result of remaining chain to be entered storage is cached.
Preferably, the transaction buffer/acceleration subsystem is additionally operable to:
Generate a trading processing as a result, then by the trading processing result addition one be generated in advance enter chain storage result
Queue, this enters chain storage result queue and stores knot as a result, this enters chain for caching the trading processing for needing to be stored into chain
The trading processing result for needing to be stored into chain in fruit queue is ranked up according to the sequencing of generated time;
The trading processing result that timing enters this storage of chain to be entered in chain storage result queue starts into chain storage
Operation, and after entering described in startup chain storage operation, judge that this enters the institute for needing to be stored into chain in chain storage result queue
Whether the quantity for stating trading processing result is less than first threshold quantity;
When the quantity for the trading processing result for needing to be stored into chain is less than or equal to first threshold quantity, press
According to clooating sequence, the memory block in the block chain accumulation layer is written into the trading processing result that chain to be entered stores;
When the quantity for the trading processing result for needing to be stored into chain is more than first threshold quantity, will sort preceding
First threshold quantity chain to be entered storage the trading processing as a result, the block chain accumulation layer is written according to clooating sequence
In memory block, the trading processing result of remaining chain to be entered storage is continued to cache.
The present invention for each block chain node configuration of transaction by block link network network layers, buffering/accelerating subsystem, substantially
Improve block chain TPS, and to the transaction data that need to enter chain storage realize it is asynchronous enter chain operation, transaction data greatly improved
The stationarity for entering chain operation, effectively supports high block chain TPS.
Specific implementation mode
The principle and features of the present invention will be described below with reference to the accompanying drawings, and the given examples are served only to explain the present invention, and
It is non-to be used to limit the scope of the present invention.
As shown in FIG. 1, FIG. 1 is the present invention is based on the flows of the transaction buffer of block chain/accelerated method first embodiment to show
It is intended to.
In the present embodiment, this method includes:
Step S10, when user initiates one with transaction by one block chain node of block link network network layers in application layer
When the transaction request of parameter, the intelligent contract on block chain carries out parameter legitimacy verifies to the parameter transaction of the transaction request;
Above-mentioned parameter transaction includes producing account address, being transferred to account address, transfer amounts, produce service charge, produce account
Nonce (number once) value, the trading signature at family etc..
Above-mentioned intelligence contract carries out parameter legitimacy verifies to the parameter transaction of transaction request, if passing through parameter legitimacy school
It tests, thens follow the steps S20, if not by parameter legitimacy verifies, do not execute step S20.Specific parameter legitimacy verifies
Method can be exemplified as:If producing account does not meet default account rule, it is determined that parameter transaction is illegal;If being transferred to account not being inconsistent
It closes and presets account rule, it is determined that parameter transaction is illegal;If producing account in predetermined blacklist, it is determined that transaction ginseng
Number is illegal.
Step S20, when by parameter legitimacy verifies, then the transaction request is sent to by the intelligent contract on the block chain
Transaction buffer/acceleration subsystem is traded processing, and the transaction buffer/acceleration subsystem passes through trading processing result asynchronous
The memory block in block chain accumulation layer is written in mode.
Preferably, in the present embodiment, above-mentioned transaction buffer/acceleration subsystem writes trading processing result by asynchronous system
The step of entering the memory block in block chain accumulation layer can be specially:
The trading processing result for needing to be stored into chain is ranked up by timing according to the sequencing of generated time;
When the quantity for the trading processing result for needing to be stored into chain is less than or equal to first threshold quantity, according to row
Sequence sequence, by the memory block in the trading processing result write-in block chain accumulation layer of chain to be entered storage;
When the quantity for the trading processing result for needing to be stored into chain is more than first threshold quantity, preceding the will be sorted
The trading processing of chain the to be entered storage of one number of thresholds according to clooating sequence as a result, be written the memory block in block chain accumulation layer
Block caches the trading processing result of remaining chain storage to be entered.
Preferably, in the present embodiment, above-mentioned transaction buffer/acceleration subsystem writes trading processing result by asynchronous system
The step of entering the memory block in block chain accumulation layer can be specially:
When transaction buffer/acceleration subsystem generates a trading processing as a result, the trading processing result is then added one
What is be generated in advance enters chain storage result queue, this enters chain storage result queue for caching the trading processing for needing to be stored into chain
As a result, this enters sequencing of the trading processing result for needing to be stored into chain in chain storage result queue according to generated time
It is ranked up;
The trading processing result that timing enters this storage of chain to be entered in chain storage result queue starts into chain storage operation,
And after starting chain storage operation, judge that this enters the trading processing result for needing to be stored into chain in chain storage result queue
Quantity whether be less than first threshold quantity;
When the quantity for the trading processing result for needing to be stored into chain is less than or equal to first threshold quantity, according to row
Sequence sequence, by the memory block in the trading processing result write-in block chain accumulation layer of chain to be entered storage;
When the quantity for the trading processing result for needing to be stored into chain is more than first threshold quantity, preceding the will be sorted
The trading processing of chain the to be entered storage of one number of thresholds according to clooating sequence as a result, be written the memory block in block chain accumulation layer
Block continues to cache to the trading processing result of remaining chain storage to be entered.
The present embodiment by block link network network layers (i.e.:P2P (Peer-to-peer, equity) network layer), it is each area
Block chain node configuration of transaction buffers/accelerate subsystem, block chain TPS, and the number of deals to chain storage need to be entered greatly improved
Factually it is existing it is asynchronous enter chain operation, the stationarity that transaction data enters chain operation greatly improved, effectively support high block chain TPS.
As shown in Fig. 2, Fig. 2 is the system architecture diagram of transaction buffer of the present invention/acceleration subsystem.
It should be noted that only showing two database groups 210 in Fig. 2, it is not meant to limit database group 210
It it is two, the present invention is not construed as limiting the quantity of database group 210, in addition, may include in proxy server group 212 multiple
Proxy server (not shown).
The present invention is based in the transaction buffer of block chain/accelerated method second embodiment, the transaction buffer/acceleration subsystem
System includes multiple database groups 210, and the data manipulation communicated included in intelligent contract and with each database group 210 connects
200 (such as API, Application Programming Interface, application programming interface) of mouth, and grasped with data
Make the control centre 220 of the communication of interface 200, wherein:
Each database group 210 respectively includes the cluster load balance device 211 communicated with data operating interface 200
(LVS), proxy server (DbProxy) group 212 communicated with cluster load balance device 211, with proxy server group 212
The first of communication is equal with primary database load for database 214 (slave) and primary database load equalizer 213 (HaProxy)
The primary database 215 (Master) that weighing apparatus 213 communicates, and communicated with primary database 215 second for database 216, a number
It is communicated for database 216 with the second of another database group 210 for database 214 according to the first of library group 210;
Control centre 220 is used to issue groups of users fragment rule to intelligent contract;
Intelligent contract initiates to preset the data trade of identification information with counterparty for a node on block chain
After request, data operating interface 200 is called, according to the groups of users fragment rule issued in advance from control centre 220, to determine
The counterparty presets database group 210 corresponding to identification information and the data trade is asked under corresponding database group 210
Database, and the data trade asked via determining 210 proxy server group 212 of database group to be sent to determination
Database carry out data reading operation or write operation.
It can be user identity information (for example, user account name) that above-mentioned counterparty, which presets identification information, and above-mentioned intelligence is closed
The effect of data operating interface 200 is about called to be, by calling data operating interface 200, which to be sent to transaction
Buffering/acceleration subsystem is traded processing.
Preferably, in the present embodiment, the groups of users fragment rule includes:
Predefine the mapping relations that each database group 210 presets identification information with each counterparty;
For example, each database group 210 can correspond to a different counterparty respectively presets identification information set, respectively
It includes that one or more counterparties preset identification information that a counterparty, which presets identification information set,.
The mapping relations of identification information are preset according to predetermined each database group 210 and each counterparty, really
The counterparty for making data trade request presets database group 210 corresponding to identification information;
According to the mapping relations of predetermined data trade request type and database, determine that data trade request corresponds to
Database.
For example, data reading operation asks corresponding database can be for first for database 214;Data write operation request pair
The database answered can be primary database 215.
Preferably, in the present embodiment, the control centre 220 is additionally operable to:
When a database group 210 is abnormal, which is asked into service queue from data trade
In it is offline, by another database group 210 communicated for database 214 with first in the database group 210
Two are adjusted to primary database 215 for database 216, are rung on behalf of to the 210 corresponding data trade of database group request
It answers;
The above-mentioned judgement being abnormal to a database group 210 can be specially:If a database group 210 can not be complete
At normal data reading operation and/or write operation, it is determined that the database group 210 is abnormal.
When the database group 210 restores normal, by second in another database group 210 for database 216
In data be synchronized to first in the database group 210 for database 214, second for database 216 and primary database
215, and the database group 210 is added in data trade request service queue and is reached the standard grade.
The control centre 220 of the present embodiment can dynamically adjust primary database 215 between database group 210, when one
When database group 210 is abnormal, second in another database group 210 can be adjusted to master data for database 216
Library 215 enables the database group 210 again when the database group 210 being abnormal restores normal, in number
When being abnormal according to library group, it independently can quickly restore to service.
Preferably, in the present embodiment, the primary database load equalizer 213 is additionally operable to:
When the primary database 215 of a database group 210 is abnormal, by the original second of the database group 210
Standby database 216 is switched to the primary database 215 of the database group 210, is handed on behalf of to the 215 corresponding data of primary database
Easily request is responded;
When the primary database 215 restores normal, which is switched to as new second for database 216
Original second and is synchronized to new second for database by former second for the standby database of database 216 for the data of database 216
216。
The primary database load equalizer 213 of the present embodiment may be implemented in a database group 210 and dynamically adjust main number
According to library 215, to when primary database 215 is abnormal, independently can quickly restore to service.
In addition, the present invention also proposes a kind of block chain transaction processing system, which is suitable for base
In transaction buffer/accelerated method of block chain.
As shown in figure 3, Fig. 3 is 1 first embodiment system architecture schematic diagram of block chain transaction processing system of the present invention.
In the present embodiment, the block chain transaction processing system 1 includes intelligence and about 10 and transaction buffer/acceleration subsystem
20;
The intelligence and about 10, for initiating one in application layer by one block chain node of block link network network layers as user
When a transaction request with parameter transaction, parameter legitimacy verifies are carried out to the parameter transaction of the transaction request;Join when passing through
Number legitimacy verifies, then be sent to transaction buffer/acceleration subsystem 20 by the transaction request and be traded processing;
The transaction buffer/acceleration subsystem 20, the transaction request for receiving the intelligence and about 10 transmissions, and according to
The transaction request received is traded processing, and trading processing result is written by asynchronous system in block chain accumulation layer
Memory block.
Above-mentioned parameter transaction includes producing account address, being transferred to account address, transfer amounts, produce service charge, produce account
Nonce (number once) value, the trading signature at family etc..
The parameter transaction of above-mentioned intelligence and about 10 pairs of transaction requests carries out parameter legitimacy verifies, if passing through parameter legitimacy
Verification, then call transaction buffer/acceleration subsystem 20, if not by parameter legitimacy verifies, never call calling transaction buffer/
Accelerate subsystem 20.The method of specific parameter legitimacy verifies can be exemplified as:If producing account does not meet default account rule,
Then determine that parameter transaction is illegal;If being transferred to account does not meet default account rule, it is determined that parameter transaction is illegal;If producing account
In predetermined blacklist, it is determined that parameter transaction is illegal.
Preferably, in the present embodiment, above-mentioned transaction buffer/acceleration subsystem 20 is additionally operable to:
The trading processing result for needing to be stored into chain is ranked up by timing according to the sequencing of generated time;
When the quantity for the trading processing result for needing to be stored into chain is less than or equal to first threshold quantity, according to row
Sequence sequence, by the memory block in the trading processing result write-in block chain accumulation layer of chain to be entered storage;
When the quantity for the trading processing result for needing to be stored into chain is more than first threshold quantity, preceding the will be sorted
The trading processing of chain the to be entered storage of one number of thresholds according to clooating sequence as a result, be written the memory block in block chain accumulation layer
Block caches the trading processing result of remaining chain storage to be entered.
Preferably, in the present embodiment, above-mentioned transaction buffer/acceleration subsystem 20 is additionally operable to:
It is tied when generating a trading processing as a result, the chain storage that enters that one is generated in advance then is added in the trading processing result
Fruit queue, this enters chain storage result queue for caching the trading processing for needing to be stored into chain as a result, this enters chain storage result
The trading processing result for needing to be stored into chain in queue is ranked up according to the sequencing of generated time;
The trading processing result that timing enters this storage of chain to be entered in chain storage result queue starts into chain storage operation,
And after starting chain storage operation, judge that this enters the trading processing result for needing to be stored into chain in chain storage result queue
Quantity whether be less than first threshold quantity;
When the quantity for the trading processing result for needing to be stored into chain is less than or equal to first threshold quantity, according to row
Sequence sequence, by the memory block in the trading processing result write-in block chain accumulation layer of chain to be entered storage;
When the quantity for the trading processing result for needing to be stored into chain is more than first threshold quantity, preceding the will be sorted
The trading processing of chain the to be entered storage of one number of thresholds according to clooating sequence as a result, be written the memory block in block chain accumulation layer
Block continues to cache to the trading processing result of remaining chain storage to be entered.
The present embodiment by the way that in block link network network layers, subsystem 20 is buffered/accelerates for each block chain node configuration of transaction,
Greatly improved block chain TPS, and to the transaction data that need to enter chain storage realize it is asynchronous enter chain operation, transaction greatly improved
Data enter the stationarity of chain operation, effectively support high block chain TPS.
Referring to Fig. 2, in 1 second embodiment of block chain transaction processing system of the present invention, the transaction buffer/acceleration
Subsystem 20 includes multiple database groups 210, is included in the number communicated in intelligence and about 10 and with each database group 210
According to operate interface 200 (such as API, Application Programming Interface, application programming interface), and
The control centre 220 communicated with data operating interface 200, wherein:
Each database group 210 respectively includes the cluster load balance device 211 communicated with data operating interface 200
(LVS), proxy server (DbProxy) group 212 communicated with cluster load balance device 211, with proxy server group 212
The first of communication is equal with primary database load for database 214 (slave) and primary database load equalizer 213 (HaProxy)
The primary database 215 (Master) that weighing apparatus 213 communicates, and communicated with primary database 215 second for database 216, a number
It is communicated for database 216 with the second of another database group 210 for database 214 according to the first of library group 210;
Control centre 220 is used to issue groups of users fragment rule to intelligence and about 10;
Intelligence carries the data friendship that counterparty presets identification information with about 10 for the node initiation on block chain
Easily after request, data operating interface 200 is called, with regular according to the groups of users fragment issued in advance from control centre 220, really
The fixed counterparty presets database group 210 corresponding to identification information and the data trade asks corresponding database group 210
Under database, and the data trade is asked to be sent to really via determining 210 proxy server group 212 of database group
Fixed database carries out data reading operation or write operation.
It can be user identity information (for example, user account name) that above-mentioned counterparty, which presets identification information, and above-mentioned intelligence is closed
The effect of about 10 calling data operating interfaces 200 is, by calling data operating interface 200, which to be sent to friendship
Easy buffering/acceleration subsystem 20 is traded processing.
Preferably, in the present embodiment, the groups of users fragment rule includes:
Predefine the mapping relations that each database group 210 presets identification information with each counterparty;
For example, each database group 210 can correspond to a different counterparty respectively presets identification information set, respectively
It includes that one or more counterparties preset identification information that a counterparty, which presets identification information set,.
The mapping relations of identification information are preset according to predetermined each database group 210 and each counterparty, really
The counterparty for making data trade request presets database group 210 corresponding to identification information;
According to the mapping relations of predetermined data trade request type and database, determine that data trade request corresponds to
Database.
For example, data reading operation asks corresponding database can be for first for database 214;Data write operation request pair
The database answered can be primary database 215.
Preferably, in the present embodiment, the control centre 220 is additionally operable to:
When a database group 210 is abnormal, which is asked into service queue from data trade
In it is offline, by another database group 210 communicated for database 214 with first in the database group 210
Two are adjusted to primary database 215 for database 216, are rung on behalf of to the 210 corresponding data trade of database group request
It answers;
The above-mentioned judgement being abnormal to a database group 210 can be specially:If a database group 210 can not be complete
At normal data reading operation and/or write operation, it is determined that the database group 210 is abnormal.
When the database group 210 restores normal, by second in another database group 210 for database 216
In data be synchronized to first in the database group 210 for database 214, second for database 216 and primary database
215, and the database group 210 is added in data trade request service queue and is reached the standard grade.
The control centre 220 of the present embodiment can dynamically adjust primary database 215 between database group 210, when one
When database group 210 is abnormal, second in another database group 210 can be adjusted to master data for database 216
Library 215 enables the database group 210 again when the database group 210 being abnormal restores normal, in number
When being abnormal according to library group, it independently can quickly restore to service.
Preferably, in the present embodiment, the primary database load equalizer 213 is additionally operable to:
When the primary database 215 of a database group 210 is abnormal, by the original second of the database group 210
Standby database 216 is switched to the primary database 215 of the database group 210, is handed on behalf of to the 215 corresponding data of primary database
Easily request is responded;
When the primary database 215 restores normal, which is switched to as new second for database 216
Original second and is synchronized to new second for database by former second for the standby database of database 216 for the data of database 216
216。
The primary database load equalizer 213 of the present embodiment may be implemented in a database group 210 and dynamically adjust main number
According to library 215, to when primary database 215 is abnormal, independently can quickly restore to service.
The foregoing is merely the preferred embodiment of the present invention, are not intended to limit the scope of the invention, every at this
Under the inventive concept of invention, using equivalent structure transformation made by description of the invention and accompanying drawing content, or directly/use indirectly
In the scope of patent protection that other related technical areas are included in the present invention.