Skip to content
Snippets Groups Projects

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

1 file
+ 17
0
Compare changes
  • Side-by-side
  • Inline
+ 17
0
@@ -30,6 +30,7 @@ use crate::error::DragoonError::{
BadListener, BootstrapError, CouldNotSendBlockResponse, DialError, NoParentDirectory,
PeerNotFound, ProviderError,
};
use crate::peer_block_info::PeerBlockInfo;
use komodo::{
self,
@@ -58,6 +59,14 @@ pub(crate) struct BlockRequest {
#[derive(Debug, Clone, Serialize, Deserialize)]
pub(crate) struct BlockResponse(Vec<u8>);
#[derive(Debug, Clone, Serialize, Deserialize)]
pub(crate) struct PeerBlockInfoRequest{
file_hash: String
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub(crate) struct PeerBlockInfoResponse(PeerBlockInfo);
pub(crate) async fn create_swarm<F, G>(
id_keys: Keypair,
) -> Result<Swarm<DragoonBehaviour<F, G>>, Box<dyn Error>>
@@ -90,6 +99,13 @@ where
)],
request_response::Config::default(),
),
request_info: request_response::cbor::Behaviour::new(
[(
StreamProtocol::new("/file-exchange/1"),
ProtocolSupport::Full,
)],
request_response::Config::default(),
),
dragoon: Behaviour::new(),
})?
.with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(60 * 60)))
@@ -110,6 +126,7 @@ where
G: CurveGroup<ScalarField = F>,
{
request_response: request_response::cbor::Behaviour<BlockRequest, BlockResponse>,
request_info: request_response::cbor::Behaviour<PeerBlockInfoRequest, PeerBlockInfoResponse>,
identify: identify::Behaviour,
kademlia: kad::Behaviour<kad::store::MemoryStore>,
dragoon: Behaviour<F, G>,
Loading