@@ -9,8 +9,8 @@ use crate::peer_store::PeerStore;
9
9
use crate :: sweep:: OutputSweeper ;
10
10
use crate :: tx_broadcaster:: TransactionBroadcaster ;
11
11
use crate :: types:: {
12
- ChainMonitor , ChannelManager , FakeMessageRouter , GossipSync , KeysManager , NetworkGraph ,
13
- OnionMessenger , PeerManager ,
12
+ ChainMonitor , ChannelManager , DynStore , FakeMessageRouter , GossipSync , KeysManager ,
13
+ NetworkGraph , OnionMessenger , PeerManager ,
14
14
} ;
15
15
use crate :: wallet:: Wallet ;
16
16
use crate :: LogLevel ;
@@ -31,7 +31,7 @@ use lightning::sign::EntropySource;
31
31
32
32
use lightning:: util:: config:: UserConfig ;
33
33
use lightning:: util:: persist:: {
34
- read_channel_monitors, KVStore , CHANNEL_MANAGER_PERSISTENCE_KEY ,
34
+ read_channel_monitors, CHANNEL_MANAGER_PERSISTENCE_KEY ,
35
35
CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE , CHANNEL_MANAGER_PERSISTENCE_SECONDARY_NAMESPACE ,
36
36
} ;
37
37
use lightning:: util:: ser:: ReadableArgs ;
@@ -96,12 +96,18 @@ pub enum BuildError {
96
96
/// The given listening addresses are invalid, e.g. too many were passed.
97
97
InvalidListeningAddresses ,
98
98
/// We failed to read data from the [`KVStore`].
99
+ ///
100
+ /// [`KVStore`]: lightning::util::persist::KVStore
99
101
ReadFailed ,
100
102
/// We failed to write data to the [`KVStore`].
103
+ ///
104
+ /// [`KVStore`]: lightning::util::persist::KVStore
101
105
WriteFailed ,
102
106
/// We failed to access the given `storage_dir_path`.
103
107
StoragePathAccessFailed ,
104
108
/// We failed to setup our [`KVStore`].
109
+ ///
110
+ /// [`KVStore`]: lightning::util::persist::KVStore
105
111
KVStoreSetupFailed ,
106
112
/// We failed to setup the onchain wallet.
107
113
WalletSetupFailed ,
@@ -256,7 +262,7 @@ impl NodeBuilder {
256
262
257
263
/// Builds a [`Node`] instance with a [`SqliteStore`] backend and according to the options
258
264
/// previously configured.
259
- pub fn build ( & self ) -> Result < Node < SqliteStore > , BuildError > {
265
+ pub fn build ( & self ) -> Result < Node , BuildError > {
260
266
let storage_dir_path = self . config . storage_dir_path . clone ( ) ;
261
267
fs:: create_dir_all ( storage_dir_path. clone ( ) )
262
268
. map_err ( |_| BuildError :: StoragePathAccessFailed ) ?;
@@ -273,7 +279,7 @@ impl NodeBuilder {
273
279
274
280
/// Builds a [`Node`] instance with a [`FilesystemStore`] backend and according to the options
275
281
/// previously configured.
276
- pub fn build_with_fs_store ( & self ) -> Result < Node < FilesystemStore > , BuildError > {
282
+ pub fn build_with_fs_store ( & self ) -> Result < Node , BuildError > {
277
283
let mut storage_dir_path: PathBuf = self . config . storage_dir_path . clone ( ) . into ( ) ;
278
284
storage_dir_path. push ( "fs_store" ) ;
279
285
@@ -286,9 +292,7 @@ impl NodeBuilder {
286
292
/// Builds a [`Node`] instance with a [`VssStore`] backend and according to the options
287
293
/// previously configured.
288
294
#[ cfg( any( vss, vss_test) ) ]
289
- pub fn build_with_vss_store (
290
- & self , url : String , store_id : String ,
291
- ) -> Result < Node < VssStore > , BuildError > {
295
+ pub fn build_with_vss_store ( & self , url : String , store_id : String ) -> Result < Node , BuildError > {
292
296
let logger = setup_logger ( & self . config ) ?;
293
297
294
298
let seed_bytes = seed_bytes_from_config (
@@ -325,9 +329,7 @@ impl NodeBuilder {
325
329
}
326
330
327
331
/// Builds a [`Node`] instance according to the options previously configured.
328
- pub fn build_with_store < K : KVStore + Sync + Send + ' static > (
329
- & self , kv_store : Arc < K > ,
330
- ) -> Result < Node < K > , BuildError > {
332
+ pub fn build_with_store ( & self , kv_store : Arc < DynStore > ) -> Result < Node , BuildError > {
331
333
let logger = setup_logger ( & self . config ) ?;
332
334
let seed_bytes = seed_bytes_from_config (
333
335
& self . config ,
@@ -442,30 +444,28 @@ impl ArcedNodeBuilder {
442
444
443
445
/// Builds a [`Node`] instance with a [`SqliteStore`] backend and according to the options
444
446
/// previously configured.
445
- pub fn build ( & self ) -> Result < Arc < Node < SqliteStore > > , BuildError > {
447
+ pub fn build ( & self ) -> Result < Arc < Node > , BuildError > {
446
448
self . inner . read ( ) . unwrap ( ) . build ( ) . map ( Arc :: new)
447
449
}
448
450
449
451
/// Builds a [`Node`] instance with a [`FilesystemStore`] backend and according to the options
450
452
/// previously configured.
451
- pub fn build_with_fs_store ( & self ) -> Result < Arc < Node < FilesystemStore > > , BuildError > {
453
+ pub fn build_with_fs_store ( & self ) -> Result < Arc < Node > , BuildError > {
452
454
self . inner . read ( ) . unwrap ( ) . build_with_fs_store ( ) . map ( Arc :: new)
453
455
}
454
456
455
457
/// Builds a [`Node`] instance according to the options previously configured.
456
- pub fn build_with_store < K : KVStore + Sync + Send + ' static > (
457
- & self , kv_store : Arc < K > ,
458
- ) -> Result < Arc < Node < K > > , BuildError > {
458
+ pub fn build_with_store ( & self , kv_store : Arc < DynStore > ) -> Result < Arc < Node > , BuildError > {
459
459
self . inner . read ( ) . unwrap ( ) . build_with_store ( kv_store) . map ( Arc :: new)
460
460
}
461
461
}
462
462
463
463
/// Builds a [`Node`] instance according to the options previously configured.
464
- fn build_with_store_internal < K : KVStore + Sync + Send + ' static > (
464
+ fn build_with_store_internal (
465
465
config : Arc < Config > , chain_data_source_config : Option < & ChainDataSourceConfig > ,
466
466
gossip_source_config : Option < & GossipSourceConfig > , seed_bytes : [ u8 ; 64 ] ,
467
- logger : Arc < FilesystemLogger > , kv_store : Arc < K > ,
468
- ) -> Result < Node < K > , BuildError > {
467
+ logger : Arc < FilesystemLogger > , kv_store : Arc < DynStore > ,
468
+ ) -> Result < Node , BuildError > {
469
469
// Initialize the on-chain wallet and chain access
470
470
let xprv = bitcoin:: bip32:: ExtendedPrivKey :: new_master ( config. network . into ( ) , & seed_bytes)
471
471
. map_err ( |e| {
@@ -545,7 +545,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
545
545
) ) ;
546
546
547
547
// Initialize the ChainMonitor
548
- let chain_monitor: Arc < ChainMonitor < K > > = Arc :: new ( chainmonitor:: ChainMonitor :: new (
548
+ let chain_monitor: Arc < ChainMonitor > = Arc :: new ( chainmonitor:: ChainMonitor :: new (
549
549
Some ( Arc :: clone ( & tx_sync) ) ,
550
550
Arc :: clone ( & tx_broadcaster) ,
551
551
Arc :: clone ( & logger) ,
@@ -658,7 +658,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
658
658
channel_monitor_references,
659
659
) ;
660
660
let ( _hash, channel_manager) =
661
- <( BlockHash , ChannelManager < K > ) >:: read ( & mut reader, read_args) . map_err ( |e| {
661
+ <( BlockHash , ChannelManager ) >:: read ( & mut reader, read_args) . map_err ( |e| {
662
662
log_error ! ( logger, "Failed to read channel manager from KVStore: {}" , e) ;
663
663
BuildError :: ReadFailed
664
664
} ) ?;
0 commit comments