-
Notifications
You must be signed in to change notification settings - Fork 321
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
Various tweaks to redesigned structures #963
Various tweaks to redesigned structures #963
Conversation
`TxGraph::try_get_chain_position` used to always exclude unconfirmed transactions with last_seen value of 0. However, what is the point of including a transaction in the graph if it cannot be part of the chain history? Additionally, maybe sometimes we don't wish to use the last_seen field at all. The new behavior will consider unconfirmed transactions with last_seen of 0.
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.
I left some comments. Other misc things I noticed that are not changed in this PR but could be:
LocalChain::get_block(height) -> BlockId
allows for invalid representation. It should beget_block_hash(height) -> BlockHash
.- It would be nice if
LocalChain
had a way to doing.blocks
and just getting a reference to the inner BTreeMap without using theAsRef
implementation. - There are all these
TODOs
as doc comments for Local chain. Can you make issues out of the TODOs and remove them from comments.
If `BlockId` implements `Anchor`, the meaning is ambiguous. We cannot tell whether it means the tx is anchors at the block, or whether it also means the tx is confirmed at that block. Instead, `ConfirmationHeightAnchor` and `ConfirmationTimeAnchor` structs are introduced as non-ambiguous `Anchor` implementations. Additionally, `TxGraph::relevant_heights` is removed because it is also ambiguous. What heights are deemed relevant? A simpler and more flexible method `TxGraph::all_anchors` is introduced instead.
8de421f
to
2ccc116
Compare
* Introduce `LocalChain::inner` method to get the inner map of block height to hash. * Replace `LocalChain::get_block` (which outputted `BlockId`, thus able to return invalid representation) with `get_blockhash` that just returns a `BlockHash`. * Remove `TODO` comments that should be github tickets.
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.
ACK a56d289
A few comments but they don't have to be addressed
@@ -27,12 +28,14 @@ impl<A, I: Default> Default for IndexedTxGraph<A, I> { | |||
} | |||
} | |||
|
|||
impl<A: Anchor, I: Indexer> IndexedTxGraph<A, I> { | |||
impl<A, I> IndexedTxGraph<A, I> { |
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.
I'm not sure how idiomatic this is, since we always end up using IndexedTxGraph with A: Anchor, I: Indexer
, but I'm not opposed to this change if it's useful for us somehow
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.
Even if it's not useful directly, it may allow building logic around/above it not require as many generic constraints. I would leave it as is unless if there are downsides to this?
After a call with @LLFourn, the follow things will be added (either to this PR, or a separate PR):
|
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.
Left another idea. Approved. Happy to merge when @evanlinjin is happy.
Also, we can get rid of `LocalChain::get_blockhash`, since we can already expose the internal map. Additionally, tests and docs are improved.
Description
The following tweaks are made:
TxGraph::try_get_chain_position
used to always exclude unconfirmed transactions with last_seen value of 0. However, what is the point of including a transaction in the graph if it cannot be part of the chain history? Additionally, maybe sometimes we don't wish to use the last_seen field at all. The new behavior will consider unconfirmed transactions with last_seen of 0.LocalChain::insert_block
. This is necessary as aLocalChain
is updated with anotherLocalChain
. The updateLocalChain
needs a simple way to insert blocks.BlockId
should not implementAnchor
. Discussion: Introduce redesignedbdk_chain
structures #926 (comment).TxGraph::relevant_heights
as it is ambiguous. A simpler and more flexible alternative methodTxGraph::all_anchors
is introduced.Changelog notice
Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features: