-
Notifications
You must be signed in to change notification settings - Fork 318
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
Remove persist
submodule
#1473
Remove persist
submodule
#1473
Conversation
b4b3cad
to
2461498
Compare
Remove `PersistBackend`, `PersistBackendAsync`, `StageExt` and `StageExtAsync`. Remove `async` feature flag and dependency. Update examples and wallet.
This is useful if the caller wishes to use the type as a staging area. This is breaking as `Append` has a `Default` bound now.
2461498
to
feb27df
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.
Approach ACK
bdk_chain::persist::StageExtAsync::commit_to(&mut self.stage, persist_backend).await?; | ||
Ok(committed.is_some()) | ||
/// Get a reference of the staged [`ChangeSet`] that are yet to be committed (if any). | ||
pub fn staged(&self) -> Option<&ChangeSet> { |
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 thought the previous implementation of this was fine too.
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.
You mean without the option?
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 think I was worried that people will try persist using this and then call take_staged
only after saving to db succeeded.
0816732
to
d4393f9
Compare
d4393f9
to
a0bf45b
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 a0bf45b
@@ -114,12 +114,21 @@ pub trait AnchorFromBlockPosition: Anchor { | |||
} | |||
|
|||
/// Trait that makes an object appendable. | |||
pub trait Append { | |||
pub trait Append: Default { |
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.
👍 This has the added benefit that it should solve #1103 by requiring all change set fields implement Default
. So if we load a wallet data file from an older bdk version we should gracefully handle fields added in newer bdk versions since they must have a reasonable default value.
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 pushed a commit to fix some docs that still mentioned |
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.
self-ACK a0bf45b
Description
@LLFourn suggested these changes which greatly simplifies the amount of code we have to maintain and removes the
async-trait
dependency. We removePersistBackend
,PersistBackendAsync
,StageExt
andStageExtAsync
completely. Instead, we introduceWallet::take_staged(&mut self) -> Option<ChangeSet>
.The original intention to keep a staging area (
StageExt
,StageExtAsync
) is to enforce:PersistBackend
) fails.We achieve
1.
by returningNone
if the staged changeset is empty.2.
is not too important. The caller can try figure out what to do with the changeset if persisting to db fails.Notes to the reviewers
I added a
take
convenience method to theAppend
trait. I thought it would be handy for the caller to do a staging area with this.Changelog notice
persist
submodule frombdk_chain
.Wallet
to outsource it's persistence logic by introducingWallet::take_staged
.take
convenience method toAppend
trait.Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features:
* [ ] I've added tests for the new feature