CN109145163A - Block chain data capacity reduction method, device and storage medium - Google Patents
Block chain data capacity reduction method, device and storage medium Download PDFInfo
- Publication number
- CN109145163A CN109145163A CN201810965094.4A CN201810965094A CN109145163A CN 109145163 A CN109145163 A CN 109145163A CN 201810965094 A CN201810965094 A CN 201810965094A CN 109145163 A CN109145163 A CN 109145163A
- Authority
- CN
- China
- Prior art keywords
- block
- node
- block chain
- data
- capacity reducing
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a kind of block chain data capacity reduction methods, comprising the following steps: when the starting of this block chain link point, reads the node type and history data store type locally saved;Based on the node type and the history data store type, judge whether this block chain link point meets data capacity reducing condition;If meeting data capacity reducing condition, data capacity reducing is carried out to the block for not carrying out data capacity reducing in current this block chain link point;Wherein, if this block chain link point is snapshot node type or thermal center vertex type, and node type does not change or degrades, it is determined that this block chain link point meets data capacity reducing condition.The invention also discloses a kind of block chain data capacity reducing device and computer readable storage mediums.The present invention realizes the flexible capacity reducing of block chain data under the premise of guaranteeing the safety and reliability of block chain operation.
Description
Technical field
The present invention relates to block chain technical field more particularly to a kind of block chain data capacity reduction methods, device and computer
Readable storage medium storing program for executing.
Background technique
With the growth of block chain transaction, the continuous addition of new block, the rapid expanding of block chain state is brought.This gives
Block chain node brings storage pressure and increases carrying cost.Therefore it needs to carry out capacity reducing to block chain data, so that
Block chain node can reduce carrying cost and storage pressure, reach continuous service free of discontinuities under the premise of guaranteeing reliability
Purpose.
The prior art, which generallys use, actively to be abandoned the mode of historical data and carries out capacity reducing, do not retain any historical data and with
Any association of historical data, by current block carry out snapshot, by institute it is stateful export be reassembled as new block chain originate
Block, and open new block chain network.Even if block chain network rapid expanding, this method can regard the degree choosing of data expansion
It selects and is periodically executed, reach capacity reducing data to purpose.But the disadvantages of this method are: can not achieve the spirit of block chain data
Capacity reducing living.For example, certain some block chain node needs to carry out capacity reducing under certain scene, and under another scene, these block chains
Node no longer needs to carry out capacity reducing again.
Summary of the invention
The main purpose of the present invention is to provide a kind of block chain data capacity reduction method, device and computer-readable storage mediums
Matter, it is intended to solve how under the premise of guaranteeing block chain node data reliability, realize the skill of the flexible capacity reducing of block chain data
Art problem.
To achieve the above object, the present invention provides a kind of block chain data capacity reduction method, the block chain data capacity reducing side
Method the following steps are included:
When the starting of this block chain link point, the node type and history data store type locally saved is read;
Based on the node type and the history data store type, judge whether this block chain link point meets data contracting
Appearance condition;
If meeting data capacity reducing condition, data are carried out to the block for not carrying out data capacity reducing in current this block chain link point
Capacity reducing;
Wherein, if this block chain link point be snapshot node type or thermal center vertex type, and node type do not change or
Person degrades, it is determined that this block chain link point meets data capacity reducing condition.
Optionally, block chain node locally preserves node parameter configuration information and node history data store information;
The node parameter configuration information includes: node type, node snapshot period, node hot data block section, wherein
The grade for achieving node is higher than snapshot node, and the grade of snapshot node is higher than thermal center point;The node history data store information
It include: history data store type, snapshot point list, current newest block field.
Optionally, described to include: to the block progress data capacity reducing for not carrying out data capacity reducing in current this block chain link point
If this block chain link point is snapshot node type, latest snapshot point in the snapshot point list and current is read
Newest block field;
Since the snapshot point corresponds to block, it is incremented by block height and successively executes the transaction in each block until currently most
New block;
If the number of blocks continuously performed reaches the node snapshot period, to each block generated in implementation procedure
Data space carries out state snapshot, and generates new snapshot point;
New snapshot point is added in the snapshot point list, the data space of this snapshot is deleted, to carry out data
Capacity reducing.
Optionally, described that the block progress data capacity reducing for not carrying out data capacity reducing in current this block chain link point is also wrapped
It includes:
If this block chain link point is thermal center vertex type, node hot data block section is read;
Node hot data block section is subtracted from current block height, the starting point block for obtaining node dsc data is high;
By the data space deletion of the starting point block all blocks before high, to carry out data capacity reducing.
Optionally, the block chain data capacity reduction method further include:
If this block chain link point is unsatisfactory for data capacity reducing condition or does not carry out data in current this block chain link point
After the block of capacity reducing carries out data capacity reducing, node hot data block section and current newest block field are read;
Node hot data block section is subtracted from current block height, the starting point block for obtaining hot spot data cache pool is high;
Since the starting point block height, it is incremented by block height and successively executes the transaction in each block until current most new district
Block;
All data spaces generated in implementation procedure are cached in memory.
Optionally, the block chain data capacity reduction method further include:
Update the node history data store information locally saved;
Into block chain network, other block chain nodes initiate the connection request, and with other block chain node interchange informations,
The interchange information includes the node type of current block chain node, current latest block height.
Further, to achieve the above object, the present invention also provides a kind of block chain data capacity reducing device, the block chains
Data capacity reducing device includes:
Node execution module, for reading the node type and history locally saved when the starting of this block chain link point
Stored Data Type;Based on the node type and the history data store type, judge whether this block chain link point meets
Data capacity reducing condition;
Node capacity reducing module, if for meeting data capacity reducing condition, to not carrying out data in current this block chain link point
The block of capacity reducing carries out data capacity reducing;Wherein, if this block chain link point is snapshot node type or thermal center vertex type, and node class
Type does not change or degrades, it is determined that this block chain link point meets data capacity reducing condition.
Optionally, block chain node locally preserves node parameter configuration information and node history data store information;
The node parameter configuration information includes: node type, node snapshot period, node hot data block section, wherein
The grade for achieving node is higher than snapshot node, and the grade of snapshot node is higher than thermal center point;The node history data store information
It include: history data store type, snapshot point list, current newest block field.
Optionally, the node capacity reducing module includes:
Snapshot node capacity reducing unit reads the snapshot point range if being snapshot node type for this block chain link point
Latest snapshot point and current newest block field in table;Since the snapshot point corresponds to block, it is incremented by block height and successively
The transaction in each block is executed until current newest block;If the number of blocks continuously performed reaches the node snapshot period,
State snapshot then is carried out to the data space of each block generated in implementation procedure, and generates new snapshot point;By new snapshot
Point is added in the snapshot point list, the data space of this snapshot is deleted, to carry out data capacity reducing.
Optionally, the node capacity reducing module further include:
Thermal center point capacity reducing unit reads the node hot data block if being thermal center vertex type for this block chain link point
Section;Node hot data block section is subtracted from current block height, the starting point block for obtaining node dsc data is high;The starting point block is high
The data space of all blocks is deleted before, to carry out data capacity reducing.
Optionally, the block chain data capacity reducing device further include:
Dsc data establishes module, if being unsatisfactory for data capacity reducing condition for this block chain link point or to this current block
Do not carried out in chain node data capacity reducing block carry out data capacity reducing after, read node hot data block section and it is current most
New block field;Node hot data block section is subtracted from current block height, the starting point block for obtaining hot spot data cache pool is high;From
The starting point block height starts, and is incremented by block height and successively executes the transaction in each block until current newest block;It will execute
All data spaces generated in journey are cached in memory.
Optionally, the block chain data capacity reducing device further include:
Update module, for updating the node history data store information locally saved;
Networking module, for into block chain network other block chain nodes initiate the connection request, and with other block chains
Node interchange information, the interchange information include the node type of current block chain node, current latest block height.
Further, to achieve the above object, the present invention also provides a kind of computer readable storage medium, the computers
Block chain data capacity reducing program is stored on readable storage medium storing program for executing, it is real when the block chain data capacity reducing program is executed by processor
Now the step of described in any item block chain data capacity reduction methods as above.
In the present invention, by block chain network interior joint carry out function combination distinguish, define achieve node, snapshot node,
Thermal center point.Wherein, all data of node memory block chain and persistence are achieved and does not do any capacity reducing, and snapshot node, thermal center
The synchronous newest block information saved in block chain network of point and last state are without saving historical state data, block chain link
The condition for clicking through row data capacity reducing is only related to node parameter configuration, and then in the safety and reliability for guaranteeing the operation of block chain
Under the premise of, by configuration node parameter, and then it can realize the flexible capacity reducing of block chain node data.
Detailed description of the invention
Fig. 1 is the flow diagram of block chain data capacity reduction method first embodiment of the present invention;
Fig. 2 is the flow diagram of block chain data capacity reduction method second embodiment of the present invention;
Fig. 3 is the functional block diagram of block chain data capacity reducing device first embodiment of the present invention;
Fig. 4 is the refinement the functional block diagram of one embodiment of Fig. 3 interior joint capacity reducing module;
Fig. 5 is the functional block diagram of block chain data capacity reducing device second embodiment of the present invention;
Fig. 6 is the functional block diagram of block chain data capacity reducing device 3rd embodiment of the present invention.
The embodiments will be further described with reference to the accompanying drawings for the realization, the function and the advantages of the object of the present invention.
Specific embodiment
It should be appreciated that described herein, specific examples are only used to explain the present invention, is not intended to limit the present invention.
To facilitate a better understanding of the present invention, technical term involved in the present invention is illustrated below.
(1) block chain
The distributed account book database of block chain, that is, decentralization.Block chain itself is a string in fact using cryptographic algorithm
Generated data block contains multiple block chain network in each data block and trades the information effectively confirmed.
(2) block chain is traded
Basic concept and nuclear structure in block chain, it can be identified and be executed by the accounting nodes of block chain, and complete
After net is reached common understanding, permanently it is recorded in block chain account book.It is the important component of block chain account book.In structure of deal
It is main to include transaction initiator, transaction acceptance side, transaction data content etc..Hereinafter referred transaction.
(3) block chain node
The process for running particular block chain software on a computing device, is referred to as block chain node in logic.Node root
Difference is combined according to the function of offer, there are different node types.But different types of node can pass through point to point network
It is contacted with other nodes foundation in block chain, and newest block head information synchronous with block chain network.
(4) block chain state
Refer to block chain in the set of all data modes of some particular moment.The set with block height growth not
Disconnected to change, the form of expression of set is generally Key-Value structure.According to different implementations, the storage of the set
Medium can be hard disk and be also possible to flash memory or distributed storage or other media.The present invention will save the area under each piece of height
Block chain state is known as state snapshot.Difference between continuous state snapshot is mainly brought by trading to execute in block.
(5) data space
Refer to all data contents of some block and its associated intelligent contract and the ensemble space of state.The set is empty
Between can constantly change with the operation of intelligent contract.Each block has a self-existent data empty in block chain
Between, but the partial data permission in data space is quoted mutually between different data spaces.The organizer of the ensemble space
Formula can be there are many implementation.Most commonly seen is to carry out tissue using the data structure of Merle Tree.
(6) block head
The important component of block in block chain.Main function be state current block and a upper block contact and
The relevant information of itself, such as block height, block Hash are described.
(7) block height
Block height is the identifier of block, refers to position of the block in block chain.There are two identifiers for block, first is that
The cryptographic Hash of block head, second is that block height.Block cryptographic Hash can it is unique, specifically identify a block, and any section
Point can independently obtain the block cryptographic Hash by simply carrying out Hash calculation to block head.
(8) node type and node related information
Capacity reducing is carried out under the premise of safety and reliability to guarantee the operation of block chain network, and reduces block chain data
Carrying cost, therefore, invention introduces the partial pressures combined based on nodal function and capacity reducing mode, specifically by block chain network
In node division be with Types Below:
(1) node is achieved
It achieves node and undertakes indispensable functional role in block chain network, be the essential node in block chain network
Type.It synchronizes and saves newest status data and all historical datas, possesses the data universal class of block chain network, and
Without any capacity reducing.It can not only participate in network common recognition, while can also provide data query service to other nodes.It deposits
The major function set of shelves node include the following:
1, transaction acceptance;
2, transaction broadcast;
3, transaction executes;
4, common recognition is participated in;
5, newest transaction and status data storage;
6, newest transaction and state-data queries;
7, historical trading and status data storage;
8, historical trading and state-data queries.
(2) snapshot node
Snapshot node is the optional node type in block chain network.It is configured according to node inherent parameters, to block shape
State carries out periodic snapshots, and the carry out capacity reducing of gap periods formula is carried out to historical data.It automatically according to block growth, no
It is disconnected by snapshot point toward front slide.Data inquiry request for hitting snapshot point is directly read from local snapshot data, if
It is not hit local express according to point data, then requests lack part data to archive node since apart from nearest snapshot point,
Inquiry request is re-executed again.The major function set of snapshot node include the following:
1, transaction acceptance;
2, transaction broadcast;
3, transaction executes;
4, common recognition is participated in;
5, newest transaction and status data storage;
6, newest transaction and state-data queries;
7, historical trading and state-data queries.
(3) thermal center point
Thermal center point is the optional node type in block chain network.It is configured according to node inherent parameters, is only saved newest
Block data and corresponding status data in one section of block height.It automatically according to block growth constantly to historical data into
Row capacity reducing is eliminated.It supports the inquiry request for current dsc data, if not hitting the inquiry request of current dsc data, then
Return to mistake.The major function set of thermal center point include the following:
1, transaction acceptance;
2, transaction broadcast;
3, transaction executes;
4, common recognition is participated in;
5, newest transaction and status data storage;
6, newest transaction and state-data queries.
In block chain network of the invention, at least possess the archive node of one or more.Snapshot node and hot spot are equal
For optional node.Memory node can be downgraded to snapshot node or thermal center point by changing node parameter configuration information.Snapshot section
Point can be downgraded to thermal center point by changing node parameter configuration information.Thermal center point is not supported to upgrade to snapshot node, also not propped up
It holds and upgrades to archive node.Snapshot node is not supported to upgrade to archive node.
(4) node parameter configuration information
Node participate in block chain network at the beginning, can be comprehensive according to factors such as network model, business scenario, machine resources
It closes and considers to select node type.Node type configures to describe to determine by node itself.Node parameter configuration information includes
Following critical field:
1, node type, including achieve node, snapshot node and thermal center point three types;
2, the node snapshot period refers to the corresponding block counts of a state snapshot, for example, the node snapshot period is 3, then refers to every
A state snapshot is carried out every 3 blocks.
3, node hot data block section refers to the block length for memory node dsc data, such as node hot data block area
Between be 100, then refer to the starting point block height of memory node dsc data to the high difference of block between terminal block height be 100.
(5) node history data store information
All types of nodes all have node history data store information, are stored in local storage medium, comprising with
Lower message structure:
1, history data store type, node type when finger joint point store historical data, since node can pass through parameter
Therefore configuration, which carries out node type change, can describe the history node type of node by history data store type, specific to wrap
It includes and achieves node, snapshot node and thermal center point three types.
2, snapshot point list includes that state snapshot snapshot point generated, the position of snapshot point are specific each time for node
It is marked by block height.For example, it is assumed that carrying out state snapshot since block height is 3 block, and node snapshot
Period is 2, then the position for the snapshot point that this state snapshot generates is block height 5.
3, current newest block field, block field refer specifically to block height, and abbreviation block is high.Newest block corresponds to node
The new block of generation or the new block being synchronized to.
Below based on the basic conception of aforementioned present invention, the realization process of block chain data capacity reduction method of the present invention is carried out
It is described in detail.
Embodiment one: data inactivity capacity reducing is carried out when node starts
Due in the present invention block chain node can by adjusting node parameter configuration information, and then can change node type,
Node snapshot period or node hot data block section, for the adjustment for coping with node parameter configuration information, therefore, it is necessary to each
Data inactivity capacity reducing is all carried out when minor node starts.
Referring to Fig.1, Fig. 1 is the flow diagram of block chain data capacity reduction method first embodiment of the present invention.The present embodiment
In, the implementation process of node data static state capacity reducing the following steps are included:
Step S110 reads the node type and history data store locally saved when the starting of this block chain link point
Type;
Step S120 is based on the node type and the history data store type, whether judges this block chain link point
Meet data capacity reducing condition;
In the present embodiment, the node type of block chain node, which can be, to be achieved in node, snapshot node and thermal center point
Any type.And history data store type is also possible to achieve any class in node, snapshot node and thermal center point
Type.
The present embodiment is specifically based on node type and history data store type, judges whether this block chain link point meets number
According to capacity reducing condition.
In the present embodiment, if this block chain link point is snapshot node type or thermal center vertex type, and node type does not occur
Variation degrades, it is determined that this block chain link point meets data capacity reducing condition, specifically includes:
(1) if history data store type is to achieve node or snapshot node, and this block chain link point is snapshot node class
Type, it is determined that this block chain link point meets data capacity reducing condition;
(2) if history data store type is to achieve node or snapshot node or thermal center point, and this block chain link point is heat
Node type, it is determined that this block chain link point meets data capacity reducing condition.
Step S130, if meeting data capacity reducing condition, to the area for not carrying out data capacity reducing in current this block chain link point
Block carries out data capacity reducing.
In the present embodiment, if this block chain link point meets data capacity reducing condition, in current this block chain link point not into
The block of row data capacity reducing carries out data capacity reducing.And if this block chain link point is unsatisfactory for data capacity reducing condition, this block chain link
Point is without carrying out data capacity reducing.For example, history data store type is to achieve node, and this block chain link point is to achieve node class
Type, then without data inactivity capacity reducing.
In the present embodiment, the condition that block chain link clicks through row data capacity reducing is only related to node parameter configuration, and then is protecting
Under the premise of the safety and reliability for demonstrate,proving the operation of block chain, by configuration node parameter, and then block chain number of nodes can be realized
According to flexible capacity reducing.
Further, in one embodiment of block chain data capacity reduction method of the present invention, block chain is based in above-described embodiment
The node type of node determines the static capacity reducing strategy of node data, specifically includes:
(1) if this block chain link point is snapshot node type, this node data capacity reducing process is as follows:
1, the latest snapshot point in snapshot point list and current newest block field are read;
2, since the snapshot point corresponds to block, it is incremented by block height and successively executes the transaction in each block until current
Newest block;
If the number of blocks 3, continuously performed reaches the node snapshot period, to the number of each block generated in implementation procedure
State snapshot is carried out according to space, and generates new snapshot point;
4, new snapshot point is added in snapshot point list, deletes the data space of this snapshot, to carry out data contracting
Hold;
5, when not regenerating new snapshot point, the static capacity reducing process of this node data is exited.
For example, it is assumed that the position of latest snapshot point is block height 30 in snapshot point list, current newest block is block
Highly 42, the node snapshot period is 10 blocks, then since block height 30, executes each block between block height 30 to 42
In transaction, while in the process of implementation, when reaching the node snapshot period, to executing between block height 30 to 40 in block
Transaction caused by data space carry out state snapshot, and 40 position of block height generate a new snapshot point, by this newly
Snapshot point is added in snapshot point list and deletes the data space of this snapshot.When having executed the transaction in block height 42
And when not regenerating new snapshot point, the static capacity reducing process of this node data is exited.
(2) if this block chain link point is thermal center vertex type, this node data capacity reducing process is as follows:
1, node hot data block section is read;
2, node hot data block section is subtracted from current block height, the starting point block for obtaining node dsc data is high;
3, by the starting point block, the data space of all blocks is deleted before high, to carry out data capacity reducing.
For example, it is assumed that node hot data block section is 100 blocks, current newest block height is 1000, then node heat
The starting point block a height of 901 of data, namely retain 100 blocks from block high 901 to 1000 as node hot data block, and delete
The data space of all blocks before block high 901.
Embodiment two: hot spot data cache pool is established
The present invention has carried out node type division to block chain link point, and all data of archive node memory block chain are simultaneously permanent
Any capacity reducing is not done in preservation, and snapshot node, thermal center the point only synchronous newest block information saved in block chain network and newest
State is without saving historical state data.Therefore it when snapshot node, thermal center point need any non-present last state data, needs
Enquiry of historical data is requested to node is achieved, thus the most of inquiry request for causing snapshot node, thermal center point to receive is equal
Need to access archive node, and then increase network load and pressure, in the case where inquiring more application scenarios, achieve node at
New system bottleneck, system delay greatly increase.
It is the flow diagram of block chain data capacity reduction method second embodiment of the present invention referring to Fig. 2, Fig. 2.
In the present embodiment, if block chain node is unsatisfactory for data capacity reducing condition when starting, or opened in block chain node
After moving and carrying out data capacity reducing to the block for not carrying out data capacity reducing in current this block chain link point, then it is slow to execute hot spot data
Deposit the Establishing process in pond.In the present embodiment, the Establishing process of hot spot data cache pool includes:
Step S210 reads node hot data block section and current newest block field;
Step S220 subtracts node hot data block section from current block height, obtains the starting point of hot spot data cache pool
Block is high;
Node hot data block section refers to for the block length of memory node dsc data, weighs especially by block counts
Amount.Current block height subtracts the block length of node dsc data, then the starting point block for obtaining hot spot data cache pool is high.
Step S230 is incremented by block height and successively executes the transaction in each block until working as since the starting point block height
Preceding newest block;
All data spaces generated in implementation procedure are cached in memory by step S240.
For example, it is assumed that node hot data block section is 100 blocks, current newest block height is 1000, then node heat
The starting point block a height of 901 of data, also i.e. using 100 blocks of block high 901 to 1000 as hot spot data cache pool.
In the present embodiment, it is incremented by block height since the starting point block height of hot spot data cache pool and successively executes each block
In transaction until current newest block, and all data spaces generated in implementation procedure are cached in memory.Due to heat
Where point data cache pool is stored in node in the memory of equipment, thus the search efficiency of hot spot data can be improved.Meanwhile heat
Point data cache pool is stored in memory, thus can be lost after restarting, and then the starting of each minor node requires to re-create newly
Hot spot data cache pool.
Further, in one embodiment of block chain data capacity reduction method of the present invention, block chain node has been started and carried out
Data capacity reducing and after establishing the process flow of hot spot data cache pool, also further executes following process flow:
1, the node history data store information locally saved is updated;
The new snapshot point update generated during local node type, data capacity reducing is saved into local storage medium
In history data store information.
2, into block chain network, other block chain nodes initiate the connection request, and exchange and believe with other block chain nodes
Breath, the interchange information include the node type of current block chain node, current latest block height.
It is the functional block diagram of block chain data capacity reducing device first embodiment of the present invention referring to Fig. 3, Fig. 3.It is based on
Above-described embodiment, in the present embodiment, the block chain data capacity reducing device includes:
Node execution module 10, for reading the node type locally saved and going through when the starting of this block chain link point
History Stored Data Type;Based on the node type and the history data store type, judge whether this block chain link point is full
Sufficient data capacity reducing condition;
Node capacity reducing module 20, if for meeting data capacity reducing condition, to not counted in current this block chain link point
Data capacity reducing is carried out according to the block of capacity reducing;Wherein, if this block chain link point is snapshot node type or thermal center vertex type, and node
Type does not change or degrades, it is determined that this block chain link point meets data capacity reducing condition.
Due in the present invention block chain node can by adjusting node parameter configuration information, and then can change node type,
Node snapshot period or node hot data block section, for the adjustment for coping with node parameter configuration information, therefore, it is necessary to each
Data inactivity capacity reducing is all carried out when minor node starts.
In the present embodiment, the node type of block chain node, which can be, to be achieved in node, snapshot node and thermal center point
Any type.And history data store type is also possible to achieve any class in node, snapshot node and thermal center point
Type.
The present embodiment is specifically based on node type and history data store type, judges whether this block chain link point meets number
According to capacity reducing condition.
In the present embodiment, if this block chain link point is snapshot node type or thermal center vertex type, and node type does not occur
Variation degrades, it is determined that this block chain link point meets data capacity reducing condition, specifically includes:
(1) if history data store type is to achieve node or snapshot node, and this block chain link point is snapshot node class
Type, it is determined that this block chain link point meets data capacity reducing condition;
(2) if history data store type is to achieve node or snapshot node or thermal center point, and this block chain link point is heat
Node type, it is determined that this block chain link point meets data capacity reducing condition.
In the present embodiment, if this block chain link point meets data capacity reducing condition, in current this block chain link point not into
The block of row data capacity reducing carries out data capacity reducing.And if this block chain link point is unsatisfactory for data capacity reducing condition, this block chain link
Point is without carrying out data capacity reducing.For example, history data store type is to achieve node, and this block chain link point is to achieve node class
Type, then without data inactivity capacity reducing.
It is the refinement the functional block diagram of one embodiment of Fig. 3 interior joint capacity reducing module referring to Fig. 4, Fig. 4.The present embodiment
In, node capacity reducing module 10 includes:
Snapshot node capacity reducing unit 101 reads the snapshot point if being snapshot node type for this block chain link point
Latest snapshot point and current newest block field in list;Since the snapshot point corresponds to block, be incremented by block height and according to
The secondary transaction executed in each block is until current newest block;If the number of blocks continuously performed reaches the node snapshot week
Phase then carries out state snapshot to the data space of each block generated in implementation procedure, and generates new snapshot point;It will be new fast
It is added in the snapshot point list according to point, deletes the data space of this snapshot, carries out data capacity reducing.
For example, it is assumed that the position of latest snapshot point is block height 30 in snapshot point list, current newest block is block
Highly 42, the node snapshot period is 10 blocks, then since block height 30, executes each block between block height 30 to 42
In transaction, while in the process of implementation, when reaching the node snapshot period, to executing between block height 30 to 40 in block
Transaction caused by data space carry out state snapshot, and 40 position of block height generate a new snapshot point, by this newly
Snapshot point is added in snapshot point list and deletes the data space of this snapshot.When having executed the transaction in block height 42
And when not regenerating new snapshot point, the static capacity reducing process of this node data is exited.
Thermal center point capacity reducing unit 102 reads the node dsc data if being thermal center vertex type for this block chain link point
Block section;Node hot data block section is subtracted from current block height, the starting point block for obtaining node dsc data is high;By the starting point block
The data space of all blocks is deleted before height, to carry out data capacity reducing.
For example, it is assumed that node hot data block section is 100 blocks, current newest block height is 1000, then node heat
The starting point block a height of 901 of data, namely retain 100 blocks from block high 901 to 1000 as node hot data block, and delete
The data space of all blocks before block high 901.
It is the functional block diagram of block chain data capacity reducing device second embodiment of the present invention referring to Fig. 5, Fig. 5.It is based on
Above-described embodiment, in the present embodiment, block chain data capacity reducing device further include:
Dsc data establishes module 30, if being unsatisfactory for data capacity reducing condition or to current local area for this block chain link point
Do not carried out in block chain node data capacity reducing block carry out data capacity reducing after, read node hot data block section and current
Newest block field;Node hot data block section is subtracted from current block height, the starting point block for obtaining hot spot data cache pool is high;
Since the starting point block height, it is incremented by block height and successively executes the transaction in each block until current newest block;It will execute
All data spaces generated in the process are cached in memory.
The present invention has carried out node type division to block chain link point, and all data of archive node memory block chain are simultaneously permanent
Any capacity reducing is not done in preservation, and snapshot node, thermal center the point only synchronous newest block information saved in block chain network and newest
State is without saving historical state data.Therefore it when snapshot node, thermal center point need any non-present last state data, needs
Enquiry of historical data is requested to node is achieved, thus the most of inquiry request for causing snapshot node, thermal center point to receive is equal
Need to access archive node, and then increase network load and pressure, in the case where inquiring more application scenarios, achieve node at
New system bottleneck, system delay greatly increase.
To solve the above problems, in the present embodiment, if block chain node is unsatisfactory for data capacity reducing condition when starting, or
After block chain node starts and carries out data capacity reducing to the block for not carrying out data capacity reducing in current this block chain link point, then
Execute the Establishing process of hot spot data cache pool.
In the present embodiment, it is incremented by block height since the starting point block height of hot spot data cache pool and successively executes each block
In transaction until current newest block, and all data spaces generated in implementation procedure are cached in memory.Due to heat
Where point data cache pool is stored in node in the memory of equipment, thus the search efficiency of hot spot data can be improved.Meanwhile heat
Point data cache pool is stored in memory, thus can be lost after restarting, and then the starting of each minor node requires to re-create newly
Hot spot data cache pool.
It is the functional block diagram of block chain data capacity reducing device 3rd embodiment of the present invention referring to Fig. 6, Fig. 6.It is based on
Above-described embodiment, in the present embodiment, block chain data capacity reducing device further include:
Update module 40, for updating the node history data store information locally saved;
The new snapshot point update generated during local node type, data capacity reducing is saved into local storage medium
In history data store information.
Networking module 50, for into block chain network other block chain nodes initiate the connection request, and with other blocks
Chain node interchange information, the interchange information include the node type of current block chain node, current latest block height.
After node starts and completes data capacity reducing, then networking is established with other block chain nodes in block chain network and is connected
It connects, and exchanges relevant information, in order to carry out capacity reducing to new block in node operational process.
The present invention also provides a kind of computer readable storage mediums.
Block chain data capacity reducing program, the block chain data capacity reducing are stored on computer readable storage medium of the present invention
The step of block chain data capacity reduction method as described in the examples such as any of the above-described is realized when program is executed by processor.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side
Method can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but in many cases
The former is more preferably embodiment.Based on this understanding, technical solution of the present invention substantially in other words does the prior art
The part contributed out can be embodied in the form of software products, which is stored in a storage medium
In (such as ROM/RAM), including some instructions are used so that a terminal (can be mobile phone, computer, server or network are set
It is standby etc.) execute method described in each embodiment of the present invention.
The embodiment of the present invention is described with above attached drawing, but the invention is not limited to above-mentioned specific
Embodiment, the above mentioned embodiment is only schematical, rather than restrictive, those skilled in the art
Under the inspiration of the present invention, without breaking away from the scope protected by the purposes and claims of the present invention, it can also make very much
Form, it is all using equivalent structure or equivalent flow shift made by description of the invention and accompanying drawing content, directly or indirectly
Other related technical areas are used in, all of these belong to the protection of the present invention.
Claims (13)
1. a kind of block chain data capacity reduction method, which is characterized in that the block chain data capacity reduction method the following steps are included:
When the starting of this block chain link point, the node type and history data store type locally saved is read;
Based on the node type and the history data store type, judge whether this block chain link point meets data capacity reducing item
Part;
If meeting data capacity reducing condition, data contracting is carried out to the block for not carrying out data capacity reducing in current this block chain link point
Hold;
Wherein, if this block chain link point is snapshot node type or thermal center vertex type, and node type is not changed or is sent out
It is raw to degrade, it is determined that this block chain link point meets data capacity reducing condition.
2. block chain data capacity reduction method as described in claim 1, which is characterized in that block chain node locally preserves node
Parameter configuration and node history data store information;
The node parameter configuration information includes: node type, node snapshot period, node hot data block section, wherein is achieved
The grade of node is higher than snapshot node, and the grade of snapshot node is higher than thermal center point;The node history data store information includes:
History data store type, snapshot point list, current newest block field.
3. block chain data capacity reduction method as claimed in claim 2, which is characterized in that described in current this block chain link point
The block for not carrying out data capacity reducing carries out data capacity reducing and includes:
If this block chain link point is snapshot node type, latest snapshot point in the snapshot point list and current newest is read
Block field;
Since the snapshot point corresponds to block, it is incremented by block height and successively executes the transaction in each block until current most new district
Block;
If the number of blocks continuously performed reaches the node snapshot period, to the data of each block generated in implementation procedure
Space carries out state snapshot, and generates new snapshot point;
New snapshot point is added in the snapshot point list, the data space of this snapshot is deleted, to carry out data capacity reducing.
4. block chain data capacity reduction method as claimed in claim 2, which is characterized in that described in current this block chain link point
The block for not carrying out data capacity reducing carries out data capacity reducing further include:
If this block chain link point is thermal center vertex type, node hot data block section is read;
Node hot data block section is subtracted from current block height, the starting point block for obtaining node dsc data is high;
By the data space deletion of the starting point block all blocks before high, to carry out data capacity reducing.
5. block chain data capacity reduction method as claimed in claim 2, which is characterized in that the block chain data capacity reduction method is also
Include:
If this block chain link point is unsatisfactory for data capacity reducing condition or does not carry out data capacity reducing in current this block chain link point
Block carry out data capacity reducing after, read node hot data block section and current newest block field;
Node hot data block section is subtracted from current block height, the starting point block for obtaining hot spot data cache pool is high;
Since the starting point block height, it is incremented by block height and successively executes the transaction in each block until current newest block;
All data spaces generated in implementation procedure are cached in memory.
6. the block chain data capacity reduction method as described in any one of claim 2-5, which is characterized in that the block chain data
Capacity reduction method further include:
Update the node history data store information locally saved;
Into block chain network, other block chain nodes initiate the connection request, and with other block chain node interchange informations, it is described
Interchange information includes the node type of current block chain node, current latest block height.
7. a kind of block chain data capacity reducing device, which is characterized in that the block chain data capacity reducing device includes:
Node execution module, for reading the node type and historical data locally saved when the starting of this block chain link point
Storage class;Based on the node type and the history data store type, judge whether this block chain link point meets data
Capacity reducing condition;
Node capacity reducing module, if for meeting data capacity reducing condition, to not carrying out data capacity reducing in current this block chain link point
Block carry out data capacity reducing;Wherein, if this block chain link point is snapshot node type or thermal center vertex type, and node type is not
It changes or degrades, it is determined that this block chain link point meets data capacity reducing condition.
8. block chain data capacity reducing device as claimed in claim 7, which is characterized in that block chain node locally preserves node
Parameter configuration and node history data store information;
The node parameter configuration information includes: node type, node snapshot period, node hot data block section, wherein is achieved
The grade of node is higher than snapshot node, and the grade of snapshot node is higher than thermal center point;The node history data store information includes:
History data store type, snapshot point list, current newest block field.
9. block chain data capacity reducing device as claimed in claim 8, which is characterized in that the node capacity reducing module includes:
Snapshot node capacity reducing unit is read in the snapshot point list if being snapshot node type for this block chain link point
Latest snapshot point and current newest block field;Since the snapshot point corresponds to block, it is incremented by block height and successively executes
Transaction in each block is until current newest block;If the number of blocks continuously performed reaches the node snapshot period, right
The data space of each block generated in implementation procedure carries out state snapshot, and generates new snapshot point;New snapshot point is added
It is added in the snapshot point list, deletes the data space of this snapshot, to carry out data capacity reducing.
10. block chain data capacity reducing device as claimed in claim 8, which is characterized in that the node capacity reducing module further include:
Thermal center point capacity reducing unit reads node hot data block section if being thermal center vertex type for this block chain link point;
Node hot data block section is subtracted from current block height, the starting point block for obtaining node dsc data is high;Before starting point block height
The data space of all blocks is deleted, to carry out data capacity reducing.
11. block chain data capacity reducing device as claimed in claim 8, which is characterized in that the block chain data capacity reducing device
Further include:
Dsc data establishes module, if being unsatisfactory for data capacity reducing condition for this block chain link point or to current this block chain link
After the block progress data capacity reducing for not carrying out data capacity reducing in point, node hot data block section and current most new district are read
Block field;Node hot data block section is subtracted from current block height, the starting point block for obtaining hot spot data cache pool is high;From this
Point block height starts, and is incremented by block height and successively executes the transaction in each block until current newest block;It will be in implementation procedure
All data spaces generated are cached in memory.
12. the block chain data capacity reducing device as described in claim 7-11, which is characterized in that the block chain data capacity reducing dress
It sets further include:
Update module, for updating the node history data store information locally saved;
Networking module, for into block chain network other block chain nodes initiate the connection request, and with other block chain nodes
Interchange information, the interchange information include the node type of current block chain node, current latest block height.
13. a kind of computer readable storage medium, which is characterized in that be stored with block chain on the computer readable storage medium
Data capacity reducing program is realized when the block chain data capacity reducing program is executed by processor such as any one of claim 1-6 institute
The step of block chain data capacity reduction method stated.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810965094.4A CN109145163B (en) | 2018-08-22 | 2018-08-22 | Block chain data capacity reduction method and device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810965094.4A CN109145163B (en) | 2018-08-22 | 2018-08-22 | Block chain data capacity reduction method and device and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109145163A true CN109145163A (en) | 2019-01-04 |
CN109145163B CN109145163B (en) | 2021-08-24 |
Family
ID=64791370
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810965094.4A Active CN109145163B (en) | 2018-08-22 | 2018-08-22 | Block chain data capacity reduction method and device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109145163B (en) |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2019179540A2 (en) | 2019-07-11 | 2019-09-26 | Alibaba Group Holding Limited | Shared blockchain data storage |
CN110602148A (en) * | 2019-10-10 | 2019-12-20 | 深圳前海微众银行股份有限公司 | Method and device for generating state tree of block and verifying data on chain |
CN111209343A (en) * | 2020-01-22 | 2020-05-29 | 腾讯科技(深圳)有限公司 | Node data synchronization method, device, equipment and storage medium |
CN111241069A (en) * | 2020-01-19 | 2020-06-05 | 上海墨珩网络科技有限公司 | Data flattening method and system based on block chain |
CN111316256A (en) * | 2019-11-29 | 2020-06-19 | 支付宝(杭州)信息技术有限公司 | Taking snapshots of blockchain data |
WO2020206847A1 (en) * | 2019-04-10 | 2020-10-15 | 深圳市网心科技有限公司 | Blockchain-based data processing method and system, and related device |
US10892898B2 (en) | 2019-07-11 | 2021-01-12 | Advanced New Technologies Co., Ltd. | Shared blockchain data storage |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104615657A (en) * | 2014-12-31 | 2015-05-13 | 天津南大通用数据技术股份有限公司 | Expanding and shrinking method for distributed cluster with nodes supporting multiple data fragments |
CN107395735A (en) * | 2017-08-03 | 2017-11-24 | 成都精灵云科技有限公司 | The delay capacity reducing dispatching method and system of a kind of container cluster |
CN107766542A (en) * | 2017-10-30 | 2018-03-06 | 上海分布信息科技有限公司 | A kind of block chain network of subregion and its method for realizing subregion inquiry |
US20180074735A1 (en) * | 2016-09-15 | 2018-03-15 | Pure Storage, Inc. | Distributed file deletion and truncation |
CN108270836A (en) * | 2017-01-03 | 2018-07-10 | 华为技术有限公司 | Data processing method, equipment and system based on block chain |
-
2018
- 2018-08-22 CN CN201810965094.4A patent/CN109145163B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104615657A (en) * | 2014-12-31 | 2015-05-13 | 天津南大通用数据技术股份有限公司 | Expanding and shrinking method for distributed cluster with nodes supporting multiple data fragments |
US20180074735A1 (en) * | 2016-09-15 | 2018-03-15 | Pure Storage, Inc. | Distributed file deletion and truncation |
CN108270836A (en) * | 2017-01-03 | 2018-07-10 | 华为技术有限公司 | Data processing method, equipment and system based on block chain |
CN107395735A (en) * | 2017-08-03 | 2017-11-24 | 成都精灵云科技有限公司 | The delay capacity reducing dispatching method and system of a kind of container cluster |
CN107766542A (en) * | 2017-10-30 | 2018-03-06 | 上海分布信息科技有限公司 | A kind of block chain network of subregion and its method for realizing subregion inquiry |
Non-Patent Citations (1)
Title |
---|
王峰等: "高可信云存储技术研究", 《电信网技术》 * |
Cited By (18)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2020206847A1 (en) * | 2019-04-10 | 2020-10-15 | 深圳市网心科技有限公司 | Blockchain-based data processing method and system, and related device |
US11405219B2 (en) | 2019-07-11 | 2022-08-02 | Advanced New Technologies Co., Ltd. | Shared blockchain data storage |
US11270308B2 (en) | 2019-07-11 | 2022-03-08 | Advanced New Technologies Co., Ltd. | Shared blockchain data storage |
WO2019179540A2 (en) | 2019-07-11 | 2019-09-26 | Alibaba Group Holding Limited | Shared blockchain data storage |
EP3673620A4 (en) * | 2019-07-11 | 2020-09-30 | Alibaba Group Holding Limited | Shared blockchain data storage |
US10892898B2 (en) | 2019-07-11 | 2021-01-12 | Advanced New Technologies Co., Ltd. | Shared blockchain data storage |
US11088849B2 (en) | 2019-07-11 | 2021-08-10 | Advanced New Technologies Co., Ltd. | Shared blockchain data storage |
US11055712B2 (en) | 2019-07-11 | 2021-07-06 | Advanced New Technologies Co., Ltd. | Shared blockchain data storage |
CN110602148B (en) * | 2019-10-10 | 2021-07-06 | 深圳前海微众银行股份有限公司 | Method and device for generating state tree of block and verifying data on chain |
CN110602148A (en) * | 2019-10-10 | 2019-12-20 | 深圳前海微众银行股份有限公司 | Method and device for generating state tree of block and verifying data on chain |
CN111316256A (en) * | 2019-11-29 | 2020-06-19 | 支付宝(杭州)信息技术有限公司 | Taking snapshots of blockchain data |
AU2019380380A1 (en) * | 2019-11-29 | 2021-06-17 | Alipay (Hangzhou) Information Technology Co., Ltd. | Taking snapshots of blockchain data |
EP3769219A4 (en) * | 2019-11-29 | 2021-04-07 | Alipay (Hangzhou) Information Technology Co., Ltd. | Taking snapshots of blockchain data |
US11194792B2 (en) | 2019-11-29 | 2021-12-07 | Alipay (Hangzhou) Information Technology Co., Ltd. | Taking snapshots of blockchain data |
AU2019380380B2 (en) * | 2019-11-29 | 2022-03-10 | Alipay (Hangzhou) Information Technology Co., Ltd. | Taking snapshots of blockchain data |
CN111241069A (en) * | 2020-01-19 | 2020-06-05 | 上海墨珩网络科技有限公司 | Data flattening method and system based on block chain |
CN111241069B (en) * | 2020-01-19 | 2023-10-20 | 上海墨珩网络科技有限公司 | Block chain-based data flattening method and system |
CN111209343A (en) * | 2020-01-22 | 2020-05-29 | 腾讯科技(深圳)有限公司 | Node data synchronization method, device, equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN109145163B (en) | 2021-08-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109145163A (en) | Block chain data capacity reduction method, device and storage medium | |
CN109324757A (en) | Block chain data capacity reduction method, device and storage medium | |
KR102392944B1 (en) | Data backup methods, storage media and computing devices | |
CN102523279B (en) | A kind of distributed file system and focus file access method thereof | |
EP4202694A1 (en) | Node memory-based data processing method and apparatus, device, and medium | |
CN105095313B (en) | A kind of data access method and equipment | |
CN109857724A (en) | The method and apparatus for supporting multitype database is realized based on block chain | |
CN109493076A (en) | A kind of unique consuming method of Kafka message, system, server and storage medium | |
CN109587271A (en) | Main chain parallel chain architecture system and block synchronous method, equipment and storage medium | |
CN105119997A (en) | Data processing method of cloud computing system | |
CN109213699A (en) | A kind of metadata management method, system, equipment and computer readable storage medium | |
CN109446222A (en) | A kind of date storage method of Double buffer, device and storage medium | |
CN109358873A (en) | A kind of application program update method, storage medium and terminal device | |
CN113596010B (en) | Data processing method, device, node equipment and computer storage medium | |
CN104838379A (en) | Database synchronization | |
CN109684338A (en) | A kind of data-updating method of storage system | |
CN110311979A (en) | A kind of the task immigration method and relevant apparatus of MEC server | |
CN109658249A (en) | A kind of block chain performance optimization method | |
CN109525678A (en) | Block chain network system and corresponding node device find method | |
CN115208841A (en) | Industrial internet identification flow caching processing method based on SDN | |
CN115146002A (en) | Cross-data-center data synchronization method and device | |
CN103297547B (en) | The P2P system constructing cloud based on DHT is used to store the method for auxiliary system | |
CN113918857A (en) | Three-level cache acceleration method for improving performance of distributed WEB application system | |
CN105975614A (en) | Cluster configuration device and data updating method and device | |
CN101833585A (en) | Database server operation control system, method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |