Skip to content
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

Add generic Params type parameter to persistence traits #1565

Closed
wants to merge 2 commits into from

Conversation

evanlinjin
Copy link
Member

Description

This is a potential solution for the problem @matthiasdebernardini mentioned in #1562 (comment).

However, I'm wondering if it would be better for persistence implementations to internally provide custom configuration. I.e.

type NamedWalletConnection<'c> {
    wallet_name: String,
    conn: sqlx::Connection<'c>,
}

impl<'c> AsyncWalletPersister for NamedWalletConnection<'c> {
    // ... stuff ...
}

I'm worried that this PR will introduce unnecessary complexity.

Notes to the reviewers

Refer to the conversation in #1562 (which this PR is based on).

Changelog notice

  • Changed bdk_wallet persistence traits to have a generic Params type parameter to allow persister implementations to include custom configurations. This is introduced via a common trait WalletPersisterCommon.

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

This introduces a `WalletPersisterCommon` trait that provides common
type parameters (`::Error` and `::Params`) for `WalletPersister` and
`AsyncWalletPersister`.

Methods/functions that construct `PersistedWallet` now take in an extra
`::Params` input.

This allows more flexible configurations for persister implementations.
@matthiasdebernardini
Copy link

I can work with this, thanks!

@notmandatory
Copy link
Member

notmandatory commented Aug 21, 2024

@matthiasdebernardini did you get a chance to try just setting wallet name when you create your postgres store struct? I still think that would be simpler and then this PR wouldn't be needed.

EDIT: It looks like you did get this working another way: #1562 (comment)

@matthiasdebernardini
Copy link

yup, I don't need it, can use Store anyways

@evanlinjin
Copy link
Member Author

Closing for now since the solution in the PR description is sufficient.

@evanlinjin evanlinjin closed this Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants