Skip to content

Commit bfece53

Browse files
committed
chore: panic if unexpected namespaces are listed from vss store
1 parent 8594e54 commit bfece53

2 files changed

Lines changed: 18 additions & 21 deletions

File tree

src/io/utils.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use crate::fee_estimator::OnchainFeeEstimator;
4545
use crate::io::{
4646
NODE_METRICS_KEY, NODE_METRICS_PRIMARY_NAMESPACE, NODE_METRICS_SECONDARY_NAMESPACE,
4747
};
48-
use crate::logger::{log_error, LdkLogger, Logger};
48+
use crate::logger::{log_error, log_trace, LdkLogger, Logger};
4949
use crate::peer_store::PeerStore;
5050
use crate::types::{Broadcaster, DynStore, KeysManager, Sweeper, WordCount};
5151
use crate::wallet::ser::{ChangeSetDeserWrapper, ChangeSetSerWrapper};
@@ -139,6 +139,7 @@ pub(crate) fn read_network_graph<L: Deref + Clone>(
139139
where
140140
L::Target: LdkLogger,
141141
{
142+
log_trace!(logger, "Reading network graph");
142143
let mut reader = Cursor::new(KVStoreSync::read(
143144
&*kv_store,
144145
NETWORK_GRAPH_PERSISTENCE_PRIMARY_NAMESPACE,

src/io/vss_store.rs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -303,16 +303,14 @@ impl KVStoreSync for VssStore {
303303
}
304304

305305
fn list(&self, primary_namespace: &str, secondary_namespace: &str) -> io::Result<Vec<String>> {
306-
// FIXME: list keys
307-
/*
308-
// Alby: also list keys from secondary storage
309-
let secondary_keys =
310-
self.secondary_kv_store.list(primary_namespace, secondary_namespace)?;
311-
312-
let all_keys: Vec<String> =
313-
keys.iter().cloned().chain(secondary_keys.iter().cloned()).collect();
314-
Ok(all_keys)
315-
*/
306+
// Alby: we use a secondary store for the network graph and currently don't support merging results
307+
if primary_namespace == NETWORK_GRAPH_PERSISTENCE_PRIMARY_NAMESPACE {
308+
panic!("Alby: cannot list from NETWORK_GRAPH_PERSISTENCE_PRIMARY_NAMESPACE");
309+
}
310+
if primary_namespace == "" {
311+
panic!("Alby: cannot list from empty primary namespace");
312+
}
313+
316314
let internal_runtime = self.internal_runtime.as_ref().ok_or_else(|| {
317315
debug_assert!(false, "Failed to access internal runtime");
318316
let msg = format!("Failed to access internal runtime");
@@ -433,16 +431,14 @@ impl KVStore for VssStore {
433431
fn list(
434432
&self, primary_namespace: &str, secondary_namespace: &str,
435433
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, io::Error>> + Send>> {
436-
// FIXME: list keys
437-
/*
438-
// Alby: also list keys from secondary storage
439-
let secondary_keys =
440-
self.secondary_kv_store.list(primary_namespace, secondary_namespace)?;
441-
442-
let all_keys: Vec<String> =
443-
keys.iter().cloned().chain(secondary_keys.iter().cloned()).collect();
444-
Ok(all_keys)
445-
*/
434+
// Alby: we use a secondary store for the network graph and currently don't support merging results
435+
if primary_namespace == NETWORK_GRAPH_PERSISTENCE_PRIMARY_NAMESPACE {
436+
panic!("Alby: cannot list from NETWORK_GRAPH_PERSISTENCE_PRIMARY_NAMESPACE");
437+
}
438+
if primary_namespace == "" {
439+
panic!("Alby: cannot list from empty primary namespace");
440+
}
441+
446442
let primary_namespace = primary_namespace.to_string();
447443
let secondary_namespace = secondary_namespace.to_string();
448444
let inner = Arc::clone(&self.inner);

0 commit comments

Comments
 (0)