-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implements an internal txindex so we don't have to run bitcoind with txindex=1
#132
Conversation
txindex
txindex=1
txindex=1
txindex=1
fc04b8e
to
58ede34
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question and a couple of small things, but otherwise looks good to me. 🔥
I'll give this PR a test run sometime this week too
teos/src/tx_index.rs
Outdated
} | ||
|
||
/// Fixes the index by removing disconnected data. | ||
fn fix(&mut self, header: &BlockHeader) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if this function name could be a bit more descriptive, like "remove_block" or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about remove_disconnected_block
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nits and questions, look good otherwise.
@mariocynicys added fixes from your review comments. @orbitalturtle did you have the chance to check the changes from your suggestions? |
@orbitalturtle @mariocynicys I will rebase the changes and merge this if you're happy with it |
Sorry I missed this. Let me quickly review this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@sr-gi I can take a second look this evening! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, yay pruned node compatibility! 🔥
In order to fix talaia-labs#130 we need to implement our own txindex. Turns out this is almost identical to our `LocatorCache`, so we can generalize it and use it for both purposes.
Rebased and squashed |
Generalizes the
Watcher
'sLocatorCache
into aTxIndex
that can be used both by theWatcher
and theResponder
. The former does use it in the same way as before (as aLocatorCache
to keep track of theLocators
of the last n blocks). As for the latter, it is used to implement a pruned transaction index (aTxid
:BlockHash
map).By adding this
TxIndex
in theResponder
we don't have to runbitcoind
withtxindex=1
anymore and, therefore, we are able to reduce the initial storage requirements significantly: from ~420 GB on disk at the time of writing to a few dozen KB in memory.With this new approach queries to past transactions will be performed internally instead of against
bitcoind
in most cases. If a transaction cannot be found in our index nor in mempool it'll mean that it was confirmed long ago (confirmation count > ourTxIndex
length). TheResponder
index is set to beIRREVOCABLY_RESOLVED
blocks long, meaning that if we don't find a transaction on it we don't need to care anyway.