-
Notifications
You must be signed in to change notification settings - Fork 324
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
LocalChain
with hardwired genesis block
#1178
Conversation
6dadc40
to
01ee8c3
Compare
7c6164d
to
eb39808
Compare
LocalChain
with hardwired genesis blockLocalChain
with hardwired genesis block
This comment was marked as resolved.
This comment was marked as resolved.
97c78e7
to
7e0cd98
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.
ACK 632b806
632b806
to
63e06fd
Compare
crates/bitcoind_rpc/src/lib.rs
Outdated
/// | ||
/// `start_height` is the block height to start emitting blocks from. | ||
pub fn from_height(client: &'c C, start_height: u32) -> Self { | ||
/// TODO |
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 wonder what we can do so that we don't forget to write this doc.
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.
Looks like docs here should be something like:
/// TODO | |
/// Construct a new [`Emitter`] with the given RPC `client`, `last_cp` and `start_height`. | |
/// | |
/// `last_cp` is the check point used to find the latest block which is still part of the best chain. | |
/// `start_height` is the block height to start emitting blocks from. |
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.
Great work Evan! I just have some nits.
impl<D> Wallet<D> { | ||
/// Create a wallet from a `descriptor` (and an optional `change_descriptor`) and load related | ||
/// transaction data from `db`. | ||
/// Initialize an empty [`Wallet`]. |
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.
What does empty
here mean? From my understanding, it means the wallet has an empty state (empty IndexedTxGraph, empty localchain). We might want to improve the doc here.
Self::load_from_changeset(descriptor, change_descriptor, db, changeset) | ||
} | ||
|
||
fn load_from_changeset<E: IntoWalletDescriptor>( |
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: I will change the name of this method to init_from_changeset
. Feel free to ignore if it doesn't resonate.
{ | ||
/// Creates a new store from a [`File`]. | ||
/// Create a new [`Store`] file in write-only mode; error if the file exists. |
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.
Is it really in write only mode given that the file is also given read option on line 65
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 e342a8c
Looks good, nice to have that chain tip Option removed!
crates/bitcoind_rpc/src/lib.rs
Outdated
/// | ||
/// `start_height` is the block height to start emitting blocks from. | ||
pub fn from_height(client: &'c C, start_height: u32) -> Self { | ||
/// TODO |
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.
Looks like docs here should be something like:
/// TODO | |
/// Construct a new [`Emitter`] with the given RPC `client`, `last_cp` and `start_height`. | |
/// | |
/// `last_cp` is the check point used to find the latest block which is still part of the best chain. | |
/// `start_height` is the block height to start emitting blocks from. |
This should also close #1107 . |
@evanlinjin looks like this one has a conflict so needs a rebase before I can merge it. |
This ensures that `LocalChain` will always have a tip. The `ChainOracle` trait's `get_chain_tip` method no longer needs to return an option.
`Wallet::new` now creates a new wallet. `Wallet::load` loads an existing wallet. The network type is now recoverable from persistence. Error types have been simplified.
e342a8c
to
b216585
Compare
These methods try to load wallet from persistence and initializes the wallet instead if non-existant. An internal helper method `create_signers` is added to reuse code. Documentation is also improved.
`PersistBackend::is_empty` is removed. Instead, `load_from_persistence` returns an option of the changeset. `None` means persistence is empty. This is a better API than a separate method. We can now differentiate between a persisted single changeset and nothing persisted. `Store::aggregate_changeset` is refactored to return a `Result` instead of a tuple. A new error type (`AggregateChangesetsError`) is introduced to include the partially-aggregated changeset in the error. This is a more idiomatic API.
b216585
to
79b84be
Compare
@notmandatory don't merge yet, I want to address comments and make clippy happier. |
closes #1079
closes #1107
Description
Many methods of
TxGraph
require achain_tip: BlockId
input to use against aChainOracle
implementation. This is used to ask theChainOracle
implementation whether a certain block exists in the chain identified by thechain_tip
. This guarantees that theTxGraph
methods will return a consistent history of transactions.However, the
ChainOracle
trait'sget_chain_tip
method returns an option ofBlockId
. It becomes unclear what to do whenget_chain_tip
returnsNone
.This PR changes the
ChainOracle::get_chain_tip
method to always return aBlockId
(noOption
).LocalChain
now hardwires the genesis block in order to implementChainOracle
.bdk::Wallet
andbdk_file_store::Store
are changed to have separate constructor methods for initializing a fresh instance and recovering a previous instance from persistence.Notes to the reviewers
Changelog notice
ChainOracle::get_chain_tip
method to return aBlockId
instead of anOption
of aBlockId
.LocalChain
so that the genesisBlockId
is hardwired. This way, theChainOracle::get_chain_tip
implementation can always return a tip.is_empty
method toPersistBackend
. This returns true when there is no data in the persistence.Wallet::new
to initialize a fresh wallet only.Wallet::load
to restore an instance of a wallet.Store::new
with separate methods to create/open the database file.Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features: