Skip to content

Commit dcca9f4

Browse files
committed
Propagate VSS runtime construction errors
Replace the Tokio runtime builder unwrap with io::Error propagation so VSS startup failures surface through the constructor instead of panicking. Co-Authored-By: HAL 9000
1 parent 0e5e906 commit dcca9f4

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/io/vss_store.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,19 @@ impl VssStore {
101101
header_provider: Arc<dyn VssHeaderProvider>,
102102
) -> io::Result<Self> {
103103
let next_version = AtomicU64::new(1);
104-
let internal_runtime = {
105-
#[allow(clippy::unwrap_used)]
106-
tokio::runtime::Builder::new_multi_thread()
107-
.enable_all()
108-
.thread_name_fn(|| {
109-
static ATOMIC_ID: AtomicUsize = AtomicUsize::new(0);
110-
let id = ATOMIC_ID.fetch_add(1, Ordering::SeqCst);
111-
format!("ldk-node-vss-runtime-{}", id)
112-
})
113-
.worker_threads(INTERNAL_RUNTIME_WORKERS)
114-
.max_blocking_threads(INTERNAL_RUNTIME_WORKERS)
115-
.build()
116-
.unwrap()
117-
};
104+
let internal_runtime = tokio::runtime::Builder::new_multi_thread()
105+
.enable_all()
106+
.thread_name_fn(|| {
107+
static ATOMIC_ID: AtomicUsize = AtomicUsize::new(0);
108+
let id = ATOMIC_ID.fetch_add(1, Ordering::SeqCst);
109+
format!("ldk-node-vss-runtime-{}", id)
110+
})
111+
.worker_threads(INTERNAL_RUNTIME_WORKERS)
112+
.max_blocking_threads(INTERNAL_RUNTIME_WORKERS)
113+
.build()
114+
.map_err(|e| {
115+
io::Error::new(io::ErrorKind::Other, format!("Failed to build VSS runtime: {}", e))
116+
})?;
118117

119118
let (data_encryption_key, obfuscation_master_key) =
120119
derive_data_encryption_and_obfuscation_keys(&vss_seed);

0 commit comments

Comments
 (0)