Power data processing method and device based on blockchain
By judging conflicts and sorting in power data processing, the error problem caused by processing the same data multiple times is solved, and more efficient and accurate data processing is achieved.
Patent Information
- Application Number
- CN202510764688.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-10
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2045-06-10
AI Technical Summary
In power data processing, when multiple operations are simultaneously encapsulated into the same data block, the same basic values are processed multiple times, intermediate results are ignored, and the final synchronized data is incorrect.
By determining the conflicts between the transaction data to be inserted and the transaction queue, sorting and inserting the data are determined according to the transaction time and type, and setting the queue to be processed to ensure data accuracy and efficiency.
It improves the accuracy of power data processing, avoids data processing errors, reduces transaction data omissions, and improves the efficiency and accuracy of data processing.
Smart Images

Figure CN120278714B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of blockchain and data security, and in particular to a blockchain-based power data processing method and device. Background Art
[0002] Power data collection technology has been widely used in power systems in recent years. Its primary goal is to collect data from various power devices to enable functions such as power usage monitoring, real-time settlement, energy efficiency analysis, load forecasting, 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 of power data, multiple operations often occur on the same data. During normal processing logic, multiple operations are superimposed on the data and the final result is calculated.
[0004] However, in related technologies, when multiple operations on the same data are encapsulated simultaneously in a single power data block, these operations each process the same underlying value multiple times, while other operations and intermediate results are ignored. Consequently, when the power data block is uploaded to the blockchain, the last processed result is synchronized to other blocks as the final result, resulting in erroneous synchronized power data. Summary of the Invention
[0005] In view of the above problems, the present invention provides a blockchain-based power data processing method and device.
[0006] According to a first aspect of the present invention, a blockchain-based power data processing method is provided, comprising: 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; 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, determining the transaction times of the transaction data to be inserted and the transaction data, wherein, 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 of the transaction data in the transaction queue; placing the transaction data in a 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.
[0007] According to an embodiment of the present invention, after encapsulating the multiple transaction data included in the transaction queue to obtain a transaction block, the blockchain-based power data processing method also includes: determining the transaction objects of each of the multiple transaction data in the queue to be processed; for the transaction object of each transaction data, based on the transaction time of each of at least one transaction data of the transaction object, determining the transaction data to be arranged from at least one transaction data; arranging the multiple transaction data to be arranged according to the 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 blockchain-based power data processing method also 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, 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; and inserting the transaction data to be inserted into the expected insertion position.
[0009] 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, the expected insertion position of the transaction data to be inserted in the transaction queue is determined, including: traversing the multiple transaction data in the transaction queue to determine the sorting priority of each of the multiple transaction data; when it is determined that there is at least one transaction data with the same sorting priority as the transaction data to be inserted among the multiple transaction data, the expected insertion position is determined according to the at least one transaction data with the same sorting priority and the transaction time of each of the transaction data to be inserted.
[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 time between the current moment and the generation moment of the previous transaction block reaches a preset time threshold.
[0011] According to an embodiment of the present invention, multiple transaction data included in a transaction queue are encapsulated to obtain a transaction block, including: selecting at least one target transaction data from the transaction queue according to the capacity required to be occupied by each of the multiple transaction data included in the transaction queue and a preset capacity; and encapsulating the at least one target transaction data to obtain a transaction block.
[0012] According to an embodiment of the present invention, at least one target transaction data is selected from the transaction queue according to the capacity required to be occupied by each of the multiple transaction data included in the transaction queue and the preset capacity, including: when the sum of the capacity required to be occupied by each of the multiple transaction data is less than or equal to the preset capacity, the multiple transaction data are all used as target transaction data; when the sum of the capacity required to be occupied by each of the multiple transaction data is greater than the preset capacity, the multiple transaction data are screened 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.
[0013] According to an embodiment of the present invention, multiple transaction data are screened in order of multiple transaction data in a transaction queue to obtain at least one target transaction data whose occupied capacity is less than a preset capacity, including: repeatedly performing the following operations until the screening of the last transaction data of the multiple transaction data is completed: determining the remaining capacity based on the capacity required to be occupied by the at least one 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, using 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, obtaining the next transaction data in the transaction queue that is located after the transaction data to be screened as the transaction data to be screened.
[0014] According to an embodiment of the present invention, the blockchain-based power data processing method also includes: adjusting the sorting priority of each of the multiple transaction data included in the transaction queue according to the respective waiting time of the multiple transaction data included in the transaction queue, to obtain multiple adjusted sorting priorities, wherein the waiting time is the time difference between the moment when the transaction data is collected and the current moment; and rearranging the multiple transaction data in the transaction queue according to the respective adjusted sorting priority 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 for generating transaction data to be inserted based on the power data in response to the power data collected by the power data acquisition equipment from the power equipment; a time determination module for determining the transaction time of the transaction data to be inserted and the transaction data 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, wherein, 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; a data movement module for placing 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 the transaction time of the transaction data; a data insertion module for placing the transaction data in the queue to be processed; a data encapsulation module for encapsulating the multiple transaction data included in the transaction queue to obtain a transaction block when it is determined that the transaction queue meets the encapsulation conditions; and a data publishing module for publishing the transaction block to the blockchain.
[0017] A third aspect of the present invention provides an electronic device, comprising: one or more processors; a memory for storing one or more computer programs, wherein the one or more processors execute the 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 having a computer program or instructions stored thereon, which implements the steps of the above method when the computer program or instructions are executed by a processor.
[0019] The fifth aspect of the present invention further provides a computer program product, comprising a computer program or instructions, which implement the steps of the above method when executed by a processor.
[0020] According to embodiments of the present invention, by determining conflicts between transaction data in the transaction queue and pending transaction data, conflicting transaction data can be promptly and separately processed, avoiding data processing errors caused by aggregating conflicting transaction data within the same transaction block. By establishing a pending queue, transaction data that conflicts with other transaction data and is executed later than other transaction data can be stored and managed, and subsequent processing of transaction data in the pending queue is prioritized. This avoids data processing errors caused by omitted transaction data and further improves data processing accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The above contents and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings, in which:
[0022] Figure 1 An application scenario diagram of a blockchain-based power data processing method and device according to an embodiment of the present invention is shown.
[0023] Figure 2 A flowchart of a blockchain-based power data processing method according to an embodiment of the present invention is shown.
[0024] Figure 3 A dependency graph constructed according to a blockchain-based power data processing method according to an embodiment of the present invention is shown.
[0025] Figure 4 The present invention shows a process of screening transaction data using a blockchain-based power data processing method according to an embodiment of the present invention.
[0026] Figure 5 A structural block diagram of a blockchain-based power data processing device according to an embodiment of the present invention is shown.
[0027] Figure 6 A block diagram of an electronic device suitable for implementing a blockchain-based power data processing method according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[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 exemplary only and are not intended to limit the scope of the present invention. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of embodiments of the present invention. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concept of the present invention.
[0029] The terms used herein are only for describing specific embodiments and are not intended to limit the present invention. The terms "comprise", "include", etc. used herein indicate the presence of the 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] When expressions such as "at least one of A, B, and C, etc." are used, they should generally be interpreted in accordance with the meaning commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, 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 used for analysis, stored data, displayed data, etc.) are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, invention and application of the relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0033] In scenarios where personal information is used for automated decision-making, the methods, devices, and systems provided by embodiments of the present invention provide users with corresponding operational portals, allowing them to choose to agree or reject the automated decision-making results; if the user chooses to reject, the expert decision-making process will be entered. The term "automated decision-making" herein refers to the activity of automatically analyzing and evaluating an individual's behavioral habits, interests, or economic, health, or credit status through computer programs and making decisions. The term "expert decision-making" herein refers to the activity of decision-making by individuals who specialize in a particular field, possess specialized experience, knowledge, and skills, and have reached a certain level of professional expertise.
[0034] An embodiment of the present invention provides a blockchain-based power data processing method, comprising: 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; 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, determining the transaction times of the transaction data to be inserted and the transaction data, wherein, 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 of the transaction data in the transaction queue; placing the transaction data in a queue to be processed; when it is determined that the transaction queue meets the encapsulation condition, encapsulating multiple transaction data included in the transaction queue to obtain a transaction block; and publishing the transaction block to the blockchain.
[0035] Figure 1An application scenario diagram of a blockchain-based power data processing method and device according to an embodiment of the present invention is shown.
[0036] like Figure 1 As shown in Figure 1, this application scenario includes two phases: power data collection and transaction block packaging. In the power data collection phase, power data is collected from power equipment using power data collection equipment, and transaction data to be inserted is generated based on this power data. This transaction data to be inserted is uploaded to the blockchain computing node via a network device, where the operations of the transaction block packaging phase are executed.
[0037] During the transaction block encapsulation phase, transaction data is sorted according to criteria such as sorting priority and transaction time. The transaction data and the transaction data to be inserted are then checked for conflicts based on their respective transaction objects and transaction types. If no conflicts are identified, the transaction data to be inserted is inserted into the transaction queue based on parameters such as sorting priority and transaction time.
[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, the subsequent power data collection will be based on the data on the updated blockchain, thereby achieving global data management and data unification.
[0040] The following will be based on Figure 1 The scene described by Figures 2 to 4 The blockchain-based power data processing method according to an embodiment of the present invention is described in detail.
[0041] Figure 2 A flowchart of a blockchain-based power data processing method according to an embodiment of the present invention is shown.
[0042] like Figure 2 As shown, the blockchain-based power data processing method of this embodiment includes operations S210 to S260.
[0043] In operation S210 , in response to 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, power equipment can include smart meters, management equipment in power centers, and power generation equipment. Power data collection equipment is communicatively connected to the power equipment to collect power data generated by the equipment. After acquiring the power data, the power data collection equipment can 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 collection process, a hash algorithm can be used to control the data collection process to avoid the problem of repeated data collection. Specifically, the hash algorithm can be used to determine the hash value of the collected power data. If it is determined that the hash value does not conflict, that is, it is different from all historically collected power data, it can be determined that the currently collected power data is not a duplicate of previously collected power data. The power data can then be processed in the next step to obtain the transaction data to be inserted.
[0046] According to another embodiment of the present invention, a hash algorithm can also be used to process multiple power data collected within a clock cycle to obtain hash values of the multiple power data. By judging whether there are repeated hash values among the multiple hash values, it is determined whether there are duplications in the multiple power data collected within the clock cycle.
[0047] According to an embodiment of the present invention, by processing a plurality of power data collected within a clock cycle, a set S as shown in formula (1) can be obtained:
[0048] (1)
[0049] Among them, v i The i-th power data collected in this clock cycle, k i v i The hash value of , i = 1, ..., n. n is the number of power data collected in this clock cycle.
[0050] According to an embodiment of the present invention, power data may include a transaction object, a transaction type, and a transaction value corresponding to the transaction type. The transaction object may be determined based on the power equipment generating the power data, and the transaction type may include a dispatch instruction type, a dispatch response type, and a power usage type.
[0051] The transaction object includes a personal object and an administrator object. When the power device is a smart meter, the transaction object can be determined as a personal object. When the power device is a management device, the transaction object can be determined as an administrator object.
[0052] If the power equipment is a management device in a power center, power data may include dispatch instructions such as power outage and power restoration instructions for the management area. Therefore, the power data transaction type is a dispatch instruction type. If the power equipment is a smart meter, power data may include user power usage data, recharge data, and other data related to changes in power balances. Therefore, the power data transaction type is a power usage status type. It may also include power outage and power restoration responses for users executed in response to dispatch instructions. Therefore, the power data transaction type is a dispatch response type.
[0053] According to an embodiment of the present invention, power data may also include transaction amounts corresponding to the transaction type. For example, if the transaction type is a dispatch instruction type, the transaction amount may be power outage or power restoration. If the transaction type is a power usage type, the transaction amount may include the user's power consumption, the electricity fee corresponding to the user's power consumption, the user's top-up amount, etc.
[0054] According to an embodiment of the present invention, the power data may also include a transaction time of the power data, which indicates the time when the power usage event corresponding to the power data occurred. Since power collection equipment typically collects data periodically, the time at which the power collection equipment collects the power data 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, the transaction times of the transaction data to be inserted and the transaction data are determined.
[0056] According to an embodiment of the present invention, it is possible to determine the data source of the power data to be inserted into the transaction data and the data source of the power data used to generate the transaction data, and to determine whether the transaction objects of the two are the same based on whether the power equipment corresponding to the data sources of the two are the same power equipment.
[0057] According to an embodiment of the present invention, if the transaction data to be inserted and the transaction data each have the same transaction object and the same transaction type, it can be determined that the transaction data to be inserted and the transaction data need to operate on data corresponding to the same transaction object and the same transaction type. Because both the transaction data to be inserted and the transaction data need to determine the underlying data corresponding to the transaction through the blockchain, the underlying data corresponding to the transaction data to be inserted and the transaction data are the same, but the operations are different. If both the transaction data to be inserted and the transaction data are allowed to operate on the underlying data, the operation result will be the result of the later operation on the transaction data or the transaction data to be inserted, rather than the result of the operation on the combined transaction data to be inserted and the transaction data.
[0058] For example, if the transaction data to be inserted indicates that a user recharged 100 kWh of electricity, and the transaction data indicates that the same user consumed 50 kWh of electricity, and based on the data currently on the blockchain, it is determined that the user's electricity balance is 300 kWh, then after the operations represented by the above-mentioned transaction data to be inserted and the transaction data, the user's remaining electricity should be 300+100-50=350 kWh.
[0059] However, since both the transaction data to be inserted and the transaction data are based on data already on the current blockchain, that is, for both the transaction data to be inserted and the transaction data, the user's electricity balance is 300 kWh. Assuming that the transaction data is placed before the transaction data to be inserted in the transaction block, the user's electricity balance calculated based on the transaction data is 300-50=250 kWh. However, since the transaction block has not yet completed the calculation and submission, the transaction data has not been synchronized to the blockchain. Therefore, when calculating the data to be traded, the basic data used is still 300 kWh. The user's electricity balance calculated based on the transaction data to be inserted is 300+100=400 kWh, and the 250 kWh calculated above is directly overwritten. After the calculation of the transaction block is completed, 400 kWh will be published as the user's electricity balance, resulting in data errors.
[0060] Therefore, when the transaction data to be inserted and the transaction data have the same transaction object and the same transaction type, it can be determined that there is a conflict between the transaction data to be inserted and the transaction data.
[0061] According to an embodiment of the present invention, a conflict detection function can be set based on the above-mentioned conflict detection logic to automatically detect conflicts between transaction data and transaction data to be inserted. The conflict detection function is shown in formula (2):
[0062] (2)
[0063] Among them, 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, writeSet(k) is the transaction object k in T new or T prev The corresponding transaction type in . Using formula (2), when the transaction type of the same transaction object k in the transaction data to be inserted is the same as that in the transaction data, a result of 1 is obtained, indicating that there is a conflict. 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 aggregated. After the transaction data to be inserted is generated, the transaction data to be inserted is directly matched with the aggregated transaction type set that belongs to the same transaction object as the transaction data to be inserted to determine whether the transaction data to be inserted conflicts with other transaction data. The aggregated transaction type set is shown in formula (3):
[0065] (3)
[0066] Among them, W merged is the aggregated transaction type set, W j is the transaction type corresponding to the jth transaction data of the same transaction object in the current transaction queue, j=1,…,m, m is the number of transaction data of the transaction object in the current transaction queue, Indicates calculation of W1 to W m The intersection of the transaction types corresponding to these m transaction data.
[0067] In operation S230 , if 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 location of the transaction data in the transaction queue.
[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 based on the sorting priority between the transaction objects and transaction types corresponding to the multiple transaction data. The transaction data corresponding to the transaction objects and transaction types with higher sorting priorities will be positioned higher in the transaction queue.
[0069] According to an embodiment of the present invention, after determining a conflict between the transaction data to be inserted and the transaction data, the order of occurrence of the corresponding transactions is determined based on the transaction times of the transaction data to be inserted and the transaction data, and the data corresponding to the earlier transaction is processed first. Therefore, if 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 transaction queue contains multiple transaction data that are pre-arranged, the transaction data to be inserted can be directly placed in the position of the transaction data, completing the data replacement.
[0070] In operation S240 , the transaction data is placed in a queue to be processed.
[0071] According to an embodiment of the present invention, after transaction data is replaced by transaction data to be inserted, in order to ensure the correctness of the data, the transaction data may be placed in a pending queue for processing, wherein the pending queue 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, a plurality of transaction data included in the transaction queue is encapsulated to obtain a transaction block.
[0073] According to an embodiment of the present invention, the encapsulation conditions may include the data size of the transaction queue, the waiting time of the transaction queue, etc. When it is determined that the transaction queue meets the encapsulation conditions, the block header is assembled based on the status of other transaction blocks in the current blockchain, and a transaction block can be generated based on the block header and multiple transaction data.
[0074] In operation S260, the transaction block is published to the blockchain.
[0075] According to an embodiment of the present invention, before publishing a transaction block to the blockchain, the transaction block is verified again to determine whether multiple transaction data in the transaction block all include the identification of the power data acquisition device. If there is transaction data in the transaction block that does not include the identification of the power data acquisition device, there is a risk of the data being forged, and therefore the transaction block and the transaction data need to be re-checked.
[0076] According to an embodiment of the present invention, when a transaction block is verified and it is determined that the transaction block has passed the verification, a consensus algorithm can be used to determine the recognition of the current transaction block by other transaction blocks on the blockchain. If the current transaction block obtains the recognition of more than a preset proportion of transaction blocks, the transaction block will be published to the blockchain.
[0077] According to an embodiment of the present invention, after a 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, thereby ensuring that their respective ledgers are in the latest and correct state.
[0078] According to embodiments of the present invention, by determining conflicts between transaction data in the transaction queue and pending transaction data, conflicting transaction data can be promptly and separately processed, avoiding data processing errors caused by aggregating conflicting transaction data within the same transaction block. By establishing a pending queue, transaction data that conflicts with other transaction data and is executed later than other transaction data can be stored and managed, and subsequent processing of transaction data in the pending queue is prioritized. This avoids data processing errors caused by omitted transaction data and further improves data processing accuracy.
[0079] 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.
[0080] According to an embodiment of the present invention, on the basis of the power data, the collection time of the power data and the electronic signature of the power data collection device used to collect the power data are added to obtain the transaction data to be inserted, wherein the electronic signature of the power data collection device may include the device identification of the power data collection device.
[0081] According to an embodiment of the present invention, in the subsequent processing process, the transaction data to be inserted can be checked for correctness and integrity to determine whether there is an accurate electronic signature in the power data, thereby determining whether there is a risk of tampering with the transaction data to be inserted.
[0082] According to an embodiment of the present invention, by adding the collection time and the electronic signature of the power data collection 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 can be verified based on the electronic signature.
[0083] According to an embodiment of the present invention, the blockchain-based power data processing method also 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, 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; and inserting the transaction data to be inserted into the expected insertion position.
[0084] According to an embodiment of the present invention, if it is determined that there is no conflict between the transaction data to be inserted and the transaction data already in the transaction queue, a desired insertion position can be determined, and the transaction data to be inserted can be inserted into the desired insertion position in the transaction queue. Because the multiple transaction data in the transaction queue are determined based on the sorting priorities of the transaction objects and transaction types corresponding to the multiple transaction data, the desired insertion position can be determined based on 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.
[0085] According to an embodiment of the present invention, multiple transaction data with the same sorting priority in the transaction queue can also be sorted according to the transaction times of the multiple transaction data, so that the transaction data with earlier transaction times are arranged before the transaction data with later transaction times, thereby ensuring that the multiple transaction data in the transaction queue are arranged according to the time when the actual transactions occurred.
[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 can be further determined, and the transaction data to be inserted can be inserted into the expected insertion position, so that the multiple transaction data in the transaction queue are maintained in descending order of 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 plurality of 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, the dependent transaction data must be uploaded to the blockchain first before any other dependent transaction data is processed. If dependencies are determined between multiple transaction data, conflicts can be identified. If conflicts arise due to dependencies, the data at the front of the dependency chain must be prioritized based on the logical relationship of interdependence.
[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 the 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 it connects. Directed edges point from the dependent data to the dependent data.
[0093] Figure 3 A dependency graph constructed according to 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. 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] Based on the dependency graph G, we can identify two dependency chains: V2 → V3 → V4 and V1 → V3 → V4. This means that the execution of V3 requires the completion of V1 and V2, and the execution of V4 requires the completion of V3. There is no directed edge between V1 and V2, and no directed edge between V5 and any other node.
[0096] Therefore, it can be determined that V2, V3, and V4 are dependent on each other, and V1, V3, and V4 are dependent on each other. Therefore, V3 and V4 in this transaction queue must be executed after V2, and also after V1. However, the execution of V1, V2, and V5 is not restricted by these dependencies. Therefore, V3 and V4 need to be moved to the pending queue and processed after V1 and V2 are processed and uploaded to the blockchain.
[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, the expected insertion position of the transaction data to be inserted in the transaction queue is determined, including: traversing the multiple transaction data in the transaction queue to determine the sorting priority of each of the multiple transaction data; when it is determined that there is at least one transaction data with the same sorting priority as the transaction data to be inserted among the multiple transaction data, the expected insertion position is determined according to the at least one transaction data with the same sorting priority and the transaction time of each of the transaction data to be inserted.
[0098] According to an embodiment of the present invention, by traversing a plurality of transaction data in a transaction queue and respectively parsing the plurality of transaction data, the transaction type of each transaction data can be determined.
[0099] According to an embodiment of the present invention, if there is no transaction data with the same sorting priority as the transaction data to be inserted among multiple transaction data, the transaction data to be inserted can be directly inserted between transaction data with a higher sorting priority and transaction data with a lower sorting priority based on the sorting priority of the transaction data to be inserted, so that the transaction queue after insertion is still arranged in descending order according to the sorting priority of the transaction data. Therefore, the desired insertion position is between transaction data with a higher sorting priority and transaction data with a lower sorting priority.
[0100] According to an embodiment of the present invention, if there is transaction data with the same sorting priority as the transaction data to be inserted among multiple transaction data, the other transaction data with the same sorting priority are parsed to determine their respective transaction times. The other transaction data and the transaction data to be inserted are then sorted based on the transaction times of the other transaction data and the transaction time of the transaction data to be inserted, so that the sorted transaction data are arranged in the order of transaction times. Therefore, the desired insertion position can be determined based on the position of the transaction data to be inserted in the sorted transaction data and the position of the other transaction data in the transaction queue.
[0101] According to an embodiment of the present invention, transaction data with the same sorting priority as the transaction data to be inserted is determined based on the sorting priority, and the transaction data to be inserted is inserted based on the transaction times of the multiple transaction data, so that the data in the transaction queue is sorted according to the order of the transaction times, reducing the situation where the transaction data corresponding to the earlier event is not uploaded to the chain, which affects the correctness of the later event, thereby improving the accuracy of data processing.
[0102] According to an embodiment of the present invention, after the multiple transaction data included in the transaction queue are encapsulated to obtain transaction blocks through operation S250, the blockchain-based power data processing method also includes: determining the transaction objects of each of the multiple transaction data in the queue to be processed; for the transaction objects of each transaction data, based on the transaction time of each transaction data of the transaction object, determining the transaction data to be arranged from at least one transaction data; arranging the multiple transaction data to be arranged according to the sorting priority to obtain a new transaction queue, wherein the sorting priority is determined based on the transaction type.
[0103] According to an embodiment of the present invention, since transaction data in the pending queue has been awaiting processing for a period of time, the transaction time of the transaction data in the pending queue is typically earlier than the transaction time of the newly generated transaction data to be inserted. After encapsulating the multiple transaction data included in the transaction queue to form a transaction block, the pending transaction data can be selected from the pending queue to form a new transaction queue. The above process can then be repeated to compare the newly generated transaction data to be inserted with the new transaction data and encapsulate the transaction block.
[0104] According to an embodiment of the present invention, since the pending queue may include multiple transaction data items for the same transaction object, and conflicts may exist between the multiple transaction data items for the same transaction object and the same transaction type, at least one non-conflicting transaction data item can be selected from the multiple transaction data items for the same transaction object in the pending queue, and a new transaction queue can be generated based on the at least one non-conflicting transaction data item for each of the multiple transaction objects.
[0105] According to embodiments of the present invention, the transaction data to be arranged to form a new transaction queue can also be determined based on the transaction time of the transaction data. If a transaction object has multiple transaction data, the transaction data with the earliest transaction time can be selected as the transaction data to be arranged based on the transaction time of each of the multiple transaction data. The transaction data to be arranged for each of the multiple transaction objects can form a new transaction queue. Therefore, simply by determining the sorting priorities between the multiple transaction types, the multiple transaction data to be arranged can be arranged to form a new transaction queue.
[0106] According to an embodiment of the present invention, after the multiple transaction data in the transaction queue are packaged, the transaction data to be queued is determined from the pending queue and queued to form a new transaction queue. Therefore, the transaction data in the new transaction queue is preferentially selected from the deferred transaction data, which can reduce the waiting time of the transaction data in the pending queue, improve the data processing efficiency of the entire system, and reduce the average waiting time.
[0107] 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 time between the current moment and the generation moment of the previous transaction block reaches a preset time threshold.
[0108] According to an embodiment of the present invention, the preset capacity threshold may 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 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, and after the transaction data to be inserted is inserted into the expected insertion position of the transaction queue, the capacity of multiple transaction data in the transaction queue is greater than the preset capacity threshold, then it can be determined that the encapsulation condition has been met, and the multiple transaction data included in the transaction queue are encapsulated to obtain a transaction block.
[0110] According to an embodiment of the present invention, when there is a conflict between the transaction data to be inserted obtained within a period of time and the transaction data already existing in the transaction queue, regardless of the relationship between the transaction times of the transaction data to be inserted and the transaction data, the number of 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 queue to be processed will be in a waiting state and cannot be packaged and uploaded to the chain.
[0111] Therefore, a preset time threshold can be set, and the timing starts after the last transaction block is generated. When it is determined that the current time has reached the preset time threshold from the generation time of the last transaction block, the multiple transaction data included in the current transaction queue are encapsulated to obtain a transaction block.
[0112] Since the power system involves a huge number of power equipment and power data, the frequency of generating transaction data to be inserted is very high. A smaller preset time threshold can be set to increase the generation frequency of transaction blocks, increase the processing frequency of transaction data to be inserted, avoid data blocking and untimely data updates, and improve data processing efficiency.
[0113] According to embodiments of the present invention, when it is determined that the capacity of a transaction queue is greater than or equal to a preset capacity threshold, multiple transaction data in the transaction queue are encapsulated, thereby increasing the frequency of data encapsulation and thus improving data processing efficiency. When it is determined that the time interval between the current moment and the generation time of the previous transaction block has reached a preset time threshold, multiple transaction data in the transaction queue are encapsulated, thereby ensuring a lower limit on the frequency of data encapsulation and thus avoiding transaction data congestion.
[0114] According to an embodiment of the present invention, multiple transaction data included in a transaction queue are encapsulated to obtain a transaction block, including: selecting at least one target transaction data from the transaction queue according to the capacity required to be occupied by each of the multiple transaction data included in the transaction queue and a preset capacity; and 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 a transaction queue may be greater than a preset capacity threshold, in this case, a transaction block cannot accommodate the capacity of multiple transaction data in the transaction queue. Therefore, multiple transaction data in the transaction queue cannot be simultaneously packaged to form a transaction block. Instead, a portion of transaction data can be selected from the transaction queue as target transaction data, such 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 packaged to form a transaction block.
[0116] According to an embodiment of the present invention, at least one target transaction data is selected from the transaction queue according to the capacity required to be occupied by each of the multiple transaction data included in the transaction queue and the preset capacity, including: when the sum of the capacity required to be occupied by each of the multiple transaction data is less than or equal to the preset capacity, the multiple transaction data are all used as target transaction data; when the sum of the capacity required to be occupied by each of the multiple transaction data is greater than the preset capacity, the multiple transaction data are screened 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, if the sum of the capacity required by multiple transaction data in a transaction queue does not reach a preset capacity threshold, and the time between the current moment and the generation of the previous transaction block reaches a preset time threshold, the encapsulation condition is triggered. However, the sum of the capacity required by multiple transaction data in the transaction queue is less than or equal to the preset capacity. In this case, the transaction block can accommodate multiple transaction data in the transaction queue. Therefore, multiple transaction data can be used as target transaction data and encapsulated simultaneously to form a transaction block.
[0118] According to an embodiment of the present invention, when the sum of the capacities required to be occupied by multiple transaction data is greater than the preset capacity, it is necessary to screen the multiple transaction data to determine part of the transaction data as target transaction data, so that the sum of the capacities required to be occupied by at least one target transaction data is less than the preset capacity.
[0119] According to an embodiment of the present invention, when the total capacity required by the transaction data does not reach a preset capacity, multiple transaction data are directly identified as target transaction data. This can reduce the time cost and computing power consumption of the comparison process, thereby improving data processing efficiency and resource utilization. When the total capacity required by the transaction data reaches the preset capacity, the multiple transaction data are screened to obtain target transaction data whose total capacity is less than the preset capacity, thereby ensuring that the transaction block can be correctly and smoothly encapsulated.
[0120] According to an embodiment of the present invention, multiple transaction data are screened in order of multiple transaction data in a transaction queue to obtain at least one target transaction data whose occupied capacity is less than a preset capacity, including: repeatedly performing the following operations until the screening of the last transaction data of the multiple transaction data is completed: determining the remaining capacity based on the capacity required to be occupied by the at least one 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, using 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, obtaining the next transaction data in the transaction queue that is located after the transaction data to be screened as the transaction data to be screened.
[0121] According to an embodiment of the present invention, transaction data are sequentially selected as transaction data to be screened according to the order of multiple transaction data in the transaction queue, thereby ensuring that the sorting priority of the transaction data to be screened is higher than the priority of the transaction data that has not yet been screened, thereby ensuring that, if capacity permits, transaction data with a high sorting priority is processed and packaged first.
[0122] According to an embodiment of the present invention, for each transaction data to be filtered, the remaining capacity is determined by using the difference between the preset capacity and the capacity required to be occupied by at least one target transaction data that has been filtered. Here, when there is currently no filtered target transaction data, the capacity required to be occupied by at least one target transaction data that has been filtered is 0, and therefore 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. When the capacity occupied by the transaction data to be screened is smaller than the remaining capacity, it indicates that the remaining capacity can accommodate the transaction data to be screened, and therefore the transaction data to be screened is used as the target transaction data.
[0124] According to an embodiment of the present invention, if the capacity occupied by the transaction data to be screened is greater than the remaining capacity, it indicates that the remaining capacity cannot accommodate the transaction data to be screened, and therefore the transaction data to be screened cannot be used as the target transaction data. If the last transaction data of multiple transaction data has not yet been screened, 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 process is repeated for determination.
[0125] According to embodiments of the present invention, sequentially screening multiple transaction data sets ensures that high-priority transaction data are more likely to be processed first, allowing more important data or instructions to be uploaded to the blockchain and reach consensus more promptly, thus ensuring data integrity and accuracy. By comparing the remaining capacity with the capacity required for each transaction data to be screened, it is possible to ensure that the total capacity required by multiple target transaction data sets does not exceed the preset capacity, thereby ensuring that the transaction block can be packaged smoothly.
[0126] Figure 4 The present invention shows a process of screening transaction data using a blockchain-based power data processing method according to an embodiment of the present invention.
[0127] like Figure 4 As shown in the figure, after conflict detection, it is determined that the transaction queue includes five transaction data V1, V2, V5, V6, and V7. Among them, V1 and V5 are both 50KB, V2 is 100KB, V6 is 1000KB, and V7 is 400KB. The preset capacity is 800KB.
[0128] Based on the order in the transaction queue, V1 is identified as the transaction data to be filtered. Currently, no target transaction data has been filtered, so the remaining capacity is the same as the preset capacity, 800KB. 800KB > 50KB, indicating that the remaining capacity can accommodate transaction data V1, which is identified as the filtered target transaction data.
[0129] Continuing with the selection of transaction data V2 as the target transaction data to be filtered, since the target transaction data currently includes V1, the remaining capacity is 800-50 = 750KB. 750KB > 100KB, indicating that the remaining capacity can accommodate transaction data V2, which is then determined as the filtered target transaction data. Similarly, V5 can be determined as the filtered target transaction data.
[0130] Figure 4 This indicates that V1, V2, and V5 have been determined as target transaction data. In this state, the remaining capacity is 800-50-100-50=600KB.
[0131] Continuing with the selection of transaction data V6, since the remaining capacity of 600KB is less than 1000KB, transaction data V6 cannot be accommodated. Therefore, V6 is not the target transaction data. From the transaction queue, transaction data V7, which follows V6, is selected as the target transaction data. The same judgment is repeated. The remaining capacity of 600KB is greater than 400KB, indicating that transaction data V7 can be accommodated. Therefore, V7 is selected as the target transaction data after screening.
[0132] At this point, all transaction data in the transaction queue have been screened, so it can be determined that the sum of the occupied storage capacity of V1, V2, V5 and V7 is less than the preset capacity. V1, V2, V5 and V7 can be encapsulated to obtain a transaction block.
[0133] According to an embodiment of the present invention, the blockchain-based power data processing method also includes: adjusting the sorting priority of each of the multiple transaction data included in the transaction queue according to the respective waiting time of the multiple transaction data included in the transaction queue, to obtain multiple adjusted sorting priorities, wherein the waiting time is the time difference between the moment when the transaction data is collected and the current moment; and rearranging the multiple transaction data in the transaction queue according to the respective adjusted sorting priority of the multiple transaction data included in the transaction queue.
[0134] According to an embodiment of the present invention, during data processing, if a transaction data item has a lower sorting priority, while other transaction data in the transaction queue and subsequently generated transaction data to be inserted have a higher sorting priority than the transaction data item, the transaction data item will remain at the end of the queue.
[0135] According to the logic of selecting target transaction data, transaction data with high sorting priority will be screened first in the process of selecting target transactions. In the case that the capacity occupied by transaction data with high sorting priority is large, the remaining capacity may be insufficient to accommodate the transaction data with low sorting priority.
[0136] In the above situation, the transaction data will remain 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 based on the waiting time of each transaction data, that is, the sorting priority of transaction data with a long waiting time is increased. Therefore, after a long waiting time, the sorting priority of transaction data with a low sorting priority is increased. After re-sorting multiple transaction data in the transaction queue, the transaction data will be placed at the front of the transaction queue. Therefore, during the transaction data screening process, the transaction data will be more easily identified as target transaction data and complete the subsequent packaging and chain upload.
[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 first, 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 embodiments of the present invention, a comprehensive performance monitoring mechanism can be built into the blockchain system to monitor resource utilization, response time, and other aspects of each data processing process, as well as the overall throughput of the blockchain. If the performance monitoring mechanism detects an anomaly in the blockchain, it can issue an alert to operations and maintenance personnel, allowing them to promptly troubleshoot and resolve the fault or anomaly, further ensuring the stable operation of the blockchain and the security and accuracy 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 the power data collected by the power data collection device from the power device. In one embodiment, the data generation module 510 may be configured to perform the operation S210 described above, which will not be described in detail here.
[0144] The time determination module 520 is configured to determine the transaction time of the transaction data to be inserted and the transaction data already in the transaction queue when a conflict is determined between the transaction data to be inserted and the transaction data already in the transaction queue. A conflict is determined between the transaction data to be inserted and the transaction data when the transaction objects and transaction types of the transaction data to be inserted are the same. In one embodiment, the time determination module 520 may be configured to perform operation S220 described above, which will not be further described here.
[0145] The data moving module 530 is configured to place the transaction data to be inserted into the transaction queue at the location of the transaction data if the transaction time of the transaction data to be inserted is earlier than the transaction time of the transaction data. In one embodiment, the data moving module 530 can be configured to perform the operation S230 described above, which will not be further described here.
[0146] The data insertion module 540 is used to place the transaction data in the queue to be processed. In one embodiment, the data insertion module 540 can be used to perform the operation S240 described above, which will not be repeated here.
[0147] The data encapsulation module 550 is used to encapsulate the 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 can be used to perform the operation S250 described above, which will not be repeated here.
[0148] The data publishing module 560 is used to publish the transaction block to the blockchain. In one embodiment, the data publishing module 560 can be used to perform the operation S260 described above, which will not be repeated here.
[0149] According to an embodiment of the present invention, the blockchain-based power data processing device 500 further includes an object determination module, a data determination module, and a data arrangement module.
[0150] The object determination module is used to determine the transaction objects of the multiple transaction data in the queue to be processed.
[0151] The data determining module is configured to determine, for each transaction object of each transaction data, transaction data to be arranged from at least one transaction data based on the transaction time of each at least one transaction data of the transaction object.
[0152] The data arrangement module is used to arrange the plurality of transaction data to be arranged according to the arrangement priority to obtain a new transaction queue, wherein the arrangement 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] A position determination module is used to determine 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 of multiple transaction data in the transaction queue, 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.
[0155] The data placement module is used to insert the transaction data to be inserted into the desired insertion position.
[0156] According to an embodiment of the present invention, the location determination module includes a priority determination submodule and a location determination submodule.
[0157] The priority determination submodule is used to traverse multiple transaction data in the transaction queue and determine the sorting priority of each of the multiple transaction data.
[0158] The position determination submodule is used to determine the expected insertion position based on the transaction times of the at least one transaction data with the same sorting priority and the transaction data to be inserted when it is determined that there is at least one transaction data with the same sorting priority as the transaction data to be inserted among multiple transaction data.
[0159] According to an embodiment of the present invention, the data encapsulation module 550 includes a data selection submodule and a data encapsulation submodule.
[0160] The data selection submodule is used to select at least one target transaction data from the transaction queue according to the capacity required to be occupied by each of the multiple transaction data included in the transaction queue and the preset capacity.
[0161] The data encapsulation submodule is used 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 submodule includes a first data selection unit and a second data selection unit.
[0163] The first data selection unit is configured to select the plurality of transaction data as target transaction data when the sum of the capacities required to be occupied by the plurality of transaction data is less than or equal to a preset capacity.
[0164] The second data selection unit is used to screen the multiple transaction data according to the order of the multiple transaction data in the transaction queue when the sum of the capacity required by each of the multiple transaction data is greater than the preset capacity, and 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 used to determine the remaining capacity based on the capacity required to be occupied by at least one screened target transaction data and the preset capacity.
[0167] The first data determination subunit is configured to use the transaction data to be screened as target transaction data when the capacity occupied by the transaction data to be screened is smaller than the remaining capacity.
[0168] The second data determining subunit is configured to obtain the next transaction data following the transaction data to be screened in the transaction queue as the transaction data to be screened when the capacity occupied by the transaction data to be screened is greater than the remaining capacity.
[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 used to adjust the sorting priority of multiple transaction data included in the transaction queue according to the waiting time of each of the multiple transaction data included in the transaction queue, so as to obtain multiple adjusted sorting priorities, wherein the waiting time is the time difference between the time when the transaction data is collected and the current time.
[0171] The data rearrangement module is used to rearrange the multiple transaction data in the transaction queue according to the 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 submodule.
[0173] The data generation submodule is used to 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.
[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 into a single module, or any one of these modules may be split into multiple modules. Alternatively, at least part of the functionality of one or more of these modules may be combined with at least part of the functionality of other modules and implemented in a single 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 a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or may be implemented in hardware or firmware through any other reasonable means of circuit integration or packaging, or may be implemented in any one of the three implementation methods of software, hardware, and firmware, or any appropriate combination of any of these. Alternatively, at least one of the data generation module 510, the moment determination module 520, the data movement module 530, the data insertion module 540, the data encapsulation module 550 and the data publishing module 560 can be at least partially implemented as a computer program module, which can perform the corresponding function when it is executed.
[0175] Figure 6 A block diagram of an electronic device suitable for implementing a blockchain-based power data processing method according to an embodiment of the present invention is shown.
[0176] like Figure 6 As shown, an electronic device 600 according to an embodiment of the present invention includes a processor 601, which can perform various appropriate actions and processes based on programs stored in a read-only memory (ROM) 602 or programs loaded from a storage unit 608 into a random access memory (RAM) 603. The processor 601 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or related chipsets and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include onboard 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] Various programs and data required for the operation of the electronic device 600 are stored in the RAM 603. The processor 601, ROM 602, and RAM 603 are connected to each other via a bus 604. The processor 601 executes the programs in the ROM 602 and / or RAM 603 to perform various operations according to the method flow of the embodiment of the present invention. It should be noted that the programs may also be stored in one or more memories other than the ROM 602 and RAM 603. The processor 601 may also execute the programs stored in the one or more memories to perform various operations according to the method flow of the embodiment of the present invention.
[0178] According to an embodiment of the present invention, electronic device 600 may further include an input / output (I / O) interface 605, which is also connected to bus 604. Electronic device 600 may also include one or more of the following components connected to I / O interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including devices such as a cathode ray tube (CRT), liquid crystal display (LCD), and speakers; a storage section 608 including a hard disk; and a communication section 609 including a network interface card such as a LAN card or modem. Communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to I / O interface 605 as needed. Removable media 611, such as a magnetic disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed in drive 610 as needed, so that computer programs read from the removable media can be installed into storage section 608 as needed.
[0179] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments, or may exist independently and not incorporated into the device / apparatus / system. The computer-readable storage medium carries one or more programs, which, when executed, implement the method according to the embodiments of the present invention.
[0180] According to an embodiment of the present invention, a computer-readable storage medium may be a non-volatile computer-readable storage medium, and may include, for example, but not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to an embodiment of the present invention, a computer-readable storage medium may include the ROM 602 and / or RAM 603 described above, and / or one or more memories other than ROM 602 and RAM 603.
[0181] The embodiments of the present invention further include a computer program product, which includes a computer program containing program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to cause the computer system to implement the method provided by the embodiments of the present invention.
[0182] The computer program executes the above functions defined in the system / device of the embodiment of the present invention when the computer program is executed by the processor 601. According to the embodiment of the present invention, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0183] In one embodiment, the computer program may be stored on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may be transmitted and distributed in the form of a signal on a network medium, downloaded and installed via the communication portion 609, and / or installed from a removable medium 611. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to wireless, wired, or any suitable combination thereof.
[0184] In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 609 and / or installed from a removable medium 611. When the computer program is executed by the processor 601, the above-described functions defined in the system of the embodiment of the present invention are performed. According to the embodiment of the present invention, the systems, devices, means, modules, units, etc. described above can be implemented by computer program modules.
[0185] According to an embodiment of the present invention, the program code for executing the computer program provided by the embodiment of the present invention can be written in any combination of one or more programming languages. Specifically, these computer 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, languages such as Java, C++, Python, "C" or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect via the Internet).
[0186] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the above-mentioned module, program segment, or a 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 box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0187] It will be understood by those skilled in the art that the features described in the various embodiments of the present invention may be combined and / or coupled in various ways, even if such combinations or couplings are not explicitly described in the present invention. In particular, the features described in the various embodiments of the present invention may be combined and / or coupled in various ways without departing from the spirit and teachings of the present invention. All such combinations and / or couplings fall within the scope of the present invention.
[0188] The above describes embodiments of the present invention. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of the present invention. Although each embodiment has been described separately above, this does not mean that the measures in each embodiment cannot be advantageously used in combination. Without departing from the scope of the present invention, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present invention.
Claims
1. A power data processing method based on blockchain, characterized in that: The method comprises: In response to the power data collected by the power data collection device from the power device, generating transaction data to be inserted based on the power data; If it is determined that there is a conflict between the transaction data to be inserted and transaction data already existing in the transaction queue, determining the transaction times of the transaction data to be inserted and the transaction data in the transaction queue that conflicts with the transaction data to be inserted, wherein if the transaction data to be inserted and the transaction data already existing in the transaction queue have the same transaction objects and the same transaction types, 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; If the transaction time of the transaction data to be inserted is earlier than the transaction time of the transaction data that conflicts with the transaction data to be inserted, the transaction data to be inserted is placed at the location of the transaction data that conflicts with the transaction data to be inserted in the transaction queue, thereby completing the data replacement; Placing the transaction data that conflicts with the transaction data to be inserted into a queue to be processed; If 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; 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 plurality of transaction data in the queue to be processed, wherein the plurality of transaction data in the queue to be processed includes a plurality of transaction data of the same transaction object and conflicts between the plurality of transaction data of the same transaction object and the same transaction type; For multiple transaction data of the same transaction object in the queue to be processed, determining the transaction data to be arranged from the multiple transaction data of the same transaction object based on the transaction times of the multiple transaction data of the same transaction object, so that there is no conflict between the determined transaction data to be arranged; and The transaction data to be arranged of the plurality of transaction objects are arranged according to the sorting priority to obtain a new transaction queue, wherein the sorting priority is determined based on the transaction type.
2. The method according to claim 1, characterized in that The method further comprises: If it is determined that there is no conflict between the transaction data to be inserted and transaction data already in the transaction queue, determining a desired 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 of the plurality of transaction data in the transaction queue; and Insert the transaction data to be inserted into the expected insertion position.
3. The method according to claim 2, characterized in that The determining, based on the transaction type of the transaction data to be inserted and the transaction types of the plurality of transaction data in the transaction queue, 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 priority of each of the multiple transaction data; When it is determined that among the multiple transaction data in the transaction queue, there is at least one transaction data with the same sorting priority as the transaction data to be inserted, the expected insertion position is determined based on the transaction times of the at least one transaction data with the same sorting priority and the transaction data to be inserted.
4. The method according to claim 1, wherein The packaging 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 time between the current time and the generation time of the previous transaction block reaches the preset time threshold.
5. The method according to claim 4, characterized in that The step of encapsulating the plurality of 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 to be occupied by each of the plurality of transaction data included in the transaction queue and the preset capacity; and The at least one target transaction data is encapsulated to obtain the transaction block.
6. The method according to claim 5, characterized in that The selecting at least one target transaction data from the transaction queue according to the capacity required to be occupied by each of the plurality of transaction data included in the transaction queue and the preset capacity includes: When the sum of the capacity occupied by each of the plurality of transaction data included in the transaction queue is less than or equal to the preset capacity, all of the plurality of transaction data included in the transaction queue are used as the target transaction data; and When the sum of the capacities required to be occupied by each of the multiple transaction data included in the transaction queue is greater than the preset capacity, the multiple transaction data in the transaction queue are screened according to 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.
7. The method according to claim 6, characterized in that The filtering of the multiple transaction data in the transaction queue according to the order of the multiple transaction data in the transaction queue to obtain the at least one target transaction data whose occupied capacity is smaller than the preset capacity includes: Repeat the following steps until the last transaction data in the transaction queue is filtered: Determining the remaining capacity based on the capacity required to be occupied by at least one of the screened target transaction data and the preset capacity; In a case where the capacity occupied by the transaction data to be screened is smaller than the remaining capacity, taking the transaction data to be screened as target transaction data; In a case where the capacity occupied by the transaction data to be screened is greater than the remaining capacity, the next transaction data located after the transaction data to be screened in the transaction queue is obtained as the transaction data to be screened.
8. The method according to any one of claims 1 to 7, characterized in that The method further comprises: adjusting the sorting priorities of the plurality of transaction data included in the transaction queue according to respective waiting times of the plurality of transaction data included in the transaction queue to obtain a plurality of adjusted sorting priorities, wherein the waiting time is the time difference between the time when the transaction data was collected and the current time; and The multiple transaction data in the transaction queue are rearranged according to the adjusted sorting priorities of the multiple transaction data included in the transaction queue.
9. The method according to claim 1, characterized in that The generating of transaction data to be inserted based on the power data includes: The collection time of the power data and the electronic signature of the power data collection device are added to the power data to obtain the transaction data to be inserted.
Citation Information
Patent Citations
Transaction processing method and device based on a block chain and electronic equipment
CN113220745A
Block chain data processing method and device, equipment and storage medium
CN119941396A