Block chain-based power data processing method and device

By judging transaction data conflicts in power data processing, setting up pending queues and encapsulating transaction blocks, the error problems caused by multiple operations in power data blockchain processing are solved, and more efficient and accurate data processing is achieved.

CN120278714AActive Publication Date: 2025-07-08TIANJIN UNIV
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202510764688.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-10
Publication Date
2025-07-08
Estimated Expiration
2045-06-10

AI Technical Summary

Technical Problem

In the prior art, data error problems caused by the superposition of multiple operations during power data blockchain processing, especially the multiple processing and intermediate results of the same data are ignored, resulting in errors in the final result.

Method used

By judging the conflict between the transaction data of the power data and the queue, determining that the data that is earlier than the transaction time is placed in the queue, setting up the pending queue, and encapsulating the transaction block when the conditions are met, using sorting priority and dependencies to process the transaction data to ensure data accuracy and efficiency.

Benefits of technology

It improves the accuracy of power data processing, avoids data omissions and errors, and enhances the efficiency and accuracy of data processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120278714A_ABST
    Figure CN120278714A_ABST
Patent Text Reader

Abstract

The invention provides a power data processing method and device based on a block chain, and can be applied to the technical field of block chains and data security. The method comprises the following steps: generating transaction data to be inserted based on electric power data in response to the electric power data acquired by electric power data acquisition equipment from electric power equipment; when it is determined that there is a conflict between the to-be-inserted transaction data and the transaction data existing in the transaction queue, determining respective transaction moments of the to-be-inserted transaction data and the transaction data; under the condition that the transaction moment of the to-be-inserted transaction data is earlier than the transaction moment of the transaction data, placing the to-be-inserted transaction data at the position of the transaction data in the transaction queue; placing the transaction data in a queue to be processed; under the condition that it is determined that the transaction queue meets the packaging condition, multiple pieces of transaction data included in the transaction queue are packaged to obtain a transaction block; and issuing the transaction block to the block chain.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of blockchain and data security, and particularly to a method and device for processing power data based on blockchain. Background Art

[0002] Power data acquisition technology has been widely applied in the power system in recent years. Its main objective is to collect data from various power devices to achieve functions such as power consumption monitoring, real-time settlement, energy efficiency analysis, load prediction, and fault diagnosis. With the development of blockchain technology, using blockchain to manage and store power data can ensure the security of power data and the efficiency of data processing.

[0003] Due to the high concurrency characteristics of power data, multiple operations on the same data often occur. In the normal processing logic, multiple operations are superimposed on this data and the final result is calculated.

[0004] However, in the related art, when multiple operations on the same data are simultaneously encapsulated into a power data block, the above multiple operations will respectively process the same basic value multiple times, while other operations and intermediate results are ignored. Therefore, when this power data block is uploaded to the blockchain, the last processing result will be synchronized to other blocks as the final result, resulting in incorrect synchronized power data. Summary of the Invention

[0005] In view of the above problems, the present invention provides a method and device for processing power data based on blockchain.

[0006] According to the first aspect of the present invention, there is provided a method for processing power data based on blockchain, including: in response to power data collected by a power data acquisition device from a power device, generating transaction data to be inserted based on the power data; in the case where it is determined that there is a conflict between the transaction data to be inserted and the existing transaction data in the transaction queue, determining the transaction times of the transaction data to be inserted and the transaction data, wherein, in the case where the transaction objects of the transaction data to be inserted and the transaction data are the same and the transaction types are the same, it is determined that there is a conflict between the transaction data to be inserted and the transaction data; in the case where the transaction time of the transaction data to be inserted is earlier than the transaction time of the transaction data, placing the transaction data to be inserted at the position where the transaction data in the transaction queue is located; placing the transaction data in the queue to be processed; in the case where it is determined that the transaction queue meets the encapsulation condition, encapsulating the multiple transaction data included in the transaction queue to obtain a transaction block; and publishing the transaction block to the blockchain.

[0007] According to an embodiment of the present invention, after encapsulating a plurality of transaction data included in a transaction queue to obtain a transaction block, the power data processing method based on a blockchain further includes: determining the transaction objects of the plurality of transaction data in the to-be-processed queue; for the transaction object of each transaction data, determining the to-be-arranged transaction data from at least one transaction data based on the transaction time of at least one transaction data of the transaction object; arranging the plurality of to-be-arranged transaction data according to a sorting priority to obtain a new transaction queue, wherein the sorting priority is determined based on the transaction type.

[0008] According to an embodiment of the present invention, the power data processing method based on a blockchain further includes: in the case that there is no conflict between the to-be-inserted transaction data and the transaction data already existing in the transaction queue, determining the expected insertion position of the to-be-inserted transaction data in the transaction queue based on the transaction type of the to-be-inserted transaction data and the transaction types to which the plurality of transaction data in the transaction queue belong; inserting the to-be-inserted transaction data into the expected insertion position.

[0009] According to an embodiment of the present invention, determining the expected insertion position of the to-be-inserted transaction data in the transaction queue based on the transaction type of the to-be-inserted transaction data and the transaction types to which the plurality of transaction data in the transaction queue belong includes: traversing the plurality of transaction data in the transaction queue to determine the sorting priorities of the plurality of transaction data; in the case that it is determined that there is at least one transaction data among the plurality of transaction data that is in the same sorting priority as the to-be-inserted transaction data, determining the expected insertion position according to the transaction times of the at least one transaction data in the same sorting priority and the to-be-inserted transaction data.

[0010] According to an embodiment of the present invention, the encapsulation condition includes at least one of the following: the capacity of the transaction queue is greater than or equal to a preset capacity threshold; the duration between the current time and the generation time of the previous transaction block reaches a preset time threshold.

[0011] According to an embodiment of the present invention, encapsulating a plurality of transaction data included in a transaction queue to obtain a transaction block includes: selecting at least one target transaction data from the transaction queue according to the capacity required by each of the plurality of transaction data included in the transaction queue and a preset capacity; encapsulating the at least one target transaction data to obtain a transaction block.

[0012] According to an embodiment of the present invention, selecting at least one target transaction data from a transaction queue according to the capacities required by each of the multiple transaction data included in the transaction queue and a preset capacity includes: when the sum of the capacities required by each of the multiple transaction data is less than or equal to the preset capacity, regarding all the multiple transaction data as target transaction data; when the sum of the capacities required by each of the multiple transaction data is greater than the preset capacity, screening the multiple transaction data in the order of the multiple transaction data in the transaction queue to obtain at least one target transaction data whose occupied capacity is less than the preset capacity.

[0013] According to an embodiment of the present invention, screening the multiple transaction data in the order of the multiple transaction data in the transaction queue to obtain at least one target transaction data whose occupied capacity is less than the preset capacity includes: repeatedly performing the following operations until the screening of the last transaction data among the multiple transaction data is completed: determining the remaining capacity based on the capacity required by the at least one target transaction data that has been screened and the preset capacity; when the capacity occupied by the transaction data to be screened is less than the remaining capacity, regarding the transaction data to be screened as target transaction data; when the capacity occupied by the transaction data to be screened is greater than the remaining capacity, obtaining the next transaction data in the transaction queue after the transaction data to be screened as the transaction data to be screened.

[0014] According to an embodiment of the present invention, the power data processing method based on a blockchain further includes: adjusting the sorting priorities of each of the multiple transaction data included in the transaction queue according to the waiting duration of each of the multiple transaction data included in the transaction queue to obtain multiple adjusted sorting priorities, where the waiting duration is the time difference between the time when the transaction data is collected and the current time; rearranging the multiple transaction data in the transaction queue according to the adjusted sorting priorities of each of the multiple transaction data included in the transaction queue.

[0015] According to an embodiment of the present invention, generating transaction data to be inserted based on power data includes: adding the collection time of the power data and the electronic signature of the power data collection device to the power data to obtain the transaction data to be inserted.

[0016] The second aspect of the present invention provides a blockchain-based power data processing device, including: a data generation module, configured to generate transaction data to be inserted based on power data in response to the power data collected by a power data collection device from a power device; a time determination module, configured to determine the transaction times of the transaction data to be inserted and the existing transaction data in the transaction queue when it is determined that there is a conflict between the transaction data to be inserted and the existing transaction data in the transaction queue, where a conflict is determined to exist between the transaction data to be inserted and the transaction data when their transaction objects and transaction types are the same; a data movement module, configured to place the transaction data to be inserted at the position where the transaction data in the transaction queue is located when the transaction time of the transaction data to be inserted is earlier than the transaction time of the transaction data; a data insertion module, configured to place the transaction data in a queue to be processed; a data encapsulation module, configured to encapsulate a plurality of transaction data included in the transaction queue to obtain a transaction block when it is determined that the transaction queue meets the encapsulation condition; and a data publishing module, configured to publish the transaction block to a blockchain.

[0017] The third aspect of the present invention provides an electronic device, including: one or more processors; a memory for storing one or more computer programs, where the above one or more processors execute the above one or more computer programs to implement the steps of the above method.

[0018] The fourth aspect of the present invention further provides a computer-readable storage medium, on which a computer program or instruction is stored, and when the computer program or instruction is executed by a processor, the steps of the above method are implemented.

[0019] The fifth aspect of the present invention further provides a computer program product, including a computer program or instruction, and when the computer program or instruction is executed by a processor, the steps of the above method are implemented.

[0020] According to the embodiments of the present invention, by judging the conflict situation between the transaction data in the transaction queue and the transaction data to be inserted, the conflicting transaction data can be separated and processed in time, avoiding the problem of data processing errors caused by conflicting transaction data in the same transaction block summary. By setting up a queue to be processed, the transaction data that conflicts with other transaction data and has a transaction time later than other transaction data can be stored and managed, and the transaction data in the queue to be processed can be preferentially processed subsequently, thus avoiding the problem of data processing errors caused by missing transaction data and further improving the accuracy of data processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Through the following description of the embodiments of the present invention with reference to the drawings, the above content and other objects, features, and advantages of the present invention will become clearer. In the drawings:

[0022] Figure 1 The application scenario diagram of the blockchain-based power data processing method and device according to an embodiment of the present invention is shown.

[0023] Figure 2 The flowchart of the blockchain-based power data processing method according to an embodiment of the present invention is shown.

[0024] Figure 3 The dependency graph constructed by the blockchain-based power data processing method according to an embodiment of the present invention is shown.

[0025] Figure 4 The screening process of transaction data by the blockchain-based power data processing method according to an embodiment of the present invention is shown.

[0026] Figure 5 The structural block diagram of the blockchain-based power data processing device according to an embodiment of the present invention is shown.

[0027] Figure 6 The block diagram of the electronic device suitable for implementing the blockchain-based power data processing method according to an embodiment of the present invention is shown. Detailed implementation manners

[0028] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are merely exemplary and are not intended to limit the scope of the present invention. In the following detailed description, for the sake of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present invention. However, obviously, one or more embodiments can also be implemented without these specific details. In addition, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessarily confusing the concepts of the present invention.

[0029] The terms used herein are merely for describing specific embodiments and are not intended to limit the present invention. The terms "including", "comprising" and the like used herein indicate the presence of the described features, steps, operations and / or components, but do not exclude the presence or addition of one or more other features, steps, operations or components.

[0030] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0031] In the case of using expressions such as "at least one of A, B, and C", generally, it should be interpreted according to the meaning that those skilled in the art usually understand this expression (for example, "a system having at least one of A, B, and C" should include, but not be limited to, a system having only A, only B, only C, having A and B, having A and C, having B and C, and / or having A, B, and C, etc.).

[0032] In the technical solution of the present invention, the user information involved (including but not limited to user personal information, user image information, user device information, such as location information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) are all information and data that have been authorized by the user or fully authorized by all parties. Moreover, the processing of relevant data, such as collection, storage, use, processing, transmission, provision, invention, and application, all comply with relevant laws, regulations, and standards, take necessary confidentiality measures, do not violate public order and good customs, and provide corresponding operation entrances for users to choose to authorize or reject.

[0033] In the scenario of making automated decisions using personal information, the methods, devices, and systems provided by the embodiments of the present invention all provide corresponding operation entrances for users to choose to agree or reject the results of automated decisions; if the user chooses to reject, the expert decision-making process will be entered. Here, the expression "automated decision" refers to an activity of automatically analyzing and evaluating an individual's behavior habits, hobbies, or economic, health, credit status, etc. through a computer program and making a decision. Here, the expression "expert decision" refers to an activity of making a decision by a person who specializes in a certain field, has specialized experience, knowledge, and skills, and has reached a certain professional level.

[0034] An embodiment of the present invention provides a blockchain-based power data processing method, including: in response to power data collected by a power data collection device from a power device, generating transaction data to be inserted based on the power data; in the case of determining that there is a conflict between the transaction data to be inserted and the existing transaction data in the transaction queue, determining the respective transaction times of the transaction data to be inserted and the transaction data, where, in the case that the transaction objects of the transaction data to be inserted and the transaction data are the same and the transaction types are the same, it is determined that there is a conflict between the transaction data to be inserted and the transaction data; in the case that the transaction time of the transaction data to be inserted is earlier than the transaction time of the transaction data, placing the transaction data to be inserted at the position where the transaction data in the transaction queue is located; placing the transaction data in the queue to be processed; in the case of determining that the transaction queue meets the encapsulation condition, encapsulating the multiple transaction data included in the transaction queue to obtain a transaction block; and publishing the transaction block to the blockchain.

[0035] Figure 1The figure shows an application scenario diagram of a blockchain-based power data processing method and apparatus according to an embodiment of the present invention.

[0036] As Figure 1 shown, this application scenario includes two stages: the power data collection stage and the transaction block encapsulation stage. Among them, in the power data collection stage, power data collection devices are used to collect power data from power equipment, and generate transaction data to be inserted based on the power data. The transaction data to be inserted is uploaded to the blockchain computing node through network devices, and in the blockchain computing node, the operations of the transaction block encapsulation stage are executed.

[0037] In the transaction block encapsulation stage, the transaction data is sorted according to sorting priorities, transaction times, etc. through data sorting, and it is judged whether there is a conflict between the transaction data and the transaction data to be inserted based on their respective transaction objects and transaction types. When it is determined that there is no conflict, the transaction data to be inserted is inserted into the transaction queue according to parameters such as the sorting priority and transaction time of the transaction data to be inserted.

[0038] After the encapsulation conditions are met, the transaction data in the transaction queue is encapsulated to obtain a transaction block, and the transaction block is submitted to the blockchain, so that all blocks on the blockchain reach a consensus based on the newly submitted block and complete the data update.

[0039] After the data update is completed, subsequent power data collection is based on the data on the updated blockchain, thereby realizing global data management and data unification.

[0040] Based on the Figure 1 scenario described below, the blockchain-based power data processing method according to an embodiment of the present invention will be described in detail through Figures 2 to 4 the following.

[0041] Figure 2 The figure shows a flowchart of a blockchain-based power data processing method according to an embodiment of the present invention.

[0042] As Figure 2 shown, the blockchain-based power data processing method of this embodiment includes operations S210 to S260.

[0043] In operation S210, in response to the power data collected by the power data collection device from the power equipment, transaction data to be inserted is generated based on the power data.

[0044] According to an embodiment of the present invention, the power equipment may include smart meters, management equipment of a power center, power generation equipment, etc. The power data acquisition device is communicatively connected to the power equipment and is used for acquiring power data generated by the power equipment. After acquiring the power data, the power data acquisition device may also perform operations such as data cleaning, format conversion, and format aggregation on the power data.

[0045] According to an embodiment of the present invention, during the data acquisition process, control may be performed through a hash algorithm to avoid the problem of duplicate data acquisition. Among them, the hash algorithm may be used to determine the hash value of the acquired power data. When it is determined that the hash value does not conflict, that is, it is different from all the previously acquired power data, it may be determined that the currently acquired power data is not obtained by duplicating the already acquired power data, and the power data may be further processed to obtain the transaction data to be inserted.

[0046] According to another embodiment of the present invention, the hash algorithm may also be used to process multiple power data acquired within one clock cycle to obtain the hash values of the multiple power data respectively, and by determining whether there are duplicate hash values among the multiple hash values, it is determined whether there are duplicate situations among the multiple power data acquired within this clock cycle.

[0047] According to an embodiment of the present invention, by processing multiple power data acquired within a clock cycle, a set S as shown in formula (1) can be obtained:

[0048] (1)

[0049] where, v i is the i-th power data acquired within this clock cycle, and k i is the hash value of v i , and i = 1,..., n. n is the number of power data acquired within this clock cycle.

[0050] According to an embodiment of the present invention, the power data may include a transaction object, a transaction type, and a transaction value corresponding to the transaction type. Among them, the transaction object may be determined according to the power equipment that generates the power data, and the transaction types include dispatching instruction types, dispatching response types, and power consumption situation types, etc.

[0051] Among them, the transaction objects include individual objects and administrator objects. When the power equipment is a smart meter, the transaction object can be determined as an individual object, and when the power equipment is management equipment, the transaction object can be determined as an administrator object.

[0052] In the case of a management device with a power device as the power center, power data may include dispatching instructions such as power supply cut-off instructions and power supply restoration instructions for the management area. Therefore, the transaction type of power data is the dispatching instruction type. In the case of a power device being a smart meter, power data may include data for changing the electricity balance of users, such as electricity consumption data and recharge data of users. Therefore, the transaction type of power data is the electricity consumption type. It may also include power-off responses and power-on responses for users in response to the execution of dispatching instructions. Therefore, the transaction type of power data is the dispatching response type.

[0053] According to an embodiment of the present invention, power data may also include the transaction volume corresponding to the transaction type. For example, in the case where the transaction type is the dispatching instruction type, the transaction volume may be power supply cut-off or power supply restoration. In the case where the transaction type is the electricity consumption type, the transaction volume may include the electricity consumption of users, the electricity charges consumed corresponding to the electricity consumption of users, the recharge volume of users, etc.

[0054] According to an embodiment of the present invention, power data may also include the transaction time of the power data, and the transaction time is used to represent the occurrence time of the electricity consumption event corresponding to the power data. Since power collection devices usually perform data collection periodically, the collection time of the power data collected by the power collection device may be later than the transaction time of the power data.

[0055] In operation S220, when it is determined that there is a conflict between the transaction data to be inserted and the transaction data already existing in the transaction queue, determine the transaction times of the transaction data to be inserted and the transaction data respectively.

[0056] According to an embodiment of the present invention, it is possible to judge the data sources of the power data used to generate the transaction data to be inserted and the power data used to generate the transaction data, and judge whether the transaction objects of the two are the same according to whether the power devices corresponding to the data sources of the two are the same power device.

[0057] According to an embodiment of the present invention, when the transaction objects of the transaction data to be inserted and the transaction data are the same and the transaction types are the same, it can be determined that the transaction data to be inserted and the transaction data need to operate on the data corresponding to the same transaction type of the same transaction object. Since both the transaction data to be inserted and the transaction data need to determine the basic data corresponding to the transaction through the blockchain, the basic data corresponding to the transaction data to be inserted and the transaction data is the same, and the operations are different. If it is allowed that both the transaction data to be inserted and the transaction data operate on the basic data, the operation result is the result of the later-operated transaction data or the transaction data to be inserted, rather than the operation result after the superposition of the transaction data to be inserted and the transaction data.

[0058] For example, when the transaction data to be inserted represents that a certain user recharges 100 kWh of electricity, and the transaction data represents that the same user consumes 50 kWh of electricity, and based on the data already on the blockchain, it is determined that the user's electricity balance is 300 kWh, in fact, after the operations represented by the above transaction data to be inserted and the transaction data, the remaining electricity of the user should be 300 + 100 - 50 = 350 kWh.

[0059] However, since both the transaction data to be inserted and the transaction data are based on the data already on the current blockchain, that is, for the transaction data to be inserted and the transaction data, the user's electricity balance is 300 kWh. Assuming that the transaction data is ranked before the transaction data to be inserted in the transaction block, then by calculating the user's electricity balance through the transaction data, it is 300 - 50 = 250 kWh. However, since this transaction block has not completed the calculation and submission, this transaction data has not been synchronized to the blockchain. Therefore, when calculating the data of the transaction to be processed, the basic data used is still 300 kWh. By calculating the user's electricity balance through the transaction data to be inserted, it is 300 + 100 = 400 kWh, and the previously calculated 250 kWh is directly overwritten. After completing the calculation of this transaction block, 400 kWh will be published as the user's electricity balance, resulting in data errors.

[0060] Therefore, when the transaction objects of the transaction data to be inserted and the transaction data are the same and the transaction types are the same, it can be determined that there is a conflict between the transaction data to be inserted and the transaction data.

[0061] According to the embodiments of the present invention, the conflict detection function can be set according to the above conflict detection logic to automatically detect conflicts between the transaction data and the transaction data to be inserted. The conflict detection function is shown in formula (2):

[0062] (2)

[0063] Where C is the conflict detection function, T new is the transaction data to be inserted, T prev is the transaction data, k is the transaction object, and writeSet(k) is the transaction type corresponding to the transaction object k in T new or T prev . Through formula (2), when the transaction types of the same transaction object k in the transaction data to be inserted and the transaction data are the same, a result of 1 indicating the existence of a conflict can be obtained. When the result of the conflict detection function is 0, it indicates that there is no conflict between the transaction data and the transaction data to be inserted.

[0064] According to an embodiment of the present invention, multiple transaction types of the same transaction object in the transaction data can be summarized, and after generating the transaction data to be inserted, the transaction data to be inserted can be directly matched in the summarized set of transaction types of the same transaction object as the transaction data to be inserted to determine whether there is a conflict between the transaction data to be inserted and other transaction data. The summarized set of transaction types is shown in formula (3):

[0065] (3)

[0066] Wherein, W merged is the summarized set of transaction types, and W j is the transaction type corresponding to the j-th transaction data of the same transaction object in the current transaction queue, j = 1,..., m, and m is the number of transaction data of this transaction object in the current transaction queue. represents calculating the intersection between the transaction types corresponding to these m transaction data from W1 to W m these m transaction data.

[0067] In operation S230, when the transaction time of the transaction data to be inserted is earlier than the transaction time of the transaction data, the transaction data to be inserted is placed at the position where the transaction data in the transaction queue is located.

[0068] According to an embodiment of the present invention, the transaction queue includes multiple pre-arranged transaction data, and the arrangement method can be determined according to the sorting priority between the respective transaction objects and transaction types of the multiple transaction data. The transaction data corresponding to the transaction object and transaction type with a higher sorting priority is arranged more forward in the transaction queue.

[0069] According to an embodiment of the present invention, after determining that there is a conflict between the transaction data to be inserted and the transaction data, the occurrence time sequence of the corresponding transactions of the two is judged respectively according to the transaction times of the transaction data to be inserted and the transaction data, and the data corresponding to the transaction that occurs first is processed first. Therefore, when the transaction time of the transaction data to be inserted is earlier than the transaction time of the transaction data, the transaction data to be inserted is placed in the transaction queue. Since the multiple transaction data summarized in the transaction queue have been pre-arranged, the transaction data to be inserted can be directly placed at the position where the transaction data is located to complete the data replacement.

[0070] In operation S240, the transaction data is placed in the queue to be processed.

[0071] According to an embodiment of the present invention, after the transaction data is replaced by the transaction data to be inserted, to ensure the correctness of the data, the transaction data can be placed in the queue to be processed for waiting for processing, where the queue to be processed and the transaction queue are stored in different storage spaces.

[0072] In operation S250, when it is determined that the transaction queue meets the encapsulation condition, multiple transaction data included in the transaction queue are encapsulated to obtain a transaction block.

[0073] According to an embodiment of the present invention, the encapsulation condition may include the data size of the transaction queue, the waiting duration of the transaction queue, etc. When it is determined that the transaction queue meets the encapsulation condition, the block header is assembled according to the situation of other transaction blocks in the current blockchain. According to the block header and multiple transaction data, a transaction block can be generated.

[0074] In operation S260, the transaction block is published to the blockchain.

[0075] According to an embodiment of the present invention, before the transaction block is published to the blockchain, the transaction block is verified again to determine whether all the multiple transaction data in the transaction block include the identifier of the power data acquisition device. If there is transaction data in the transaction block that does not include the identifier of the power data acquisition device, there is a risk of forgery of this data. Therefore, the transaction block and this transaction data need to be verified again.

[0076] According to an embodiment of the present invention, when verifying the transaction block and determining that the transaction block passes the verification, a consensus algorithm can be used to determine the recognition situation of other transaction blocks on the blockchain for the current transaction block. When the current transaction block is recognized by more than a preset proportion of transaction blocks, the transaction block is published to the blockchain.

[0077] According to an embodiment of the present invention, after the transaction block is published to the blockchain, all nodes and transaction blocks in the blockchain update their own ledgers according to the newly published transaction block, so as to ensure that their respective ledgers are in the latest and correct state.

[0078] According to an embodiment of the present invention, by judging the conflict situation between the transaction data in the transaction queue and the transaction data to be inserted, the conflicting transaction data can be separated and processed in time, avoiding the problem that data processing errors occur due to the existence of conflicting transaction data in the same transaction block summary. By setting up a queue to be processed, the transaction data that conflicts with other transaction data and has a transaction time later than other transaction data can be stored and managed, and the transaction data in the queue to be processed is preferentially processed subsequently, thus avoiding the problem that data processing errors occur due to the omission of transaction data, and further improving the accuracy of data processing.

[0079] According to an embodiment of the present invention, generating the transaction data to be inserted based on the power data includes: adding the acquisition time of the power data and the electronic signature of the power data acquisition device to the power data to obtain the transaction data to be inserted.

[0080] According to an embodiment of the present invention, on the basis of power data, adding the acquisition time of the power data and the electronic signature of the power data acquisition device used to acquire the power data can obtain the transaction data to be inserted, where the electronic signature of the power data acquisition device may include the device identifier of the power data acquisition device.

[0081] According to an embodiment of the present invention, in the subsequent processing process, the transaction data to be inserted can be verified for correctness and integrity, and it can be determined whether there is an accurate electronic signature in the power data, so as to determine whether there is a risk of the transaction data to be inserted being tampered with.

[0082] According to an embodiment of the present invention, by adding the acquisition time and the electronic signature of the power data acquisition device to the power data, reference parameters can be provided for the subsequent data verification process, that is, the correctness of the transaction data to be inserted is verified according to the electronic signature.

[0083] According to an embodiment of the present invention, the power data processing method based on blockchain further includes: when it is determined that there is no conflict between the transaction data to be inserted and the transaction data already existing in the transaction queue, determining the expected insertion position of the transaction data to be inserted in the transaction queue based on the transaction type of the transaction data to be inserted and the transaction types to which the multiple transaction data in the transaction queue belong; inserting the transaction data to be inserted into the expected insertion position.

[0084] According to an embodiment of the present invention, when it is determined that there is no conflict between the transaction data to be inserted and the transaction data already existing in the transaction queue, the expected insertion position can be determined, and the transaction data to be inserted is inserted into the expected insertion position of the transaction queue. Since the multiple transaction data in the transaction queue are determined according to the sorting priority between the transaction objects and transaction types corresponding to the multiple transaction data, the expected insertion position can be determined according to the transaction object and transaction type of the transaction data to be inserted and the transaction objects and transaction types of the multiple transaction data in the transaction queue, so as to determine the expected insertion position of the transaction data to be inserted in the transaction queue.

[0085] According to an embodiment of the present invention, it is also possible to sort the multiple transaction data with the same sorting priority in the transaction queue according to the transaction times of the multiple transaction data, so that the transaction data with an earlier transaction time is arranged before the transaction data with a later transaction time, thereby ensuring that the multiple transaction data in the transaction queue are arranged according to the actual transaction occurrence time.

[0086] According to an embodiment of the present invention, the sorting priority can be determined according to the transaction type, and the expected insertion position of the transaction data to be inserted is further determined, and the transaction data to be inserted is inserted into the expected insertion position, so that the multiple transaction data in the transaction queue are maintained in descending order of the sorting priority, thereby ensuring the correctness of the subsequent data processing process.

[0087] According to an embodiment of the present invention, a dependency relationship may exist between the multiple transaction data, and two transaction data with a dependency relationship need to be executed in a fixed order.

[0088] For example, if transaction data 1 indicates that user A used 100 kWh of electricity on a certain day, transaction data 2 indicates the electricity charge corresponding to the electricity used by user A on the same day. Since the unit price per kWh of electricity is known or fixed, the electricity charge needs to be determined based on the electricity consumption, that is, transaction data 2 needs to be executed after transaction data 1 is processed.

[0089] Therefore, when processing transaction data with dependencies, it is also necessary to put the dependent transaction data on the chain first, and then process the transaction data that depends on other transaction data. When it is determined that there are dependencies between multiple transaction data, it can be determined that there are conflicts between multiple transaction data. In the case that multiple transaction data are in conflict due to dependencies, multiple transaction data need to be processed according to the logical relationship of mutual dependence, and the data at the front of the dependency chain should be processed first.

[0090] According to an embodiment of the present invention, a dependency graph can be constructed for multiple transaction data in a transaction queue to determine the dependency relationship between the multiple transaction data. As shown in formula (4):

[0091] (4)

[0092] Among them, G is a dependency graph, which is a directed graph, V is the vertex set of the dependency graph, and E is the edge set of the dependency graph. The vertices in the vertex set represent transaction data, and the edges in the edge set represent the dependency relationship between the transaction data corresponding to the two vertices connected to it. The directed edge points from the dependent data to the dependent data.

[0093] Figure 3 A dependency graph constructed by a blockchain-based power data processing method according to an embodiment of the present invention is shown.

[0094] like Figure 3 As shown, a dependency graph G is constructed for the transaction queue, and the dependency graph G includes five vertices V1, V2, V3, V4 and V5, and three directed edges E1, E2 and E3, where E1 points from V2 to V3, E2 points from V3 to V4, and E3 points from V1 to V3.

[0095] According to the dependency graph G, two dependency chains can be determined, namely V2→V3→V4 and V1→V3→V4. That is, the prerequisite for V3 to execute is that V1 and V2 have completed execution, and the prerequisite for V4 to execute is that V3 has completed execution. There is no directed edge between V1 and V2, and there is no directed edge between V5 and any other node.

[0096] Therefore, it can be determined that there is a dependency relationship among V2, V3, and V4, and there is a dependency relationship among V1, V3, and V4. Therefore, V3 and V4 in this transaction queue need to be executed after V2 is executed, and also need to be executed after V1 is executed. The execution of V1, V2, and V5 is not restricted by the dependency relationship. Therefore, V3 and V4 need to be moved to the pending queue and processed after V1 and V2 are processed and chained.

[0097] According to an embodiment of the present invention, based on the transaction type of the transaction data to be inserted and the transaction types of multiple transaction data in the transaction queue, determining the expected insertion position of the transaction data to be inserted in the transaction queue includes: traversing multiple transaction data in the transaction queue to determine the sorting priorities of the multiple transaction data; in the case where at least one transaction data in the multiple transaction data is determined to be of the same sorting priority as the transaction data to be inserted, determining the expected insertion position according to the transaction times of the at least one transaction data of the same sorting priority and the transaction data to be inserted.

[0098] According to an embodiment of the present invention, by traversing multiple transaction data in the transaction queue and parsing the multiple transaction data respectively, the transaction type of each transaction data can be determined.

[0099] According to an embodiment of the present invention, in the case where there is no transaction data in the multiple transaction data that is of the same sorting priority as the transaction data to be inserted, the transaction data to be inserted can be directly inserted between the transaction data with a higher sorting priority and the transaction data with a lower sorting priority than it according to the sorting priority of the transaction data to be inserted, so that the inserted transaction queue is still sorted in descending order according to the sorting priorities of the transaction data. Therefore, the expected insertion position is between the transaction data with a higher sorting priority and the transaction data with a lower sorting priority than it.

[0100] According to an embodiment of the present invention, in multiple transaction data, when there is transaction data with the same sorting priority as the to-be-inserted transaction data, other transaction data with the same sorting priority is parsed to determine their respective transaction times, and the other transaction data and the to-be-inserted transaction data are sorted according to the transaction times of the other transaction data and the to-be-inserted transaction data, so that the sorted transaction data is arranged in the order of transaction times. Therefore, according to the position of the to-be-inserted transaction data in the sorted transaction data and the positions of the other transaction data in the transaction queue, the expected insertion position can be determined.

[0101] According to an embodiment of the present invention, according to the sorting priority, the transaction data with the same sorting priority as the to-be-inserted transaction data is determined, and the to-be-inserted transaction data is inserted according to the respective transaction times of the multiple transaction data, so that the data in the transaction queue is sorted in the order of transaction times, reducing the situation that the correctness of the events that occur later is affected because the transaction data corresponding to the events that occur earlier has not been chained, and improving the accuracy of data processing.

[0102] According to an embodiment of the present invention, after encapsulating the multiple transaction data included in the transaction queue to obtain a transaction block through operation S250, the power data processing method based on the blockchain further includes: determining the respective transaction objects of the multiple transaction data in the to-be-processed queue; for the transaction object of each transaction data, determining the to-be-arranged transaction data from at least one transaction data based on the transaction times of at least one transaction data of the transaction object; arranging the multiple to-be-arranged transaction data according to the sorting priority to obtain a new transaction queue, where the sorting priority is determined based on the transaction type.

[0103] According to an embodiment of the present invention, since the transaction data in the to-be-processed queue has been waiting to be processed for a period of time, generally, the transaction times of the transaction data in the to-be-processed queue are earlier than the transaction times of the newly generated to-be-inserted transaction data. After encapsulating the multiple transaction data included in the transaction queue to obtain a transaction block, the transaction data in the waiting state can be selected from the to-be-processed queue to obtain a new transaction queue, and the above process can be repeated to compare the newly generated to-be-inserted transaction data with the new transaction data and perform the encapsulation of the transaction block.

[0104] According to an embodiment of the present invention, since the to-be-processed queue may include multiple transaction data of the same transaction object, and there are conflicts between multiple transaction data of the same transaction type of the same transaction object. Therefore, at least one non-conflicting transaction data can be selected from the multiple transaction data of the same transaction object in the to-be-processed queue, and a new transaction queue can be obtained according to at least one non-conflicting transaction data of each of the multiple transaction objects.

[0105] According to an embodiment of the present invention, the to-be-arranged transaction data for forming a new transaction queue can also be determined according to the transaction time of the transaction data. In the case where there are multiple transaction data for a transaction object, one transaction data with the earliest transaction time can be selected as the to-be-arranged transaction data based on the respective transaction times of the multiple transaction data. The to-be-arranged transaction data of each of the multiple transaction objects can form a new transaction queue. Therefore, by only determining the sorting priority among multiple transaction types, the multiple to-be-arranged transaction data can be sorted to obtain a new transaction queue.

[0106] According to an embodiment of the present invention, after encapsulating multiple transaction data in the transaction queue, the to-be-arranged transaction data is determined from the to-be-processed queue and arranged to obtain a new transaction queue. Therefore, the transaction data in the new transaction queue is preferentially selected from the transaction data that has been postponed for processing, which can reduce the waiting time of the transaction data in the to-be-processed queue, improve the processing efficiency of the data in the entire system, and reduce the average waiting time.

[0107] According to an embodiment of the present invention, the encapsulation conditions include at least one of the following: the capacity of the transaction queue is greater than or equal to a preset capacity threshold; the duration between the current time and the generation time of the previous transaction block reaches a preset time threshold.

[0108] According to an embodiment of the present invention, the preset capacity threshold can be the same as the preset capacity of the transaction block, and the preset capacity represents the maximum capacity that each transaction block can accommodate.

[0109] If there is no conflict between the to-be-inserted transaction data and the transaction data already existing in the transaction queue, after inserting the to-be-inserted transaction data into the expected insertion position of the value transaction queue and the capacity of the multiple transaction data in the transaction queue exceeds the preset capacity threshold, it can be determined that the encapsulation condition is satisfied, and the multiple transaction data included in the transaction queue is encapsulated to obtain a transaction block.

[0110] According to an embodiment of the present invention, in the case where all the to-be-inserted transaction data obtained within a period of time has a conflict with the transaction data already existing in the transaction queue, regardless of the relationship between the transaction times of the to-be-inserted transaction data and the transaction data, the quantity of the transaction data in the transaction queue and the total capacity of the transaction queue will not change. In this case, a large amount of transaction data in the transaction queue and the to-be-processed queue will be in a waiting state and cannot be encapsulated and uploaded to the chain.

[0111] Therefore, a preset time threshold can be set, starting to count time after the generation of the previous transaction block. In the case where it is determined that the duration between the current time and the generation time of the previous transaction block reaches the preset time threshold, the multiple transaction data included in the current transaction queue is encapsulated to obtain a transaction block.

[0112] Since the power system involves a huge number of power equipment and power data, the generation frequency of the transaction data to be inserted is very high. A relatively small preset time threshold can be set to increase the generation frequency of transaction blocks, improve the processing frequency of the transaction data to be inserted, avoid data blockage and untimely data updates, and improve the data processing efficiency.

[0113] According to an embodiment of the present invention, when it is determined that the capacity of the transaction queue is greater than or equal to the preset capacity threshold, encapsulating multiple transaction data in the transaction queue can improve the data encapsulation frequency, thereby improving the data processing efficiency. When it is determined that the duration between the current moment and the generation moment of the previous transaction block reaches the preset time threshold, encapsulating multiple transaction data in the transaction queue can ensure the lower limit of the data encapsulation frequency, thereby avoiding congestion of transaction data.

[0114] According to an embodiment of the present invention, encapsulating multiple transaction data included in the transaction queue to obtain a transaction block includes: selecting at least one target transaction data from the transaction queue according to the capacity required by each of the multiple transaction data included in the transaction queue and the preset capacity; encapsulating the at least one target transaction data to obtain a transaction block.

[0115] According to an embodiment of the present invention, since the capacity of multiple transaction data in the transaction queue may be greater than the preset capacity threshold, in this case, the transaction block cannot accommodate the capacity of multiple transaction data in the transaction queue. Therefore, multiple transaction data in the transaction queue cannot be encapsulated simultaneously to obtain a transaction block. Part of the transaction data can be selected from the transaction queue as target transaction data so that the capacity of at least one target transaction data is less than or equal to the preset capacity threshold, and then the at least one target transaction data is encapsulated to obtain a transaction block.

[0116] According to an embodiment of the present invention, selecting at least one target transaction data from the transaction queue according to the capacity required by each of the multiple transaction data included in the transaction queue and the preset capacity includes: when the sum of the capacities required by each of the multiple transaction data is less than or equal to the preset capacity, all the multiple transaction data are used as target transaction data; when the sum of the capacities required by each of the multiple transaction data is greater than the preset capacity, screening the multiple transaction data according to the order of the multiple transaction data in the transaction queue to obtain at least one target transaction data whose occupied capacity is less than the preset capacity.

[0117] According to an embodiment of the present invention, when the sum of the capacities required by multiple transaction data in a transaction queue does not reach a preset capacity threshold, and the time duration between the current moment and the generation moment of the previous transaction block reaches a preset time threshold, an encapsulation condition is triggered, but the sum of the capacities required by the multiple transaction data in the transaction queue is less than or equal to the preset capacity. In this case, it means that the transaction block can accommodate the multiple transaction data in the transaction queue. Therefore, the multiple transaction data can be used as target transaction data and encapsulated simultaneously to obtain a transaction block.

[0118] According to an embodiment of the present invention, when the sum of the capacities required by multiple transaction data is greater than the preset capacity, it is necessary to screen the multiple transaction data to determine some transaction data as target transaction data, so that the sum of the capacities required by at least one target transaction data is less than the preset capacity.

[0119] According to an embodiment of the present invention, when the sum of the capacities required by transaction data does not reach the preset capacity, directly determining multiple transaction data as target transaction data can reduce the time cost of the comparison process and the occupancy of computing power, and improve the data processing efficiency and resource utilization rate. When the sum of the capacities required by transaction data has reached the preset capacity, screening the multiple transaction data can obtain target transaction data with a sum of occupied capacities less than the preset capacity, thereby ensuring that the encapsulation of the transaction block can be completed correctly and smoothly.

[0120] According to an embodiment of the present invention, screening multiple transaction data in the order of the multiple transaction data in the transaction queue to obtain at least one target transaction data with a capacity less than the preset capacity includes: repeatedly performing the following operations until the screening of the last transaction data among the multiple transaction data is completed: determining the remaining capacity based on the capacity required by the at least one target transaction data that has been screened and the preset capacity; when the capacity occupied by the transaction data to be screened is less than the remaining capacity, using the transaction data to be screened as target transaction data; when the capacity occupied by the transaction data to be screened is greater than the remaining capacity, obtaining the next transaction data in the transaction queue after the transaction data to be screened as the transaction data to be screened.

[0121] According to an embodiment of the present invention, sequentially using the transaction data as the transaction data to be screened in the order of the multiple transaction data in the transaction queue can ensure that the sorting priority of the transaction data to be screened is higher than the priority of the transaction data that has not been screened yet, thereby ensuring that the transaction data with a higher sorting priority is preferentially processed and encapsulated when the capacity permits.

[0122] According to an embodiment of the present invention, for each transaction data to be screened, the remaining capacity is determined by using the difference between the preset capacity and the capacity required by at least one screened target transaction data. Wherein, in the case that there is no screened target transaction data currently, the capacity required by at least one screened target transaction data is 0, so the remaining capacity is the preset capacity.

[0123] According to an embodiment of the present invention, the preset capacity is compared with the capacity occupied by the transaction data to be screened. In the case that the capacity occupied by the transaction data to be screened is less than the remaining capacity, it means that the remaining capacity can accommodate the transaction data to be screened. Therefore, the transaction data to be screened is taken as the target transaction data.

[0124] According to an embodiment of the present invention, in the case that the capacity occupied by the transaction data to be screened is greater than the remaining capacity, it means that the remaining capacity cannot accommodate the transaction data to be screened. Therefore, the transaction data to be screened cannot be used as the target transaction data. In the case that the last transaction data among multiple transaction data has not been screened yet, the next transaction data after the transaction data to be screened is obtained from the transaction queue and used as the transaction data to be screened, and the above operations are repeated for judgment.

[0125] According to an embodiment of the present invention, screening multiple transaction data in sequence can ensure that transaction data with a high sorting priority is more likely to be processed preferentially, so that more important data or instructions can be uploaded to the blockchain more timely and reach a consensus, ensuring the integrity and accuracy of the data. By comparing the remaining capacity with the capacity required by each transaction data to be screened, it can be ensured that the total capacity required by multiple target transaction data does not exceed the preset capacity, thus ensuring the smooth encapsulation of the transaction block.

[0126] Figure 4 The screening process of transaction data by the blockchain-based power data processing method according to an embodiment of the present invention is shown.

[0127] As Figure 4 shown, after conflict detection, it is determined that the transaction queue includes five transaction data V1, V2, V5, V6, and V7. Among them, both V1 and V5 are 50KB, V2 is 100KB, V6 is 1000KB, and V7 is 400KB. The preset capacity is 800KB.

[0128] In the order of the transaction queue, V1 is determined as the transaction data to be screened. Since there is no screened target transaction data in the current state, the remaining capacity is the same as the preset capacity, which is 800KB. 800KB > 50KB, indicating that the remaining capacity can accommodate the transaction data V1, and it is determined as the screened target transaction data.

[0129] Continue to determine V2 as the transaction data to be screened. Since in the current state, the target transaction data includes V1, the remaining capacity is 800 - 50 = 750 KB. 750 KB > 100 KB, indicating that the remaining capacity can accommodate the transaction data V2, and it is determined as the screened target transaction data. Similarly, it can be determined that V5 is the screened target transaction data.

[0130] Figure 4 Indicates the state where V1, V2, and V5 have been determined as target transaction data. In this state, the remaining capacity is 800 - 50 - 100 - 50 = 600 KB.

[0131] Continue to determine V6 as the transaction data to be screened. Since in the current state, the remaining capacity 600 KB < 1000 KB, indicating that the remaining capacity cannot accommodate the transaction data V6. Therefore, V6 is not the target transaction data. From the transaction queue, take the transaction data V7 after V6 as the transaction data to be screened and make the same judgment. The remaining capacity 600 KB > 400 KB, indicating that the remaining capacity can accommodate the transaction data V7, and it is determined as the screened target transaction data.

[0132] At this time, the screening of multiple transaction data in the transaction queue has been completed. Therefore, it can be determined that V1, V2, V5, and V7 can satisfy that the sum of the occupied storage capacities is less than the preset capacity, and V1, V2, V5, and V7 can be encapsulated to obtain a transaction block.

[0133] According to an embodiment of the present invention, the power data processing method based on the blockchain further includes: adjusting the sorting priorities of the multiple transaction data included in the transaction queue according to the respective waiting durations of the multiple transaction data included in the transaction queue to obtain multiple adjusted sorting priorities, where the waiting duration is the time difference between the moment when the transaction data is collected and the current moment; re - arranging the multiple transaction data in the transaction queue according to the respective adjusted sorting priorities of the multiple transaction data included in the transaction queue.

[0134] According to an embodiment of the present invention, during the data processing, if the sorting priority of a certain transaction data is relatively low, while the sorting priorities of other transaction data in the transaction queue and the to - be - inserted transaction data generated subsequently are all higher than that of this transaction data. Then the position of this transaction data in the transaction queue will continuously be at the end of the queue.

[0135] According to the logic of selecting target transaction data, the transaction data with a high sorting priority will be preferentially screened during the process of selecting target transactions. In the case where the capacity required by the transaction data with a high sorting priority is relatively large, there will be a situation where the remaining capacity is not enough to accommodate the transaction data with a low sorting priority.

[0136] In the above case, the transaction data will continue to be in a waiting state and cannot be packaged and uploaded to the chain. Therefore, other transaction blocks in the blockchain cannot synchronize the data changes corresponding to the transaction data, making it difficult to ensure the accuracy of the data in the blockchain.

[0137] According to an embodiment of the present invention, the sorting priority of each transaction data can be adjusted according to the waiting time of each transaction data, that is, the sorting priority of the transaction data with a long waiting time can be increased. Therefore, after a long waiting time, the sorting priority of the transaction data with a low sorting priority can be increased, and after re-sorting the multiple transaction data in the transaction queue, the transaction data will be at the front position in the transaction queue. Therefore, in the process of transaction data screening, the transaction data will be more easily identified as the target transaction data, and the subsequent packaging and chaining can be completed.

[0138] According to an embodiment of the present invention, the sorting priority of transaction data is adjusted according to the waiting time of the transaction data, so that the priority of transaction data with a longer waiting time can be improved. Therefore, when there are multiple transaction data with the same initial sorting priority, the data with a longer waiting time can be processed preferentially, thereby reducing the average waiting time of the transaction data, improving the efficiency of data processing and improving the accuracy of the data in the blockchain.

[0139] According to the embodiments of the present invention, a comprehensive performance monitoring mechanism can be built into the blockchain system to monitor resource utilization, response time, etc. of each data processing process, and monitor the overall throughput of the blockchain. If the performance monitoring mechanism finds that there is an abnormality in the blockchain, a reminder can be issued to the operation and maintenance personnel so that the operation and maintenance personnel can promptly investigate and resolve the fault or abnormality, thereby further ensuring the stable operation of the blockchain and the security and correctness of the data.

[0140] Based on the above-mentioned blockchain-based power data processing method, the present invention also provides a blockchain-based power data processing device. Figure 5 The device is described in detail.

[0141] Figure 5 A structural block diagram of a blockchain-based power data processing device according to an embodiment of the present invention is shown.

[0142] like Figure 5 As shown, the blockchain-based power data processing device 500 of this embodiment includes a data generation module 510, a time determination module 520, a data movement module 530, a data insertion module 540, a data encapsulation module 550 and a data publishing module 560.

[0143] The data generation module 510 is configured to generate transaction data to be inserted based on power data in response to the power data collected by the power data collection device from the power equipment. In one embodiment, the data generation module 510 may be configured to perform the operation S210 described above, which will not be elaborated herein.

[0144] The time determination module 520 is configured to determine the transaction times of the transaction data to be inserted and the existing transaction data in the transaction queue when it is determined that there is a conflict between the transaction data to be inserted and the existing transaction data in the transaction queue, where a conflict is determined to exist between the transaction data to be inserted and the transaction data when their transaction objects are the same and their transaction types are the same. In one embodiment, the time determination module 520 may be configured to perform the operation S220 described above, which will not be elaborated herein.

[0145] The data movement module 530 is configured to place the transaction data to be inserted at the position of the transaction data in the transaction queue when the transaction time of the transaction data to be inserted is earlier than that of the transaction data. In one embodiment, the data movement module 530 may be configured to perform the operation S230 described above, which will not be elaborated herein.

[0146] The data insertion module 540 is configured to place the transaction data in the to-be-processed queue. In one embodiment, the data insertion module 540 may be configured to perform the operation S240 described above, which will not be elaborated herein.

[0147] The data encapsulation module 550 is configured to encapsulate multiple transaction data included in the transaction queue to obtain a transaction block when it is determined that the transaction queue meets the encapsulation condition. In one embodiment, the data encapsulation module 550 may be configured to perform the operation S250 described above, which will not be elaborated herein.

[0148] The data publishing module 560 is configured to publish the transaction block to the blockchain. In one embodiment, the data publishing module 560 may be configured to perform the operation S260 described above, which will not be elaborated herein.

[0149] According to an embodiment of the present invention, the power data processing device 500 based on the blockchain further includes an object determination module, a data determination module, and a data arrangement module.

[0150] The object determination module is configured to determine the transaction objects of multiple transaction data in the to-be-processed queue.

[0151] The data determination module is configured to determine the transaction data to be arranged from at least one transaction data based on the transaction times of at least one transaction data of each transaction object for each transaction object.

[0152] A data arrangement module, configured to arrange multiple to-be-arranged transaction data according to a sorting priority to obtain a new transaction queue, where the sorting priority is determined based on the transaction type.

[0153] According to an embodiment of the present invention, the blockchain-based power data processing device 500 further includes a location determination module and a data placement module.

[0154] The location determination module is configured to determine an expected insertion position of the to-be-inserted transaction data in the transaction queue based on the transaction type of the to-be-inserted transaction data and the transaction types of multiple transaction data in the transaction queue when it is determined that there is no conflict between the to-be-inserted transaction data and the existing transaction data in the transaction queue.

[0155] The data placement module is configured to insert the to-be-inserted transaction data into the expected insertion position.

[0156] According to an embodiment of the present invention, the location determination module includes a priority determination sub-module and a location determination sub-module.

[0157] The priority determination sub-module is configured to traverse multiple transaction data in the transaction queue to determine the sorting priorities of the multiple transaction data.

[0158] The location determination sub-module is configured to determine the expected insertion position according to the transaction times of at least one transaction data with the same sorting priority as the to-be-inserted transaction data and the to-be-inserted transaction data when it is determined that there is at least one transaction data with the same sorting priority as the to-be-inserted transaction data among the multiple transaction data.

[0159] According to an embodiment of the present invention, the data encapsulation module 550 includes a data selection sub-module and a data encapsulation sub-module.

[0160] The data selection sub-module is configured to select at least one target transaction data from the transaction queue according to the capacities required by multiple transaction data included in the transaction queue and a preset capacity.

[0161] The data encapsulation sub-module is configured to encapsulate at least one target transaction data to obtain a transaction block.

[0162] According to an embodiment of the present invention, the data selection sub-module includes a first data selection unit and a second data selection unit.

[0163] The first data selection unit is configured to use multiple transaction data as target transaction data when the sum of the capacities required by the multiple transaction data is less than or equal to the preset capacity.

[0164] A second data selection unit, configured to, when the sum of the capacities required by multiple transaction data is greater than a preset capacity, screen the multiple transaction data in the order of the multiple transaction data in the transaction queue, so as to obtain at least one target transaction data whose occupied capacity is less than the preset capacity.

[0165] According to an embodiment of the present invention, the second data selection unit includes a capacity determination subunit, a first data determination subunit, and a second data determination subunit.

[0166] The capacity determination subunit is configured to determine the remaining capacity based on the capacity required by at least one target transaction data that has been screened and the preset capacity.

[0167] The first data determination subunit is configured to use the transaction data to be screened as the target transaction data when the capacity occupied by the transaction data to be screened is less than the remaining capacity.

[0168] The second data determination subunit is configured to, when the capacity occupied by the transaction data to be screened is greater than the remaining capacity, obtain the next transaction data in the transaction queue after the transaction data to be screened as the transaction data to be screened.

[0169] According to an embodiment of the present invention, the blockchain-based power data processing device 500 further includes a priority adjustment module and a data rearrangement module.

[0170] The priority adjustment module is configured to adjust the sorting priorities of the multiple transaction data included in the transaction queue according to the respective waiting durations of the multiple transaction data included in the transaction queue, so as to obtain multiple adjusted sorting priorities, where the waiting duration is the time difference between the acquisition time of the transaction data and the current time.

[0171] The data rearrangement module is configured to rearrange the multiple transaction data in the transaction queue according to the respective adjusted sorting priorities of the multiple transaction data included in the transaction queue.

[0172] According to an embodiment of the present invention, the data generation module 510 includes a data generation sub-module.

[0173] The data generation sub-module is configured to add the acquisition time of the power data and the electronic signature of the power data acquisition device to the power data to obtain the transaction data to be inserted.

[0174] According to an embodiment of the present invention, any multiple modules among the data generation module 510, the time determination module 520, the data movement module 530, the data insertion module 540, the data encapsulation module 550, and the data publishing module 560 may be combined and implemented in one module, or any one of them may be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules may be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present invention, at least one of the data generation module 510, the time determination module 520, the data movement module 530, the data insertion module 540, the data encapsulation module 550, and the data publishing module 560 may be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on chip, a system on substrate, a system on package, an application specific integrated circuit (ASIC), or any other reasonable way of integrating or packaging circuits, etc., in hardware or firmware, or implemented in any one of the three implementation manners of software, hardware, and firmware, or in any suitable combination of several of them. Alternatively, at least one of the data generation module 510, the time determination module 520, the data movement module 530, the data insertion module 540, the data encapsulation module 550, and the data publishing module 560 may be at least partially implemented as a computer program module, and when the computer program module runs, it can execute corresponding functions.

[0175] Figure 6 The block diagram of an electronic device suitable for implementing the blockchain-based power data processing method according to an embodiment of the present invention is shown.

[0176] As Figure 6 shown, the electronic device 600 according to an embodiment of the present invention includes a processor 601, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 602 or the program loaded from the storage section 608 into the random access memory (RAM) 603. The processor 601 may include, for example, a general microprocessor (such as a CPU), an instruction set processor, and / or a related chipset, and / or a dedicated microprocessor (such as an application specific integrated circuit (ASIC)), etc. The processor 601 may also include on-board memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.

[0177] In the RAM 603, various programs and data required for the operation of the electronic device 600 are stored. The processor 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. The processor 601 performs various operations of the method flow according to the embodiments of the present invention by executing the programs in the ROM 602 and / or the RAM 603. It should be noted that the programs may also be stored in one or more memories other than the ROM 602 and the RAM 603. The processor 601 may also perform various operations of the method flow according to the embodiments of the present invention by executing the programs stored in the one or more memories.

[0178] According to an embodiment of the present invention, the electronic device 600 may further include an input / output (I / O) interface 605, and the input / output (I / O) interface 605 is also connected to the bus 604. The electronic device 600 may further include one or more of the following components connected to the input / output (I / O) interface 605: an input part 606 including a keyboard, a mouse, etc.; an output part 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc. and a speaker, etc.; a storage part 608 including a hard disk, etc.; and a communication part 609 including a network interface card such as a LAN card, a modem, etc. The communication part 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the input / output (I / O) interface 605 as required. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is mounted on the drive 610 as required so that a computer program read from it can be installed into the storage part 608 as required.

[0179] The present invention also provides a computer-readable storage medium, which may be included in the device / device / system described in the above embodiments; or may exist alone without being assembled into the device / device / system. The above computer-readable storage medium carries one or more programs, and when the one or more programs are executed, the method according to the embodiments of the present invention is implemented.

[0180] According to an embodiment of the present invention, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, it may include but is not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In the present invention, the computer-readable storage medium may be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, apparatus, or device. For example, according to an embodiment of the present invention, the computer-readable storage medium may include the above-described ROM 602 and / or RAM 603 and / or one or more memories other than ROM 602 and RAM 603.

[0181] An embodiment of the present invention also includes a computer program product, which includes a computer program, and this computer program contains program code for executing the method shown in the flowchart. When the computer program product runs in a computer system, this program code is used to enable the computer system to implement the method provided by the embodiment of the present invention.

[0182] When this computer program is executed by the processor 601, it executes the above functions defined in the system / apparatus of the embodiment of the present invention. According to an embodiment of the present invention, the above-described systems, apparatuses, modules, units, etc. can be implemented by computer program modules.

[0183] In one embodiment, this computer program can rely on tangible storage media such as optical storage devices and magnetic storage devices. In another embodiment, this computer program can also be transmitted and distributed in the form of a signal on a network medium, and is downloaded and installed through the communication part 609, and / or installed from the removable medium 611. The program code contained in this computer program can be transmitted by any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0184] In such an embodiment, this computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When this computer program is executed by the processor 601, it executes the above functions defined in the system of the embodiment of the present invention. According to an embodiment of the present invention, the above-described systems, devices, apparatuses, modules, units, etc. can be implemented by computer program modules.

[0185] In accordance with embodiments of the present invention, program code for executing the computer programs provided by the embodiments of the present invention can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, such as Java, C++, Python, the "C" language, or similar programming languages. The program code can be executed entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device can be connected to the user's computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., by using an Internet service provider to connect through the Internet).

[0186] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of code, and the above-mentioned module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram or flowchart, and the combination of blocks in the block diagram or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.

[0187] Those skilled in the art can understand that the features described in the various embodiments of the present invention can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in the present invention. In particular, without departing from the spirit and teachings of the present invention, the features described in the various embodiments of the present invention can be combined and / or combined in various ways. All such combinations and / or combinations fall within the scope of the present invention.

[0188] The above describes the embodiments of the present invention. However, these embodiments are only for illustrative purposes and not for limiting the scope of the present invention. Although the embodiments are described separately above, this does not mean that the measures in each embodiment cannot be used advantageously in combination. Without departing from the scope of the present invention, those skilled in the art can make various substitutions and modifications, and all such substitutions and modifications should fall within the scope of the present invention.

Claims

1. A blockchain-based power data processing method, characterized in that The method includes: In response to the power data collected by the power data collection device from the power equipment, generating transaction data to be inserted based on the power data; When it is determined that there is a conflict between the transaction data to be inserted and the existing transaction data in the transaction queue, determining the transaction times of the transaction data to be inserted and the transaction data respectively, where, when the transaction objects and transaction types of the transaction data to be inserted and the transaction data are the same, it is determined that there is a conflict between the transaction data to be inserted and the transaction data; When the transaction time of the transaction data to be inserted is earlier than the transaction time of the transaction data, placing the transaction data to be inserted at the position where the transaction data is located in the transaction queue; Placing the transaction data in the queue to be processed; When it is determined that the transaction queue meets the encapsulation condition, encapsulating the multiple transaction data included in the transaction queue to obtain a transaction block; and Publishing the transaction block to the blockchain.

2. The method according to claim 1, wherein After encapsulating the multiple transaction data included in the transaction queue to obtain a transaction block, the method further includes: Determining the transaction objects of the multiple transaction data in the queue to be processed; For the transaction object of each transaction data, determining the transaction data to be arranged from the at least one transaction data based on the transaction times of the at least one transaction data of the transaction object; and Arranging the multiple transaction data to be arranged according to the sorting priority to obtain a new transaction queue, where the sorting priority is determined based on the transaction type.

3. The method according to claim 1, characterized in that, The method further includes: When it is determined that there is no conflict between the transaction data to be inserted and the existing transaction data in the transaction queue, determining the expected insertion position of the transaction data to be inserted in the transaction queue based on the transaction type of the transaction data to be inserted and the transaction types to which the multiple transaction data in the transaction queue belong; and Inserting the transaction data to be inserted into the expected insertion position.

4. The method according to claim 3, wherein The determining the expected insertion position of the transaction data to be inserted in the transaction queue based on the transaction type of the transaction data to be inserted and the transaction types to which the multiple transaction data in the transaction queue belong includes: Traversing the multiple transaction data in the transaction queue to determine the sorting priorities of the multiple transaction data respectively; When it is determined that among the multiple transaction data, there is at least one transaction data having the same sorting priority as the transaction data to be inserted, determining the expected insertion position according to the transaction times of the at least one transaction data having the same sorting priority and the transaction data to be inserted.

5. The method according to claim 2, wherein The encapsulation condition includes at least one of the following: The capacity of the transaction queue is greater than or equal to a preset capacity threshold; The time duration between the current moment and the generation moment of the previous transaction block reaches a preset time threshold.

6. The method according to claim 5, wherein The encapsulating the multiple transaction data included in the transaction queue to obtain a transaction block includes: Select at least one target transaction data from the transaction queue according to the capacity required by each of the multiple transaction data included in the transaction queue and a preset capacity; and Encapsulate the at least one target transaction data to obtain the transaction block.

7. The method according to claim 6, characterized in that, The step of selecting at least one target transaction data from the transaction queue according to the capacity required by each of the multiple transaction data included in the transaction queue and a preset capacity includes: When the sum of the capacities required by each of the multiple transaction data is less than or equal to the preset capacity, all of the multiple transaction data are used as the target transaction data; and When the sum of the capacities required by each of the multiple transaction data is greater than the preset capacity, screen the multiple transaction data in the order of the multiple transaction data in the transaction queue to obtain the at least one target transaction data whose occupied capacity is less than the preset capacity.

8. The method according to claim 7, characterized in that, The step of screening the multiple transaction data in the order of the multiple transaction data in the transaction queue to obtain the at least one target transaction data whose occupied capacity is less than the preset capacity includes: Repeatedly execute the following operations until the screening of the last transaction data among the multiple transaction data is completed: Determine the remaining capacity based on the capacity required by at least one of the screened target transaction data and the preset capacity; When the capacity occupied by the transaction data to be screened is less than the remaining capacity, use the transaction data to be screened as the target transaction data; When the capacity occupied by the transaction data to be screened is greater than the remaining capacity, obtain the next transaction data in the transaction queue after the transaction data to be screened as the transaction data to be screened.

9. The method according to any one of claims 1 to 8, characterized in that, The method further includes: Adjust the sorting priorities of each of the multiple transaction data included in the transaction queue according to the waiting duration of each of the multiple transaction data included in the transaction queue, to obtain multiple adjusted sorting priorities, where the waiting duration is the time difference between the time when the transaction data is collected and the current time; and Rearrange the multiple transaction data in the transaction queue according to the adjusted sorting priorities of each of the multiple transaction data included in the transaction queue.

10. The method according to claim 1, wherein The step of generating the transaction data to be inserted based on the power data includes: Add the collection time of the power data and the electronic signature of the power data collection device to the power data to obtain the transaction data to be inserted.

Citation Information

Patent Citations

  • Power transaction method and device based on block chain, equipment and medium

    CN111489160A

  • Transaction processing method and device based on a block chain and electronic equipment

    CN113220745A

  • Data processing method and device based on block chain and readable storage medium

    CN116542668A

  • Data processing method, device and equipment based on block chain and readable storage medium

    CN116977067A

  • Block chain transaction processing method and device, electronic equipment and readable medium

    CN117149901A