Skip to content

Commit a7cbc8a

Browse files
committed
lib!: rename database feature to rusqlite
1 parent 8230747 commit a7cbc8a

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ tokio = { version = "1", default-features = false, features = [
3333
rusqlite = { version = "0.31.0", features = ["bundled"], optional = true }
3434

3535
[features]
36-
default = ["database"]
37-
database = ["rusqlite"]
36+
default = ["rusqlite"]
37+
rusqlite = ["dep:rusqlite"]
3838
filter-control = []
3939

4040
[dev-dependencies]

src/builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use bitcoin::Network;
66
use bitcoin::ScriptBuf;
77

88
use super::{client::Client, config::NodeConfig, node::Node};
9-
#[cfg(feature = "database")]
9+
#[cfg(feature = "rusqlite")]
1010
use crate::db::error::SqlInitializationError;
11-
#[cfg(feature = "database")]
11+
#[cfg(feature = "rusqlite")]
1212
use crate::db::sqlite::{headers::SqliteHeaderDb, peers::SqlitePeerDb};
1313
use crate::network::dns::{DnsResolver, DNS_RESOLVER_PORT};
1414
use crate::network::ConnectionType;
@@ -18,7 +18,7 @@ use crate::{
1818
};
1919
use crate::{FilterSyncPolicy, LogLevel, PeerStoreSizeConfig, TrustedPeer};
2020

21-
#[cfg(feature = "database")]
21+
#[cfg(feature = "rusqlite")]
2222
/// The default node returned from the [`NodeBuilder`](crate::core).
2323
pub type NodeDefault = Node<SqliteHeaderDb, SqlitePeerDb>;
2424

@@ -210,7 +210,7 @@ impl NodeBuilder {
210210
/// # Errors
211211
///
212212
/// Building a node and client will error if a database connection is denied or cannot be found.
213-
#[cfg(feature = "database")]
213+
#[cfg(feature = "rusqlite")]
214214
pub fn build(&mut self) -> Result<(NodeDefault, Client), SqlInitializationError> {
215215
let peer_store = SqlitePeerDb::new(self.network, self.config.data_path.clone())?;
216216
let header_store = SqliteHeaderDb::new(self.network, self.config.data_path.clone())?;

src/db/error.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fmt::Debug;
22

33
/// Errors when initializing a SQL-based backend.
4-
#[cfg(feature = "database")]
4+
#[cfg(feature = "rusqlite")]
55
#[derive(Debug)]
66
pub enum SqlInitializationError {
77
/// A file or directory could not be opened or created.
@@ -10,7 +10,7 @@ pub enum SqlInitializationError {
1010
SQL(rusqlite::Error),
1111
}
1212

13-
#[cfg(feature = "database")]
13+
#[cfg(feature = "rusqlite")]
1414
impl core::fmt::Display for SqlInitializationError {
1515
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1616
match self {
@@ -24,7 +24,7 @@ impl core::fmt::Display for SqlInitializationError {
2424
}
2525
}
2626

27-
#[cfg(feature = "database")]
27+
#[cfg(feature = "rusqlite")]
2828
impl std::error::Error for SqlInitializationError {
2929
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
3030
match self {
@@ -34,22 +34,22 @@ impl std::error::Error for SqlInitializationError {
3434
}
3535
}
3636

37-
#[cfg(feature = "database")]
37+
#[cfg(feature = "rusqlite")]
3838
impl From<rusqlite::Error> for SqlInitializationError {
3939
fn from(value: rusqlite::Error) -> Self {
4040
Self::SQL(value)
4141
}
4242
}
4343

44-
#[cfg(feature = "database")]
44+
#[cfg(feature = "rusqlite")]
4545
impl From<std::io::Error> for SqlInitializationError {
4646
fn from(value: std::io::Error) -> Self {
4747
Self::IO(value)
4848
}
4949
}
5050

5151
/// Errors while reading or writing to and from a SQL-based peer backend.
52-
#[cfg(feature = "database")]
52+
#[cfg(feature = "rusqlite")]
5353
#[derive(Debug)]
5454
pub enum SqlPeerStoreError {
5555
/// A consensus critical data structure is malformed.
@@ -60,7 +60,7 @@ pub enum SqlPeerStoreError {
6060
SQL(rusqlite::Error),
6161
}
6262

63-
#[cfg(feature = "database")]
63+
#[cfg(feature = "rusqlite")]
6464
impl core::fmt::Display for SqlPeerStoreError {
6565
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6666
match self {
@@ -80,7 +80,7 @@ impl core::fmt::Display for SqlPeerStoreError {
8080
}
8181
}
8282

83-
#[cfg(feature = "database")]
83+
#[cfg(feature = "rusqlite")]
8484
impl std::error::Error for SqlPeerStoreError {
8585
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
8686
match self {
@@ -91,22 +91,22 @@ impl std::error::Error for SqlPeerStoreError {
9191
}
9292
}
9393

94-
#[cfg(feature = "database")]
94+
#[cfg(feature = "rusqlite")]
9595
impl From<rusqlite::Error> for SqlPeerStoreError {
9696
fn from(value: rusqlite::Error) -> Self {
9797
Self::SQL(value)
9898
}
9999
}
100100

101-
#[cfg(feature = "database")]
101+
#[cfg(feature = "rusqlite")]
102102
impl From<bitcoin::consensus::encode::Error> for SqlPeerStoreError {
103103
fn from(value: bitcoin::consensus::encode::Error) -> Self {
104104
Self::Deserialize(value)
105105
}
106106
}
107107

108108
/// Errors while reading or writing to and from a SQL-based block header backend.
109-
#[cfg(feature = "database")]
109+
#[cfg(feature = "rusqlite")]
110110
#[derive(Debug)]
111111
pub enum SqlHeaderStoreError {
112112
/// The headers do not link together.
@@ -117,7 +117,7 @@ pub enum SqlHeaderStoreError {
117117
SQL(rusqlite::Error),
118118
}
119119

120-
#[cfg(feature = "database")]
120+
#[cfg(feature = "rusqlite")]
121121
impl core::fmt::Display for SqlHeaderStoreError {
122122
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
123123
match self {
@@ -134,7 +134,7 @@ impl core::fmt::Display for SqlHeaderStoreError {
134134
}
135135
}
136136

137-
#[cfg(feature = "database")]
137+
#[cfg(feature = "rusqlite")]
138138
impl std::error::Error for SqlHeaderStoreError {
139139
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
140140
match self {
@@ -145,14 +145,14 @@ impl std::error::Error for SqlHeaderStoreError {
145145
}
146146
}
147147

148-
#[cfg(feature = "database")]
148+
#[cfg(feature = "rusqlite")]
149149
impl From<rusqlite::Error> for SqlHeaderStoreError {
150150
fn from(value: rusqlite::Error) -> Self {
151151
Self::SQL(value)
152152
}
153153
}
154154

155-
#[cfg(feature = "database")]
155+
#[cfg(feature = "rusqlite")]
156156
impl From<bitcoin::consensus::encode::Error> for SqlHeaderStoreError {
157157
fn from(value: bitcoin::consensus::encode::Error) -> Self {
158158
Self::Deserialize(value)

src/db/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::chain::IndexedHeader;
1515
/// Errors a database backend may produce.
1616
pub mod error;
1717
/// Persistence traits defined with SQL Lite to store data between sessions.
18-
#[cfg(feature = "database")]
18+
#[cfg(feature = "rusqlite")]
1919
pub mod sqlite;
2020
/// Traits that define the header and peer databases.
2121
pub mod traits;

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ pub use chain::checkpoints::{
120120
HeaderCheckpoint, MAINNET_HEADER_CP, SIGNET_HEADER_CP, TESTNET4_HEADER_CP,
121121
};
122122

123-
#[cfg(feature = "database")]
123+
#[cfg(feature = "rusqlite")]
124124
#[doc(inline)]
125125
pub use db::sqlite::{headers::SqliteHeaderDb, peers::SqlitePeerDb};
126126

0 commit comments

Comments
 (0)