Skip to content

Commit 5cd7eed

Browse files
committed
Add NodeBuilder::build_with_store_and_logger
This internal method allows us to avoid instantiating the logger twice during the creation of a `Node`.
1 parent 7df1736 commit 5cd7eed

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/builder.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ impl NodeBuilder {
641641
log_error!(logger, "Failed to setup Sqlite store: {}", e);
642642
BuildError::KVStoreSetupFailed
643643
})?;
644-
self.build_with_store(node_entropy, kv_store)
644+
self.build_with_store_and_logger(node_entropy, kv_store, logger)
645645
}
646646

647647
/// Builds a [`Node`] instance with a [`FilesystemStore`] backend and according to the options
@@ -656,7 +656,7 @@ impl NodeBuilder {
656656
BuildError::StoragePathAccessFailed
657657
})?;
658658
let kv_store = FilesystemStore::new(storage_dir_path);
659-
self.build_with_store(node_entropy, kv_store)
659+
self.build_with_store_and_logger(node_entropy, kv_store, logger)
660660
}
661661

662662
/// Builds a [`Node`] instance with a [VSS] backend and according to the options
@@ -687,7 +687,7 @@ impl NodeBuilder {
687687
BuildError::KVStoreSetupFailed
688688
})?;
689689

690-
self.build_with_store(node_entropy, vss_store)
690+
self.build_with_store_and_logger(node_entropy, vss_store, logger)
691691
}
692692

693693
/// Builds a [`Node`] instance with a [VSS] backend and according to the options
@@ -724,7 +724,7 @@ impl NodeBuilder {
724724
BuildError::KVStoreSetupFailed
725725
})?;
726726

727-
self.build_with_store(node_entropy, vss_store)
727+
self.build_with_store_and_logger(node_entropy, vss_store, logger)
728728
}
729729

730730
/// Builds a [`Node`] instance with a [VSS] backend and according to the options
@@ -751,7 +751,7 @@ impl NodeBuilder {
751751
BuildError::KVStoreSetupFailed
752752
})?;
753753

754-
self.build_with_store(node_entropy, vss_store)
754+
self.build_with_store_and_logger(node_entropy, vss_store, logger)
755755
}
756756

757757
/// Builds a [`Node`] instance with a [VSS] backend and according to the options
@@ -776,7 +776,7 @@ impl NodeBuilder {
776776
BuildError::KVStoreSetupFailed
777777
})?;
778778

779-
self.build_with_store(node_entropy, vss_store)
779+
self.build_with_store_and_logger(node_entropy, vss_store, logger)
780780
}
781781

782782
/// Builds a [`Node`] instance according to the options previously configured.
@@ -785,6 +785,12 @@ impl NodeBuilder {
785785
) -> Result<Node, BuildError> {
786786
let logger = setup_logger(&self.log_writer_config, &self.config)?;
787787

788+
self.build_with_store_and_logger(node_entropy, kv_store, logger)
789+
}
790+
791+
fn build_with_store_and_logger<S: SyncAndAsyncKVStore + Send + Sync + 'static>(
792+
&self, node_entropy: NodeEntropy, kv_store: S, logger: Arc<Logger>,
793+
) -> Result<Node, BuildError> {
788794
let runtime = if let Some(handle) = self.runtime_handle.as_ref() {
789795
Arc::new(Runtime::with_handle(handle.clone(), Arc::clone(&logger)))
790796
} else {

0 commit comments

Comments
 (0)