Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ indexmap = { version = "2.9.0", features = ["std"] }
libc = "0.2.158"
mockall = "0.13.1"
multiaddr = "0.17.0"
multihash = { version = "0.17.0", default-features = false, features = ["std", "multihash-impl", "identity", "sha2", "blake2b"] }
multihash = { version = "0.17.0", default-features = false, features = ["std", "multihash-impl", "identity", "sha2", "sha3", "blake2b"] }
network-interface = "2.0.1"
parking_lot = "0.12.3"
pin-project = "1.1.10"
Expand Down
26 changes: 21 additions & 5 deletions src/protocol/libp2p/bitswap/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,19 @@ pub enum BitswapEvent {
/// Requested CIDs.
cids: Vec<(Cid, WantType)>,
},

/// Bitswap response.
Response {
/// Peer ID.
peer: PeerId,

/// Response entries: vector of CIDs with either block data or block presence.
responses: Vec<ResponseType>,
},
}

/// Response type for received bitswap request.
#[derive(Debug)]
#[derive(Debug, Clone)]
#[cfg_attr(feature = "fuzz", derive(serde::Serialize, serde::Deserialize))]
pub enum ResponseType {
/// Block.
Expand All @@ -73,6 +82,15 @@ pub enum ResponseType {
#[derive(Debug)]
#[cfg_attr(feature = "fuzz", derive(serde::Serialize, serde::Deserialize))]
pub enum BitswapCommand {
/// Send bitswap request.
SendRequest {
/// Peer ID.
peer: PeerId,

/// Requested CIDs.
cids: Vec<(Cid, WantType)>,
},

/// Send bitswap response.
SendResponse {
/// Peer ID.
Expand All @@ -99,10 +117,8 @@ impl BitswapHandle {
}

/// Send `request` to `peer`.
///
/// Not supported by the current implementation.
pub async fn send_request(&self, _peer: PeerId, _request: Vec<u8>) {
unimplemented!("bitswap requests are not supported");
pub async fn send_request(&self, peer: PeerId, cids: Vec<(Cid, WantType)>) {
let _ = self.cmd_tx.send(BitswapCommand::SendRequest { peer, cids }).await;
}

/// Send `response` to `peer`.
Expand Down
Loading
Loading