From 918cd0de95e51b05527b08f4d56a47f8b9f83647 Mon Sep 17 00:00:00 2001 From: Christien Rioux Date: Sun, 7 Apr 2024 11:43:34 -0400 Subject: [PATCH] seed dht fanout --- veilid-core/src/storage_manager/get_value.rs | 8 +++++++- veilid-core/src/storage_manager/inspect_value.rs | 8 +++++++- veilid-core/src/storage_manager/set_value.rs | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/veilid-core/src/storage_manager/get_value.rs b/veilid-core/src/storage_manager/get_value.rs index 51d00213..3cdf3210 100644 --- a/veilid-core/src/storage_manager/get_value.rs +++ b/veilid-core/src/storage_manager/get_value.rs @@ -43,6 +43,12 @@ impl StorageManager { ) }; + // Get the nodes we know are caching this value to seed the fanout + let init_fanout_queue = { + let inner = self.inner.lock().await; + inner.get_value_nodes(key)?.unwrap_or_default() + }; + // Make do-get-value answer context let schema = if let Some(d) = &last_get_result.opt_descriptor { Some(d.schema()?) @@ -179,7 +185,7 @@ impl StorageManager { check_done, ); - let kind = match fanout_call.run(vec![]).await { + let kind = match fanout_call.run(init_fanout_queue).await { // If we don't finish in the timeout (too much time passed checking for consensus) TimeoutOr::Timeout => FanoutResultKind::Timeout, // If we finished with or without consensus (enough nodes returning the same value) diff --git a/veilid-core/src/storage_manager/inspect_value.rs b/veilid-core/src/storage_manager/inspect_value.rs index 66bf1be6..4d032e52 100644 --- a/veilid-core/src/storage_manager/inspect_value.rs +++ b/veilid-core/src/storage_manager/inspect_value.rs @@ -82,6 +82,12 @@ impl StorageManager { } }; + // Get the nodes we know are caching this value to seed the fanout + let init_fanout_queue = { + let inner = self.inner.lock().await; + inner.get_value_nodes(key)?.unwrap_or_default() + }; + // Make do-inspect-value answer context let opt_descriptor_info = if let Some(descriptor) = &local_inspect_result.opt_descriptor { // Get the descriptor info. This also truncates the subkeys list to what can be returned from the network. @@ -253,7 +259,7 @@ impl StorageManager { check_done, ); - let kind = match fanout_call.run(vec![]).await { + let kind = match fanout_call.run(init_fanout_queue).await { // If we don't finish in the timeout (too much time passed checking for consensus) TimeoutOr::Timeout => FanoutResultKind::Timeout, // If we finished with or without consensus (enough nodes returning the same value) diff --git a/veilid-core/src/storage_manager/set_value.rs b/veilid-core/src/storage_manager/set_value.rs index 0ddeebb4..5980e780 100644 --- a/veilid-core/src/storage_manager/set_value.rs +++ b/veilid-core/src/storage_manager/set_value.rs @@ -44,6 +44,12 @@ impl StorageManager { ) }; + // Get the nodes we know are caching this value to seed the fanout + let init_fanout_queue = { + let inner = self.inner.lock().await; + inner.get_value_nodes(key)?.unwrap_or_default() + }; + // Make do-set-value answer context let schema = descriptor.schema()?; let context = Arc::new(Mutex::new(OutboundSetValueContext { @@ -170,7 +176,7 @@ impl StorageManager { check_done, ); - let kind = match fanout_call.run(vec![]).await { + let kind = match fanout_call.run(init_fanout_queue).await { // If we don't finish in the timeout (too much time passed checking for consensus) TimeoutOr::Timeout => FanoutResultKind::Timeout, // If we finished with or without consensus (enough nodes returning the same value)