Skip to content
Snippets Groups Projects

Write `get-file` and commands to get the list of blocks from another node

1 file
+ 13
4
Compare changes
  • Side-by-side
  • Inline
+ 13
4
@@ -795,6 +795,15 @@ where
}
}
async fn get_providers(&mut self, key: String, sender: Sender<Vec<PeerId>>) {
let query_id = self
.swarm
.behaviour_mut()
.kademlia
.get_providers(key.into_bytes().into());
self.pending_get_providers.insert(query_id, sender);
}
async fn bootstrap(&mut self) -> Result<()> {
match self.swarm.behaviour_mut().kademlia.bootstrap() {
Ok(_) => Ok(()),
@@ -820,17 +829,17 @@ where
}
async fn get_block_list(&mut self, file_hash: String) -> Result<Vec<String>> {
let block_path = self.get_block_dir(file_hash);
let block_path = self.get_block_dir(file_hash.clone());
let mut block_names = vec![];
let mut dir_entry = tfs::read_dir(block_path).await?;
while let Some(entry) = dir_entry.next_entry().await? {
block_names.push(entry.file_name().into_string().map_err(
|os_string| -> anyhow::Error {
anyhow::anyhow!(
"Could not convert the os string {:?} as a valid String",
os_string
"Could not convert the os string {:?} as a valid String for file {}",
os_string,
file_hash,
)
.into()
},
)?);
}
Loading