node: improve seeds information

Previously, the seeds information would only consist of the connected
NodeIds.

Improve on this by adding any disconnected and fetching seeds as
well. A seed can either be disconnected, connected, or fetching --
where fetching implies connected.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny
2023-02-27 17:48:11 +01:00
committed by Alexis Sellier
parent c0b92d25fb
commit c70dc71b18
7 changed files with 121 additions and 25 deletions
+5 -5
View File
@@ -174,21 +174,21 @@ pub fn clone<G: Signer>(
}
// Get seeds. This consults the local routing table only.
let seeds = node.seeds(id)?;
if seeds.is_empty() {
let mut seeds = node.seeds(id)?;
if !seeds.has_connections() {
return Err(CloneError::NotFound(id));
}
// Fetch from all seeds.
for seed in seeds {
for seed in seeds.connected() {
let spinner = term::spinner(format!(
"Fetching {} from {}..",
term::format::tertiary(id),
term::format::tertiary(term::format::node(&seed))
term::format::tertiary(term::format::node(seed))
));
// TODO: If none of them succeeds, output an error. Otherwise tell the caller
// how many succeeded.
match node.fetch(id, seed)? {
match node.fetch(id, *seed)? {
FetchResult::Success { .. } => {
spinner.finish();
}