@@ -15,8 +15,8 @@ use crate::peer_store::PeerStore;
15
15
use crate :: sweep:: OutputSweeper ;
16
16
use crate :: tx_broadcaster:: TransactionBroadcaster ;
17
17
use crate :: types:: {
18
- ChainMonitor , ChannelManager , FakeMessageRouter , GossipSync , KeysManager , NetworkGraph ,
19
- OnionMessenger , PeerManager ,
18
+ ChainMonitor , ChannelManager , DynStore , FakeMessageRouter , GossipSync , KeysManager ,
19
+ NetworkGraph , OnionMessenger , PeerManager ,
20
20
} ;
21
21
use crate :: wallet:: Wallet ;
22
22
use crate :: { LogLevel , Node } ;
@@ -33,7 +33,7 @@ use lightning::sign::EntropySource;
33
33
34
34
use lightning:: util:: config:: UserConfig ;
35
35
use lightning:: util:: persist:: {
36
- read_channel_monitors, KVStore , CHANNEL_MANAGER_PERSISTENCE_KEY ,
36
+ read_channel_monitors, CHANNEL_MANAGER_PERSISTENCE_KEY ,
37
37
CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE , CHANNEL_MANAGER_PERSISTENCE_SECONDARY_NAMESPACE ,
38
38
} ;
39
39
use lightning:: util:: ser:: ReadableArgs ;
@@ -114,12 +114,18 @@ pub enum BuildError {
114
114
/// The given listening addresses are invalid, e.g. too many were passed.
115
115
InvalidListeningAddresses ,
116
116
/// We failed to read data from the [`KVStore`].
117
+ ///
118
+ /// [`KVStore`]: lightning::util::persist::KVStore
117
119
ReadFailed ,
118
120
/// We failed to write data to the [`KVStore`].
121
+ ///
122
+ /// [`KVStore`]: lightning::util::persist::KVStore
119
123
WriteFailed ,
120
124
/// We failed to access the given `storage_dir_path`.
121
125
StoragePathAccessFailed ,
122
126
/// We failed to setup our [`KVStore`].
127
+ ///
128
+ /// [`KVStore`]: lightning::util::persist::KVStore
123
129
KVStoreSetupFailed ,
124
130
/// We failed to setup the onchain wallet.
125
131
WalletSetupFailed ,
@@ -298,7 +304,7 @@ impl NodeBuilder {
298
304
299
305
/// Builds a [`Node`] instance with a [`SqliteStore`] backend and according to the options
300
306
/// previously configured.
301
- pub fn build ( & self ) -> Result < Node < SqliteStore > , BuildError > {
307
+ pub fn build ( & self ) -> Result < Node , BuildError > {
302
308
let storage_dir_path = self . config . storage_dir_path . clone ( ) ;
303
309
fs:: create_dir_all ( storage_dir_path. clone ( ) )
304
310
. map_err ( |_| BuildError :: StoragePathAccessFailed ) ?;
@@ -315,7 +321,7 @@ impl NodeBuilder {
315
321
316
322
/// Builds a [`Node`] instance with a [`FilesystemStore`] backend and according to the options
317
323
/// previously configured.
318
- pub fn build_with_fs_store ( & self ) -> Result < Node < FilesystemStore > , BuildError > {
324
+ pub fn build_with_fs_store ( & self ) -> Result < Node , BuildError > {
319
325
let mut storage_dir_path: PathBuf = self . config . storage_dir_path . clone ( ) . into ( ) ;
320
326
storage_dir_path. push ( "fs_store" ) ;
321
327
@@ -328,9 +334,7 @@ impl NodeBuilder {
328
334
/// Builds a [`Node`] instance with a [`VssStore`] backend and according to the options
329
335
/// previously configured.
330
336
#[ cfg( any( vss, vss_test) ) ]
331
- pub fn build_with_vss_store (
332
- & self , url : String , store_id : String ,
333
- ) -> Result < Node < VssStore > , BuildError > {
337
+ pub fn build_with_vss_store ( & self , url : String , store_id : String ) -> Result < Node , BuildError > {
334
338
let logger = setup_logger ( & self . config ) ?;
335
339
336
340
let seed_bytes = seed_bytes_from_config (
@@ -368,9 +372,7 @@ impl NodeBuilder {
368
372
}
369
373
370
374
/// Builds a [`Node`] instance according to the options previously configured.
371
- pub fn build_with_store < K : KVStore + Sync + Send + ' static > (
372
- & self , kv_store : Arc < K > ,
373
- ) -> Result < Node < K > , BuildError > {
375
+ pub fn build_with_store ( & self , kv_store : Arc < DynStore > ) -> Result < Node , BuildError > {
374
376
let logger = setup_logger ( & self . config ) ?;
375
377
let seed_bytes = seed_bytes_from_config (
376
378
& self . config ,
@@ -499,31 +501,29 @@ impl ArcedNodeBuilder {
499
501
500
502
/// Builds a [`Node`] instance with a [`SqliteStore`] backend and according to the options
501
503
/// previously configured.
502
- pub fn build ( & self ) -> Result < Arc < Node < SqliteStore > > , BuildError > {
504
+ pub fn build ( & self ) -> Result < Arc < Node > , BuildError > {
503
505
self . inner . read ( ) . unwrap ( ) . build ( ) . map ( Arc :: new)
504
506
}
505
507
506
508
/// Builds a [`Node`] instance with a [`FilesystemStore`] backend and according to the options
507
509
/// previously configured.
508
- pub fn build_with_fs_store ( & self ) -> Result < Arc < Node < FilesystemStore > > , BuildError > {
510
+ pub fn build_with_fs_store ( & self ) -> Result < Arc < Node > , BuildError > {
509
511
self . inner . read ( ) . unwrap ( ) . build_with_fs_store ( ) . map ( Arc :: new)
510
512
}
511
513
512
514
/// Builds a [`Node`] instance according to the options previously configured.
513
- pub fn build_with_store < K : KVStore + Sync + Send + ' static > (
514
- & self , kv_store : Arc < K > ,
515
- ) -> Result < Arc < Node < K > > , BuildError > {
515
+ pub fn build_with_store ( & self , kv_store : Arc < DynStore > ) -> Result < Arc < Node > , BuildError > {
516
516
self . inner . read ( ) . unwrap ( ) . build_with_store ( kv_store) . map ( Arc :: new)
517
517
}
518
518
}
519
519
520
520
/// Builds a [`Node`] instance according to the options previously configured.
521
- fn build_with_store_internal < K : KVStore + Sync + Send + ' static > (
521
+ fn build_with_store_internal (
522
522
config : Arc < Config > , chain_data_source_config : Option < & ChainDataSourceConfig > ,
523
523
gossip_source_config : Option < & GossipSourceConfig > ,
524
524
liquidity_source_config : Option < & LiquiditySourceConfig > , seed_bytes : [ u8 ; 64 ] ,
525
- logger : Arc < FilesystemLogger > , kv_store : Arc < K > ,
526
- ) -> Result < Node < K > , BuildError > {
525
+ logger : Arc < FilesystemLogger > , kv_store : Arc < DynStore > ,
526
+ ) -> Result < Node , BuildError > {
527
527
// Initialize the on-chain wallet and chain access
528
528
let xprv = bitcoin:: bip32:: ExtendedPrivKey :: new_master ( config. network . into ( ) , & seed_bytes)
529
529
. map_err ( |e| {
@@ -603,7 +603,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
603
603
) ) ;
604
604
605
605
// Initialize the ChainMonitor
606
- let chain_monitor: Arc < ChainMonitor < K > > = Arc :: new ( chainmonitor:: ChainMonitor :: new (
606
+ let chain_monitor: Arc < ChainMonitor > = Arc :: new ( chainmonitor:: ChainMonitor :: new (
607
607
Some ( Arc :: clone ( & tx_sync) ) ,
608
608
Arc :: clone ( & tx_broadcaster) ,
609
609
Arc :: clone ( & logger) ,
@@ -734,7 +734,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
734
734
channel_monitor_references,
735
735
) ;
736
736
let ( _hash, channel_manager) =
737
- <( BlockHash , ChannelManager < K > ) >:: read ( & mut reader, read_args) . map_err ( |e| {
737
+ <( BlockHash , ChannelManager ) >:: read ( & mut reader, read_args) . map_err ( |e| {
738
738
log_error ! ( logger, "Failed to read channel manager from KVStore: {}" , e) ;
739
739
BuildError :: ReadFailed
740
740
} ) ?;
0 commit comments