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
| 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.
I thought the previous implementation of this was fine too.
There was a problem hiding this comment.
You mean without the option?
There was a problem hiding this comment.
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
|
|
||
| /// Trait that makes an object appendable. | ||
| pub trait Append { | ||
| pub trait Append: Default { |
There was a problem hiding this comment.
👍 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.
|
I pushed a commit to fix some docs that still mentioned |
Description
@LLFourn suggested these changes which greatly simplifies the amount of code we have to maintain and removes the
async-traitdependency. We removePersistBackend,PersistBackendAsync,StageExtandStageExtAsynccompletely. 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 returningNoneif 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
takeconvenience method to theAppendtrait. I thought it would be handy for the caller to do a staging area with this.Changelog notice
persistsubmodule frombdk_chain.Walletto outsource it's persistence logic by introducingWallet::take_staged.takeconvenience method toAppendtrait.Checklists
All Submissions:
cargo fmtandcargo clippybefore committingNew Features:
* [ ] I've added tests for the new feature