Logistics cargo path query efficiency improvement method based on block chain right proof
By introducing hashing algorithms and dynamic loading factor mechanisms on the blockchain, combining smart contracts and proof of stake mechanisms, the problems of low query efficiency and uneven data distribution in traditional blockchain are solved, and the efficiency of logistics goods path query is achieved and Quick positioning improves overall query performance.
Patent Information
- Application Number
- CN202411062311.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-05
- Publication Date
- 2024-11-22
AI Technical Summary
Traditional blockchain systems have high complexity and time cost when querying discontinuous data, lack an efficient indexing mechanism, especially when the data volume is large, query efficiency is low, and traditional sharding technology leads to uneven data distribution, affecting query efficiency.
Design a logistics goods path query method based on blockchain proof of stake, manage path data through smart contracts, introduce hash algorithms and dynamic loading factor mechanisms to optimize the hash table, adopt intelligent sharding strategy to ensure uniform data distribution, and pass through the material Networked devices monitor and adjust the number of shards in real time, and use the proof of stake mechanism to verify transactions and query operations.
It significantly improves query efficiency, avoids data congestion and query bottlenecks, quickly locates data by optimizing the hash table, reduces query time, and ensures resource utilization by dynamically adjusting the number of shards and proof of stake mechanisms, improving overall query performance.
Smart Images

Figure CN119003657A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of blockchain technology, logistics information technology, and data query efficiency optimization technology, and in particular to a method for improving logistics cargo path query efficiency based on blockchain equity proof. Background Art
[0002] The logistics cargo path query method based on blockchain currently has the following defects and shortcomings, which are also the problems that this invention needs to solve
[0003] The essence of blockchain is a chain data structure, where all data is stored in a chain in chronological order. This storage method requires that when querying non-continuous data, the entire chain needs to be traversed from the head node until the required data is found, which increases the complexity and time cost of the query. Traditional blockchain systems usually lack an efficient indexing mechanism. In the case of a large amount of data, the lack of an index means that each query needs to scan the entire blockchain, further reducing the query efficiency. As blockchain data continues to grow, a large amount of data is stored on the blockchain. Without effective data management and query optimization strategies, query operations may become very slow.
[0004] Traditional sharding technology has obvious shortcomings when processing cargo path queries in blockchains based on proof of equity. Because traditional sharding methods often divide and distribute data based on fixed strategies, this may lead to uneven data distribution, and some shards carry too much data, affecting query efficiency. Based on the above reasons, the present invention designs a method for improving the efficiency of logistics cargo path queries based on blockchain proof of equity. Summary of the invention
[0005] The purpose of the present invention is to solve the problems in the prior art and to propose a method for improving the efficiency of logistics cargo path query based on blockchain equity proof.
[0006] A method for improving the efficiency of logistics cargo path query based on blockchain equity proof. It includes the following steps:
[0007] The following steps are involved:
[0008] S1: Establish a blockchain network, build a blockchain network based on proof of stake, determine the node roles and permissions in the network, and the specific implementation method of the proof of stake mechanism;
[0009] S2: Define the data structure and design the data structure used to store logistics cargo path information, including transaction format, path node information, timestamp, etc.;
[0010] S3: Develop a sharding strategy based on factors such as the geographical location and transportation method of the goods to ensure even data distribution. Then, use technical means to divide the original data into shards according to the strategy and create an efficient index for each shard. When a query request comes, select the relevant shard and execute the query operation.
[0011] S4: Deploy smart contracts. Deploy smart contracts in the blockchain network to manage the storage, verification and query operations of path data.
[0012] S5: IoT device data collection, which collects the location, status and other path information of goods in real time through IoT devices;
[0013] S6: Data encapsulation and signature: encapsulate the collected data into data packets that conform to the blockchain transaction format, and use digital signature technology to ensure the integrity and non-tamperability of the data.
[0014] S7: Transaction upload: upload the signed transaction to the blockchain network, which will be verified and stored by the nodes in the network;
[0015] S8: Stake verification, nodes verify received transactions according to the stake proof mechanism, ensuring that only nodes with sufficient stake can participate in the verification process;
[0016] S9: Smart contract execution, triggering the corresponding smart contract to execute the query operation, retrieving relevant path information in the blockchain network according to the query conditions, and establishing an efficient indexing mechanism.
[0017] In the above-mentioned method for improving the efficiency of logistics cargo path query based on blockchain equity proof, in the process of defining the data structure, a hash algorithm is introduced to improve the speed of data positioning and retrieval. By introducing a dynamic loading factor mechanism, the system can adjust the size of the hash table in real time to optimize performance. The optimized hash function is based on data characteristic analysis and selects the most distinguishing features for mapping, ensuring the uniform distribution of hash values and greatly reducing the possibility of hash conflicts. When the load factor exceeds the preset threshold, the system will automatically expand the capacity to improve the retrieval efficiency; otherwise, it will shrink the capacity to save space. At the same time, each path information is stored in the hash table in the form of a key-value pair, where the key is the unique identifier of the path and the value is the relevant detailed information. Through the hash function, the system can quickly map the path identifier to a specific location in the hash table to achieve fast data storage.
[0018] In the above-mentioned method for improving the efficiency of logistics cargo path query based on blockchain equity proof, in the process of data collection of IoT devices, the generation and query of cargo path data in the blockchain network are monitored in real time, including the growth rate of data, the frequency of queries and the load status of nodes. According to the real-time data monitoring results, the system dynamically adjusts the number of shards. When the amount of data increases rapidly or the query load increases, the number of shards is increased to disperse the load; when the amount of data decreases or the query load decreases, the shards are merged to improve resource utilization. Under the equity proof mechanism, nodes compete to become the leader or validator of the shard based on the equity they hold (such as the number of tokens). The system dynamically allocates data to different shards based on the equity and performance of the nodes to ensure that each shard has sufficient resources to process query requests.
[0019] In the above-mentioned method for improving the efficiency of logistics cargo path query based on blockchain equity proof, in the process of data encapsulation and signing, the original data collected by the IoT device, including key information such as the location and status of the goods, will first be carefully encapsulated to meet the specific format requirements of blockchain transactions. The encapsulated data packet is signed using digital signature technology, and the data packet is encrypted using the sender's private key to generate a unique digital signature. This signature is closely linked to the original data, and any tampering with the data will cause the signature to become invalid, thereby ensuring the integrity and immutability of the data. The receiver can decrypt and verify the digital signature through the sender's public key. Once the verification is successful, the integrity and authenticity of the data can be confirmed, and subsequent transaction operations can be performed.
[0020] In the above-mentioned method for improving the efficiency of logistics cargo path query based on blockchain proof of equity, in the process of equity verification, the node uses a certain number of tokens or digital currencies to prove its equity in the network. The amount of equity held directly determines the weight and influence of the node in the verification process. When the node receives a transaction, it verifies the transaction according to the proof of equity mechanism. The verification process includes checking the transaction format, signature, sender and receiver's equity status, etc. The verification process is completed by multiple nodes holding equity.
[0021] In the above-mentioned method for improving the efficiency of logistics cargo path query based on blockchain equity proof, during the execution of the smart contract, relevant path information is retrieved in the blockchain network according to the query conditions. The query conditions include the starting point, destination, transportation status, etc. of the goods. The smart contract traverses the transaction records and data storage on the blockchain to extract information that matches the query conditions. At the same time, the smart contract utilizes the distributed characteristics and data structure advantages of the blockchain to build an index to achieve rapid query and positioning of data. The index mechanism considers factors including data relevance and access frequency. The execution environment of the smart contract adopts multiple security measures including access control and data encryption.
[0022] Compared with the prior art, the present invention has the following advantages:
[0023] 1. By introducing intelligent sharding technology and optimized hash table data structure, the present invention significantly improves query efficiency. The intelligent sharding strategy ensures the uniform distribution of data, avoids data congestion and query bottlenecks, and at the same time, the optimized hash table can quickly locate the location of specific data without traversing the entire blockchain, thereby greatly reducing query time.
[0024] 2. An optimized hash table data structure is introduced to speed up the query process. It can quickly locate the location of specific data, avoiding the complexity and time cost of traversing the entire chain. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 This is a schematic diagram of a method for improving logistics cargo path query efficiency based on blockchain equity proof proposed by the present invention. DETAILED DESCRIPTION
[0026] See also Figure 1 This example aims to provide a method for improving the efficiency of logistics cargo path query based on proof of stake. This method adopts an optimized data hash table data structure to quickly locate and retrieve data, establishes an efficient indexing mechanism to quickly locate relevant path data, and intelligently shards data according to factors such as geographic location and transportation method, thereby reducing the data scanning range during query and improving access speed.
[0027] In conjunction with the accompanying drawings, the method of using the present invention is as follows:
[0028] S1: Establish a blockchain network, build a blockchain network based on proof of stake, determine the node roles and permissions in the network, and the specific implementation method of the proof of stake mechanism;
[0029] S2: The system uses smart contracts to check whether the user's equity certificate is valid, including whether the user has enough equity to initiate a query request and whether the equity certificate has been used for other queries. If the verification is successful, the user will be authorized to perform subsequent query operations; if the verification fails, the query request will be rejected.
[0030] S3: Optimize data structure and index. When storing logistics cargo path information, the system uses an optimized hash table data structure to quickly locate and retrieve data.
[0031] When optimizing the storage data structure for cargo path query based on proof of stake, we have optimized it from the following aspects, taking into account the characteristics and advantages of hash tables:
[0032] In order to reduce hash conflicts, it is necessary to select a hash function with uniform distribution and high computational efficiency to ensure that different path information can be evenly distributed in the hash table and improve query efficiency. Hash conflicts occur when different path information calculates the same hash value. When there are too many or too few elements in the hash table, the query efficiency will be affected. Therefore, we design a mechanism to dynamically adjust the size of the hash table to dynamically expand or reduce the hash table according to the load factor of the hash table (the ratio of the number of elements to the size of the hash table) to maintain the performance of the hash table. In order to make the hash table adjustment strategy more innovative and adaptive, we introduce a method for dynamically calculating the load factor threshold. This method can dynamically adjust the threshold based on the current state of the hash table (such as element distribution, conflict rate, etc.) and the real-time performance data of the system (such as query response time, memory usage, etc.). The algorithm of this process is as follows:
[0033] 1. Initialize the hash table and threshold range
[0034] Set the hash table size: Set an initial hash table size (M) based on the expected number of logistics cargo routes to be stored.
[0035] Set the threshold range: According to system performance and actual needs, set the initial range of the upper threshold (UT_{min}) and (UT_{max}) and the lower threshold (LT_{min}) and (LT_{max})
[0036] 2. Insert and delete path information
[0037] Calculate hash value: For each new logistics cargo path information, use the hash function (h(key)) to calculate its hash value.
[0038] Storing path information: According to the calculated hash value, the path information is stored in the corresponding bucket of the hash table.
[0039] Handling Collisions: If a hash collision occurs (i.e., multiple path information maps to the same bucket), an appropriate collision resolution strategy (such as chaining) is adopted to handle it.
[0040] Updating the Load Factor: After each insertion or deletion of path information, update the number of elements (N) and the load factor (LF = frac{N}{M}) of the hash table.
[0041] 3. Dynamically Adjusting Threshold RangesCalculating Dynamic Thresholds: Based on performance monitoring data and the current load factor, use functions (f_{UT}) and (f_{LT}) to calculate the dynamic upper threshold (UT) and lower threshold (LT).
[0042] (UT = f_{UT}(P_{metrics}, UT_{min}, UT_{max}))
[0043] (LT = f_{LT}(P_{metrics}, LT_{min}, LT_{max}))
[0044] Adjusting Threshold Ranges: Based on the calculated dynamic thresholds, adjust the ranges of the upper threshold and the lower threshold.
[0045] 4. Checking the Load Factor and Triggering Adjustments.
[0046] Comparing the Load Factor with the Thresholds: Compare the current load factor (LF) with the dynamic thresholds (UT) and (LT).
[0047] Triggering Hash Table Expansion: If (LF > UT), trigger the expansion operation of the hash table to increase the size (M) of the hash table.
[0048] Triggering Hash Table Contraction: If (LF < LT), trigger the contraction operation of the hash table to decrease the size (M) of the hash table.
[0049] 5. Rehashing Process
[0050] Recalculating Hash Values: For each element after hash table expansion or contraction, use the hash function (h(key)) to recalculate its hash value.
[0051] Remapping Elements: Based on the new hash values and the hash table size, remap the elements to new buckets.
[0052] S4: Introduce a smart sharding model to evaluate the dynamic sharding strategy in the blockchain environment, optimize resource utilization, and dynamically adjust the size and number of shards based on factors such as network status, node performance, and transaction type to ensure that the load on each shard is relatively balanced. This can avoid overloading certain shards, while making full use of idle resources in the network and improving overall resource utilization. Therefore, we use linear programming to build an evaluation model to evaluate the strategies of network sharding, transaction sharding, and state sharding, which is an effective method;
[0053] Below is a simplified linear programming model for evaluating sharding strategies:
[0054] The first step is to define variables. Suppose we have the following variables:
[0055] (x) represents the number of network shards
[0056] (y) represents the number of transaction shards
[0057] (z) represents the number of state shards
[0058] The second step is to define the objective function. The goal is to maximize the performance of the entire system, which can be achieved by comprehensively considering transaction throughput, latency, and storage efficiency. For simplicity, we assume that each shard can bring a certain performance improvement, and the impact of different types of shards on performance is linear. The objective function can be expressed as:
[0059] Maximizef(x,y,z)=a*x+b*y+c*z
[0060] Among them, (a), (b), and (c) are weight coefficients, which indicate the degree of impact of each shard type on performance. These coefficients can be determined based on actual business needs and historical data.
[0061] The third step is to define constraints. We need to consider the following constraints:
[0062] Resource limitation: The number of shards is limited by available resources, such as the number of nodes, network bandwidth, etc. Assuming the maximum number of network shards is (x_max), the maximum number of transaction shards is (y_max), and the maximum number of state shards is (z_max), then:
[0063] x≤x_max
[0064] y≤y_max
[0065] z≤z_max
[0066] Load balancing: To ensure that the load on each shard is relatively balanced, we can set some constraints to limit the load differences between shards. This usually needs to be defined based on specific business logic and performance indicators.
[0067] The fourth step is to solve the linear programming problem. Once we have defined the objective function and constraints, we can use a linear programming solver to find the optimal (x), (y), and (z) values. This usually involves converting the problem into a standard form linear programming problem and solving it using an appropriate algorithm.
[0068] The fifth step is to simulate the required input parameters. In order to simulate this problem, some input parameter values are assumed. For example:
[0069] (a=2), (b=3), (c=1) (indicates that transaction sharding has the greatest impact on performance, followed by network sharding, and finally state sharding)
[0070] (x_max=10), (y_max=8), (z_max=6) (indicates resource limitations)
[0071] We can then use these inputs to solve the linear programming problem and find the optimal sharding strategy;
[0072] S5: Real-time data monitoring results, the system can dynamically adjust the number of shards. When the amount of data grows rapidly or the query load increases, the number of shards can be increased to disperse the load; when the amount of data decreases or the query load decreases, the shards can be merged to improve resource utilization. Under the proof-of-stake mechanism, nodes compete to become the leader or validator of the shard based on the equity they hold (such as the number of tokens). The system dynamically distributes data to different shards based on the equity and performance of the nodes to ensure that each shard has sufficient resources to process query requests. Therefore, the following algorithm is designed to support the dynamic adjustment of the number of shards:
[0073] We define some basic variables and parameters:
[0074] DataGrowthRate: data growth rate, the amount of data growth per unit time.
[0075] QueryFrequency: query frequency, the number of queries per unit time.
[0076] NodeLoad: Node load status, indicating the processing capacity and current load status of the node.
[0077] PerformanceRequirement: Performance requirement, such as expected query response time or throughput;
[0078] Next, we use some simplified formulas to simulate the process of calculating the number of shards.
[0079] Initial number of shards:
[0080] InitialShardCount=f(NodeLoad,PerformanceRequirement)
[0081] This formula indicates that the initial number of shards is determined based on node load and performance requirements. The specific function f may involve some complex calculations, but here we can simply assume that it allocates initial shards based on the number of nodes and performance requirements;
[0082] Shard quantity adjustment threshold:
[0083] ShardAdjustmentThreshold=g(DataGrowthRate, QueryFrequency)
[0084] This formula indicates that when the data growth rate and query frequency exceed a certain threshold, the number of shards needs to be adjusted. Function g can be designed according to actual conditions, for example, the product or weighted sum of data growth rate and query frequency can be considered;
[0085] The step size for adjusting the number of shards:
[0086] ShardAdjustmentStep=h(NodeLoad)
[0087] This formula indicates that the step size of each adjustment of the number of shards is determined based on the node load. Function h can set the step size based on the processing power of the node.
[0088] Calculate the adjusted number of shards:
[0089] AdjustedShardCount=InitialShardCount+(ShardAdjustmentStep*ShardAdjustmentDirection)
[0090] This formula indicates that the adjusted number of shards is calculated based on the adjustment direction and step size. ShardAdjustmentDirection can be a positive number (increasing shards) or a negative number (reducing shards), depending on the comparison between the monitoring data and the performance requirements.
[0091] It is known from common technical knowledge that the present invention can be implemented by other embodiments that do not deviate from its spirit or essential features. Therefore, the above disclosed embodiments are only illustrative in all respects and are not exclusive. All changes within the scope of the present invention or within the scope equivalent to the present invention are included in the present invention.
Claims
1. A method for improving the efficiency of logistics cargo path query based on blockchain equity proof, characterized in that: The following steps are involved: S1: Establish a blockchain network, build a blockchain network based on proof of stake, determine the node roles and permissions in the network, and the specific implementation method of the proof of stake mechanism; S2: Define the data structure and design the data structure used to store logistics cargo path information, including transaction format, path node information, timestamp, etc.; S3: Develop a sharding strategy based on factors such as the geographical location and transportation method of the goods to ensure even data distribution; then, use technical means to divide the original data into shards according to the strategy and establish an efficient index for each shard; When a query request comes, select the relevant shard and execute the query operation; S4: Deploy smart contracts. Deploy smart contracts in the blockchain network to manage the storage, verification and query operations of path data. S5: IoT device data collection, which collects the location, status and other path information of goods in real time through IoT devices; S6: Data encapsulation and signature: encapsulate the collected data into data packets that conform to the blockchain transaction format, and use digital signature technology to ensure the integrity and non-tamperability of the data. S7: Transaction upload: upload the signed transaction to the blockchain network, which will be verified and stored by the nodes in the network; S8: Stake verification, nodes verify received transactions according to the stake proof mechanism, ensuring that only nodes with sufficient stake can participate in the verification process; S9: Smart contract execution, triggering the corresponding smart contract to execute the query operation, retrieving relevant path information in the blockchain network according to the query conditions, and establishing an efficient indexing mechanism.
2. According to claim 1, a method for improving the efficiency of logistics cargo path query based on blockchain equity proof, characterized in that: In the process of defining the data structure, the hash algorithm is introduced to improve the speed of data location and retrieval. By introducing the dynamic loading factor mechanism, the system can adjust the size of the hash table in real time to optimize performance. The optimized hash function is based on data characteristic analysis and selects the most distinguishing features for mapping, ensuring the uniform distribution of hash values and greatly reducing the possibility of hash conflicts. When the load factor exceeds the preset threshold, the system will automatically expand the capacity to improve retrieval efficiency; otherwise, it will shrink the capacity to save space. At the same time, each path information is stored in the hash table in the form of a key-value pair, where the key is the unique identifier of the path and the value is the relevant detailed information. Through the hash function, the system can quickly map the path identifier to a specific location in the hash table to achieve fast data storage.
3. According to claim 1, a method for improving the efficiency of logistics cargo path query based on blockchain equity proof, characterized in that: In the process of IoT device data collection, the generation and query of cargo path data in the blockchain network are monitored in real time, including the growth rate of data, the frequency of queries, and the load status of nodes. According to the real-time data monitoring results, the system dynamically adjusts the number of shards. When the amount of data increases rapidly or the query load increases, the number of shards is increased to disperse the load; when the amount of data decreases or the query load decreases, the shards are merged to improve resource utilization. Under the proof-of-stake mechanism, nodes compete to become the leader or validator of the shard based on the equity they hold (such as the number of tokens). The system dynamically allocates data to different shards based on the equity and performance of the nodes to ensure that each shard has sufficient resources to process query requests.
4. According to claim 1, a method for improving the efficiency of logistics cargo path query based on blockchain equity proof, characterized in that: In the process of data encapsulation and signing, the original data collected by the IoT device, including key information such as the location and status of the goods, will first be carefully encapsulated to meet the specific format requirements of blockchain transactions. The encapsulated data packet will be signed using digital signature technology, and the data packet will be encrypted using the sender's private key to generate a unique digital signature. This signature is closely linked to the original data. Any tampering with the data will invalidate the signature, thereby ensuring the integrity and non-tamperability of the data. The recipient can decrypt and verify the digital signature using the sender's public key. Once the verification is successful, the integrity and authenticity of the data can be confirmed, and subsequent transaction operations can be performed.
5. According to claim 4, a method for improving the efficiency of logistics cargo path query based on blockchain equity proof, characterized in that: In the process of stake verification, nodes use a certain number of tokens or digital currencies to prove their stake in the network. The amount of stake held directly determines the weight and influence of the node in the verification process. When a node receives a transaction, it verifies the transaction according to the stake proof mechanism. The verification process includes checking the transaction format, signature, sender and receiver's stake, etc. The verification process is completed by multiple nodes holding stakes.
6. According to claim 4, a method for improving the efficiency of logistics cargo path query based on blockchain equity proof, characterized in that: In the process of smart contract execution, the relevant path information is retrieved in the blockchain network according to the query conditions, including the starting point, destination, transportation status, etc. of the goods. The smart contract extracts the information matching the query conditions by traversing the transaction records and data storage on the blockchain. At the same time, the smart contract takes advantage of the distributed characteristics and data structure of the blockchain to build an index. For fast query and location of data, the index mechanism considers factors such as data relevance and access frequency. The execution environment of smart contracts adopts multiple security measures including access control and data encryption.
Citation Information
Cited By
Logistics information tracking system and method based on block chain
CN120258672A
