Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
docs: remove changelog, correct template iroh.computer URLS
Browse files Browse the repository at this point in the history
  • Loading branch information
b5 committed May 19, 2023
1 parent d0ddf29 commit 9fb062c
Show file tree
Hide file tree
Showing 7 changed files with 257 additions and 516 deletions.
367 changes: 0 additions & 367 deletions CHANGELOG.md

This file was deleted.

155 changes: 107 additions & 48 deletions beetle-bitswap/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,65 +173,124 @@ impl ConnectionHandler for BitswapHandler {
self.listen_protocol.clone()
}

fn inject_fully_negotiated_inbound(
&mut self,
substream: <Self::InboundProtocol as InboundUpgrade<NegotiatedSubstream>>::Output,
_info: Self::InboundOpenInfo,
) {
let protocol_id = substream.codec().protocol;
if self.protocol.is_none() {
self.protocol = Some(protocol_id);
fn map_in_event<TNewIn, TMap>(
self,
map: TMap,
) -> libp2p::swarm::handler::MapInEvent<Self, TNewIn, TMap>
where
Self: Sized,
TMap: Fn(&TNewIn) -> Option<&Self::InEvent>,
{
libp2p::swarm::handler::MapInEvent {
inner: self,
map,
marker: None,
}

trace!("New inbound substream request: {:?}", protocol_id);
self.inbound_substreams
.push(Box::pin(inbound_substream(substream)));
}

fn inject_fully_negotiated_outbound(
&mut self,
substream: <Self::OutboundProtocol as OutboundUpgrade<NegotiatedSubstream>>::Output,
message: Self::OutboundOpenInfo,
) {
let protocol_id = substream.codec().protocol;
if self.protocol.is_none() {
self.protocol = Some(protocol_id);
}

trace!("New outbound substream: {:?}", protocol_id);
self.outbound_substreams
.push(Box::pin(outbound_substream(substream, message)));
fn map_out_event<TMap, TNewOut>(
self,
map: TMap,
) -> libp2p::swarm::handler::MapOutEvent<Self, TMap>
where
Self: Sized,
TMap: FnMut(Self::OutEvent) -> TNewOut,
{
}

fn inject_event(&mut self, message: BitswapHandlerIn) {
match message {
BitswapHandlerIn::Message(m, response) => {
self.send_queue.push_back((m, response));
fn on_behaviour_event(&mut self, _event: Self::InEvent) {}

// sending a message, reset keepalive
self.keep_alive = KeepAlive::Until(Instant::now() + self.idle_timeout);
}
BitswapHandlerIn::Protect => {
self.keep_alive = KeepAlive::Yes;
}
BitswapHandlerIn::Unprotect => {
self.keep_alive =
KeepAlive::Until(Instant::now() + Duration::from_secs(INITIAL_KEEP_ALIVE));
}
}
}

fn inject_dial_upgrade_error(
fn on_connection_event(
&mut self,
_: Self::OutboundOpenInfo,
e: ConnectionHandlerUpgrErr<
<Self::OutboundProtocol as OutboundUpgrade<NegotiatedSubstream>>::Error,
event: libp2p::swarm::handler::ConnectionEvent<
Self::InboundProtocol,
Self::OutboundProtocol,
Self::InboundOpenInfo,
Self::OutboundOpenInfo,
>,
) {
warn!("Dial upgrade error {:?}", e);
self.upgrade_errors.push_back(e);
}

fn select<TProto2>(
self,
other: TProto2,
) -> libp2p::swarm::ConnectionHandlerSelect<Self, TProto2>
where
Self: Sized,
{
return self;
}

// fn map_in_event<TNewIn, TMap>(
// self,
// map: TMap,
// ) -> libp2p::swarm::handler::MapInEvent<Self, TNewIn, TMap>
// where
// Self: Sized,
// TMap: Fn(&TNewIn) -> Option<&Self::InEvent>,
// {
// libp2p::swarm::handler::MapInEvent::new(self, map)
// }

// fn inject_fully_negotiated_inbound(
// &mut self,
// substream: <Self::InboundProtocol as InboundUpgrade<NegotiatedSubstream>>::Output,
// _info: Self::InboundOpenInfo,
// ) {
// let protocol_id = substream.codec().protocol;
// if self.protocol.is_none() {
// self.protocol = Some(protocol_id);
// }

// trace!("New inbound substream request: {:?}", protocol_id);
// self.inbound_substreams
// .push(Box::pin(inbound_substream(substream)));
// }

// fn inject_fully_negotiated_outbound(
// &mut self,
// substream: <Self::OutboundProtocol as OutboundUpgrade<NegotiatedSubstream>>::Output,
// message: Self::OutboundOpenInfo,
// ) {
// let protocol_id = substream.codec().protocol;
// if self.protocol.is_none() {
// self.protocol = Some(protocol_id);
// }

// trace!("New outbound substream: {:?}", protocol_id);
// self.outbound_substreams
// .push(Box::pin(outbound_substream(substream, message)));
// }

// fn inject_event(&mut self, message: BitswapHandlerIn) {
// match message {
// BitswapHandlerIn::Message(m, response) => {
// self.send_queue.push_back((m, response));

// // sending a message, reset keepalive
// self.keep_alive = KeepAlive::Until(Instant::now() + self.idle_timeout);
// }
// BitswapHandlerIn::Protect => {
// self.keep_alive = KeepAlive::Yes;
// }
// BitswapHandlerIn::Unprotect => {
// self.keep_alive =
// KeepAlive::Until(Instant::now() + Duration::from_secs(INITIAL_KEEP_ALIVE));
// }
// }
// }

// fn inject_dial_upgrade_error(
// &mut self,
// _: Self::OutboundOpenInfo,
// e: ConnectionHandlerUpgrErr<
// <Self::OutboundProtocol as OutboundUpgrade<NegotiatedSubstream>>::Error,
// >,
// ) {
// warn!("Dial upgrade error {:?}", e);
// self.upgrade_errors.push_back(e);
// }

fn connection_keep_alive(&self) -> KeepAlive {
self.keep_alive
}
Expand Down
Loading

0 comments on commit 9fb062c

Please sign in to comment.