Skip to content

Commit

Permalink
Let build_with_store_internal take a runtime parameter
Browse files Browse the repository at this point in the history
This is required to allow the VSS `KVStore` to share a reference to the runtime.

The runtime option will be set `Some` by `Node::start`.
  • Loading branch information
tnull committed May 29, 2023
1 parent 88e4c91 commit d12726a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,14 @@ impl Builder {
let entropy_source_config = self.entropy_source_config.read().unwrap();
let chain_data_source_config = self.chain_data_source_config.read().unwrap();
let gossip_source_config = self.gossip_source_config.read().unwrap();
let runtime = Arc::new(RwLock::new(None));
Arc::new(build_with_store_internal(
config,
entropy_source_config.as_ref(),
chain_data_source_config.as_ref(),
gossip_source_config.as_ref(),
kv_store,
runtime,
))
}
}
Expand All @@ -178,6 +180,7 @@ fn build_with_store_internal<'a, K: KVStore + Sync + Send + 'static>(
config: Arc<Config>, entropy_source_config: Option<&'a EntropySourceConfig>,
chain_data_source_config: Option<&'a ChainDataSourceConfig>,
gossip_source_config: Option<&'a GossipSourceConfig>, kv_store: Arc<K>,
runtime: Arc<RwLock<Option<tokio::runtime::Runtime>>>,
) -> Node<K> {
let ldk_data_dir = format!("{}/ldk", config.storage_dir_path);
fs::create_dir_all(ldk_data_dir.clone()).expect("Failed to create LDK data directory");
Expand Down Expand Up @@ -247,7 +250,6 @@ fn build_with_store_internal<'a, K: KVStore + Sync + Send + 'static>(
}
};

let runtime = Arc::new(RwLock::new(None));
let wallet =
Arc::new(Wallet::new(blockchain, bdk_wallet, Arc::clone(&runtime), Arc::clone(&logger)));

Expand Down

0 comments on commit d12726a

Please sign in to comment.