Skip to content

Commit 9ed1e82

Browse files
committed
wrap
1 parent 78fa512 commit 9ed1e82

File tree

15 files changed

+252
-152
lines changed

15 files changed

+252
-152
lines changed

Cargo.toml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,29 @@ panic = 'abort' # Abort on panic
2929
default = []
3030

3131
[dependencies]
32-
lightning = { version = "0.2.0-rc1", features = ["std"] }
33-
lightning-types = { version = "0.3.0-rc1" }
34-
lightning-invoice = { version = "0.34.0-rc1", features = ["std"] }
35-
lightning-net-tokio = { version = "0.2.0-rc1" }
36-
lightning-persister = { version = "0.2.0-rc1", features = ["tokio"] }
37-
lightning-background-processor = { version = "0.2.0-rc1" }
38-
lightning-rapid-gossip-sync = { version = "0.2.0-rc1" }
39-
lightning-block-sync = { version = "0.2.0-rc1", features = ["rest-client", "rpc-client", "tokio"] }
40-
lightning-transaction-sync = { version = "0.2.0-rc1", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
41-
lightning-liquidity = { version = "0.2.0-rc1", features = ["std"] }
42-
lightning-macros = { version = "0.2.0-rc1" }
43-
44-
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
45-
#lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
46-
#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
47-
#lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
48-
#lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["tokio"] }
49-
#lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
50-
#lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
51-
#lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["rest-client", "rpc-client", "tokio"] }
52-
#lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["esplora-async-https", "electrum-rustls-ring", "time"] }
53-
#lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
54-
#lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
32+
#lightning = { version = "0.2.0-rc1", features = ["std"] }
33+
#lightning-types = { version = "0.3.0-rc1" }
34+
#lightning-invoice = { version = "0.34.0-rc1", features = ["std"] }
35+
#lightning-net-tokio = { version = "0.2.0-rc1" }
36+
#lightning-persister = { version = "0.2.0-rc1", features = ["tokio"] }
37+
#lightning-background-processor = { version = "0.2.0-rc1" }
38+
#lightning-rapid-gossip-sync = { version = "0.2.0-rc1" }
39+
#lightning-block-sync = { version = "0.2.0-rc1", features = ["rest-client", "rpc-client", "tokio"] }
40+
#lightning-transaction-sync = { version = "0.2.0-rc1", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
41+
#lightning-liquidity = { version = "0.2.0-rc1", features = ["std"] }
42+
#lightning-macros = { version = "0.2.0-rc1" }
43+
44+
lightning = { git = "https://git.bitcoin.ninja/rust-lightning", branch = "2025-10-msrv-less-box", features = ["std"] }
45+
lightning-types = { git = "https://git.bitcoin.ninja/rust-lightning", branch = "2025-10-msrv-less-box" }
46+
lightning-invoice = { git = "https://git.bitcoin.ninja/rust-lightning", branch = "2025-10-msrv-less-box", features = ["std"] }
47+
lightning-net-tokio = { git = "https://git.bitcoin.ninja/rust-lightning", branch = "2025-10-msrv-less-box" }
48+
lightning-persister = { git = "https://git.bitcoin.ninja/rust-lightning", branch = "2025-10-msrv-less-box", features = ["tokio"] }
49+
lightning-background-processor = { git = "https://git.bitcoin.ninja/rust-lightning", branch = "2025-10-msrv-less-box" }
50+
lightning-rapid-gossip-sync = { git = "https://git.bitcoin.ninja/rust-lightning", branch = "2025-10-msrv-less-box" }
51+
lightning-block-sync = { git = "https://git.bitcoin.ninja/rust-lightning", branch = "2025-10-msrv-less-box", features = ["rest-client", "rpc-client", "tokio"] }
52+
lightning-transaction-sync = { git = "https://git.bitcoin.ninja/rust-lightning", branch = "2025-10-msrv-less-box", features = ["esplora-async-https", "electrum-rustls-ring", "time"] }
53+
lightning-liquidity = { git = "https://git.bitcoin.ninja/rust-lightning", branch = "2025-10-msrv-less-box" }
54+
lightning-macros = { git = "https://git.bitcoin.ninja/rust-lightning", branch = "2025-10-msrv-less-box" }
5555

5656
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03", features = ["std"] }
5757
#lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03" }
@@ -108,9 +108,9 @@ prost = { version = "0.11.6", default-features = false}
108108
winapi = { version = "0.3", features = ["winbase"] }
109109

110110
[dev-dependencies]
111-
lightning = { version = "0.2.0-rc1", features = ["std", "_test_utils"] }
112-
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
113-
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03", features = ["std", "_test_utils"] }
111+
#lightning = { version = "0.2.0-rc1", features = ["std", "_test_utils"] }
112+
lightning = { git = "https://git.bitcoin.ninja/rust-lightning", branch="2025-10-msrv-less-box", features = ["std", "_test_utils"] }
113+
#lightning = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "21e9a9c0ef80021d0669f2a366f55d08ba8d9b03", features = ["std", "_test_utils"] }
114114
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
115115
proptest = "1.0.0"
116116
regex = "1.5.6"

src/builder.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ use crate::peer_store::PeerStore;
6969
use crate::runtime::Runtime;
7070
use crate::tx_broadcaster::TransactionBroadcaster;
7171
use crate::types::{
72-
ChainMonitor, ChannelManager, DynStore, GossipSync, Graph, KeysManager, MessageRouter,
73-
OnionMessenger, PaymentStore, PeerManager, Persister,
72+
ChainMonitor, ChannelManager, DynStore, DynStoreWrapper, GossipSync, Graph, KeysManager,
73+
MessageRouter, OnionMessenger, PaymentStore, PeerManager, Persister, SyncAndAsyncKVStore,
7474
};
7575
use crate::wallet::persist::KVStoreWalletPersister;
7676
use crate::wallet::Wallet;
@@ -588,14 +588,12 @@ impl NodeBuilder {
588588
let storage_dir_path = self.config.storage_dir_path.clone();
589589
fs::create_dir_all(storage_dir_path.clone())
590590
.map_err(|_| BuildError::StoragePathAccessFailed)?;
591-
let kv_store = Arc::new(
592-
SqliteStore::new(
593-
storage_dir_path.into(),
594-
Some(io::sqlite_store::SQLITE_DB_FILE_NAME.to_string()),
595-
Some(io::sqlite_store::KV_TABLE_NAME.to_string()),
596-
)
597-
.map_err(|_| BuildError::KVStoreSetupFailed)?,
598-
);
591+
let kv_store = SqliteStore::new(
592+
storage_dir_path.into(),
593+
Some(io::sqlite_store::SQLITE_DB_FILE_NAME.to_string()),
594+
Some(io::sqlite_store::KV_TABLE_NAME.to_string()),
595+
)
596+
.map_err(|_| BuildError::KVStoreSetupFailed)?;
599597
self.build_with_store(kv_store)
600598
}
601599

@@ -607,7 +605,7 @@ impl NodeBuilder {
607605

608606
fs::create_dir_all(storage_dir_path.clone())
609607
.map_err(|_| BuildError::StoragePathAccessFailed)?;
610-
let kv_store = Arc::new(FilesystemStore::new(storage_dir_path));
608+
let kv_store = FilesystemStore::new(storage_dir_path);
611609
self.build_with_store(kv_store)
612610
}
613611

@@ -743,12 +741,12 @@ impl NodeBuilder {
743741
seed_bytes,
744742
runtime,
745743
logger,
746-
Arc::new(vss_store),
744+
Arc::new(DynStoreWrapper(vss_store)),
747745
)
748746
}
749747

750748
/// Builds a [`Node`] instance according to the options previously configured.
751-
pub fn build_with_store(&self, kv_store: Arc<DynStore>) -> Result<Node, BuildError> {
749+
pub fn build_with_store<S: SyncAndAsyncKVStore + Send + Sync + 'static>(&self, kv_store: S) -> Result<Node, BuildError> {
752750
let logger = setup_logger(&self.log_writer_config, &self.config)?;
753751

754752
let runtime = if let Some(handle) = self.runtime_handle.as_ref() {
@@ -777,7 +775,7 @@ impl NodeBuilder {
777775
seed_bytes,
778776
runtime,
779777
logger,
780-
kv_store,
778+
Arc::new(DynStoreWrapper(kv_store)),
781779
)
782780
}
783781
}

src/chain/bitcoind.rs

Lines changed: 64 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// accordance with one or both of these licenses.
77

88
use std::collections::{HashMap, VecDeque};
9+
use std::future::Future;
910
use std::sync::atomic::{AtomicU64, Ordering};
1011
use std::sync::{Arc, Mutex, RwLock};
1112
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
@@ -23,7 +24,7 @@ use lightning_block_sync::poll::{ChainPoller, ChainTip, ValidatedBlockHeader};
2324
use lightning_block_sync::rest::RestClient;
2425
use lightning_block_sync::rpc::{RpcClient, RpcError};
2526
use lightning_block_sync::{
26-
AsyncBlockSourceResult, BlockData, BlockHeaderData, BlockSource, BlockSourceErrorKind, Cache,
27+
BlockData, BlockHeaderData, BlockSource, BlockSourceError, BlockSourceErrorKind, Cache,
2728
SpvClient,
2829
};
2930
use serde::Serialize;
@@ -643,46 +644,56 @@ impl BlockSource for UtxoSourceClient {
643644
&'a self,
644645
header_hash: &'a BlockHash,
645646
height_hint: Option<u32>,
646-
) -> AsyncBlockSourceResult<'a, BlockHeaderData> {
647-
match self {
648-
Self::Rpc(client) => client.get_header(header_hash, height_hint),
649-
Self::Rest(client) => client.get_header(header_hash, height_hint),
647+
) -> impl Future<Output = Result<BlockHeaderData, BlockSourceError>> + 'a {
648+
async move {
649+
match self {
650+
Self::Rpc(client) => client.get_header(header_hash, height_hint).await,
651+
Self::Rest(client) => client.get_header(header_hash, height_hint).await,
652+
}
650653
}
651654
}
652655

653656
fn get_block<'a>(
654657
&'a self,
655658
header_hash: &'a BlockHash,
656-
) -> AsyncBlockSourceResult<'a, BlockData> {
657-
match self {
658-
Self::Rpc(client) => client.get_block(header_hash),
659-
Self::Rest(client) => client.get_block(header_hash),
659+
) -> impl Future<Output = Result<BlockData, BlockSourceError>> + 'a {
660+
async move {
661+
match self {
662+
Self::Rpc(client) => client.get_block(header_hash).await,
663+
Self::Rest(client) => client.get_block(header_hash).await,
664+
}
660665
}
661666
}
662667

663-
fn get_best_block(
664-
&self,
665-
) -> AsyncBlockSourceResult<'_, (BlockHash, Option<u32>)> {
666-
match self {
667-
Self::Rpc(client) => client.get_best_block(),
668-
Self::Rest(client) => client.get_best_block(),
668+
fn get_best_block<'a>(
669+
&'a self,
670+
) -> impl Future<Output = Result<(BlockHash, Option<u32>), BlockSourceError>> + 'a {
671+
async move {
672+
match self {
673+
Self::Rpc(client) => client.get_best_block().await,
674+
Self::Rest(client) => client.get_best_block().await,
675+
}
669676
}
670677
}
671678
}
672679

673680

674681
impl UtxoSource for UtxoSourceClient {
675-
fn get_block_hash_by_height<'a>(&'a self, block_height: u32) -> AsyncBlockSourceResult<'a, BlockHash> {
676-
match self {
677-
Self::Rpc(client) => client.get_block_hash_by_height(block_height),
678-
Self::Rest(client) => client.get_block_hash_by_height(block_height),
682+
fn get_block_hash_by_height<'a>(&'a self, block_height: u32) -> impl Future<Output = Result<BlockHash, BlockSourceError>> + 'a {
683+
async move {
684+
match self {
685+
Self::Rpc(client) => client.get_block_hash_by_height(block_height).await,
686+
Self::Rest(client) => client.get_block_hash_by_height(block_height).await,
687+
}
679688
}
680689
}
681690

682-
fn is_output_unspent<'a>(&'a self, outpoint: OutPoint) -> AsyncBlockSourceResult<'a, bool> {
683-
match self {
684-
Self::Rpc(client) => client.is_output_unspent(outpoint),
685-
Self::Rest(client) => client.is_output_unspent(outpoint),
691+
fn is_output_unspent<'a>(&'a self, outpoint: OutPoint) -> impl Future<Output = Result<bool, BlockSourceError>> + 'a {
692+
async move {
693+
match self {
694+
Self::Rpc(client) => client.is_output_unspent(outpoint).await,
695+
Self::Rest(client) => client.is_output_unspent(outpoint).await,
696+
}
686697
}
687698
}
688699
}
@@ -1235,38 +1246,44 @@ impl BitcoindClient {
12351246
impl BlockSource for BitcoindClient {
12361247
fn get_header<'a>(
12371248
&'a self, header_hash: &'a bitcoin::BlockHash, height_hint: Option<u32>,
1238-
) -> AsyncBlockSourceResult<'a, BlockHeaderData> {
1239-
match self {
1240-
BitcoindClient::Rpc { rpc_client, .. } => {
1241-
Box::pin(async move { rpc_client.get_header(header_hash, height_hint).await })
1242-
},
1243-
BitcoindClient::Rest { rest_client, .. } => {
1244-
Box::pin(async move { rest_client.get_header(header_hash, height_hint).await })
1245-
},
1249+
) -> impl Future<Output = Result<BlockHeaderData, BlockSourceError>> + 'a {
1250+
async move {
1251+
match self {
1252+
BitcoindClient::Rpc { rpc_client, .. } => {
1253+
rpc_client.get_header(header_hash, height_hint).await
1254+
},
1255+
BitcoindClient::Rest { rest_client, .. } => {
1256+
rest_client.get_header(header_hash, height_hint).await
1257+
},
1258+
}
12461259
}
12471260
}
12481261

12491262
fn get_block<'a>(
12501263
&'a self, header_hash: &'a bitcoin::BlockHash,
1251-
) -> AsyncBlockSourceResult<'a, BlockData> {
1252-
match self {
1253-
BitcoindClient::Rpc { rpc_client, .. } => {
1254-
Box::pin(async move { rpc_client.get_block(header_hash).await })
1255-
},
1256-
BitcoindClient::Rest { rest_client, .. } => {
1257-
Box::pin(async move { rest_client.get_block(header_hash).await })
1258-
},
1264+
) -> impl Future<Output = Result<BlockData, BlockSourceError>> + 'a {
1265+
async move {
1266+
match self {
1267+
BitcoindClient::Rpc { rpc_client, .. } => {
1268+
rpc_client.get_block(header_hash).await
1269+
},
1270+
BitcoindClient::Rest { rest_client, .. } => {
1271+
rest_client.get_block(header_hash).await
1272+
},
1273+
}
12591274
}
12601275
}
12611276

1262-
fn get_best_block(&self) -> AsyncBlockSourceResult<'_, (bitcoin::BlockHash, Option<u32>)> {
1263-
match self {
1264-
BitcoindClient::Rpc { rpc_client, .. } => {
1265-
Box::pin(async move { rpc_client.get_best_block().await })
1266-
},
1267-
BitcoindClient::Rest { rest_client, .. } => {
1268-
Box::pin(async move { rest_client.get_best_block().await })
1269-
},
1277+
fn get_best_block<'a>(&'a self) -> impl Future<Output = Result<(bitcoin::BlockHash, Option<u32>), BlockSourceError>> + 'a {
1278+
async move {
1279+
match self {
1280+
BitcoindClient::Rpc { rpc_client, .. } => {
1281+
rpc_client.get_best_block().await
1282+
},
1283+
BitcoindClient::Rest { rest_client, .. } => {
1284+
rest_client.get_best_block().await
1285+
},
1286+
}
12701287
}
12711288
}
12721289
}

src/data_store.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ mod tests {
176176

177177
use super::*;
178178
use crate::hex_utils;
179+
use crate::types::DynStoreWrapper;
179180

180181
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
181182
struct TestObjectId {
@@ -234,7 +235,7 @@ mod tests {
234235

235236
#[test]
236237
fn data_is_persisted() {
237-
let store: Arc<DynStore> = Arc::new(TestStore::new(false));
238+
let store: Arc<DynStore> = Arc::new(DynStoreWrapper(TestStore::new(false)));
238239
let logger = Arc::new(TestLogger::new());
239240
let primary_namespace = "datastore_test_primary".to_string();
240241
let secondary_namespace = "datastore_test_secondary".to_string();

src/event.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,10 +1608,11 @@ mod tests {
16081608
use lightning::util::test_utils::{TestLogger, TestStore};
16091609

16101610
use super::*;
1611+
use crate::types::DynStoreWrapper;
16111612

16121613
#[tokio::test]
16131614
async fn event_queue_persistence() {
1614-
let store: Arc<DynStore> = Arc::new(TestStore::new(false));
1615+
let store: Arc<DynStore> = Arc::new(DynStoreWrapper(TestStore::new(false)));
16151616
let logger = Arc::new(TestLogger::new());
16161617
let event_queue = Arc::new(EventQueue::new(Arc::clone(&store), Arc::clone(&logger)));
16171618
assert_eq!(event_queue.next_event(), None);
@@ -1647,7 +1648,7 @@ mod tests {
16471648

16481649
#[tokio::test]
16491650
async fn event_queue_concurrency() {
1650-
let store: Arc<DynStore> = Arc::new(TestStore::new(false));
1651+
let store: Arc<DynStore> = Arc::new(DynStoreWrapper(TestStore::new(false)));
16511652
let logger = Arc::new(TestLogger::new());
16521653
let event_queue = Arc::new(EventQueue::new(Arc::clone(&store), Arc::clone(&logger)));
16531654
assert_eq!(event_queue.next_event(), None);

0 commit comments

Comments
 (0)