From: Alekos Filini Date: Wed, 5 Feb 2020 10:59:02 +0000 (+0100) Subject: Add a generalized database trait and a Sled-based implementation X-Git-Tag: 0.1.0-beta.1~78 X-Git-Url: http://internal-gitweb-vhost/%22https:/parse/scripts/database/engine/enum.VerifyError.html?a=commitdiff_plain;h=6ab29fcec5bf318d4d57f54b6f89cd791ed1c92e;p=bdk Add a generalized database trait and a Sled-based implementation --- diff --git a/core/lib/Cargo.toml b/core/lib/Cargo.toml index 6894d5e9..1f0b2c2d 100644 --- a/core/lib/Cargo.toml +++ b/core/lib/Cargo.toml @@ -10,3 +10,10 @@ miniscript = { version = "0.12" } serde = { version = "^1.0", features = ["derive"] } serde_json = { version = "^1.0" } base64 = "^0.11" + +# Optional dependencies +sled = { version = "0.31.0", optional = true } + +[features] +default = ["sled"] +key-value-db = ["sled"] diff --git a/core/lib/src/database/keyvalue.rs b/core/lib/src/database/keyvalue.rs new file mode 100644 index 00000000..f04e9fbd --- /dev/null +++ b/core/lib/src/database/keyvalue.rs @@ -0,0 +1,390 @@ +use std::borrow::Borrow; +use std::convert::{From, TryInto}; + +use sled::{Batch, Db, IVec, Tree}; + +use bitcoin::consensus::encode::{deserialize, serialize}; +use bitcoin::hash_types::Txid; +use bitcoin::util::bip32::{ChildNumber, DerivationPath}; +use bitcoin::{OutPoint, Script, Transaction, TxOut}; + +use crate::database::{BatchDatabase, BatchOperations, Database}; +use crate::error::Error; +use crate::types::*; + +// TODO: rename mod to Sled? + +// path -> script p{i,e} -> script +// script -> path s