mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-23 07:35:03 +01:00
feat: Add optional redb feature flag for database support
This commit is contained in:
committed by
thesimplekid
parent
9b87a65940
commit
7a9faec984
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -123,6 +123,8 @@ jobs:
|
||||
-p cdk-payment-processor,
|
||||
--bin cdk-cli,
|
||||
--bin cdk-cli --features sqlcipher,
|
||||
--bin cdk-cli --features redb,
|
||||
--bin cdk-cli --features "sqlcipher redb",
|
||||
--bin cdk-mintd,
|
||||
--bin cdk-mintd --features redis,
|
||||
--bin cdk-mintd --features redb,
|
||||
|
||||
@@ -11,12 +11,14 @@ rust-version.workspace = true
|
||||
|
||||
[features]
|
||||
sqlcipher = ["cdk-sqlite/sqlcipher"]
|
||||
# MSRV is not tracked with redb enabled
|
||||
redb = ["dep:cdk-redb"]
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
bip39.workspace = true
|
||||
cdk = { workspace = true, default-features = false, features = ["wallet", "auth"]}
|
||||
cdk-redb = { workspace = true, features = ["wallet"] }
|
||||
cdk-redb = { workspace = true, features = ["wallet"], optional = true }
|
||||
cdk-sqlite = { workspace = true, features = ["wallet"] }
|
||||
clap.workspace = true
|
||||
serde.workspace = true
|
||||
|
||||
@@ -9,6 +9,7 @@ use bip39::Mnemonic;
|
||||
use cdk::cdk_database;
|
||||
use cdk::cdk_database::WalletDatabase;
|
||||
use cdk::wallet::{HttpClient, MultiMintWallet, Wallet, WalletBuilder};
|
||||
#[cfg(feature = "redb")]
|
||||
use cdk_redb::WalletRedbDatabase;
|
||||
use cdk_sqlite::WalletSqliteDatabase;
|
||||
use clap::{Parser, Subcommand};
|
||||
@@ -132,10 +133,16 @@ async fn main() -> Result<()> {
|
||||
Arc::new(sql)
|
||||
}
|
||||
"redb" => {
|
||||
#[cfg(feature = "redb")]
|
||||
{
|
||||
let redb_path = work_dir.join("cdk-cli.redb");
|
||||
|
||||
Arc::new(WalletRedbDatabase::new(&redb_path)?)
|
||||
}
|
||||
#[cfg(not(feature = "redb"))]
|
||||
{
|
||||
bail!("redb feature not enabled");
|
||||
}
|
||||
}
|
||||
_ => bail!("Unknown DB engine"),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user