CN112487094B - Method, device, computer equipment and storage medium for synchronizing energy block data - Google Patents

Method, device, computer equipment and storage medium for synchronizing energy block data Download PDF

Info

Publication number
CN112487094B
CN112487094B CN202011423850.4A CN202011423850A CN112487094B CN 112487094 B CN112487094 B CN 112487094B CN 202011423850 A CN202011423850 A CN 202011423850A CN 112487094 B CN112487094 B CN 112487094B
Authority
CN
China
Prior art keywords
block
energy transaction
time period
node
historical
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011423850.4A
Other languages
Chinese (zh)
Other versions
CN112487094A (en
Inventor
艾精文
游奕弘
李艳
张华赢
明阳阳
曹军威
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Power Supply Bureau Co Ltd
Original Assignee
Shenzhen Power Supply Bureau Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Power Supply Bureau Co Ltd filed Critical Shenzhen Power Supply Bureau Co Ltd
Priority to CN202011423850.4A priority Critical patent/CN112487094B/en
Publication of CN112487094A publication Critical patent/CN112487094A/en
Application granted granted Critical
Publication of CN112487094B publication Critical patent/CN112487094B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/278Data partitioning, e.g. horizontal or vertical partitioning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/275Synchronous replication
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • G06F16/285Clustering or classification
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes

Abstract

The application relates to a method, a device, computer equipment and a storage medium for synchronizing energy block data. The method comprises the following steps: processing historical block data on a current energy block chain by adopting a clustering algorithm, and establishing a plurality of target partitions in a current time period; determining block sub-chains corresponding to each target partition according to node identifications contained in each target partition and predicted energy transaction amounts of the nodes in a current time period, wherein all the block sub-chains in the current time period run in parallel; merging the hash value of the last block on each block subchain, determining a merged block in the current time period, and sending the merged block to the current block chain, wherein the merged block is used for representing all block data on the current block chain; after each block subchain runs in parallel, each block subchain is combined into a combined block which is connected to the current block chain, so that synchronization of subchain data, and inter-chain data sharing and unified management are realized.

Description

Method, device, computer equipment and storage medium for synchronizing energy block data
Technical Field
The present disclosure relates to the field of blockchain technologies, and in particular, to a method and apparatus for synchronizing energy block data, a computer device, and a storage medium.
Background
With the development of computer technology, blockchains are widely applied to various fields by the unique characteristics of non-tampering, traceability, high reliability and decentralization; however, as the internet transaction data increases, the block data processing capacity of the blockchain faces a bottleneck, which results in low throughput of the blockchain system, that is, a small number of transactions processed per second by the blockchain system, and thus, low processing speed.
In order to improve throughput of a blockchain system, a partition-based method is adopted in the prior art, namely, a single-chain distributed storage is changed into a multi-chain distributed storage, and parallel transaction processing is performed by different fragments so as to increase concurrency of transaction processing and consensus.
However, the partition-based method described above brings difficulty to data synchronization, and it is difficult to achieve unified management and data sharing.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a method, an apparatus, a computer device, and a storage medium for synchronizing energy block data that can achieve post-partition data synchronization.
In a first aspect, a method for synchronizing energy block data is provided, the method comprising:
processing historical block data on a current energy block chain by adopting a clustering algorithm, and establishing a plurality of target partitions in a current time period; wherein each target partition comprises at least one identification of a node associated with the historical block data and a predicted energy transaction amount of the node in a current time period;
determining a block sub-chain corresponding to each target partition according to the node identification contained in each target partition and the predicted energy transaction amount of the node in the current time period; all block subchains in the current time period run in parallel;
merging the hash value of the last block on each block sub-chain, determining a merged block in the current time period, and transmitting the merged block to the current block chain; wherein the merge block is used to characterize all block data on the current blockchain.
In one embodiment, merging the hash value of the last chunk on each blocksub-chain to determine the merged chunk for the current time period includes: obtaining a hash value of a last block on each block sub-chain; performing serial operation on the hash value of the last block on each block sub-chain to obtain serial characters; and carrying out encryption calculation on the serial characters to obtain the merging block.
In one embodiment, a clustering algorithm is used to process historical block data on a current energy block chain, and a plurality of target partitions within a current time period are established, including: acquiring a history merging block of the previous history time period, and determining the current node network topology according to the history merging block; the history merging block is used for representing all block data in the previous history time period; acquiring historical energy transaction amounts of each node in a plurality of historical time periods on a current blockchain, and determining predicted energy transaction amounts of each node in a current time period in a current node network topology according to the historical energy transaction amounts of each node in the plurality of historical time periods; clustering the current node network topology by adopting the clustering algorithm to obtain a plurality of initial partitions; each initial partition comprises the identification of part of nodes in the current node network topology and forecast energy transaction amount; and optimizing the plurality of initial partitions according to the identification of each node in the current node network topology and the predicted energy transaction amount to obtain a plurality of target partitions in the current time period.
In one embodiment, the optimizing the plurality of initial partitions according to the identification of each node in the current node network topology and the predicted energy transaction amount to obtain a plurality of target partitions in the current time period includes: summing the predicted energy transaction amounts of each node in each initial partition to obtain the predicted energy transaction total amount corresponding to each initial partition; determining a first initial partition with the smallest predicted energy transaction total amount and a second initial partition with the smallest predicted energy transaction total amount from each initial partition, and obtaining the sum of the predicted energy transaction total amount of the first initial partition and the predicted energy total amount of the second initial partition to obtain the reference energy transaction total amount; and determining whether to merge the first initial partition and the second initial partition into a target partition according to the total reference energy transaction amount and a preset merging threshold.
In one embodiment, determining whether to merge the first initial partition and the second initial partition into a target partition according to the total amount of the reference energy transaction and a preset merge threshold includes: merging the first initial partition and the second initial partition into a target partition under the condition that the total amount of the reference energy transaction is smaller than the merging threshold; and determining the first initial partition as one target partition and the second initial partition as another target partition under the condition that the total amount of the reference energy transaction is not less than the merging threshold.
In one embodiment, the optimizing process is performed on the plurality of initial partitions according to the identifier of each node in the current node network topology and the predicted energy transaction amount, so as to obtain a plurality of target partitions in the current time period, and the method further includes: determining a third initial partition with the maximum predicted total energy transaction amount from each initial partition; and splitting the third initial partition into a plurality of target partitions under the condition that the total predicted energy transaction amount of the third initial partition is larger than a preset classification threshold.
In one embodiment, splitting the third initial partition into a plurality of target partitions includes: splitting the third initial partition into the plurality of target partitions according to the number of nodes in the third initial partition and the predicted energy transaction amount of each node; the difference value of the total predicted energy transaction amounts of the target partitions is smaller than a preset threshold value.
In one embodiment, the clustering algorithm is used to perform clustering processing on the current node network topology, and before obtaining a plurality of initial partitions, the method further includes: acquiring a first historical energy transaction total amount of a last historical time period; the method comprises the steps that a plurality of historical block sub-chains are operated in parallel in the previous historical time period, and the first historical energy transaction total amount comprises the historical energy transaction total amounts of the plurality of historical block sub-chains; determining a target historical block sub-chain with the maximum total amount of historical energy transaction from a plurality of historical block sub-chains which are operated in parallel in the previous historical time period; and determining the number of the initial partitions according to the quotient of the total first historical energy transaction amount and the historical energy transaction amount of the target historical block subchain.
In one embodiment, the merge block further includes at least one of a number of block subchains running in parallel during a current time period, an identification of a node on each block subchain, and a total amount of energy transactions by the node on each block subchain during the current time period.
In one embodiment, the method further comprises: acquiring a first target partition with the maximum predicted energy transaction total amount from target partitions in a current time period; and according to the sum of the predicted energy transaction total amount of the first target partition and a preset random number, multiplying the product of the processing rates of the block sub-chains operated in the current time period, and determining the operation time length of all the block sub-chains in the current time period.
In one embodiment, determining the predicted energy transaction amount for each node in the current node network topology in the current time period according to the historical energy transaction amounts for each node in the plurality of historical time periods includes: and estimating the predicted energy transaction amount of each node in the current time period in the current node network topology by adopting a linear autoregressive algorithm and the historical energy transaction amounts of each node in a plurality of historical time periods to obtain the predicted energy transaction amount of each node in the current time period in the current node network topology.
In a second aspect, there is provided a synchronization apparatus for energy block data, the apparatus comprising:
the building module is used for processing the historical block data on the current energy block chain by adopting a clustering algorithm and building a plurality of target partitions in the current time period; wherein each target partition includes an identification of at least one node associated with the historical block data and a predicted energy transaction amount for the node at a current time period.
The first determining module is used for determining a block sub-chain corresponding to each target partition according to the node identification contained in each target partition and the predicted energy transaction amount of the node in the current time period; wherein all the block subchains in the current time period run in parallel.
The second determining module is used for merging the hash value of the last block on each block sub-chain, determining a merging block in the current time period and sending the merging block to the current block chain; wherein the merge block is used to characterize all block data on the current blockchain.
In a third aspect, a computer device is provided, comprising a memory storing a computer program and a processor implementing the following steps when the computer program is executed:
processing historical block data on a current energy block chain by adopting a clustering algorithm, and establishing a plurality of target partitions in a current time period; wherein each target partition comprises at least one identifier of a node related to the historical block data and a predicted energy transaction amount of the node in a current time period;
determining a block sub-chain corresponding to each target partition according to the node identification contained in each target partition and the predicted energy transaction amount of the node in the current time period; all block subchains in the current time period run in parallel;
merging the hash value of the last block on each block sub-chain, determining a merged block in the current time period, and transmitting the merged block to the current block chain; wherein the merge block is used to characterize all block data on the current blockchain.
In a fourth aspect, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of:
processing historical block data on a current energy block chain by adopting a clustering algorithm, and establishing a plurality of target partitions in a current time period; wherein each target partition comprises at least one identifier of a node related to the historical block data and a predicted energy transaction amount of the node in a current time period;
determining a block sub-chain corresponding to each target partition according to the node identification contained in each target partition and the predicted energy transaction amount of the node in the current time period; all block subchains in the current time period run in parallel;
merging the hash value of the last block on each block sub-chain, determining a merged block in the current time period, and transmitting the merged block to the current block chain; wherein the merge block is used to characterize all block data on the current blockchain.
The method, the device, the computer equipment and the storage medium for synchronizing the energy block data process the historical block data on the current energy block chain by adopting a clustering algorithm, and establish a plurality of target partitions in the current time period; wherein each target partition comprises at least one identification of a node associated with the historical block data and a predicted energy transaction amount of the node in a current time period; determining a block sub-chain corresponding to each target partition according to the node identification contained in each target partition and the predicted energy transaction amount of the node in the current time period; all block subchains in the current time period run in parallel; combining the hash value of the last block on each block sub-chain, determining a combined block in the current time period, and transmitting the combined block to the current block chain; wherein the merge block is used for representing all block data on the current block chain; that is, in the embodiment of the present application, in a current time period, a plurality of target partitions are established according to historical block data on a current energy block chain, each target partition corresponds to one block sub-chain respectively, all the block sub-chains in the current time period operate in parallel, and then each block sub-chain is combined into a combined block, connected to the current block chain, and according to the combined block, all the block data on the current block chain can be obtained; therefore, the merging block can realize the synchronization of the energy transaction data in the sub-chains corresponding to each partition, realize the sharing and unified management of the inter-chain data, and conveniently realize the authentication, encryption and information sharing of the related blocks of the parallel sub-chains.
Drawings
FIG. 1 is a diagram of an application environment of a method for synchronizing energy block data according to one embodiment;
FIG. 2 is a flowchart of another embodiment of a method for synchronizing energy block data;
FIG. 3 is a flowchart illustrating a method for synchronizing energy block data according to another embodiment;
FIG. 4 is a flowchart illustrating a method for synchronizing energy block data according to another embodiment;
FIG. 5 is a block diagram of an embodiment of a device for synchronizing energy block data;
fig. 6 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
Because of the widely accessed distributed renewable energy power generation and regional micro-grid energy sharing mechanism, the energy internet needs to realize frequent and ubiquitous local energy transactions. Because the transaction amount of the transaction is small and has short time and dispersibility, the traditional transaction mode generates a large amount of cost expenditure, and the blockchain transaction technology based on the consensus mechanism can obviously reduce the energy transaction expenditure and ensure the safety and fairness of the transaction, so that the transaction method can be widely popularized in energy networks such as the energy Internet.
However, the adoption of the mechanism of multiparty consensus causes the block data processing capacity of the blockchain to have a bottleneck, and the number of blocks processed per second is very limited, namely the throughput of the blockchain system is low, which may cause a certain limitation to the large-scale distributed energy transaction requirement and even affect the normal operation of the blockchain system.
To improve throughput of blockchain systems, there is a partition (Sharding) based method in the prior art that changes single-chain distributed storage into multi-chain distributed storage; dividing all nodes in the whole blockchain network into a plurality of sub-networks, wherein each sub-network comprises a part of nodes, and each sub-network is namely a Sharding (Sharding); meanwhile, the transactions in the network can be divided into different fragments for processing, so that nodes of each fragment only need to process a small part of incoming transactions, and the different fragments can process the transactions in parallel, namely the concurrency of transaction processing and consensus can be increased, thereby improving the throughput of the whole blockchain network; however, this method brings difficulty to data synchronization in the network, and it is difficult to realize unified management and data sharing.
The application provides an energy block data synchronization method, which can divide a network into proper areas through robust partitioning and merging iterative algorithm based on the prediction of the energy transaction amount of each node at the next stage, then realize the transaction of a partitioned energy block chain through parallel sub-chain technology, wherein each section of parallel sub-chain is responsible for the transaction of one area in a certain transaction time period, and the transaction time length can be dynamically determined according to the estimated energy transaction amount, so that the transaction completion of all sub-chains is ensured to the greatest extent; and inserting a merging block at each parallel ending time point to realize the synchronization of the information among the nodes.
The method for synchronizing the energy block data can be applied to an energy block chain system, the energy block chain system can comprise a plurality of nodes, each node can be a computer device, the computer device can be a server or a terminal, the server can be realized by an independent server or a server cluster formed by a plurality of servers, and the terminal can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers and the like; in the specific implementation of the embodiments of the methods described below, each node may be implemented separately, or may be implemented by a node that is common to multiple nodes, or may be implemented by a part of the multiple nodes.
In one embodiment, as shown in fig. 1, a method for synchronizing energy block data is provided, and the method is applied to the above computer device for illustration, and includes the following steps:
step 101, processing historical block data on a current energy block chain by adopting a clustering algorithm, and establishing a plurality of target partitions in a current time period; wherein each target partition includes an identification of at least one node associated with the historical block data and a predicted energy transaction amount for the node at a current time period.
On an initial energy block chain, each historical energy transaction data which passes verification is connected on a single chain in series in a block form according to time sequence, and as the energy transaction data is increased, the total transaction amount of the energy block chain is gradually increased, and as for the newly-increased energy transaction data, the data processing efficiency of the energy block chain is low due to the limited number of blocks processed per second by an energy block chain system; therefore, optionally, when the energy transaction data of the energy blockchain reaches a preset energy transaction threshold, all node data on the blockchain can be divided into a plurality of different areas, each area corresponds to one sub-chain, and each sub-chain runs in parallel, so that each sub-chain only needs to be responsible for recording and storing the energy transaction of one area.
In an optional embodiment of the present application, a clustering algorithm may be used to process historical block data on the current energy blockchain to establish a plurality of target partitions within the current time period; optionally, the number of target partitions may be preset, and the number of target partitions may be selected randomly, or may be the number of target partitions obtained through big data analysis, or may be another selection manner, where the method of how to determine the number of target partitions is not limited in the present application; after establishing a plurality of target partitions, each target partition can comprise at least one identifier of a node related to the historical block data and a predicted energy transaction amount of the node in a current time period; optionally, the predicted energy transaction amount of the node in the current time period may be obtained according to a ratio of the historical energy transaction total amount of the node to the transaction operation duration of the node, and the predicted energy transaction amount of the node in the current time period is determined according to the energy transaction amount of the node in the unit time.
Step 102, determining a block sub-chain corresponding to each target partition according to node identifiers contained in each target partition and the predicted energy transaction amount of the node in the current time period; wherein all of the blocksubchains within the current time period run in parallel.
In an optional embodiment of the present application, in the plurality of target partitions obtained above, each target partition includes a node identifier of at least one node and a predicted energy transaction amount of each node in the current time period, and an energy transaction data block of each node; optionally, for each target partition, a block sub-chain may be respectively corresponding to each target partition, where the block sub-chain includes energy transaction data blocks corresponding to all nodes in the target partition, and the energy transaction data blocks corresponding to all nodes in the target partition form, in series, the block sub-chain of the target partition in the current time period; each target partition is respectively corresponding to a block sub-chain, the block sub-chains run in parallel in the current time period, and each block sub-chain is responsible for recording and storing the energy transaction of the area where the block sub-chain is located; in addition, the consensus node may be randomly selected within the area.
Step 103, merging the hash value of the last block on each block sub-chain, determining a merged block in the current time period, and transmitting the merged block to the current block chain; wherein the merge block is used to characterize all block data on the current blockchain.
In an optional embodiment of the present application, after the time of the current time period is over, one node may be selected from all nodes of the current blockchain as a merging node, where the node may be a node with the greatest workload, or may be any node in a network, and the embodiment of the present application is not limited to this; the hash value of the last block on each block sub-chain is combined through the combining node, a combined block in the current time period is determined, and the combined block is sent to the current block chain; wherein the merge block may be used to characterize all block data on the current blockchain; optionally, the merging node may obtain the hash value of the last block on each block sub-chain, perform a concatenation operation on the hash value of the last block on each block sub-chain to obtain a concatenation character, perform encryption calculation on the concatenation character, and store the encrypted data in the merging block; alternatively, the process of merging and encrypting the hash value of the last block on each sub-chain of blocks may be implemented by using homomorphic encryption technology and a mechanism of serial connection processing of multiple paths of identity authentication information, so as to generate the data of the merged block.
In an optional embodiment of the present application, the merging block may further include at least one of a number of block subchains running in parallel in the current time period, an identification of a node on each block subchain, and a total amount of energy transactions of the node on each block subchain in the current time period.
In the above method for synchronizing the energy block data, a clustering algorithm is adopted to process the historical block data on the current energy block chain, and a plurality of target partitions in the current time period are established; wherein each target partition comprises at least one identification of a node associated with the historical block data and a predicted energy transaction amount of the node in a current time period; determining a block sub-chain corresponding to each target partition according to the node identification contained in each target partition and the predicted energy transaction amount of the node in the current time period; all block subchains in the current time period run in parallel; combining the hash value of the last block on each block sub-chain, determining a combined block in the current time period, and transmitting the combined block to the current block chain; wherein the merge block is used for representing all block data on the current block chain; that is, in the embodiment of the present application, in a current time period, a plurality of target partitions are established according to historical block data on a current energy block chain, each target partition corresponds to one block sub-chain respectively, all the block sub-chains in the current time period operate in parallel, and then each block sub-chain is combined into a combined block, connected to the current block chain, and according to the combined block, all the block data on the current block chain can be obtained; therefore, the merging block can realize the synchronization of the energy transaction data in the sub-chains corresponding to each partition, realize the sharing and unified management of the inter-chain data, and conveniently realize the authentication, encryption and information sharing of the related blocks of the parallel sub-chains.
Fig. 2 is a flowchart of a method for synchronizing energy block data according to another embodiment. The present embodiment relates to an optional implementation process of processing historical block data on a current energy block chain by using a clustering algorithm and establishing a plurality of target partitions in a current time period. On the basis of the above embodiment, as shown in fig. 2, the step 101 includes:
step 201, acquiring a history merging block of a previous history period, and determining a current node network topology according to the history merging block; the history merging block is used for representing all block data in the previous history period.
In an alternative embodiment of the present application, there are multiple historical time periods of parallel subchain operation on the current blockchain and historical merge blocks after each time period ends, since each historical merge block contains all of the block data of the current blockchain after each historical time period ends; thus, a historical merge block for the last historical time period may be obtained, the historical merge block may characterize all block data for the last historical time period, and a current node network topology may be determined from the historical merge block, the current node network topology characterizing the transaction connectivity relationships of all nodes in the current blockchain.
Step 202, obtaining historical energy transaction amounts of each node in a plurality of historical time periods on the current blockchain, and determining predicted energy transaction amounts of each node in the current time period in the current node network topology according to the historical energy transaction amounts of each node in the plurality of historical time periods.
In an alternative embodiment of the present application, there is a parallel subchain operation of multiple historical time periods and a historical merge block after the end of each time period on the current blockchain, as described in step 201 above; can acquire the current areaOptionally, according to the description of step 103, each merging block may include the total amount of energy transactions of the nodes on each block subchain in the current time period; that is, it can be inferred that the total amount of energy transactions of the nodes on each block sub-chain in each history period in the history period is included in the history merging nodes after the parallel sub-chains of each history period are run; therefore, according to the plurality of history merging blocks, the history energy transaction amount of each node in a plurality of history time periods on the current blockchain can be obtained; according to the historical energy transaction amount of each node in the plurality of historical time periods, determining the predicted energy transaction amount of each node in the current time period in the current node network topology; optionally, a linear autoregressive algorithm and historical energy transaction amounts of each node in a plurality of historical time periods can be adopted to estimate the predicted energy transaction amount of each node in the current time period in the current node network topology, so as to obtain the predicted energy transaction amount of each node in the current time period in the current node network topology; for example: the historical energy transaction amount of each node in 3 historical time periods can be obtained, one node is taken as an example, the historical energy transaction amounts of the node in 3 historical time periods are respectively P1, P2 and P3, and the predicted energy transaction amount of the node in the current time period can be obtained through a linear autoregressive algorithm and can be P4=a 0 P1+a 1 P2+a 2 P3+b, wherein a 0 、a 1 、a 2 And b may be derived based on historical energy transaction data using a minimum mean square error training estimate.
Alternatively, an upper limit value of the transaction amount may be set, and in the case where the predicted energy transaction amount of the node in the current period is greater than the upper limit value, the predicted energy transaction amount of the node in the current period may be set as the upper limit value.
Step 203, clustering the current node network topology by adopting the clustering algorithm to obtain a plurality of initial partitions; each initial partition comprises the identification of part of nodes in the current node network topology and the predicted energy transaction amount.
In an optional embodiment of the present application, a clustering algorithm may be used to perform clustering on the current node network topology according to the preset classification number, so as to obtain an initial partition of the preset classification number; optionally, a self-adaptive clustering (K-means) algorithm may be adopted, first, a random clustering center of a preset classification number is generated, all nodes are allocated to different centers based on the shortest distance, and a new clustering center is calculated based on a distance averaging mechanism, so that iteration is performed until the partition change rate is smaller than a specific value or reaches a certain iteration number, and an initial partition of the preset classification number is obtained; each initial partition comprises the identification of part of nodes in the current node network topology and the predicted energy transaction amount.
And 204, optimizing the plurality of initial partitions according to the identification of each node in the current node network topology and the predicted energy transaction amount to obtain a plurality of target partitions in the current time period.
In an optional embodiment of the present application, according to the identification of each node in the current node network topology and the predicted energy transaction amount, the predicted energy transaction amount of each node in each initial partition is summed to obtain a predicted energy transaction total amount corresponding to each initial partition; determining a first initial partition with the smallest predicted energy transaction total amount and a second initial partition with the smallest predicted energy transaction total amount from each initial partition, wherein the second initial partition with the smallest predicted energy transaction total amount can be an area with the smallest predicted energy transaction total amount in an adjacent area with the first initial partition; obtaining the sum of the predicted energy transaction total amount of the first initial partition and the predicted energy total amount of the second initial partition to obtain a reference energy transaction total amount; optionally, determining whether to merge the first initial partition and the second initial partition into a target partition according to the total amount of the reference energy transaction and a preset merging threshold; optionally, in the case that the total amount of the reference energy transaction is less than the merging threshold, the first initial partition and the second initial partition may be merged into one target partition; in the case where the total amount of reference energy transactions is not less than the merge threshold, the first initial partition may be determined to be one target partition and the second initial partition may be determined to be another target partition.
In an alternative embodiment of the present application, a third initial partition with the largest total predicted energy transaction amount may also be determined from each initial partition; under the condition that the total predicted energy transaction amount of the third initial partition is larger than a preset classification threshold, wherein the preset classification threshold is 2 times larger than the combination threshold, the third initial partition can be split into a plurality of target partitions; optionally, the third initial partition may be split into the plurality of target partitions according to the number of nodes in the third initial partition and the predicted energy transaction amount of each node; the difference value of the total predicted energy transaction amounts of the target partitions is smaller than a preset threshold value; for example: the third initial partition includes node a, node B, and node C, where the predicted energy trading amount of node a is 40, the predicted energy trading amount of node B is 50, and the predicted energy trading amount of node C is 100, and the third initial partition may be divided into two target partitions, where the two target partitions may be three different cases, as shown in table 1:
TABLE 1
Case(s) Target partition 1 Target partition 2 Difference value
1 A、B C 10
2 A、C B 90
3 B、C A 110
When the preset threshold is 50, after the third initial partition is divided into two target partitions, it can be seen from the above table that the difference between the total amounts of the predicted energy transactions of the two target partitions corresponding to the case 1 is smaller than the preset threshold, so that the partition result corresponding to the case 1 can be used as the optimal result after the third initial partition is divided.
Optionally, when the optimization of the initial partition is performed, the merging or splitting actions of the partitions can be performed for multiple times until the partitions are unchanged, so that a plurality of optimized target partitions are finally obtained; in addition, the combination threshold and the classification threshold may be determined by analyzing historical energy transactions and/or predicted energy transactions using big data.
In this embodiment, the current node network topology is determined by acquiring a history merging block of a previous history period and according to the history merging block; the historical energy transaction amount of each node in a plurality of historical time periods on the current blockchain is obtained, and the predicted energy transaction amount of each node in the current time period in the current node network topology is determined according to the historical energy transaction amount of each node in the plurality of historical time periods; clustering the current node network topology by adopting the clustering algorithm to obtain a plurality of initial partitions; optimizing the plurality of initial partitions according to the identification of each node in the current node network topology and the predicted energy transaction amount to obtain a plurality of target partitions in the current time period; that is, in this embodiment, a clustering algorithm is adopted to perform initial partitioning according to the current node network topology, and then the predicted energy transaction amount of each node in the current time period is predicted according to the historical energy transaction amount of each node; further, the initial partition is optimized according to the predicted energy transaction amount of each node in the current time period to obtain a plurality of target partitions, so that the accuracy and the optimality of the target partitions can be greatly improved, and the running efficiency of the energy block chain system is further improved.
Fig. 3 is a flowchart of a method for synchronizing energy block data according to another embodiment. The present embodiment relates to an alternative implementation procedure for determining the number of the initial partitions. On the basis of the above embodiment, as shown in fig. 3, the foregoing step 203 further includes:
step 301, obtaining a first historical energy transaction total amount in a previous historical time period; the first historical energy transaction total amount comprises the historical energy transaction total amounts of the historical block sub-chains.
In an optional embodiment of the present application, the historical energy transaction total amount of all nodes in the previous historical time period may be obtained by the historical merging block of the previous historical time period according to the sum of the energy transaction total amounts of the nodes on each block subchain included in the historical merging block in the historical time period, and the historical energy transaction total amount is used as the first historical energy transaction total amount of the previous historical time period.
Step 302, determining a target historical block sub-chain with the largest total historical energy transaction amount from a plurality of historical block sub-chains which are operated in parallel in the previous historical time period.
In an optional embodiment of the present application, the total historical energy transaction amount of each parallel running historical block sub-chain in the previous historical time period may be obtained through the historical merging block of the previous historical time period according to the total energy transaction amount of the node on each block sub-chain included in the historical merging block in the historical time period, and the historical block sub-chain with the largest historical energy transaction amount is selected from the total historical energy transaction amount of each historical block sub-chain as the target historical block sub-chain.
Step 303, determining the number of the initial partitions according to the quotient of the total amount of the first historical energy transaction and the historical energy transaction amount of the target historical block sub-chain.
In an optional embodiment of the present application, the number of the initial partitions may be determined according to a quotient of the first historical energy transaction total and the historical energy transaction amount of the target historical block sub-chain; optionally, when the quotient is a non-integer, any rounding method may be used to round the quotient, and the rounded integer is used as the number of the initial partitions.
In this embodiment, the number of the initial partitions is determined according to the total amount of the first historical energy transaction in the previous historical time period and the target historical block subchain with the maximum total amount of the historical energy transaction in the multiple historical block subchains in the previous historical time period, and the quotient value of the total amount of the first historical energy transaction and the historical energy transaction amount of the target historical block subchain; compared with the random setting of the number of the initial partitions, the method can greatly improve the rationality and accuracy of the initial partitions and improve the efficiency of the initial partitions.
Fig. 4 is a flowchart of a method for synchronizing energy block data according to another embodiment. The present embodiment relates to an optional implementation process for determining the running duration of all block subchains in the current time period. On the basis of the above embodiment, as shown in fig. 4, the above method further includes:
Step 401, obtaining a first target partition with the maximum predicted total energy transaction amount from target partitions in the current time period.
In an optional embodiment of the present application, the total predicted energy transaction amount of each target partition may be determined according to the node included in each target partition in the current time period and the predicted energy transaction amounts of each node in the current time period, and the target partition with the maximum predicted energy transaction amount may be selected as the first target partition according to the total predicted energy transaction amount of each target partition.
Step 402, determining the operation duration of all the block sub-chains in the current time period according to the product of the sum of the predicted energy transaction total amount of the first target partition and the preset random number and the processing rate of the block sub-chains operated in the current time period.
In an alternative embodiment of the present application, the preset random number may be a random integer between 2 and 5, and the running duration of all the blocksub-chains in the current time period is determined according to the multiplied product by summing the predicted energy transaction total amount of the first target partition with the preset random number, multiplying the sum with the processing rate of the blocksub-chains running in the current time period, and determining the running duration of all the blocksub-chains in the current time period according to the multiplied product.
In this embodiment, the operation duration of all the block subchains in the current time period is determined by acquiring a first target partition with the maximum predicted energy transaction total amount from the target partitions in the current time period, multiplying the product of the processing rates of the block subchains operated in the current time period by the sum of the predicted energy transaction total amount of the first target partition and a preset random number; the maximum value of the total energy transaction amount in each target partition in the current time period is adopted, and after a random number is added, the maximum value is multiplied by the processing rate of the block sub-chain to obtain the operation duration of all the block sub-chains in the current time period, so that the energy transaction data in all the target partitions in the current time period can be ensured to be processed in the operation duration, and the completion degree of the transaction processing of all the sub-chains is ensured to the maximum extent.
In an alternative embodiment of the present application, if there is a trans-regional energy transaction in multiple target partitions in the current time period, that is, an energy transaction between a node in one target partition and a node in another target partition, an intermediate proxy node may be set up, where the intermediate proxy node may be a newly added node device or may be a dedicated intermediate proxy node; the intermediate node plays the role of an intermediate quotient, can respectively proxy the transaction between the two parties, can be divided into slave nodes (also can be public nodes) of two areas where the two parties of the transaction are located, and can respectively sign intelligent contracts with the two parties of the transaction node to realize the cross-regional energy transaction; the method and the device can ensure the independence of each area during the transaction between the areas, and do not influence the energy transaction between the areas.
In an alternative embodiment of the present application, after the running duration of the current time period is finished, if there is an unprocessed energy transaction on the sub-chain, the remaining unprocessed transaction amount may be added to the predicted energy transaction amount of the next time period, and the processing of the remaining unprocessed transaction amount is completed in the next time period.
It should be understood that, although the steps in the flowcharts of fig. 1-4 are shown in order as indicated by the arrows, these steps are not necessarily performed in order as indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in FIGS. 1-4 may include multiple steps or stages that are not necessarily performed at the same time, but may be performed at different times, nor do the order in which the steps or stages are performed necessarily performed in sequence, but may be performed alternately or alternately with at least a portion of the steps or stages in other steps or other steps.
In one embodiment, as shown in fig. 5, there is provided a synchronization apparatus for energy block data, including: a setup module 501, a first determination module 502, and a second determination module 503, wherein:
The establishing module 501 is configured to process historical block data on a current energy block chain by using a clustering algorithm, and establish a plurality of target partitions in a current time period; wherein each target partition includes an identification of at least one node associated with the historical block data and a predicted energy transaction amount for the node at a current time period.
The first determining module 502 is configured to determine a block sub-chain corresponding to each target partition according to a node identifier included in each target partition and a predicted energy transaction amount of the node in a current time period; wherein all the block subchains in the current time period run in parallel.
A second determining module 503, configured to combine the hash values of the last block on each block sub-chain, determine a combined block in the current time period, and send the combined block to the current block chain; wherein the merge block is used to characterize all block data on the current blockchain.
In one embodiment, the second determining module 503 is specifically configured to obtain a hash value of a last chunk on each chunk subchain; performing serial operation on the hash value of the last block on each block sub-chain to obtain serial characters; and carrying out encryption calculation on the serial characters to obtain the merging block.
In one embodiment, the establishing module 501 is specifically configured to obtain a history merging block of a previous history period, and determine a current node network topology according to the history merging block; the history merging block is used for representing all block data in the previous history time period; the historical energy transaction amount of each node in a plurality of historical time periods on the current blockchain is obtained, and the predicted energy transaction amount of each node in the current time period in the current node network topology is determined according to the historical energy transaction amount of each node in the plurality of historical time periods; clustering the current node network topology by adopting the clustering algorithm to obtain a plurality of initial partitions; each initial partition comprises the identification of part of nodes in the current node network topology and forecast energy transaction amount; and optimizing the plurality of initial partitions according to the identification of each node in the current node network topology and the predicted energy transaction amount to obtain a plurality of target partitions in the current time period.
In one embodiment, the establishing module 501 is specifically configured to sum the predicted energy transaction amounts of each node in each initial partition to obtain a predicted energy transaction total amount corresponding to each initial partition; determining a first initial partition with the smallest predicted energy transaction total amount and a second initial partition with the smallest predicted energy transaction total amount from each initial partition, and obtaining the sum of the predicted energy transaction total amount of the first initial partition and the predicted energy total amount of the second initial partition to obtain the reference energy transaction total amount; and determining whether to merge the first initial partition and the second initial partition into a target partition according to the total reference energy transaction amount and a preset merging threshold.
In one embodiment, the establishing module 501 is specifically configured to combine the first initial partition and the second initial partition into a target partition when the total amount of the reference energy transaction is less than the combination threshold; and determining the first initial partition as one target partition and the second initial partition as another target partition under the condition that the total amount of the reference energy transaction is not less than the merging threshold.
In one embodiment, the establishing module 501 is further configured to determine a third initial partition with a maximum predicted total energy transaction amount from each initial partition; and splitting the third initial partition into a plurality of target partitions under the condition that the total predicted energy transaction amount of the third initial partition is larger than a preset classification threshold.
In one embodiment, the establishing module 501 is specifically configured to split the third initial partition into the plurality of target partitions according to the number of nodes in the third initial partition and the predicted energy transaction amount of each node; the difference value of the total predicted energy transaction amounts of the target partitions is smaller than a preset threshold value.
In one embodiment, the apparatus further includes: a third determination module; the third determining module is used for obtaining the total amount of the first historical energy transaction in the last historical time period; the method comprises the steps that a plurality of historical block sub-chains are operated in parallel in the previous historical time period, and the first historical energy transaction total amount comprises the historical energy transaction total amounts of the plurality of historical block sub-chains; and determining a target historical block sub-chain with the maximum total amount of historical energy transaction from a plurality of historical block sub-chains which are operated in parallel in the previous historical time period; and determining the number of the initial partitions according to the quotient of the total first historical energy transaction amount and the historical energy transaction amount of the target historical block subchain.
In one embodiment, the merge block further includes at least one of a number of block subchains running in parallel during a current time period, an identification of a node on each block subchain, and a total amount of energy transactions by the node on each block subchain during the current time period.
In one embodiment, the apparatus further includes: a fourth determination module; the fourth determining module is used for acquiring a first target partition with the maximum predicted energy transaction total amount from target partitions in the current time period; and determining the operation duration of all the block sub-chains in the current time period according to the product of the sum of the predicted energy transaction total amount of the first target partition and the preset random number and the processing rate of the block sub-chains operated in the current time period.
In one embodiment, the establishing module 501 is specifically configured to estimate, by using a linear autoregressive algorithm and a historical energy transaction amount of each node in a plurality of historical time periods, a predicted energy transaction amount of each node in a current node network topology in a current time period, so as to obtain a predicted energy transaction amount of each node in the current node network topology in the current time period.
For specific limitation of the synchronization device of the energy block data, reference may be made to the above limitation of the synchronization method of the energy block data, and the description thereof will not be repeated here. The modules in the above-mentioned synchronization device for energy block data may be all or partially implemented by software, hardware, and a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server or a terminal, and the internal structure of which may be as shown in fig. 6. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used for storing energy transaction data or energy blockchain data of the computer device. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method of synchronizing energy block data.
It will be appreciated by those skilled in the art that the structure shown in fig. 6 is merely a block diagram of some of the structures associated with the present application and is not limiting of the computer device to which the present application may be applied, and that a particular computer device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided comprising a memory and a processor, the memory having stored therein a computer program, the processor when executing the computer program performing the steps of:
processing historical block data on a current energy block chain by adopting a clustering algorithm, and establishing a plurality of target partitions in a current time period; wherein each target partition comprises at least one identification of a node associated with the historical block data and a predicted energy transaction amount of the node in a current time period;
determining a block sub-chain corresponding to each target partition according to the node identification contained in each target partition and the predicted energy transaction amount of the node in the current time period; all block subchains in the current time period run in parallel;
merging the hash value of the last block on each block sub-chain, determining a merged block in the current time period, and transmitting the merged block to the current block chain; wherein the merge block is used to characterize all block data on the current blockchain.
In one embodiment, the processor when executing the computer program further performs the steps of: obtaining a hash value of a last block on each block sub-chain; performing serial operation on the hash value of the last block on each block sub-chain to obtain serial characters; and carrying out encryption calculation on the serial characters to obtain the merging block.
In one embodiment, the processor when executing the computer program further performs the steps of: acquiring a history merging block of the previous history time period, and determining the current node network topology according to the history merging block; the history merging block is used for representing all block data in the previous history time period; acquiring historical energy transaction amounts of each node in a plurality of historical time periods on a current blockchain, and determining predicted energy transaction amounts of each node in a current time period in a current node network topology according to the historical energy transaction amounts of each node in the plurality of historical time periods; clustering the current node network topology by adopting the clustering algorithm to obtain a plurality of initial partitions; each initial partition comprises the identification of part of nodes in the current node network topology and forecast energy transaction amount; and optimizing the plurality of initial partitions according to the identification of each node in the current node network topology and the predicted energy transaction amount to obtain a plurality of target partitions in the current time period.
In one embodiment, the processor when executing the computer program further performs the steps of: summing the predicted energy transaction amounts of each node in each initial partition to obtain the predicted energy transaction total amount corresponding to each initial partition; determining a first initial partition with the smallest predicted energy transaction total amount and a second initial partition with the smallest predicted energy transaction total amount from each initial partition, and obtaining the sum of the predicted energy transaction total amount of the first initial partition and the predicted energy total amount of the second initial partition to obtain the reference energy transaction total amount; and determining whether to merge the first initial partition and the second initial partition into a target partition according to the total reference energy transaction amount and a preset merging threshold.
In one embodiment, the processor when executing the computer program further performs the steps of: merging the first initial partition and the second initial partition into a target partition under the condition that the total amount of the reference energy transaction is smaller than the merging threshold; and determining the first initial partition as one target partition and the second initial partition as another target partition under the condition that the total amount of the reference energy transaction is not less than the merging threshold.
In one embodiment, the processor when executing the computer program further performs the steps of: determining a third initial partition with the maximum predicted total energy transaction amount from each initial partition; and splitting the third initial partition into a plurality of target partitions under the condition that the total predicted energy transaction amount of the third initial partition is larger than a preset classification threshold.
In one embodiment, the processor when executing the computer program further performs the steps of: splitting the third initial partition into the plurality of target partitions according to the number of nodes in the third initial partition and the predicted energy transaction amount of each node; the difference value of the total predicted energy transaction amounts of the target partitions is smaller than a preset threshold value.
In one embodiment, the processor when executing the computer program further performs the steps of: acquiring a first historical energy transaction total amount of a last historical time period; the method comprises the steps that a plurality of historical block sub-chains are operated in parallel in the previous historical time period, and the first historical energy transaction total amount comprises the historical energy transaction total amounts of the plurality of historical block sub-chains; determining a target historical block sub-chain with the maximum total amount of historical energy transaction from a plurality of historical block sub-chains which are operated in parallel in the previous historical time period; and determining the number of the initial partitions according to the quotient of the total first historical energy transaction amount and the historical energy transaction amount of the target historical block subchain.
In one embodiment, the processor when executing the computer program further performs the steps of: the merge block also includes at least one of a number of block subchains running in parallel within a current time period, an identification of a node on each block subchain, and a total amount of energy transactions by the node on each block subchain within the current time period.
In one embodiment, the processor when executing the computer program further performs the steps of: acquiring a first target partition with the maximum predicted energy transaction total amount from target partitions in a current time period; and according to the sum of the predicted energy transaction total amount of the first target partition and a preset random number, multiplying the product of the processing rates of the block sub-chains operated in the current time period, and determining the operation time length of all the block sub-chains in the current time period.
In one embodiment, the processor when executing the computer program further performs the steps of: and estimating the predicted energy transaction amount of each node in the current time period in the current node network topology by adopting a linear autoregressive algorithm and the historical energy transaction amounts of each node in a plurality of historical time periods to obtain the predicted energy transaction amount of each node in the current time period in the current node network topology.
In one embodiment, a computer readable storage medium is provided having a computer program stored thereon, which when executed by a processor, performs the steps of:
processing historical block data on a current energy block chain by adopting a clustering algorithm, and establishing a plurality of target partitions in a current time period; wherein each target partition comprises at least one identification of a node associated with the historical block data and a predicted energy transaction amount of the node in a current time period;
determining a block sub-chain corresponding to each target partition according to the node identification contained in each target partition and the predicted energy transaction amount of the node in the current time period; all block subchains in the current time period run in parallel;
Merging the hash value of the last block on each block sub-chain, determining a merged block in the current time period, and transmitting the merged block to the current block chain; wherein the merge block is used to characterize all block data on the current blockchain.
In one embodiment, the computer program when executed by the processor further performs the steps of: obtaining a hash value of a last block on each block sub-chain; performing serial operation on the hash value of the last block on each block sub-chain to obtain serial characters; and carrying out encryption calculation on the serial characters to obtain the merging block.
In one embodiment, the computer program when executed by the processor further performs the steps of: acquiring a history merging block of the previous history time period, and determining the current node network topology according to the history merging block; the history merging block is used for representing all block data in the previous history time period; acquiring historical energy transaction amounts of each node in a plurality of historical time periods on a current blockchain, and determining predicted energy transaction amounts of each node in a current time period in a current node network topology according to the historical energy transaction amounts of each node in the plurality of historical time periods; clustering the current node network topology by adopting the clustering algorithm to obtain a plurality of initial partitions; each initial partition comprises the identification of part of nodes in the current node network topology and forecast energy transaction amount; and optimizing the plurality of initial partitions according to the identification of each node in the current node network topology and the predicted energy transaction amount to obtain a plurality of target partitions in the current time period.
In one embodiment, the computer program when executed by the processor further performs the steps of: summing the predicted energy transaction amounts of each node in each initial partition to obtain the predicted energy transaction total amount corresponding to each initial partition; determining a first initial partition with the smallest predicted energy transaction total amount and a second initial partition with the smallest predicted energy transaction total amount from each initial partition, and obtaining the sum of the predicted energy transaction total amount of the first initial partition and the predicted energy total amount of the second initial partition to obtain the reference energy transaction total amount; and determining whether to merge the first initial partition and the second initial partition into a target partition according to the total reference energy transaction amount and a preset merging threshold.
In one embodiment, the computer program when executed by the processor further performs the steps of: merging the first initial partition and the second initial partition into a target partition under the condition that the total amount of the reference energy transaction is smaller than the merging threshold; and determining the first initial partition as one target partition and the second initial partition as another target partition under the condition that the total amount of the reference energy transaction is not less than the merging threshold.
In one embodiment, the computer program when executed by the processor further performs the steps of: determining a third initial partition with the maximum predicted total energy transaction amount from each initial partition; and splitting the third initial partition into a plurality of target partitions under the condition that the total predicted energy transaction amount of the third initial partition is larger than a preset classification threshold.
In one embodiment, the computer program when executed by the processor further performs the steps of: splitting the third initial partition into the plurality of target partitions according to the number of nodes in the third initial partition and the predicted energy transaction amount of each node; the difference value of the total predicted energy transaction amounts of the target partitions is smaller than a preset threshold value.
In one embodiment, the computer program when executed by the processor further performs the steps of: acquiring a first historical energy transaction total amount of a last historical time period; the method comprises the steps that a plurality of historical block sub-chains are operated in parallel in the previous historical time period, and the first historical energy transaction total amount comprises the historical energy transaction total amounts of the plurality of historical block sub-chains; determining a target historical block sub-chain with the maximum total amount of historical energy transaction from a plurality of historical block sub-chains which are operated in parallel in the previous historical time period; and determining the number of the initial partitions according to the quotient of the total first historical energy transaction amount and the historical energy transaction amount of the target historical block subchain.
In one embodiment, the computer program when executed by the processor further performs the steps of: the merge block also includes at least one of a number of block subchains running in parallel within a current time period, an identification of a node on each block subchain, and a total amount of energy transactions by the node on each block subchain within the current time period.
In one embodiment, the computer program when executed by the processor further performs the steps of: acquiring a first target partition with the maximum predicted energy transaction total amount from target partitions in a current time period; and according to the sum of the predicted energy transaction total amount of the first target partition and a preset random number, multiplying the product of the processing rates of the block sub-chains operated in the current time period, and determining the operation time length of all the block sub-chains in the current time period.
In one embodiment, the computer program when executed by the processor further performs the steps of: and estimating the predicted energy transaction amount of each node in the current time period in the current node network topology by adopting a linear autoregressive algorithm and the historical energy transaction amounts of each node in a plurality of historical time periods to obtain the predicted energy transaction amount of each node in the current time period in the current node network topology.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, or the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples merely represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the invention. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application is to be determined by the claims appended hereto.

Claims (11)

1. A method for synchronizing energy block data, the method comprising:
processing historical block data on a current energy block chain by adopting a clustering algorithm, and establishing a plurality of target partitions in a current time period; wherein each target partition comprises at least one identification of a node associated with the historical block data and a predicted energy transaction amount of the node in a current time period;
determining a block sub-chain corresponding to each target partition according to node identifiers contained in each target partition and the predicted energy transaction amount of the nodes in the current time period; all block sub-chains in the current time period run in parallel;
Merging the hash value of the last block on each block sub-chain, determining a merged block in the current time period, and transmitting the merged block to the current energy block chain; the merging block is used for representing all block data on the current energy block chain;
the step of merging the hash value of the last block on each block sub-chain to determine a merged block in the current time period includes:
obtaining a hash value of a last block on each block sub-chain;
performing serial operation on the hash value of the last block on each block sub-chain to obtain serial characters;
performing encryption calculation on the serial characters to obtain the merging block;
the method for processing the historical block data on the current energy block chain by adopting a clustering algorithm, and establishing a plurality of target partitions in the current time period comprises the following steps:
acquiring a history merging block of a previous history time period, and determining the current node network topology according to the history merging block; the history merging block is used for representing all block data in the previous history time period;
acquiring historical energy transaction amounts of each node in a plurality of historical time periods on the current energy blockchain, and determining predicted energy transaction amounts of each node in the current node network topology in the current time period according to the historical energy transaction amounts of each node in the plurality of historical time periods;
Clustering the current node network topology by adopting the clustering algorithm to obtain a plurality of initial partitions; each initial partition comprises identifications of partial nodes in the current node network topology and predicted energy transaction amounts;
optimizing the plurality of initial partitions according to the identification of each node in the current node network topology and the predicted energy transaction amount to obtain a plurality of target partitions in the current time period;
the optimizing the plurality of initial partitions according to the identification of each node in the current node network topology and the predicted energy transaction amount to obtain a plurality of target partitions in the current time period, including:
summing the predicted energy transaction amounts of each node in each initial partition to obtain the predicted energy transaction total amount corresponding to each initial partition;
determining a first initial partition with the smallest predicted energy transaction total amount and a second initial partition with the smallest predicted energy transaction total amount from each initial partition, and obtaining the sum of the predicted energy transaction total amount of the first initial partition and the predicted energy total amount of the second initial partition to obtain a reference energy transaction total amount;
And determining whether to merge the first initial partition and the second initial partition into a target partition according to the total reference energy transaction amount and a preset merging threshold.
2. The method of claim 1, wherein determining whether to merge the first initial partition and the second initial partition into a target partition based on the reference energy transaction total and a preset merge threshold comprises:
if the total amount of the reference energy transaction is smaller than the merging threshold, merging the first initial partition and the second initial partition into a target partition;
and if the total amount of the reference energy transaction is not smaller than the merging threshold, determining the first initial partition as one target partition, and determining the second initial partition as another target partition.
3. The method of claim 1, wherein the optimizing the plurality of initial partitions according to the identification of each node in the current node network topology and the predicted energy transaction amount to obtain a plurality of target partitions in the current time period further comprises:
determining a third initial partition with the maximum predicted total energy transaction amount from the initial partitions;
If the total predicted energy transaction amount of the third initial partition is larger than a preset classification threshold, splitting the third initial partition into a plurality of target partitions.
4. The method of claim 3, wherein splitting the third initial partition into a plurality of target partitions comprises:
splitting the third initial partition into the plurality of target partitions according to the number of nodes in the third initial partition and the predicted energy transaction amount of each node; the difference value of the total predicted energy transaction amounts of the target partitions is smaller than a preset threshold value.
5. The method of claim 1, wherein before clustering the current node network topology using the clustering algorithm to obtain a plurality of initial partitions, further comprises:
acquiring a first historical energy transaction total amount of the last historical time period; the first historical energy transaction total amount comprises the historical energy transaction total amounts of the plurality of historical block subchains;
determining a target historical block sub-chain with the maximum total amount of historical energy transaction from a plurality of historical block sub-chains which are operated in parallel in the last historical time period;
And determining the number of the initial partitions according to the quotient of the total first historical energy transaction amount and the historical energy transaction amount of the target historical block subchain.
6. The method of any of claims 1-5, wherein the merge block further comprises at least one of a number of blocksubchains running in parallel during the current time period, an identification of a node on each blocksubchain, and a total amount of energy transactions by the node on each blocksubchain during the current time period.
7. The method according to any one of claims 1 to 5, further comprising:
acquiring a first target partition with the maximum predicted energy transaction total amount from the target partitions in the current time period;
and according to the sum of the predicted energy transaction total amount of the first target partition and a preset random number, multiplying the product of the processing rates of the block sub-chains operated in the current time period, and determining the operation duration of all the block sub-chains in the current time period.
8. The method of any one of claims 1 to 5, wherein determining a predicted energy transaction amount for each node in the current node network topology for the current time period based on the historical energy transaction amounts for each node in the plurality of historical time periods comprises:
And estimating the predicted energy transaction amount of each node in the current node network topology in the current time period by adopting a linear autoregressive algorithm and the historical energy transaction amount of each node in the plurality of historical time periods to obtain the predicted energy transaction amount of each node in the current node network topology in the current time period.
9. An apparatus for synchronizing energy block data, the apparatus comprising:
the building module is used for processing the historical block data on the current energy block chain by adopting a clustering algorithm and building a plurality of target partitions in the current time period; wherein each target partition comprises at least one identification of a node associated with the historical block data and a predicted energy transaction amount of the node in a current time period;
the first determining module is used for determining a block sub-chain corresponding to each target partition according to the node identification contained in each target partition and the predicted energy transaction amount of the node in the current time period; all block sub-chains in the current time period run in parallel;
the second determining module is used for merging the hash value of the last block on each block sub-chain, determining a merging block in the current time period and sending the merging block to the current energy block chain; the merging block is used for representing all block data on the current energy block chain;
The second determining module is specifically configured to obtain a hash value of a last block on each block sub-chain; performing serial operation on the hash value of the last block on each block sub-chain to obtain serial characters; performing encryption calculation on the serial characters to obtain the merging block;
the establishing module is specifically configured to obtain a history merging block of a previous history period, and determine a current node network topology according to the history merging block; the history merging block is used for representing all block data in the previous history time period; acquiring historical energy transaction amounts of each node in a plurality of historical time periods on the current energy blockchain, and determining predicted energy transaction amounts of each node in the current node network topology in the current time period according to the historical energy transaction amounts of each node in the plurality of historical time periods; clustering the current node network topology by adopting the clustering algorithm to obtain a plurality of initial partitions; each initial partition comprises identifications of partial nodes in the current node network topology and predicted energy transaction amounts; optimizing the plurality of initial partitions according to the identification of each node in the current node network topology and the predicted energy transaction amount to obtain a plurality of target partitions in the current time period;
The establishment module is specifically configured to sum the predicted energy transaction amounts of each node in each initial partition to obtain a predicted energy transaction total amount corresponding to each initial partition; determining a first initial partition with the smallest predicted energy transaction total amount and a second initial partition with the smallest predicted energy transaction total amount from each initial partition, and obtaining the sum of the predicted energy transaction total amount of the first initial partition and the predicted energy total amount of the second initial partition to obtain a reference energy transaction total amount; and determining whether to merge the first initial partition and the second initial partition into a target partition according to the total reference energy transaction amount and a preset merging threshold.
10. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any one of claims 1 to 8 when the computer program is executed.
11. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 8.
CN202011423850.4A 2020-12-08 2020-12-08 Method, device, computer equipment and storage medium for synchronizing energy block data Active CN112487094B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011423850.4A CN112487094B (en) 2020-12-08 2020-12-08 Method, device, computer equipment and storage medium for synchronizing energy block data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011423850.4A CN112487094B (en) 2020-12-08 2020-12-08 Method, device, computer equipment and storage medium for synchronizing energy block data

Publications (2)

Publication Number Publication Date
CN112487094A CN112487094A (en) 2021-03-12
CN112487094B true CN112487094B (en) 2024-01-19

Family

ID=74940766

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011423850.4A Active CN112487094B (en) 2020-12-08 2020-12-08 Method, device, computer equipment and storage medium for synchronizing energy block data

Country Status (1)

Country Link
CN (1) CN112487094B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107766542A (en) * 2017-10-30 2018-03-06 上海分布信息科技有限公司 A kind of block chain network of subregion and its method for realizing subregion inquiry
CN108765142A (en) * 2018-03-29 2018-11-06 深圳市网心科技有限公司 Electronic device, multi-tiling chain integral traffic control method and computer readable storage medium
CN109271805A (en) * 2018-08-10 2019-01-25 广东工业大学 A kind of storage of data subregion, querying method and system based on block chain
CN110928953A (en) * 2019-12-03 2020-03-27 上海墨珩网络科技有限公司 Data synchronization method and system based on block chain technology
CN110968883A (en) * 2019-12-04 2020-04-07 中船黄埔文冲船舶有限公司 Data management method and device based on block chain technology and storage medium
CN111339086A (en) * 2020-02-18 2020-06-26 腾讯科技(深圳)有限公司 Block processing method, and data query method and device based on block chain

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CA3061594A1 (en) * 2018-11-14 2020-05-14 Royal Bank Of Canada System and method for cross-border blockchain platform

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107766542A (en) * 2017-10-30 2018-03-06 上海分布信息科技有限公司 A kind of block chain network of subregion and its method for realizing subregion inquiry
CN108765142A (en) * 2018-03-29 2018-11-06 深圳市网心科技有限公司 Electronic device, multi-tiling chain integral traffic control method and computer readable storage medium
CN109271805A (en) * 2018-08-10 2019-01-25 广东工业大学 A kind of storage of data subregion, querying method and system based on block chain
CN110928953A (en) * 2019-12-03 2020-03-27 上海墨珩网络科技有限公司 Data synchronization method and system based on block chain technology
CN110968883A (en) * 2019-12-04 2020-04-07 中船黄埔文冲船舶有限公司 Data management method and device based on block chain technology and storage medium
CN111339086A (en) * 2020-02-18 2020-06-26 腾讯科技(深圳)有限公司 Block processing method, and data query method and device based on block chain

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"微网电力交易的多链式区块链动态分区方法设计与实现";周强等;《电子器件》;全文 *

Also Published As

Publication number Publication date
CN112487094A (en) 2021-03-12

Similar Documents

Publication Publication Date Title
KR102103130B1 (en) Method and device for writing service data to blockchain, and method for determining service subset
US10585889B2 (en) Optimizing skewed joins in big data
Hegeman et al. Toward optimal bounds in the congested clique: Graph connectivity and MST
Anchalia et al. MapReduce design of K-means clustering algorithm
EP3432157B1 (en) Data table joining mode processing method and apparatus
CN112449009B (en) SVD-based communication compression method and device for Federal learning recommendation system
Ribeiro et al. Efficient parallel subgraph counting using g-tries
CN110765320B (en) Data processing method, device, storage medium and computer equipment
CN109189572B (en) Resource estimation method and system, electronic equipment and storage medium
WO2015180340A1 (en) Data mining method and device
US11221890B2 (en) Systems and methods for dynamic partitioning in distributed environments
CN109101338A (en) A kind of block chain processing framework and its method based on the extension of multichannel chip
US10162830B2 (en) Systems and methods for dynamic partitioning in distributed environments
Nigmetov et al. Local-global merge tree computation with local exchanges
CN113900810A (en) Distributed graph processing method, system and storage medium
CN112487094B (en) Method, device, computer equipment and storage medium for synchronizing energy block data
Doerr et al. Island models meet rumor spreading
CN111522873B (en) Block generation method, device, computer equipment and storage medium
CN111028092A (en) Community discovery method based on Louvain algorithm, computer equipment and readable storage medium thereof
CN115221244A (en) Block chain cross-chain method and device, computer equipment and storage medium
CN115955323A (en) Network security situation sensing method and device and electronic equipment
Balashov et al. Optimal shattering of complex networks
Zhang et al. Social network sensitive area perturbance method based on firefly algorithm
US11442792B2 (en) Systems and methods for dynamic partitioning in distributed environments
Ren et al. Parallel set determination and k-means clustering for data mining on telecommunication networks

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