Methods, devices, electronic equipment and storage media for electricity data traceability
By applying the power traceability model and the composite index structure, the problem of long traceability time in blockchain was solved, and efficient power consumption data query and traceability were achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- WENZHOU ELECTRIC POWER BUREAU
- Filing Date
- 2026-04-23
- Publication Date
- 2026-05-26
AI Technical Summary
Traditional blockchain traceability methods are time-consuming, consume enormous amounts of network bandwidth and computing resources when dealing with massive amounts of data, making it difficult to meet the needs for efficient real-time or near real-time queries.
A standardized model of electricity consumption data is adopted using an electricity traceability model to construct a joint index structure, including a traceability location table and a multi-bucket index structure. The target traceability results are directly obtained through cross-block location and intra-block data extraction.
It significantly shortens the query path and data retrieval time, improves the efficiency of tracing, and avoids the delay and computational overhead of traditional sequential scanning and multiple random accesses.
Smart Images

Figure CN122087012A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of blockchain technology, and in particular to a method, apparatus, electronic device, and storage medium for tracing electricity consumption data. Background Technology
[0002] The essence of blockchain is a linked list structure that connects blocks in chronological order using hash pointers. Due to its decentralized, immutable, and transparent characteristics, it is widely used in supply chain finance, product traceability, and data storage.
[0003] When it's necessary to trace the complete operational history of a specific object (such as a particular user), because its related records are scattered across thousands of discontinuous blocks on the blockchain, the traditional tracing method starts from the latest block and downloads, parses, and traverses block by block along the hash pointer until it backtracks to the original block to ensure that all relevant records are found. This "carpet-bombing" sequential scan consumes an astonishing amount of time, network bandwidth, and computing resources when dealing with massive amounts of data, making a complete tracing query potentially take several minutes or even hours.
[0004] Therefore, traditional data tracing methods are unable to meet the needs of efficient real-time or near real-time querying or data tracing. Summary of the Invention
[0005] This invention provides a method, apparatus, electronic device, and storage medium for tracing electricity consumption data, which can solve at least one of the above-mentioned technical problems.
[0006] In a first aspect, embodiments of the present invention provide a method for tracing electricity consumption data, including: The preset power traceability model is invoked to standardize and model the electricity consumption data of each user, obtain each triplet data, and store each triplet data on the blockchain. Based on the first field in each of the triplet data, a composite index structure is constructed, wherein the composite index structure includes a traceability table and a multi-bucket index structure; In response to the query request from the target user, cross-block positioning is performed based on the second field in the query request and the tracing and positioning table to obtain the cross-block tracing link; Based on the second field and the multi-bucket index structure, perform intra-block data extraction on each block in the cross-block tracing link to obtain the target tracing result; The target tracing result is sent to the target user, wherein the target tracing result includes user identifier, meter number, timestamp, operation behavior data, and agent identifier.
[0007] Secondly, embodiments of the present invention provide an electricity consumption data traceability device, comprising: The model invocation module is used to invoke a preset power traceability model to standardize and model the electricity consumption data of each user, obtain each triplet data, and store each triplet data on the blockchain. A composite index structure construction module is used to construct a composite index structure based on the first field in each of the triplet data, wherein the composite index structure includes a traceability table and a multi-bucket index structure; The cross-block location module is used to respond to the query request of the target user, perform cross-block location based on the second field in the query request and the traceability location table, and obtain the cross-block tracing link; The block data extraction module is used to perform block data extraction on each block in the cross-block tracing link according to the second field and the multi-bucket index structure to obtain the target tracing result; The traceability result distribution module is used to distribute the target traceability result to the target user, wherein the target traceability result includes user identifier, meter number, timestamp, operation behavior data, and agent identifier.
[0008] Thirdly, embodiments of the present invention also provide an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the method described in any one of the embodiments of the present invention.
[0009] Fourthly, embodiments of the present invention also provide a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause a computer to perform the method described in any one of the embodiments of the present invention.
[0010] This invention employs a pre-defined power tracing model to standardize and model the electricity consumption data of each user, obtaining triplet data sets, which are then stored on the blockchain. Based on this, a joint index structure, including a traceability table and a multi-bucket index structure, is constructed using the first field of each triplet data set. Subsequently, cross-block tracing is performed in each block according to the second field in the target user's query request and the traceability table, resulting in a cross-block tracing link. Then, based on the second field and the multi-bucket index structure, intra-block data extraction is performed on each block in the cross-block tracing link to obtain the target tracing result. As can be seen, the tracing process of this invention does not require starting from the latest block and traversing back block by block along the main chain hash. Instead, when a query is initiated, cross-block tracing is performed directly based on the fields and the traceability table, and data can be efficiently extracted from each block based on the fields and the multi-bucket index structure. This invention avoids the latency and computational overhead caused by traditional sequential scanning and multiple random accesses, thus significantly shortening the query path and data retrieval time, and improving tracing efficiency.
[0011] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0012] The accompanying drawings are provided for a better understanding of this solution and do not constitute a limitation of the invention. Wherein: Figure 1 This is a flowchart of an embodiment of the electricity data tracing method of the present invention; Figure 2 This is a structural block diagram of an electricity data tracing device according to an embodiment of the present invention; Figure 3 This is a schematic block diagram of an electronic device used to implement the methods of the embodiments of the present invention. Detailed Implementation
[0013] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of the present invention, including various details to aid understanding. These details should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of the invention. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0014] Figure 1 This is a flowchart of an embodiment of the electricity data tracing method of the present invention.
[0015] like Figure 1 As shown, this method for tracing electricity consumption data may include: S110, call the preset power traceability model to standardize the electricity consumption data of each user, obtain each triplet data and store each triplet data on the chain; S120, construct a composite index structure based on the first field in each triplet data, wherein the composite index structure includes a traceability table and a multi-bucket index structure; S130, responding to the target user's query request, performs cross-block location based on the second field in the query request and the traceability and location table to obtain the cross-block traceability link; S140, Based on the second field and the multi-bucket index structure, perform intra-block data extraction on each block in the cross-block tracing link to obtain the target tracing result; S150, send the target traceability results to the target user, whereby the target traceability results include user identifier, meter number, timestamp, operation behavior data, and agent identifier.
[0016] For example, a power traceability model refers to a data model that, based on predefined data structure specifications, feature extraction rules, and mapping relationships, transforms raw electricity consumption behavior data into a data model with traceability, verifiability, and consistent semantic expression. This model at least constrains the composition, meaning, and order of fields. An example of a power traceability model is the Enhanced Power Provenance (E-PROV) model.
[0017] For example, user electricity consumption behavior can be uniformly mapped into a structured representation that includes user identifier, meter number, and behavior summary to ensure that data from different sources have consistent traceability semantics on the blockchain.
[0018] For example, electricity consumption data refers to raw or processed data collected during the operation of the power system that reflects the user's electricity consumption status and behavior, including but not limited to electricity consumption, voltage, current, collection time, equipment number, and operation events.
[0019] For example, a user's minute-level electricity consumption record and corresponding collection timestamp within a specified time period.
[0020] For example, triplet data refers to the data structure formed after standardizing and modeling electricity consumption data based on the power traceability model.
[0021] For example, the target tracing result refers to the complete set of tracing information obtained after responding to the query request and completing the extraction of data across blocks and within blocks, which is used to provide feedback to the target user. This set of information includes at least the user identifier, meter number, timestamp, operation behavior data, and agent identifier.
[0022] For example, it can return the electricity consumption records of a certain electricity meter within a specified time range and the corresponding on-chain agent node identifier.
[0023] According to the above implementation method, firstly, user electricity consumption data is standardized and modeled using a pre-defined power traceability model, and stored on the blockchain in the form of triples to ensure consistent semantic expression and traceability of the data on the chain. Secondly, a joint index containing a traceability positioning table and a multi-bucket index structure is constructed based on the first field of the triple data to achieve synergy between cross-block positioning and fast intra-block retrieval. On this basis, for user query requests, the relevant blocks are quickly determined using the traceability positioning table to form a cross-block traceability link. Then, the target data is accurately extracted in each block using the multi-bucket index structure. Finally, a complete traceability result containing user identifier, meter number, timestamp, operation behavior data, and agent identifier is returned to the target user. In this way, on the one hand, the original electricity consumption data is transformed into structured, indexable on-chain data units, avoiding the query complexity caused by disordered storage; on the other hand, through the hierarchical query mechanism of cross-block positioning and intra-block index extraction, the full chain traversal and repeated scanning operations are significantly reduced, the query path and response time are shortened, thereby effectively improving the query efficiency and traceability efficiency of power data.
[0024] In one implementation, a preset power traceability model is invoked to standardize and model the electricity consumption data of each user, resulting in triplet data. This includes: acquiring the electricity consumption data of each user, wherein the electricity consumption data includes historical electricity consumption data, operational behavior data that caused the change in the state of the historical electricity consumption data, and operational subject data; for each user, the power traceability model is invoked to map the historical electricity consumption data to entities, the operational behavior data to activities, and the operational subject data to agents, so as to obtain the entities, activities, and agents corresponding to each user; and semantic association links are established between the entities, activities, and agents corresponding to each user through the standard semantic relation words of the power traceability model, to obtain the triplet data.
[0025] For example, historical electricity consumption data refers to a set of data continuously collected and recorded by electricity meters, data acquisition terminals or master station systems during the operation of the power system, reflecting the user's electricity consumption status and results within a historical period. This data includes at least information such as electricity consumption, collection time, meter number and corresponding metering cycle.
[0026] For example, a raw record collected by a smart meter at 10:00:00 on 2025-10-01: {User Identifier (ID): "User001", Meter Number: "Meter12345", Timestamp: "...", Power Consumption: 2.0 kW, Voltage: 221 V, ...}.
[0027] For example, operational behavior data refers to the data corresponding to control, configuration, or business operations that cause changes in the status of historical electricity consumption data. It is used to describe "what behavior caused the change in electricity consumption status", including but not limited to collection, uploading, sharing, modification, and archiving.
[0028] For example, the action data for a data collection operation is: {Operation type: "Collection", Occurrence time: "2025-10-01 10:00:00", Operating device: "Smart meter D1"}. The action data for a modification operation is: {Operation type: "Modification", Occurrence time: "2025-10-01 14:05:30", Data hash before modification: "0xabc...", Data hash after modification: "0xdef..."}.
[0029] For example, the operation subject data refers to the data subject identification information that performs the operation, used to describe "who performed the operation." The subject may include smart devices, power grid companies, and third-party organizations. This data may include the identity information of human subjects or system subjects, such as user identifiers, maintenance personnel numbers, dispatch system identifiers, or agent node identifiers.
[0030] For example, the principal data of a power grid company is: {Principal Identifier: "GridCorp", Principal Type: "Organization", Organization Code: "...", Address: "...", Public Key: "04B..."}.
[0031] In this example, firstly, in response to an operation event involving electricity consumption data, the system extracts all relevant data fields from the event's carrier (such as system logs, Application Programming Interface (API) call requests, or message queue messages). Then, these fields are categorized: fields describing the physical quantity and status of electricity consumption are categorized into the historical electricity consumption data set; fields describing the operation type, occurrence time, and other action information are categorized into the operation behavior data set; and fields describing the identity, role, and credentials of the operation initiator are categorized into the operation subject data set.
[0032] Second, the pre-defined power traceability model is invoked, using the three types of data obtained in the first step as input. The mapping logic within the model is triggered: First, a standardized entity object is created based on the "historical electricity consumption data," and its data hash is calculated. Simultaneously, an activity object is created based on the "operation behavior data." Finally, a proxy object is created based on the "operation subject data," and its public key and other identity information are associated with it. In this way, an unstructured operation event is transformed into three independent, structured core traceability elements. For example, entity E2 = {type: "shared electricity consumption data", data: {...}, hash: "0xdef456..."}; activity A2 = {type: "shared", timestamp: "...11:00:00"}; proxy Ag2 = {id: "GridCorp", publicKey: "04B..."}.
[0033] Third, after generating independent entity, activity, and proxy objects, the power traceability model further invokes its internal semantic association module. This module, based on the business logic of the current operation (e.g., the "sharing" operation is executed by a "proxy," thus "generating" a new "entity"), selects appropriate relational terms (e.g., "was Generated By," "was GeneratedBy," "was Associated With," "was AssociatedWith") from the Provenance Data Model (PROV) standard vocabulary. Then, by establishing pointers or references between these objects, they are connected into a logical graph with clear causal and responsibility relationships. This final, complete information record, composed of entities, activities, proxies, and the relationships between them, constitutes a triplet data set.
[0034] For example, in the previous example, a link named `wasGeneratedBy` is established between E2 and A2, indicating that "shared data E2" was generated by "shared activity A2". A link named `wasAssociatedWith` is established between A2 and Ag2, indicating that "shared activity A2" was initiated by "proxy GridCorp". These three objects and the two associated links together constitute a complete triplet of data, clearly recording the complete event that "GridCorp performed a sharing operation, generating shared data E2".
[0035] It should be noted that the semantic association module is the core processing unit built into the power traceability model. It aims to automatically analyze the causal dependencies between entities, activities, and agents based on power business logic and PROV (Provenance Data Model) standards and specifications, and map unstructured data into a traceability semantic graph with a topological structure.
[0036] Specifically, this module uses a pre-defined relational lexicon and inference rules to structurally reconstruct the data operation chain. Its functionality extends beyond basic object recognition; it focuses on semantic parsing to transform isolated source elements into causal logic chains with chain-like causal characteristics. For example, the module can identify action features such as "collect," "modify," and "upload" through a rule engine, automatically matching standard semantic relational terms (such as "derived from," "caused by," and "associated with"), and then establishing pointer references or links between source elements. This chain-building process essentially transforms a discrete electricity consumption behavior into a complete causal description with "who, when, using what equipment, through what logic, and generating what state," ensuring that each electricity consumption record can be traced back to its source, the process of change, and the responsible party. Furthermore, the semantic association module also has relational consistency verification capabilities, verifying whether the established links conform to electricity business specifications (e.g., ensuring that a "modify" activity must be associated with only one valid entity), thereby guaranteeing the logical completeness and traceability of the resulting triplet data.
[0037] According to the above implementation method, firstly, a set of electricity consumption data, including historical electricity consumption data, corresponding operational behavior data, and operational subject data, is acquired. Then, based on the electricity traceability model, historical electricity consumption data is abstracted into entities, operational behaviors that trigger state changes are abstracted into activities, and the subjects executing the operations are abstracted into agents. Based on this, using pre-set standard semantic relation words in the model, clear semantic association links are constructed between entities, activities, and agents, ultimately forming structured and semantically clear triplet data. In this way, the originally scattered and heterogeneous electricity consumption data can be transformed into structured traceability units with unified semantics and clear causal relationships. This not only improves the consistency and understandability of on-chain data but also makes the association between changes in electricity consumption status, operational behaviors, and operational subjects clearer and more traceable. Furthermore, it provides a reliable data foundation for subsequent index construction, query positioning, and cross-block traceability.
[0038] In one implementation, a composite index structure is constructed based on the first field in each triplet data. This composite index structure includes a traceability table and a multi-bucket index structure. The process includes: retrieving the first field from each triplet data in the blockchain, where the first field includes a user identifier, meter number, first block hash value, and operation type; determining a first composite key based on the user identifier and meter number to obtain various first composite keys; for each first composite key, searching for a second block hash value that has a pointing relationship with the first block hash value according to the derivation relationship between the triplet data, and using the first composite key, the first block hash value, and the second block hash value as an index entry to obtain various index entries; determining the traceability table based on the various index entries; grouping and storing each triplet data based on each user identifier and each operation type to construct a multi-bucket index structure; and associatively storing the multi-bucket index structure and the traceability table to obtain the composite index structure.
[0039] For example, the first field refers to the set of key fields extracted from the various triplet data in the blockchain for index construction and traceability. This set of fields includes at least the user identifier, meter number, first block hash value, and operation type. For example, the first field of a certain triplet data can be represented as "user A, meter 001, block hash H1, modification operation".
[0040] In this example, each triplet data record in the blockchain's blocks is traversed. For each record, an E-PROV parser is invoked to precisely extract a set of core fields for building the index from its internal entities, activities, and proxies. This set of fields includes at least the user identifier associated with the proxies, the meter number associated with the entities, the hash value of the block in which the record resides, and the operation type corresponding to the activity.
[0041] For example, a triplet data is read from block #888. The following first field is extracted by parsing: {User ID: "User001", Meter number: "Meter12345", First block hash value H1: "0xHash888", Operation type: "Modify"}.
[0042] For example, the first composite key refers to a composite identifier formed by combining the user identifier and the meter number in the first field. For instance, the user identifier "User A" is combined with the meter number "Meter 001" to form the composite key "User A-Meter 001", which can be used as the primary key for cross-block tracing and location.
[0043] For example, the first block hash value refers to the hash identifier of the block storing the current triplet data in the blockchain, used to uniquely identify the block location where the triplet data is located. For example, the current block containing the electricity consumption triplet data of "User A-Meter 001" has a block hash value denoted as H1.
[0044] For example, the second block hash value refers to the hash identifier of the previous block that has a pointing relationship with the first block hash value. This pointing relationship is established based on the derivation relationship between triplet data and is used to reflect the time evolution or state inheritance relationship of electricity consumption data under the same composite key across different blocks. For example, if the current block with a block hash value of H1 points to the previous block hash value H0, it means that H0 stores the previous stage's electricity consumption or operation data of the same user and the same meter.
[0045] In this example, the extracted user identifier and meter number are concatenated to form a unique first composite key. Then, based on this key, the existing traceability table is queried to find the block hash recorded when this key last appeared. This hash value is the second block hash value (i.e., the previous block hash) with a pointing relationship. Subsequently, a new index entry is created, which at least contains the current first composite key, the first block hash value of the current record, and the retrieved second block hash value.
[0046] For example, combining "User001" and "Meter12345" determines the first compound key as "User001-Meter12345". Then, querying the lookup table reveals that the last associated block for this key was block #750 (whose hash is 0xHash750), which is the hash value of the second block. Finally, a new index entry is generated: {Keyword: "User001-Meter12345", Latest Block Hash: "0xHash888", Previous Block Hash: "0xHash750", ...}.
[0047] For example, a composite index structure refers to a complex index system formed by associating a traceability table with a multi-bucket index structure. The traceability table maintains the mapping between the first composite key and the block hash link to support cross-block traceability. The multi-bucket index structure groups and stores triplet data within a single block according to user identifier and operation type to support fast intra-block retrieval. For instance, using a composite index structure, the block hash link H3→H2→H1 can be determined first based on "User A-Meter 001" in the traceability table, and then the triplet data corresponding to the shared or modified operation can be quickly located within each block through the corresponding data bucket.
[0048] In this example, an insert or update operation is performed using the first compound key in the index entry as the key and the entire index entry as the value. If the key already exists, the old entry is overwritten with the new index entry to ensure that the table always stores the latest block information associated with that key. The dynamically maintained key-value pair table containing the latest location information for all keys is the traceability table.
[0049] When processing all triplet data within the same block, a grouping key is determined based on the user identifier and operation type in each triplet. This grouping key is typically formed by concatenating the operation type string with the first few characters of the user identifier. Then, based on this grouping key, the triplet data is stored in a separate storage container or logical group, which is called a "bucket". By performing this grouping storage operation on all triplet data within the block, a multi-bucket index structure is constructed, with the grouping key as the index and the triplet data set as the content.
[0050] For example, for the triplet data in block #888, the user identifier "User001" and operation type "Modify" are extracted. Based on the grouping rule (operation type + first two digits of user ID), its grouping key is determined to be "Modify-Us". This triplet data is then stored in the bucket with the key "Modify-Us". After all records in block #888 have undergone this processing, the multi-bucket index structure of that block is formed.
[0051] According to the above implementation method, firstly, the first field of the triplet data is extracted from the blockchain, and a first composite key is constructed based on the user identifier and meter number. Based on this, according to the derivation relationship between the triplet data, a pointing relationship between block hash values is established, and the first composite key and the corresponding block hash link are encapsulated together as an index entry, thus forming a traceability positioning table for cross-block location. Simultaneously, the triplet data is grouped and stored according to the user identifier and operation type, constructing a multi-bucket index structure that supports fast access within blocks. Finally, the multi-bucket index structure is associated with the traceability positioning table to obtain a unified composite index structure. In this way, on the one hand, the composite key and block hash pointing relationship enable rapid determination of cross-block traceability paths, avoiding block-by-block traversal of the entire chain data; on the other hand, the multi-bucket index classifies and aggregates data within blocks, significantly reducing the complexity of data retrieval within a single block. The synergistic effect of these two methods creates a layered and decoupled query process for cross-block location and data extraction within blocks, effectively improving the query efficiency and traceability efficiency of on-chain electricity consumption data.
[0052] In one implementation, the triplet data is grouped and stored based on each user identifier and each operation type to construct a multi-bucket index structure, including: determining a second composite key based on the user identifier and operation type to obtain each second composite key; grouping the triplet data based on each second composite key to obtain each grouped triplet data; and storing each grouped triplet data in each data bucket to construct a multi-bucket index structure.
[0053] For example, the second composite keyword refers to a composite identifier formed by combining the user identifier and operation type in the triplet data, which is used to group, store and index similar operations of the same user within a block.
[0054] In this example, when processing a triplet within a block, the user identifier is first extracted from the proxy element of the triplet, and the operation type is extracted from the activity element. Then, according to preset rules, the user identifier is processed to obtain its prefix. Finally, the operation type string is concatenated with the user identifier prefix string. The resulting string, which uniquely identifies a data group, is determined as the second compound key corresponding to that triplet.
[0055] For example, when processing a triplet of data, we extract the user identifier "User00123" and the operation type "Shared". Assuming the grouping rule is "Operation type + first four digits of user identifier", we concatenate "Shared" with "User" to determine the second compound key of the record as "Shared-User".
[0056] The algorithm iterates through all triplet records within a block, extracting the second compound key for each triplet in each iteration. Then, all triplet records with the same second compound key are grouped into a temporary set. By performing this sorting operation on all records, the original, unordered list of triplet records is reorganized into multiple independent data groups identified by their second compound keys; these groups are the individual triplet records.
[0057] For example, suppose a block contains three records, each with the second compound key "Shared-User", "Modified-Grid", and "Shared-User". After performing a grouping operation, two logical groups will be formed: Group 1 (key: "Shared-User"): contains the first and third triplet data; Group 2 (key: "Modify-Grid"): contains the second triplet data. Thus, the two groups of data are the triplet data after grouping.
[0058] Each data group is given an independent storage container, which is called a data bucket. Then, all triplet data records within each group are stored in their corresponding data bucket. Simultaneously, each data bucket's associated data structures are configured and updated, including a Bloom filter for fast existence checks and a self-balancing binary search tree for ordered management. This hierarchical storage system, composed of multiple independent data buckets indexed by composite keys and with efficiently organized internal data, constitutes the final multi-bucket index structure.
[0059] For example, bucket A (corresponding key: "Shared-User") stores two triples from group 1 here. Simultaneously, the Bloom filter and red-black tree of bucket A are updated to reflect the existence of these two new records. Bucket B (corresponding key: "Modified-Grid") stores one triple from group 2 here, and the associated structures of bucket B are updated. Thus, buckets A and B together form a multi-bucket index structure.
[0060] According to the above implementation method, firstly, a second composite keyword is constructed based on user identifier and operation type to characterize the user scope and behavior category to which the data belongs; then, the triple data is grouped according to each second composite keyword, and triples with the same semantic and behavioral characteristics are aggregated in the same group; finally, the grouped triple data is stored in the corresponding data buckets, thereby forming a multi-bucket index structure. In this way, the triple data that was originally randomly distributed in the block can be transformed into a structured storage form aggregated by user and operation type. When performing a query within a block, the target data bucket can be directly located, avoiding the traversal and comparison of irrelevant data, significantly reducing retrieval complexity and access overhead, thereby improving the efficiency of data extraction within the block.
[0061] In one implementation, cross-block location is performed based on the second field in the query request and the traceability table to obtain a cross-block tracing link, including: obtaining the second field in the query request, wherein the second field includes the user identifier and meter number of the user to be queried; determining a third composite keyword based on the user identifier and meter number of the user to be queried; searching for a composite keyword matching the third composite keyword in the traceability table to obtain a target composite keyword; performing an initial query, extracting the target block hash value and the previous block hash value that has a pointing relationship with the target block hash value from the target index entry where the target composite keyword is located; using the previous block hash value as the target block hash value for the next round of query, so as to extract the previous block hash value that has a pointing relationship with the target block hash value in the traceability table; stopping the iterative query when the previous block hash value is empty, and mapping each target block hash value and each previous block hash value obtained in the query process according to the pointing relationship to construct a cross-block tracing link.
[0062] For example, the second field refers to the set of key information carried in the query request that identifies the user to be queried and its target electricity meter, and is used to quickly locate the corresponding index entry in the traceability and location table. It includes at least the user identifier and the electricity meter number.
[0063] For example, the third composite keyword refers to a composite identifier constructed based on the user identifier and meter number in the second field, used for precise matching in the traceability and location table.
[0064] For example, the target composite keyword refers to the composite identifier determined after matching with the third composite keyword in the traceability positioning table.
[0065] In this example, the received query request is parsed and two core fields used to uniquely identify the traceability target are extracted: the user identifier of the user to be queried and its corresponding meter number. Then, the strings of these two fields are concatenated to generate a standard-format compound string, which is the third compound keyword.
[0066] For example, upon receiving a query request, the user identifier "User001" and the meter number "Meter12345" are extracted. The "user identifier" and the "meter number" are concatenated to obtain the third compound keyword "User001-Meter12345".
[0067] Using the third composite keyword as the query key, a key-value lookup operation is performed in the traceability table stored in the in-memory database. After successfully matching the corresponding target index entry, two core hash values are extracted from the entry's data structure: the first is the block hash that records the block hash associated with the keyword, which is the target block hash value; the second is the block hash that points to the last occurrence position of the keyword, which is the previous block hash value.
[0068] For example, using "User001-Meter12345" as the key, a target index entry is found in the trace location table. From this entry, the target block hash value "0xHash888" (representing the latest record in block #888) and the previous block hash value "0xHash750" (representing the last related record in block #750) are extracted.
[0069] An iterative backtracking loop is initiated, using the hash value of the previous block extracted in the previous step as the initial input. In each iteration, the current hash value is first recorded. Then, based on this hash value, the corresponding historical block is located on the blockchain, and the hash value of the previous related block is retrieved from the block's record or associated index—the new "previous block hash value." This newly acquired hash value is then used as the input for the next iteration. This loop continues until the previous block hash value obtained in a certain iteration is NULL, indicating that the backtracking has reached the starting point of the tracing chain, and the iterative query process terminates.
[0070] For example, in the first iteration: the input is "0xHash750". "0xHash750" is recorded, and then, through some means (querying the record for block #750 or querying the index again in the table), its corresponding previous block hash value is found to be "0xHash600". In the second iteration: the input is updated to "0xHash600". "0xHash600" is recorded, and its corresponding previous block hash value is found to be NULL. Termination: Since the obtained hash value is empty, the iterative query stops. During this process, a hash sequence is recorded: ["0xHash750", "0xHash600"].
[0071] The target block hash value obtained in the initial location step, along with all the previous block hash values recorded during the iterative backtracking query, are compiled into a unified list. Then, based on the inherent pointing relationship between them established through hash pointers from newest to oldest, all hash values in the list are sorted in reverse chronological order. This sorted sequence of block hash values, from the earliest genesis block or starting record block to the latest record block, is ultimately determined as the complete cross-block tracing link.
[0072] For example, the initially located target block hash value "0xHash888" is combined with the hash sequence ["0xHash750", "0xHash600"] obtained from the iterative query to obtain ["0xHash888", "0xHash750", "0xHash600"]. After sorting in reverse order according to time, the final cross-block tracing link is: "0xHash600" → "0xHash750" → "0xHash888".
[0073] According to the above implementation method, firstly, a second field containing user identifier, operation type, and operation timestamp is obtained from the query request, and a fourth composite key is constructed based on this. Then, along the established cross-block tracing link, the corresponding data bucket is quickly located in each block using the fourth composite key in the multi-bucket index structure, and data buckets that do not contain target electricity consumption data are filtered out through existence checks. If the target data bucket is confirmed to be valid, a sorting key is further constructed using the user identifier and operation timestamp. An ordered traversal and key-value comparison are performed in the self-balancing binary search tree maintained by the target data bucket to accurately locate the target node that meets the query constraints. Finally, triplet data is extracted from the target node as the target tracing result. In this way, the data extraction process within a block is transformed from unordered traversal to a two-level query mode of "index bucket location + ordered structure retrieval." This not only reduces the access scope of irrelevant data within the block but also achieves precise matching of the time and user dimensions by leveraging the logarithmic retrieval performance of the self-balancing binary search tree. This significantly improves the efficiency and accuracy of data extraction within the block and further enhances the real-time performance and scalability of the overall tracing query.
[0074] In one implementation, based on the second field and the multi-bucket index structure, intra-block data extraction is performed on each block in the cross-block tracing link to obtain the target tracing result. This includes: obtaining the second field from the query request, wherein the second field includes the user identifier, operation type, and operation timestamp of the user to be queried; determining the fourth composite key based on the operation type and user identifier; locating the target data bucket in the multi-bucket index structure of each block in the cross-block tracing link based on the fourth composite key; performing an existence judgment operation on the target data bucket to determine whether the target data bucket contains the target electricity consumption data corresponding to the second field; if it is determined that the target data bucket contains the target electricity consumption data, performing the following data extraction operation: constructing a sorting key based on the user identifier and operation timestamp; traversing the self-balancing binary search tree maintained by the target data bucket, and comparing the sorting key with the node key value corresponding to each node in the self-balancing binary search tree during the traversal process to obtain the target node that satisfies the constraint condition of the second field; extracting the triplet data stored in the target node to obtain the target tracing result.
[0075] For example, the fourth composite keyword refers to a composite identifier formed by combining the user identifier and operation type in the triplet data, which is used to quickly locate the target data bucket in the multi-bucket index structure within the block, so as to achieve efficient retrieval of data for a specific user and a specific operation category.
[0076] For example, the target data bucket refers to the set of triplet data aggregated and stored according to the fourth composite key in the multi-bucket index structure within the block. It is used to carry all relevant triplet records for a specific user and operation type, and serves as the positioning unit for subsequent data extraction within the block.
[0077] In this example, the query request is parsed and the fields "Operation Type" and "User Identifier" are extracted. Then, based on the multi-bucket index's preset keyword generation rules (i.e., the operation type is appended with a prefix of the user identifier), these two fields are combined into a fourth composite keyword. Subsequently, each block in the cross-block tracing chain is traversed. Within each block, this fourth composite keyword is used as the index key to search within its multi-bucket index structure to precisely locate the target data bucket uniquely corresponding to that keyword.
[0078] For example, the operation type "Modify" and the user identifier "User001" are extracted from the query request. Based on the rule of "operation type - first two digits of user ID", the fourth compound key is determined to be "Modify-Us". Then, in the multi-bucket index structure of the first block in the cross-block tracing chain (e.g., block #888), the target data bucket with the key "Modify-Us" is found.
[0079] In this example, after locating the target data bucket, the Bloom filter configured for that bucket is invoked to perform a quick existence check. This operation inputs the core keywords from the query request (such as the combination of "user ID-meter number") into the Bloom filter. The Bloom filter calculates a set of bit array indices using multiple internal hash functions and checks the values at these index positions. If any position is 0, it is determined that the target electricity data absolutely does not exist in the bucket, and subsequent queries for that bucket are terminated; if all positions are 1, it is determined that the target electricity data exists in the bucket, and the process proceeds to the next step of the precise search process.
[0080] For example, the core keyword "User001-Meter12345" is input into the Bloom filter of the located target data bucket. After the Bloom filter calculates, it checks bits 120, 256, 389, and 512 of its internal bit array and finds that the values at these positions are all 1. Therefore, the conclusion after performing the existence check is "exists," allowing the next step of a precise search.
[0081] In this example, after filtering using a Bloom filter, a sorting key is first constructed based on the user identifier and operation timestamp in the query request, ensuring it perfectly matches the node key-value format of a self-balancing binary search tree (red-black tree). Then, within the red-black tree maintained inside the target data bucket, this sorting key is used to perform efficient binary search or range search operations. During tree traversal, by comparing the query sorting key with the key values of each node, one or more target nodes that fully satisfy the time and user constraints in the query request are precisely located. Finally, using pointers stored within the target node, the associated and complete E-PROV triplet data is extracted. This E-PROV triplet data is the final target tracing result obtained from this block data extraction operation.
[0082] For example, based on the user identifier "User001" and the operation timestamp "2025-10-01 14:05:30", a sort key "202510011405-User001" is constructed. Then, a search is performed in the red-black tree of the target data bucket. By comparing logarithmic time complexity, the target node whose key value completely matches the sort key is located. Finally, the complete E-PROV triplet data pointed to by the target node is extracted, which is the target source result of this query.
[0083] According to the above implementation method, firstly, a second field containing user identifier, operation type, and operation timestamp is obtained from the query request, and a fourth composite key is constructed based on this. Then, along the established cross-block tracing link, the corresponding data bucket is quickly located in each block using the fourth composite key in the multi-bucket index structure, and data buckets that do not contain target electricity consumption data are filtered out through existence checks. If the target data bucket is confirmed to be valid, a sorting key is further constructed using the user identifier and operation timestamp. An ordered traversal and key-value comparison are performed in the self-balancing binary search tree maintained by the target data bucket to accurately locate the target node that meets the query constraints. Finally, triplet data is extracted from the target node as the target tracing result. In this way, the data extraction process within a block is transformed from unordered traversal to a two-level query mode of "index bucket location + ordered structure retrieval." This not only reduces the access scope of irrelevant data within the block but also achieves precise matching of the time and user dimensions by leveraging the logarithmic retrieval performance of the self-balancing binary search tree. This significantly improves the efficiency and accuracy of data extraction within the block and further enhances the real-time performance and scalability of the overall tracing query.
[0084] In one implementation, the existence determination operation for the target data bucket includes: performing a hash mapping operation on the Bloom filter configured in the target data bucket based on the fourth composite key to obtain multiple mapping bits; determining the value status of each mapping bit in the bit array; if the value of any mapping bit is a preset negative value, determining that the target data bucket does not contain the target electricity consumption data corresponding to the second field; if the values of each mapping bit are preset positive values, determining that the target data bucket contains the target electricity consumption data corresponding to the second field.
[0085] For example, first, the core keyword used for existence determination, namely the fourth composite keyword, is obtained from the query request. Then, this keyword is used as input and sequentially passed to each independent hash function (e.g., four Message-Digest Algorithm 5 (MD5) variant hash functions) within the Bloom filter configured in the target data bucket. Each hash function performs a hash calculation on the keyword string and generates an integer value. A modulo operation is performed on this integer value, with the modulus being the length of the bit array within the Bloom filter; the result is an index pointing to a specific position in the bit array. By executing all hash functions, a set of mapped bits, consisting of multiple index positions, corresponding to the keyword, is finally obtained.
[0086] For example, the fourth composite key is obtained as "User001-Meter12345". This key is sequentially input into the four hash functions of the target data bucket Bloom filter. After calculation and modulo operation, a set of mapping bits (index positions) is obtained: [120, 256, 389, 512].
[0087] For example, the state of the internal bit array of the Bloom filter for the target data bucket is queried based on the set of mapped bits. Specifically, each index position in the set is traversed, and the binary value stored in the bit array at that index position is read. This binary value represents the value state of the mapped bit.
[0088] For example, based on the mapped bit set [120, 256, 389, 512], query the value status of the bit array: the value of the bit array at index 120 is 1; the value of the bit array at index 256 is 1; the value of the bit array at index 389 is 1; the value of the bit array at index 512 is 1.
[0089] For example, a logical check is performed on the value states of all mapped bits. If the check finds that at least one value in the set of value states is a preset negative value (usually the binary value "0"), a determination is immediately made based on the deterministic negation principle of the Bloom filter. The determination conclusion is: the target data bucket does not contain the target electricity consumption data corresponding to the query keyword, and the query process immediately terminates further access to that bucket.
[0090] For example, suppose in another query the mapping bits are [150, 280, 400, 600]. After the query, it is found that the bit array at index 280 has the preset negative value 0. Although other positions may be 1, because any mapping bit is 0, it is immediately determined that the target data is not included in the bucket, and the result "not found" is returned directly, avoiding the subsequent red-black tree search.
[0091] If, after checking the values of all mapped bits, every value in the set is found to be a preset positive value (usually the binary value "1"), a preliminary judgment is made based on the probabilistic affirmative principle of the Bloom filter. The judgment conclusion is: the target data bucket contains the target electricity consumption data corresponding to the query keyword. This judgment then triggers the next step of the precise search process, namely, final confirmation within the self-balancing binary search tree inside the bucket.
[0092] According to the above implementation method, firstly, multiple hash mappings are performed on the Bloom filter based on the fourth composite key to obtain multiple corresponding mapping bits. Then, the value status of each mapping bit in the bit array is detected. When any mapping bit is a preset negative value, it is directly determined that the target data bucket does not contain the target electricity consumption data corresponding to the second field. When all mapping bits are preset positive values, it is determined that the target data bucket may contain the target electricity consumption data, thus entering the subsequent data extraction process. In this way, the filtering of target data buckets can be completed quickly, effectively avoiding invalid traversal of obviously irrelevant data buckets. Furthermore, by utilizing the efficient space utilization and constant-time determination characteristics of the Bloom filter, the computational overhead and access latency of intra-block queries are significantly reduced, thereby further improving the overall efficiency of source tracing queries.
[0093] In one implementation, target tracing results are sent to the target user, wherein the target tracing results include user identifier, meter number, timestamp, operation behavior data, and agent identifier.
[0094] Specifically, first, the one or more triples extracted in the previous steps undergo final semantic parsing and formatting. This process involves extracting key traceability information fields from the three core elements: entity, activity, and agent. Examples include user identifier, meter number, timestamp of the operation, specific operation data, and the agent identifier that initiated the action. Then, these extracted fields are integrated into a standardized data format (such as a JavaScript Object Notation (JSON) object or a formatted report). Finally, the standardized data format (i.e., the target traceability result) is sent to the target user who initiated the query through a pre-defined communication channel (such as a secure API response, encrypted email, or data push from a front-end page).
[0095] For example, after completing the source tracing query of the data tampering behavior of user User001, the following key information fields are parsed and extracted from the finally located triple data: User ID: "User001"; Meter number: "Meter12345"; Timestamp: "2025-10-01 14:05:30"; Operation behavior data: {Operation type: "Modify", Starting hash from_hash: "0xdef...", Ending hash to_hash: "0x789..."}; Proxy ID: "ThirdPartyA". Subsequently, this information is integrated into a target tracing result in JSON format: {"userId": "User001", "meterId": "Meter12345", "timestamp": "2025-10-01 14:05:30", "activity": {"type": "Modify", "from_hash": "...", "to_hash": "..."}, "agentId": "ThirdPartyA"}. Finally, this JSON data is sent as the response body of the API call to the front-end application interface of the target user who initiated the query.
[0096] Figure 2 This is a structural block diagram of an electricity data traceability device according to an embodiment of the present invention.
[0097] like Figure 2 As shown, the electricity consumption data traceability device may include: The model invocation module 510 is used to invoke a preset power traceability model to standardize and model the electricity consumption data of each user, obtain each triplet data, and store each triplet data on the blockchain. The composite index structure construction module 520 is used to construct a composite index structure based on the first field in each of the triplet data, wherein the composite index structure includes a traceability table and a multi-bucket index structure; The cross-block positioning module 530 is used to respond to the query request of the target user, perform cross-block positioning based on the second field in the query request and the traceability positioning table, and obtain the cross-block tracing link; The block data extraction module 540 is used to perform block data extraction on each block in the cross-block tracing link according to the second field and the multi-bucket index structure to obtain the target tracing result; The traceability result distribution module 550 is used to distribute the target traceability result to the target user, wherein the target traceability result includes user identifier, meter number, timestamp, operation behavior data and agent identifier.
[0098] In one implementation, the model invocation module includes: The electricity user acquisition unit is used to acquire the electricity consumption data of each user, wherein the electricity consumption data includes historical electricity consumption data, operation behavior data that causes the status of the historical electricity consumption data to change, and operation subject data; The mapping unit is used to call the power traceability model to map the historical electricity consumption data into entities, the operation behavior data into activities, and the operation subject data into agents for each user, so as to obtain the entities, activities, and agents corresponding to each user. The semantic association link establishment unit is used to establish semantic association links between entities, activities and agents corresponding to each user through the standard semantic relation words of the power traceability model, and obtain each triple data.
[0099] In one implementation, the composite index structure construction module includes: The first acquisition unit is used to acquire the first field from each of the triplet data from the blockchain, wherein the first field includes user identifier, meter number, first block hash value, and operation type; The first composite keyword determination unit is used to determine the first composite keyword based on the user identifier and the meter number, so as to obtain each first composite keyword; The first search unit is used to search for a second block hash value that has a pointing relationship with the first block hash value for each of the first composite keywords, based on the derivation relationship between the triplet data, and to use the first composite keyword, the first block hash value and the second block hash value as an index entry to obtain each index entry; The traceability positioning table determination unit is used to determine the traceability positioning table based on each of the index entries; A multi-bucket index structure construction unit is used to group and store each triplet data based on each user identifier and each operation type to construct the multi-bucket index structure. An associated storage unit is used to associate and store the multi-bucket index structure and the traceability table to obtain the composite index structure.
[0100] In one embodiment, the multi-bucket index structure construction unit includes: The second composite keyword subunit is used to determine the second composite keyword based on the user identifier and the operation type, so as to obtain each of the second composite keywords; The grouping subunit is used to group the triplet data based on each of the second composite keywords to obtain the grouped triplet data. The storage subunit is used to store the grouped triplet data in different data buckets to construct the multi-bucket index structure.
[0101] In one embodiment, the cross-block positioning module includes: The second acquisition unit is used to acquire the second field in the query request, wherein the second field includes the user identifier and meter number of the user to be queried; The third composite keyword determination unit is used to determine the third composite keyword based on the user identifier and meter number of the user to be queried. The second search unit is used to search for a composite keyword that matches the third composite keyword from the traceability and positioning table to obtain the target composite keyword; The hash value extraction unit is used for initial querying, extracting the target block hash value and the previous block hash value that has a pointing relationship with the target block hash value from the target index entry where the target composite keyword is located; An iterative extraction unit is used to use the previous block hash value as the target block hash value for the next round of query, so as to extract the previous block hash value that has a pointing relationship with the target block hash value from the traceability positioning table; The hash value mapping unit is used to stop the iterative query when the hash value of the previous block is empty, and to map the hash values of each target block obtained during the query process to each previous block hash value according to the pointing relationship, so as to construct the cross-block tracing link.
[0102] In one embodiment, the data extraction module within the block includes: The third acquisition unit is used to acquire the second field in the query request, wherein the second field includes the user identifier, operation type and operation timestamp of the user to be queried; The fourth compound keyword determination unit is used to determine the fourth compound keyword based on the operation type and the user identifier; The positioning unit is used to locate the target data bucket in the multi-bucket index structure of the block based on the fourth composite keyword for each block in the cross-block tracing link. An existence determination unit is used to perform an existence determination operation on the target data bucket to determine whether the target data bucket contains target electricity consumption data corresponding to the second field; The data extraction unit is configured to perform the following data extraction operation when it is determined that the target data bucket contains the target electricity consumption data: A sorting key construction subunit is used to construct a sorting key based on the user identifier and the operation timestamp; The comparison subunit is used to traverse and locate the self-balancing binary search tree maintained by the target data bucket, and compare the sort key with the node key value corresponding to each node in the self-balancing binary search tree during the traversal process to obtain the target node that satisfies the second field constraint condition. The triplet data extraction subunit is used to extract the triplet data stored in the target node to obtain the target tracing result.
[0103] In one embodiment, the existence determination unit includes: The hash mapping subunit is used to perform a hash mapping operation on the Bloom filter configured in the target data bucket based on the fourth composite key to obtain multiple mapping bits; The judgment subunit is used to determine the value status of each of the mapped bits in the bit array; Determining that no sub-units are included is used to determine that the target data bucket does not contain the target electricity consumption data corresponding to the second field when any mapping bit takes the value of a preset negative value. The sub-unit is determined to determine that the target data bucket contains target electricity consumption data corresponding to the second field, provided that the values of each of the mapping bits are preset positive values.
[0104] The specific functions and examples of each module and submodule of the system in this embodiment of the invention can be found in the relevant descriptions of the corresponding steps in the above method embodiments, and will not be repeated here.
[0105] The acquisition, storage, and application of user personal information involved in the technical solution of this invention all comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0106] This invention also provides an electronic device, comprising: At least one processor; and a memory communicatively connected to said at least one processor; The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the method described in any one of the embodiments of the present invention.
[0107] The beneficial effects of the electronic equipment in this embodiment of the invention are equivalent to the beneficial effects of the above-described electricity data tracing method, and will not be repeated here.
[0108] This invention also provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause a computer to perform the method described in any one of the embodiments of this invention.
[0109] The beneficial effects of the storage medium of the present invention are equivalent to the beneficial effects of the above-described method for tracing electricity data, and will not be repeated here.
[0110] Figure 3 A schematic block diagram of an example electronic device 800 that can be used to implement embodiments of the present invention is shown. Electronic device 800 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. Electronic device 800 may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0111] like Figure 3 As shown, the electronic device 800 includes a computing unit 801, which can perform various appropriate actions and processes based on a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. The RAM 803 may also store various programs and data required for the operation of the electronic device 800. The computing unit 801, ROM 802, and RAM 803 are interconnected via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0112] Multiple components in electronic device 800 are connected to I / O interface 805, including: input unit 806, such as keyboard, mouse, etc.; output unit 807, such as various types of displays, speakers, etc.; storage unit 808, such as disk, optical disk, etc.; and communication unit 809, such as network card, modem, wireless transceiver, etc. Communication unit 809 allows electronic device 800 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0113] The computing unit 801 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 801 performs the various methods and processes described above, such as the electricity data tracing method. For example, in some embodiments, the electricity data tracing method can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by the computing unit 801, one or more steps of the electricity data tracing method described above can be performed. Alternatively, in other embodiments, the computing unit 801 can be configured to perform the electricity data tracing method by any other suitable means (e.g., by means of firmware).
[0114] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0115] The program code used to implement the methods of the present invention can be written in any combination of one or more programming languages. This program code can be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing device, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code can be executed entirely on the machine, partially on the machine, as a standalone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0116] In the context of this invention, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0117] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0118] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0119] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0120] It should be understood that the various forms of processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this invention can be achieved, and this is not limited herein.
[0121] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for tracing electricity consumption data, characterized in that, include: The preset power traceability model is invoked to standardize and model the electricity consumption data of each user, obtain each triplet data, and store each triplet data on the blockchain. Based on the first field in each of the triplet data, a composite index structure is constructed, wherein the composite index structure includes a traceability table and a multi-bucket index structure; In response to the query request from the target user, cross-block positioning is performed based on the second field in the query request and the tracing and positioning table to obtain the cross-block tracing link; Based on the second field and the multi-bucket index structure, perform intra-block data extraction on each block in the cross-block tracing link to obtain the target tracing result; The target tracing result is sent to the target user, wherein the target tracing result includes user identifier, meter number, timestamp, operation behavior data, and agent identifier.
2. The method according to claim 1, characterized in that, The process involves calling a preset power tracing model to standardize and model the electricity consumption data of each user, resulting in various triplet data sets, including: Obtain electricity consumption data for each user, wherein the electricity consumption data includes historical electricity consumption data, operation behavior data that caused the status of the historical electricity consumption data to change, and operation subject data; For each user, the power traceability model is invoked to map the historical electricity consumption data to entities, the operation behavior data to activities, and the operation subject data to agents, so as to obtain the entities, activities, and agents corresponding to each user. Using the standard semantic relation words of the power traceability model, semantic association links are established between the entities, activities, and agents corresponding to each user to obtain the triple data.
3. The method according to claim 1, characterized in that, The first field in each of the triplet data is used to construct a composite index structure, wherein the composite index structure includes a traceability table and a multi-bucket index structure, including: Obtain the first field from each of the triplet data from the blockchain, wherein the first field includes user identifier, meter number, first block hash value, and operation type; Based on the user identifier and the meter number, a first composite keyword is determined to obtain various first composite keywords; For each of the first composite keywords, based on the derivation relationship between the triplet data, find the second block hash value that has a pointing relationship with the first block hash value, and use the first composite keyword, the first block hash value, and the second block hash value as an index entry to obtain each index entry; Based on each of the index entries, the traceability and location table is determined; Based on each user identifier and each operation type, the triplet data is grouped and stored to construct the multi-bucket index structure; The multi-bucket index structure and the traceability table are associated and stored to obtain the composite index structure.
4. The method according to claim 3, characterized in that, The step of grouping and storing the triplet data based on each user identifier and each operation type to construct the multi-bucket index structure includes: Based on the user identifier and the operation type, a second composite keyword is determined to obtain each of the second composite keywords; Based on each of the second composite keywords, the triplet data are grouped to obtain the grouped triplet data. The grouped triples are stored in their respective buckets to construct the multi-bucket index structure.
5. The method according to claim 1, characterized in that, The step of performing cross-block location based on the second field in the query request and the traceability table to obtain the cross-block tracing link includes: Obtain the second field from the query request, wherein the second field includes the user identifier and meter number of the user to be queried; Based on the user identifier and meter number of the user to be queried, a third composite keyword is determined; The target composite keyword is obtained by searching the traceability and positioning table for a composite keyword that matches the third composite keyword. The initial query extracts the target block hash value and the previous block hash value that has a pointing relationship with the target block hash value from the target index entry where the target composite keyword is located; The previous block hash value is used as the target block hash value for the next round of query, so as to extract the previous block hash value that has a pointing relationship with the target block hash value from the traceability and positioning table; If the hash value of the previous block is empty, the iterative query stops, and the hash values of each target block obtained during the query process are mapped to the hash values of each previous block according to the pointing relationship, so as to construct the cross-block tracing link.
6. The method according to claim 1, characterized in that, The step of extracting intra-block data from each block in the cross-block tracing chain based on the second field and the multi-bucket index structure to obtain the target tracing result includes: Obtain the second field from the query request, wherein the second field includes the user identifier, operation type, and operation timestamp of the user to be queried; Based on the operation type and the user identifier, a fourth composite keyword is determined; For each block in the cross-block tracing link, the target data bucket is located in the multi-bucket index structure of the block based on the fourth composite keyword; An existence check operation is performed on the target data bucket to determine whether the target data bucket contains target electricity consumption data corresponding to the second field. If it is determined that the target data bucket contains the target electricity consumption data, the following data extraction operation is performed: construct a sorting key based on the user identifier and the operation timestamp; traverse and locate the self-balancing binary search tree maintained by the target data bucket, and compare the sorting key with the node key value corresponding to each node in the self-balancing binary search tree during the traversal process to obtain the target node that satisfies the second field constraint condition; Extract the triplet data stored in the target node to obtain the target tracing result.
7. The method according to claim 6, characterized in that, The existence check operation performed on the target data bucket includes: Based on the fourth composite keyword, a hash mapping operation is performed on the Bloom filter configured in the target data bucket to obtain multiple mapping bits; Determine the value status of each of the mapped bits in the bit array; If any mapping bit takes the value of a preset negative value, it is determined that the target data bucket does not contain the target electricity consumption data corresponding to the second field; If the values of each of the mapping bits are all preset positive values, it is determined that the target data bucket contains the target electricity consumption data corresponding to the second field.
8. An electricity consumption data traceability device, characterized in that, include: The model invocation module is used to invoke a preset power traceability model to standardize and model the electricity consumption data of each user, obtain each triplet data, and store each triplet data on the blockchain. A composite index structure construction module is used to construct a composite index structure based on the first field in each of the triplet data, wherein the composite index structure includes a traceability table and a multi-bucket index structure; The cross-block location module is used to respond to the query request of the target user, perform cross-block location based on the second field in the query request and the traceability location table, and obtain the cross-block tracing link; The block data extraction module is used to perform block data extraction on each block in the cross-block tracing link according to the second field and the multi-bucket index structure to obtain the target tracing result; The traceability result distribution module is used to distribute the target traceability result to the target user, wherein the target traceability result includes user identifier, meter number, timestamp, operation behavior data, and agent identifier.
9. An electronic device, characterized in that, include: At least one processor; and a memory communicatively connected to the at least one processor; The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-7.
10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-7.
Citation Information
Patent Citations
CN115186010A
CN120179650A
US20250139109A1