Commit 430614b
committed
tapdb: refactor logic to reduce duplication between IgnoreTree and BurnTree
Previously, the `BurnUniverseTree` and `IgnoreUniverseTree` implementations
contained significant duplicated logic for common operations such as:
- Deriving a universe identifier from an asset specifier.
- Calculating the total sum of leaf values in a tree.
- Querying specific leaves and generating their MS-SMT inclusion proofs.
- Listing all leaves within a specific universe namespace.
This commit introduces several generic helper functions within
`tapdb/universe.go` to centralize this logic:
- `specifierToIdentifier`: Creates a universe identifier for a given
specifier and proof type.
- `getUniverseTreeSum`: Calculates the sum of a universe tree root.
- `queryUniverseLeavesAndProofs`: A generic function to query leaves,
decode them, fetch MS-SMT proofs, and build authenticated results.
- `listUniverseLeaves`: A generic function to list and decode all leaves
in a namespace.
The `BurnUniverseTree` and `IgnoreUniverseTree` methods (`Sum`,
`QueryBurns`, `ListBurns`, `QueryTuples`, `ListTuples`) have been
refactored to utilize these new helpers. This significantly reduces
code duplication and improves the maintainability of universe tree
interactions.
The `IgnoreTree` interface and related tests were updated to reflect
changes in the `ListTuples` return type.1 parent 91f07c8 commit 430614b
File tree
5 files changed
+489
-408
lines changed- tapdb
- universe
5 files changed
+489
-408
lines changed
0 commit comments