Light node storage and query method, device and equipment for supply chain traceability data

By adopting a light node storage method in the blockchain and managing supply chain traceability data based on temperature weights, the problem of poor scalability and low throughput of blockchain in supply chain traceability data storage and query is solved, and the data is realized Quick query and storage pressure relief.

CN118193633BActive Publication Date: 2024-11-12BEIJING RES CENT FOR INFORMATION TECH & AGRI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410197029.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-02-22
Publication Date
2024-11-12
Estimated Expiration
2044-02-22

AI Technical Summary

Technical Problem

Blockchain has problems such as poor scalability and low throughput in supply chain traceability data storage and query, resulting in storage bottlenecks and difficult to meet the needs of the entire supply chain.

Method used

The light node storage method is adopted to store or delete data based on the temperature weight (correlation, generation time and access frequency) of the data, and divide the data into hot data, temperature data and cold data. The light node stores hot data and selectively store it. Temperature data and delete cold data to reduce storage pressure on blockchain.

Benefits of technology

It improves the processing speed of data queries, reduces the storage pressure of blockchain, ensures data security, and realizes rapid querying, improving query processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118193633B_ABST
    Figure CN118193633B_ABST
Patent Text Reader

Abstract

The present invention provides a light node storage and query method, device and equipment for supply chain traceability data, the method comprising: the light node determines whether target data satisfying the query condition is stored locally based on the query condition input by the user; if it is determined that the target data satisfying the query condition is stored locally, the query result is returned to the user based on the target data; otherwise, if it is determined that the target data satisfying the query condition is not stored locally, the target data is requested from the full node and the query result is returned to the user based on the target data; wherein the light node stores or deletes the data based on the temperature weight of the data, and the temperature weight of the data is determined based on the correlation between the data and the participant corresponding to the light node in the supply chain link, the generation time of the data, and the access frequency of the data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain technology, and in particular to a light node storage and query method, device and equipment for supply chain traceability data. Background Art

[0002] For the supply chain of goods, there are many participants and a large amount of traceability data, which are stored and queried through the blockchain network. However, the poor scalability and low throughput of blockchain have always been a difficult problem to solve. In addition, the insufficient storage performance of blockchain itself can no longer meet the needs of tracing data storage in the entire supply chain, and it is easy to encounter storage bottlenecks. Therefore, how to improve the processing speed of supply chain transaction queries and reduce the storage pressure of blockchain are technical problems that need to be solved. Summary of the invention

[0003] In view of the problems existing in the prior art, the present invention provides a light node storage and query method, device and equipment for supply chain traceability data.

[0004] In a first aspect, the present invention provides a light node storage and query method for supply chain traceability data, which is applied to a light node and includes:

[0005] Based on the query conditions input by the user, determining whether target data satisfying the query conditions is stored locally;

[0006] If it is determined that the target data that meets the query condition is stored locally, the query result is returned to the user based on the target data; otherwise, if it is determined that the target data that meets the query condition is not stored locally, the target data is requested from the full node and the query result is returned to the user based on the target data;

[0007] Among them, the light node stores or deletes data based on the temperature weight of the data, and the temperature weight of the data is determined based on the correlation between the data and the participant corresponding to the light node in the supply chain link, the generation time of the data, and the access frequency of the data.

[0008] In some embodiments, the temperature weight of the data is calculated as follows:

[0009] W=T temperature +α*T time +F

[0010] Wherein, W represents the temperature weight of the data; T temperature represents the correlation temperature of the data, which is used to characterize the correlation between the data and the participants corresponding to the light node in the supply chain; α represents the coefficient of the time temperature of the data changing with time, T timerepresents the initial value of the time temperature of the data, and the time temperature of the data is used to characterize the time when the data was generated; F represents the access frequency of the data.

[0011] In some embodiments, the correlation temperature of the data is selected from a plurality of predefined candidate values, and the selection rule is:

[0012] The correlation temperature value of the data of the same link corresponding to the participant is the maximum value among the multiple candidate values; the farther the link is from the participant, the smaller the correlation temperature value of the data of the corresponding link; under the same distance, the correlation temperature value of the data of the downstream link is larger.

[0013] In some embodiments, in the first set time period after the data is generated, the value of α is an initial value, and the value of α decreases once each set time period.

[0014] In some embodiments, the access frequency of the data is determined based on the number of times the data is queried within a set time unit.

[0015] In some embodiments, storing or deleting data based on the temperature weight of the data includes:

[0016] Based on the temperature weight of the data, the data is divided into hot data, warm data or cold data; wherein the hot data is data whose temperature weight is greater than or equal to a first threshold, the warm data is data whose temperature weight is greater than or equal to a second threshold and less than the first threshold, and the cold data is data whose temperature weight is less than the second threshold;

[0017] For the hot data, the light node stores it; for the warm data, the light node selectively stores it; for the cold data, the light node does not store it or deletes it.

[0018] In a second aspect, the present invention further provides a light node storage and query device for supply chain traceability data, which is applied to a light node and includes:

[0019] A determination module, used to determine whether there is target data satisfying the query condition stored locally based on the query condition input by the user;

[0020] A query module, configured to return the query result to the user based on the target data if it is determined that the target data that meets the query condition is stored locally; otherwise, if it is determined that the target data that meets the query condition is not stored locally, request the target data from the full node and then return the query result to the user based on the target data;

[0021] Among them, the light node stores or deletes data based on the temperature weight of the data, and the temperature weight of the data is determined based on the correlation between the data and the participant corresponding to the light node in the supply chain link, the generation time of the data, and the access frequency of the data.

[0022] In a third aspect, the present invention also provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein when the processor executes the program, the light node storage and query method for supply chain traceability data as described in the first aspect above is implemented.

[0023] In a fourth aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the light node storage and query method for supply chain traceability data as described in the first aspect above.

[0024] In a fifth aspect, the present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements a light node storage and query method for supply chain traceability data as described in any one of the above.

[0025] The light node storage and query method, device and equipment for supply chain traceability data provided by the present invention utilize light nodes to store part of the relevant supply chain data, and the light nodes store data based on the temperature weight of the supply chain data, which not only reduces the storage pressure of the blockchain and ensures data security, but also is more conducive to realizing rapid data query and effectively improves the efficiency of query processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions in the present invention or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0027] Figure 1 A schematic diagram of the flow of the light node storage and query method for supply chain traceability data provided by the present invention;

[0028] Figure 2 A flow chart of the wheat supply chain provided by the present invention;

[0029] Figure 3 An example diagram of the data temperature assessment process provided by the present invention;

[0030] Figure 4 An example diagram of the Bloom filter query preprocessing process provided by the present invention;

[0031] Figure 5 An example diagram of the Bloom filter provided by the present invention;

[0032] Figure 6 An example diagram of the light node storage query process provided by the present invention;

[0033] Figure 7 An example diagram of the light node verification process provided by the present invention;

[0034] Figure 8 A schematic diagram of the structure of a light node storage and query device for supply chain traceability data provided by the present invention;

[0035] Fig. 9 This is a schematic structural diagram of an electronic device provided by the present invention. DETAILED DESCRIPTION

[0036] In the present invention, the term "and / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.

[0037] In the present invention, the term "plurality" refers to two or more than two, and other quantifiers are similar to them.

[0038] In the present invention, the terms "first", "second", etc. are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present invention can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first" and "second" are generally of the same type, and the number of objects is not limited. For example, the first object can be one or more.

[0039] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0040] Traditional light nodes only store part of the block header information and only perform simple transaction verification and query. The block header includes important information such as the block's hash, timestamp, difficulty target, and Merkle root. When a new transaction is received, it requests the Merkle proof of the relevant block from the full node, and sends a query request for a specific transaction or address to the full node as needed. Although traditional light nodes only verify block header information, they still need to request transaction data from the full node when tracing the source, and return it to the light node, which reduces the efficiency of data query. The present invention designs a method to reduce the storage pressure of a single node and query efficiently and quickly.

[0041] Figure 1 A schematic diagram of a light node storage and query method for supply chain traceability data provided by the present invention, which is applied to light nodes, such as Figure 1 As shown, the method comprises the following steps:

[0042] Step 100: Based on the query conditions input by the user, determine whether there is target data satisfying the query conditions stored locally.

[0043] Step 101: If it is determined that the target data that meets the query conditions is stored locally, the query results are returned to the user based on the target data; otherwise, if it is determined that the target data that meets the query conditions is not stored locally, the target data is requested from the full node and the query results are returned to the user based on the target data; wherein the light node stores or deletes the data based on the temperature weight of the data, and the temperature weight of the data is determined based on the correlation between the data and the participant corresponding to the light node in the supply chain link, the generation time of the data, and the access frequency of the data.

[0044] Specifically, for ease of understanding, the various embodiments of the present invention are described using the wheat supply chain as an example. It should be understood that, in addition to the wheat supply chain, other commodity supply chains can also apply the technical solution provided by the present invention, and the present invention is not limited to this.

[0045] The present invention utilizes light node storage to reduce the storage pressure of the entire blockchain network. In some implementations, 30% of full nodes and 70% of light nodes can be set, with full nodes storing all data and light nodes storing some of the hottest data.

[0046] For the participants, if participants from different departments of the same enterprise join the blockchain as light nodes to query relevant link information, the technical solution proposed by the present invention can greatly improve the efficiency of data query while reducing storage pressure. According to the characteristics of the production process of wheat supply chain traceability, distributed storage of data in each link is carried out, and the probability of data in each link being queried is different. For the planting link data, the probability of data being queried by growers is extremely high, while the probability of data query in the subsequent links is extremely low. Therefore, the weight level of the data is set according to factors such as the role and time of the participants. Each participant stores the hottest data that is most relevant to himself, and the regulator can query all data. In this way, the purpose of fast query can be achieved while reducing storage pressure. And privacy is stronger, which can protect the privacy information of the supply chain. Thereby achieving the purpose of reducing the overall storage pressure of the entire blockchain network, while ensuring security, each participant stores part of the hottest data.

[0047] Take the wheat supply chain as an example. Figure 2 The wheat supply chain process flow chart provided by the present invention is as follows: Figure 2 As shown, the wheat supply chain can be divided into six major links: planting, storage, processing, warehousing, logistics (transportation), and sales.

[0048] Among them, the planting link includes the basic information of the growers, planting methods, contact information, the name of the planting base, etc., as well as environmental information, crop information, etc. The storage link includes three links: purchase, impurity removal, and storage. The purchase includes the information of the growers, the pesticide sampling records at the time of purchase, the origin of wheat, the purchase time, the wheat type, the purchase location, the storage enterprise information, etc. The impurity removal link includes the type of impurities, the amount of impurities, the impurity removal rate and other information. The processing link includes four processes: wheat tempering, flour grinding, flour blending, and packaging. The warehousing link includes the name and address of the warehousing enterprise, the corporate legal person information, the warehousing administrator information, price information, etc. The transportation link includes the name of the logistics enterprise, the address of the logistics company, the information of the person in charge of transportation, the license information, the contact information of the person in charge, the means of transportation, the tool number (license plate number), the departure place, time, destination, arrival time, etc., as well as the temperature and hygiene conditions inside the transportation vehicle, the temperature and humidity, and the transportation cost. The last part is the sales link, which includes the merchant name, store address, person in charge information, business license information, merchant contact information, product name, product quantity, purchase time, product storage time, product storage location, purchase number, shipping time, as well as basic information and health conditions, sales photos, purchase price and selling price and other information.

[0049] The data from the planting stage is collected by agricultural sensors, data acquisition equipment, and communication equipment, and is transmitted to the blockchain through the Internet of Things platform; the crops are purchased, cleaned, and then stored in the storage stage, and the data of this stage is uploaded to the blockchain; then it enters the crop processing stage, which involves moistening the wheat, grinding, blending, and packaging, and then the data of the four parts of this stage are uploaded to the blockchain data layer; the data from the warehousing stage includes the basic information of the warehousing enterprise, hazard information, environmental testing information, transaction records, and price information, which also need to be uploaded to the blockchain; then logistics transmission is carried out, and the logistics enterprise and transportation-related information are uploaded to the blockchain; the final sales stage is from distributors to dealers, and finally purchased by consumers, and the data of the last stage is uploaded to the blockchain data layer.

[0050] In the present invention, data of each link is uploaded to the same block. After the data is stored on the chain, the data is broadcasted. After receiving the data, the light node determines the cold and hot temperature of the data (i.e., the temperature weight), decides whether to store it, and verifies the authenticity of the data. After the data cools down (for example, after the traceability product data expires six months according to relevant laws and regulations), it can be deleted. For example, data that expires six months later is set as cold data, and automatically deleted according to the time setting, replaced at the light node, and the latest data is requested again.

[0051] When a user queries, the light node client first determines whether the target data to be queried is stored locally based on the query conditions. If it does not exist, it requests the full node. In some implementations, the query condition is the product batch number id (identification), and the product batch number id is in the form of "product name + production batch number + link number", such as "sp20231205010A". For the entire traceability process, each light node client only queries the hottest data related to itself, which greatly protects the security of the data while reducing storage and improving queries.

[0052] In some implementations, the light node can perform data query preprocessing through a Bloom filter to quickly determine whether the data is stored locally. If not, a request is made to the full node. The full node can also quickly determine the data storage location through the Bloom filter.

[0053] The light node storage and query method for supply chain traceability data provided by the present invention utilizes light nodes to store part of the relevant supply chain data, and the light nodes store data based on the temperature weight of the supply chain data. This not only reduces the storage pressure of the blockchain and ensures data security, but is also more conducive to realizing rapid data query and effectively improving the efficiency of query processing.

[0054] Taking the wheat supply chain as an example, after the data collection of the first link is completed, it will be uploaded to the blockchain by a dedicated administrator. At this time, the data of the same link is stored in the same block. After data analysis, most of the data is stored in a small number of newly generated blocks. The product batch number id set by the present invention is in the form of "trade name + production batch number + link number", such as "sp20231205010A", and each block stores the data of one link, that is, the batch data of the link can be obtained in each cycle.

[0055] Light nodes decide whether to store data based on the time when the data is generated, the data relevance, and the frequency of queries. For the participants, for example, when a batch of products has a problem, the probability of being queried in a short time is higher. And for the inquirer of the data, the data is more likely to be queried by related participants and upstream and downstream data. Therefore, the present invention assigns different temperature weights to the data according to the identity of the participants, the time when the data is generated, and the frequency of queries.

[0056] In some embodiments, the temperature weight of the data is calculated as follows:

[0057] W=T temperature +α*T time +F

[0058] Where W represents the temperature weight of the data; T temperature It represents the correlation temperature of data. The correlation temperature of data is used to characterize the correlation between data and participants corresponding to light nodes in the supply chain. α represents the coefficient of the change of the time temperature of data over time. time It represents the initial value of the time temperature of the data. The time temperature of the data is used to characterize the time when the data was generated. F represents the access frequency of the data.

[0059] In some embodiments, the correlation temperature of the data is selected from a plurality of predefined candidate values, and the selection rule is:

[0060] The correlation temperature value of the data at the same link as the participant is the maximum value among multiple candidate values; the farther the link is from the participant, the smaller the correlation temperature value of the data at the corresponding link; under the same distance, the correlation temperature value of the data at the downstream link is larger.

[0061] For example, Table 1 shows the temperature assignment table of the data association. 1 ~T 6 The temperature values ​​are 12, 10, 8, 6, 4, and 2. The temperature of the relevant link (data and participants in the same link) is the highest, followed by the downstream link, and then decreases step by step.

[0062] Table 1 Data association temperature assignment table

[0063]

[0064] In some embodiments, in the first set period after data is generated, the value of α is an initial value, and the value of α decreases once each set period.

[0065] For example, assuming that the set period is 6 months, the initial value of α is 1, and the decreasing coefficient of α is set to 1 / 2, the initial value of α for data within 6 months is 1, the α for data within 6 to 12 months is 1 / 2, the α for data within 12 to 18 months is 1 / 4, the α for data within 18 to 24 months is 1 / 8, and so on, and α is multiplied by 1 / 2 for every additional 6 months. Assuming that the initial value of the time temperature of the data is 8, the time temperature of the data within half a year is 8, and after 6 months, the temperature drops to 4, showing a decreasing trend.

[0066] In some embodiments, the access frequency of data is determined based on the number of times the data is queried within a set time unit, that is, the higher the number of times the data is queried within a period of time, the higher its access frequency and the higher the popularity of the data.

[0067] For example, N is the number of times a batch of data ID is queried in one day, and t refers to the time unit of one day.

[0068] In some implementations, different F values ​​may be set for different frequency intervals, such as the following formula:

[0069]

[0070] When the data is queried more than or equal to 3 times in a day, F is set to 1, when it is less than 3 times, it is set to 0.5, and when it is not accessed, it is set to 0.

[0071] In some embodiments, storing or deleting data based on the temperature weight of the data includes:

[0072] Based on the temperature weight of the data, the data is divided into hot data, warm data or cold data; wherein hot data is data whose temperature weight is greater than or equal to a first threshold, warm data is data whose temperature weight is greater than or equal to a second threshold and less than the first threshold, and cold data is data whose temperature weight is less than the second threshold;

[0073] For hot data, light nodes store it; for warm data, light nodes selectively store it; for cold data, light nodes do not store it or delete it.

[0074] For example, assuming that the first threshold is set to 16 and the second threshold is set to 6, the data division can be as follows:

[0075]

[0076] When W≥16, it means that the data is the latest six months of data for the most relevant link, and it is the hottest data at this time; when 6≤W<16, it means that the data is more than six months old or has low relevance, and it is warm data at this time; W<6 means that the data relevance is extremely low and the data has expired, and it is cold data at this time.

[0077] After the light node divides the temperature level, if it is hot data, it can be stored locally. If it is warm data, it can be stored temporarily or deleted when the storage capacity is insufficient according to the storage intention. If it is cold data, it can be not stored or deleted. The light node can manage local data locally. Once the data becomes warm or cold, it can be deleted by itself. Cold data can be automatically deleted according to the time setting. Figure 3 Shown is an example diagram of the data temperature assessment process provided by the present invention.

[0078] The following is an exemplary introduction to the relevant technical implementation of the present invention by taking the wheat supply chain as an example.

[0079] 1. Network framework

[0080] The present invention is implemented using a blockchain network, and the scheme is designed as a blockchain. Eight organizations are involved in the blockchain network. The first organization is the planting link, which includes one node. Most of the data is directly uploaded by the Internet of Things device, and an administrator is used to maintain and upload the data; the second organization is the storage link, which includes three link nodes of procurement, impurity removal, and storage; the third organization is the processing link, which includes four link nodes of wheat tempering, flour grinding, flour blending, and packaging; the fourth organization is the warehousing link, which includes a node of the warehousing link; the fifth organization is the logistics link, which includes a node of the logistics transportation link; the sixth organization is the sales link, which includes two nodes of distributors and dealers; the seventh organization is the supply chain external data acquisition organization, which is mainly light nodes such as growers, storage parties, processors, warehousing parties, logistics parties, sellers, consumers and regulators; the eighth organization is a server organization, in which two server nodes are set.

[0081] 2. Information tracing

[0082] The wheat supply chain traceability information mainly includes planting-related data, fertilizer and pesticide usage, picking and irrigation information, a series of related information such as picking, storage and processing, logistics information, and final product sales data.

[0083] When the traceability data of the wheat supply chain is queried by the regulator, it can directly send a request to the full node, and the corresponding light node client will respond to the requests of the growers, storage parties, and processors. In this way, fast query can be achieved while reducing some storage pressure, and the light node only queries the traceability data that is directly related to itself, which can protect the privacy of the data to a great extent.

[0084] In specific implementation, we can first divide light nodes and full nodes according to the influence of factors such as node storage capacity, storage willingness, and network bandwidth, and wait for the supply chain data to be uploaded. After the upload is successful, the data will be broadcast to the blockchain. After receiving the data, the light node will divide the temperature level. If it is hot data, it will be stored locally. If it is warm data, it can be temporarily stored or deleted according to the storage willingness when the storage capacity is insufficient. If it is cold data, it can be deleted directly. When querying, the improved Bloom filter is first used for query preprocessing to enable it to quickly determine whether the data to be queried is stored locally on the light node. If it does not exist locally, a request is sent to the full node. The full node quickly locates the storage location through the Bloom filter, and can quickly determine which blocks the data to be queried may be located in. By assigning weights to the data generation time, access frequency, and data temperature, the hot data located in the light node represents the latest and highest temperature data, the warm data represents data that has been stored for more than six months but has not exceeded the shelf life, and the cold data refers to expired data. The light node can manage local data locally by itself. Once the data becomes warm or cold, it can be deleted by itself. The cold data can be set to automatically delete the mechanism according to time. By utilizing light node storage to implement fine-grained classified storage of wheat supply chain data, fast data query can be achieved while ensuring data security and reducing storage pressure.

[0085] 3. Bloom filter query preprocessing

[0086] Bloom filter is a data structure that determines whether an element exists in a set. The present invention uses Bloom filter to realize fast data query. The difference from traditional Bloom filter is that the present invention uses batch number id keyword of each link in the supply chain for filtering.

[0087] Figure 4 The Bloom filter query preprocessing process example diagram provided by the present invention is as follows: Figure 4As shown, first, when a light node user queries local data, the Bloom filter can be used to filter whether the data to be queried is stored locally. If not, a request is made to the full node. After receiving the request, the full node uses the Bloom filter of each block header to determine which blocks the data may exist in, that is, traverse all block headers according to the Bloom filter, narrow the query range from the possible blocks, determine which blocks the data may be stored in, and then traverse the narrowed blocks to return the corresponding data, thereby reducing the memory computing overhead.

[0088] Figure 5 The Bloom filter example diagram provided by the present invention is as follows: Figure 5 As shown, first extract the batch number id in the block body (the batch number uploaded in each link is different), perform a hash operation on the extracted keywords, perform a bitwise OR operation on the hash operation result value with Bloom, and obtain the corresponding filter.

[0089] The process of establishing a Bloom filter is as follows:

[0090] A. Initialization stage: create a 16-bit bit vector with all bits initialized to 0.

[0091] B. Adding elements: Map the elements to be added to the positions in the bit vector through a hash function. The present invention adds a Bloom filter to the block header information. Compared with the traditional Bloom filter, the present invention adds the batch number id of the transaction data to the Bloom filter, performs a hash operation on the batch id of the transaction data k=8 times, and then sets the keyword id%16 to obtain the data bit to 1.

[0092] C. Query elements: Map the elements to be queried, such as the batch ID of the product, to the positions mapped to the bit vector through the hash function, and check whether these positions are 1. If any bit is 0, the element does not exist in the Bloom filter; if all bits are 1, it is judged that the element may exist in the Bloom filter (with a false positive rate). Based on this judgment method, it can be judged that the data may be stored in certain blocks while allowing a certain error.

[0093] 4. Light node request data process

[0094] A. Establish a network connection: The light node and the full node establish a network connection by using the IP address and port number between the nodes.

[0095] B. Send a request message. After establishing a connection, the light node can send a request message to the full node, which contains the required specific information and request type, that is, each light node client requests the latest data that it needs to store.

[0096] C. Full node processing request: After receiving the request message from the light node, the full node will perform corresponding processing, such as verifying the identity of the light node.

[0097] D. Data transmission: When the full node confirms the validity of the request and there is corresponding data for the light node to obtain, it will transmit the required data to the light node. The transmission method can be direct transmission through the network protocol or creation of a specific data channel for interaction.

[0098] E. Light nodes receive data: Light nodes receive and process data, and perform corresponding verification, parsing or storage.

[0099] 5. Light node storage process

[0100] Figure 6 The light node storage query process example diagram provided by the present invention is as follows: Figure 6 As shown in the figure, the light node storage process mainly includes:

[0101] First, after the data is generated, it will be broadcast to the blockchain. At this time, the light node will verify the validity of the data after receiving it. If it is valid, the heat level of the data will be assessed; if the verification is invalid, it will be discarded directly. Then the level of the received data will be assessed. If it is hot data, that is, the latest data of the relevant link, it will be stored locally. If it is warm data, it can be temporarily stored locally. If it is cold data, it can be discarded directly. After the data temperature cools down, it can be deleted and updated. And set an automatic deletion mechanism, once the data expires for six months, it does not need to be stored locally. If there is a lot of data, you can select data with a lower temperature from the warm data to delete, so as to save space to store the current hotter data. The light node storage process is as follows:

[0102] 6. Light Node Verification Process

[0103] Figure 7 The light node verification process example diagram provided by the present invention is as follows: Figure 7 As shown in the figure, the light node verification process mainly includes:

[0104] A. The light node first synchronizes the block header information of the longest chain in the current blockchain to the full node, and stores the required specified content locally.

[0105] B. The light node calculates the hash value of the transaction to be verified and creates a Bloom filter in the full node block header. The Bloom filter is a method based on hash operations to quickly determine whether an element is in the set. The full node quickly finds the block where the transaction is located based on the Bloom filter results.

[0106] C. The full node determines whether the block where the transaction is located is the current valid block. If it meets the conditions, the full node returns the Merkle tree verification path of the transaction to be verified to the light node.

[0107] D. After receiving the verification path, the light node performs hash calculation based on the verification information to obtain the root value Root' of the Merkle tree.

[0108] E. Finally, the root value Root' of the Merkle tree is calculated by verifying the path information, and compared with the root value Root of the Merkle tree in the locally obtained block. If they are equal, it can be proved that the transaction exists.

[0109] Summary: The present invention provides a supply chain traceability storage technology solution based on improved light node storage technology, which uses light node storage to achieve fine-grained classification storage of supply chain data, while ensuring data security and reducing storage pressure, and can achieve fast data query.

[0110] The present invention divides the traceability data appearing in the supply chain into hot and cold data according to the time sequence of block generation. Each light node stores the block header and part of the data with the highest probability of being queried. The data hot and cold degree level thresholds are divided according to the access frequency, storage time and relevance heat of the data, that is, hot data, warm data and cold data. The data participants join the blockchain network as light nodes, which can greatly reduce the storage pressure of the client, and store hot data and part of warm data according to storage capacity and willingness. The batch number of each link is set with a different id, and the judgment is made through the Bloom filter to filter the required information. Thereby achieving the purpose of reducing the storage pressure of a single ordinary node of the blockchain. In addition, in combination with relevant regulations, data that is overdue for six months is judged as cold data, and the query probability is extremely low, and an automatic deletion mechanism is set at the light node. Warm data is data with a low query probability. If the storage pressure is large, it can be deleted locally by itself according to the temperature, and a request can be made to the full node when necessary.

[0111] When querying data, Bloom filters can be used to make judgments. First, determine whether the queried data is hot data, that is, whether it is stored locally on the light node. If the required data is not found through the bloom filter, warm data is requested from the full node, which can quickly locate which blocks the product batches to be queried are located in. Use the improved Bloom filter to achieve efficient query, and store the batch number id of the transaction data in the Bloom filter of each block header. Because when querying at the light node, the Bloom filter can be used to quickly determine whether the data is stored locally on the light node, so as to filter and judge the transaction batch number id. The judgment of the data batch number id can quickly locate the data stored in certain block headers, which greatly reduces the memory overhead, thereby achieving efficient query.

[0112] The light node storage and query device for supply chain traceability data provided by the present invention is described below. The light node storage and query device for supply chain traceability data described below and the light node storage and query method for supply chain traceability data described above can be referenced to each other.

[0113] Figure 8 A schematic diagram of the structure of a light node storage and query device for supply chain traceability data provided by the present invention, which is applied to light nodes, such as Figure 8 As shown, the device comprises:

[0114] The determination module 800 is used to determine whether there is target data satisfying the query condition stored locally based on the query condition input by the user;

[0115] The query module 810 is used to return the query result to the user based on the target data if it is determined that the target data that meets the query condition is stored locally; otherwise, if it is determined that the target data that meets the query condition is not stored locally, request the target data from the full node and return the query result to the user based on the target data;

[0116] Among them, the light node stores or deletes data based on the temperature weight of the data. The temperature weight of the data is determined based on the correlation between the data and the participants corresponding to the light node in the supply chain link, the time when the data is generated, and the access frequency of the data.

[0117] In some embodiments, the temperature weight of the data is calculated as follows:

[0118] W=T temperature +α*T time +F

[0119] Where W represents the temperature weight of the data; T temperatureIt represents the correlation temperature of data. The correlation temperature of data is used to characterize the correlation between data and participants corresponding to light nodes in the supply chain. α represents the coefficient of the change of the time temperature of data over time. time It represents the initial value of the time temperature of the data. The time temperature of the data is used to characterize the time when the data was generated. F represents the access frequency of the data.

[0120] In some embodiments, the correlation temperature of the data is selected from a plurality of predefined candidate values, and the selection rule is:

[0121] The correlation temperature value of the data at the same link as the participant is the maximum value among multiple candidate values; the farther the link is from the participant, the smaller the correlation temperature value of the data at the corresponding link; under the same distance, the correlation temperature value of the data at the downstream link is larger.

[0122] In some embodiments, in the first set period after data is generated, the value of α is an initial value, and the value of α decreases once each set period.

[0123] In some embodiments, the access frequency of the data is determined based on the number of times the data is queried within a set time unit.

[0124] In some embodiments, storing or deleting data based on the temperature weight of the data includes:

[0125] Based on the temperature weight of the data, the data is divided into hot data, warm data or cold data; wherein hot data is data whose temperature weight is greater than or equal to a first threshold, warm data is data whose temperature weight is greater than or equal to a second threshold and less than the first threshold, and cold data is data whose temperature weight is less than the second threshold;

[0126] For hot data, light nodes store it; for warm data, light nodes selectively store it; for cold data, light nodes do not store it or delete it.

[0127] It should be noted here that the above-mentioned device provided by the present invention can implement all the method steps implemented by the above-mentioned method embodiment, and can achieve the same technical effect. The parts and beneficial effects that are the same as the method embodiment in this embodiment will not be described in detail here.

[0128] Fig. 9 A schematic diagram of the structure of an electronic device provided by the present invention, such as Fig. 9As shown, the electronic device may include: a processor 910, a communication interface 920, a memory 930 and a communication bus 940, wherein the processor 910, the communication interface 920 and the memory 930 communicate with each other through the communication bus 940. The processor 910 may call the logic instructions in the memory 930 to execute any of the light node storage and query methods for supply chain traceability data provided in the above embodiments, for example: based on the query conditions input by the user, determine whether the target data that meets the query conditions is stored locally; if it is determined that the target data that meets the query conditions is stored locally, return the query result to the user based on the target data; otherwise, if it is determined that the target data that meets the query conditions is not stored locally, request the target data from the full node and return the query result to the user based on the target data; wherein the light node stores or deletes the data based on the temperature weight of the data, and the temperature weight of the data is determined based on the correlation between the data and the participants corresponding to the light node in the supply chain link, the generation time of the data, and the access frequency of the data.

[0129] In addition, the logic instructions in the above-mentioned memory 930 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0130] It should be noted here that the electronic device provided by the present invention can implement all the method steps implemented by the above-mentioned method embodiment, and can achieve the same technical effects. The parts and beneficial effects of this embodiment that are the same as the method embodiment will not be described in detail here.

[0131] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it can implement any of the light node storage and query methods for supply chain traceability data provided in the above-mentioned embodiments, for example: based on the query conditions input by the user, determine whether the target data that meets the query conditions is stored locally; if it is determined that the target data that meets the query conditions is stored locally, return the query results to the user based on the target data; otherwise, if it is determined that the target data that meets the query conditions is not stored locally, request the target data from the full node and then return the query results to the user based on the target data; wherein the light node stores or deletes the data based on the temperature weight of the data, and the temperature weight of the data is determined based on the correlation between the data and the participant corresponding to the light node in the supply chain link, the generation time of the data, and the access frequency of the data.

[0132] It should be noted here that the non-transitory computer-readable storage medium provided by the present invention can implement all the method steps implemented by the above-mentioned method embodiment, and can achieve the same technical effect. The parts and beneficial effects that are the same as the method embodiment in this embodiment will not be described in detail here.

[0133] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute any of the light node storage and query methods for supply chain traceability data provided in the above embodiments, for example: based on the query conditions input by the user, determine whether the target data that meets the query conditions is stored locally; if it is determined that the target data that meets the query conditions is stored locally, return the query results to the user based on the target data; otherwise, if it is determined that the target data that meets the query conditions is not stored locally, request the target data from the full node and then return the query results to the user based on the target data; wherein the light node stores or deletes the data based on the temperature weight of the data, and the temperature weight of the data is determined based on the correlation between the data and the participant corresponding to the light node in the supply chain link, the generation time of the data, and the access frequency of the data.

[0134] It should be noted here that the computer program product provided by the present invention can implement all the method steps implemented by the above-mentioned method embodiment, and can achieve the same technical effect. The parts and beneficial effects of this embodiment that are the same as those of the method embodiment will not be described in detail here.

[0135] The device embodiments described above are merely illustrative, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.

[0136] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0137] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A light node storage and query method for supply chain traceability data, characterized in that: Applicable to light nodes, including: Based on the query conditions input by the user, determining whether target data satisfying the query conditions is stored locally; If it is determined that the target data that meets the query condition is stored locally, the query result is returned to the user based on the target data; otherwise, if it is determined that the target data that meets the query condition is not stored locally, the target data is requested from the full node and the query result is returned to the user based on the target data; The light node stores or deletes data based on the temperature weight of the data, and the temperature weight of the data is determined based on the relevance of the data to the participant corresponding to the light node in the supply chain link, the generation time of the data, and the access frequency of the data; The calculation formula of the temperature weight of the data is: W=T temperature +α*T time +F Wherein, W represents the temperature weight of the data; T temperature represents the correlation temperature of the data, which is used to characterize the correlation between the data and the participants corresponding to the light node in the supply chain; α represents the coefficient of the time temperature of the data changing with time, T time represents the initial value of the time temperature of the data, and the time temperature of the data is used to characterize the time when the data was generated; F represents the access frequency of the data; The correlation temperature of the data is selected from a plurality of predefined candidate values, and the selection rule is: The correlation temperature value of the data of the same link corresponding to the participant is the maximum value among the multiple candidate values; the farther the link is from the participant, the smaller the correlation temperature value of the data of the corresponding link; under the same distance, the correlation temperature value of the data of the downstream link is larger.

2. The light node storage and query method for supply chain traceability data according to claim 1 is characterized in that: In the first set period after the data is generated, the value of α is an initial value, and the value of α decreases every time a set period is moved backward.

3. The light node storage and query method for supply chain traceability data according to claim 1 is characterized in that: The access frequency of the data is determined based on the number of times the data is queried within a set time unit.

4. The light node storage and query method for supply chain traceability data according to any one of claims 1 to 3, characterized in that: The storing or deleting of data based on the temperature weight of the data includes: Dividing the data into hot data, warm data or cold data based on the temperature weight of the data; wherein the hot data is data whose temperature weight is greater than or equal to a first threshold, the warm data is data whose temperature weight is greater than or equal to a second threshold and less than the first threshold, and the cold data is data whose temperature weight is less than the second threshold; For the hot data, the light node stores it; for the warm data, the light node selectively stores it; for the cold data, the light node does not store it or deletes it.

5. A light node storage and query device for supply chain traceability data, characterized in that: Applicable to light nodes, including: A determination module, used to determine whether there is target data satisfying the query condition stored locally based on the query condition input by the user; A query module, configured to return the query result to the user based on the target data if it is determined that the target data that meets the query condition is stored locally; otherwise, if it is determined that the target data that meets the query condition is not stored locally, request the target data from the full node and then return the query result to the user based on the target data; The light node stores or deletes data based on the temperature weight of the data, and the temperature weight of the data is determined based on the relevance of the data to the participant corresponding to the light node in the supply chain link, the generation time of the data, and the access frequency of the data; The calculation formula of the temperature weight of the data is: W=T temperature +α*T time +F Wherein, W represents the temperature weight of the data; T temperature represents the correlation temperature of the data, which is used to characterize the correlation between the data and the participants corresponding to the light node in the supply chain; α represents the coefficient of the time temperature of the data changing with time, T time represents the initial value of the time temperature of the data, and the time temperature of the data is used to characterize the time when the data was generated; F represents the access frequency of the data; The correlation temperature of the data is selected from a plurality of predefined candidate values, and the selection rule is: The correlation temperature value of the data of the same link corresponding to the participant is the maximum value among the multiple candidate values; the farther the link is from the participant, the smaller the correlation temperature value of the data of the corresponding link; under the same distance, the correlation temperature value of the data of the downstream link is larger.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the program, it implements the light node storage and query method for supply chain traceability data as described in any one of claims 1 to 4.

7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it implements the light node storage and query method for supply chain traceability data as described in any one of claims 1 to 4.

8. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, it implements the light node storage and query method for supply chain traceability data as described in any one of claims 1 to 4.