Replace spacedb block indexes and snumeric index with SQLite#159
Merged
buffrr merged 2 commits intospacesprotocol:subspacesfrom Mar 24, 2026
Merged
Replace spacedb block indexes and snumeric index with SQLite#159buffrr merged 2 commits intospacesprotocol:subspacesfrom
buffrr merged 2 commits intospacesprotocol:subspacesfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR:
Adds --index_node_hashes flag to enable indexing hashes of internal nodes in spacedb for faster build_chain_proof. This is needed for certrelay since it builds proofs frequently. This flag is disabled by default.
Replaces the spaces block index (block_index.sdb) and nums block index (nums_block_index.sdb) with a single SQLite database (index.sqlite), since these indexes don't need merkle proofs.
Moves the snumeric→NumId mapping out of the production nums tree into SQLite, eliminating duplicate entries that inflate the tree
Snumeric index uses a composite integer primary key (block_height, tx_pos, vout) instead of a 32-byte hash .Sequential inserts, faster lookups, no hashing needed.
Inserts are staged in memory and batch-flushed at the existing 36-block commit interval
Reorgs handled via DELETE WHERE block_height > ? instead of spacedb snapshot rollback