Blockchain Map Iteration via Forest Data Structure
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing map iteration methods in blockchain systems are computationally intensive and time-consuming, especially when retrieving all keys or values, as they often require traversing the entire map, leading to bottlenecks and conflicts in concurrent data access.
Innovation Solution
Implementing a forest data structure with multiple trees that use hash functions to distribute keys across storage nodes, allowing for concurrent access and reducing I/O complexity through configurable parameters like tree width and depth, enabling efficient key insertion, deletion, and retrieval.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Measurement precision
If traditional map iteration methods are used to retrieve all keys or values, then complete data retrieval is achieved, but computational complexity and time consumption increase significantly
Solution Approach 1:
The patent segments the map data structure into multiple trees organized in a forest structure. Each tree contains multiple levels with storage nodes that hold subsets of keys. This segmentation allows parallel traversal of multiple trees simultaneously, reducing the time required to retrieve all keys or values while maintaining completeness of data retrieval.
2Measurement precision
If sequential traversal of the entire map is performed, then all key-value pairs are accessed, but concurrent data access bottlenecks occur
Solution Approach 1:
By dividing the map into multiple independent trees, the patent enables multiple threads to traverse different trees concurrently without conflict. Each tree can be accessed independently, allowing parallel execution of map iteration operations and significantly improving concurrent data access throughput while ensuring all key-value pairs are eventually accessed.
Solution Approach 2:
The patent introduces a hierarchical dimension to the data structure by organizing trees into levels. This multi-level hierarchical structure provides additional traversal paths and access points, enabling concurrent access from different levels and reducing bottlenecks in sequential traversal operations.
3Device complexity
If a simple data structure is used for map storage, then implementation complexity is reduced, but I/O complexity and access latency increase
Solution Approach 1:
The forest of trees structure segments the data storage into manageable units (storage nodes at different levels), which balances implementation complexity with access performance. Each node stores a subset of keys, allowing targeted access rather than scanning the entire structure, thus improving access speed while maintaining reasonable implementation complexity through modular design.
Data Source
Figure 1~2
Figure 3~4
Figure 5
AI summary
Disclosed herein are methods, systems, and apparatus, including computer programs encoded on computer storage media, for storing keys of a number of key-value pairs by a network node of a blockchain network. One of the methods includes maintaining data representing a forest that stores a number of keys of the number of key-value pairs that are stored in a map. The forest includes a number of trees, each tree includes a respective number of storage nodes, and each storage node stores a subset of the number of keys. The network node receives a request to add a key of a key-value pair into the forest, the key-value pair stored in the map. A first hash value of the key is computed using a first hash function. One of the number of trees to store the key is determined based on the first hash value. The network node determines a target storage node of the one of the number of trees to store the key, and stores the key in the target storage node.