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

Commit f52b532

Browse files
committed
docs: remove changelog, correct template iroh.computer URLS
1 parent 1e0e9f1 commit f52b532

File tree

7 files changed

+257
-516
lines changed

7 files changed

+257
-516
lines changed

CHANGELOG.md

Lines changed: 0 additions & 367 deletions
This file was deleted.

beetle-bitswap/src/handler.rs

Lines changed: 107 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -173,65 +173,124 @@ impl ConnectionHandler for BitswapHandler {
173173
self.listen_protocol.clone()
174174
}
175175

176-
fn inject_fully_negotiated_inbound(
177-
&mut self,
178-
substream: <Self::InboundProtocol as InboundUpgrade<NegotiatedSubstream>>::Output,
179-
_info: Self::InboundOpenInfo,
180-
) {
181-
let protocol_id = substream.codec().protocol;
182-
if self.protocol.is_none() {
183-
self.protocol = Some(protocol_id);
176+
fn map_in_event<TNewIn, TMap>(
177+
self,
178+
map: TMap,
179+
) -> libp2p::swarm::handler::MapInEvent<Self, TNewIn, TMap>
180+
where
181+
Self: Sized,
182+
TMap: Fn(&TNewIn) -> Option<&Self::InEvent>,
183+
{
184+
libp2p::swarm::handler::MapInEvent {
185+
inner: self,
186+
map,
187+
marker: None,
184188
}
185-
186-
trace!("New inbound substream request: {:?}", protocol_id);
187-
self.inbound_substreams
188-
.push(Box::pin(inbound_substream(substream)));
189189
}
190190

191-
fn inject_fully_negotiated_outbound(
192-
&mut self,
193-
substream: <Self::OutboundProtocol as OutboundUpgrade<NegotiatedSubstream>>::Output,
194-
message: Self::OutboundOpenInfo,
195-
) {
196-
let protocol_id = substream.codec().protocol;
197-
if self.protocol.is_none() {
198-
self.protocol = Some(protocol_id);
199-
}
200-
201-
trace!("New outbound substream: {:?}", protocol_id);
202-
self.outbound_substreams
203-
.push(Box::pin(outbound_substream(substream, message)));
191+
fn map_out_event<TMap, TNewOut>(
192+
self,
193+
map: TMap,
194+
) -> libp2p::swarm::handler::MapOutEvent<Self, TMap>
195+
where
196+
Self: Sized,
197+
TMap: FnMut(Self::OutEvent) -> TNewOut,
198+
{
204199
}
205200

206-
fn inject_event(&mut self, message: BitswapHandlerIn) {
207-
match message {
208-
BitswapHandlerIn::Message(m, response) => {
209-
self.send_queue.push_back((m, response));
201+
fn on_behaviour_event(&mut self, _event: Self::InEvent) {}
210202

211-
// sending a message, reset keepalive
212-
self.keep_alive = KeepAlive::Until(Instant::now() + self.idle_timeout);
213-
}
214-
BitswapHandlerIn::Protect => {
215-
self.keep_alive = KeepAlive::Yes;
216-
}
217-
BitswapHandlerIn::Unprotect => {
218-
self.keep_alive =
219-
KeepAlive::Until(Instant::now() + Duration::from_secs(INITIAL_KEEP_ALIVE));
220-
}
221-
}
222-
}
223-
224-
fn inject_dial_upgrade_error(
203+
fn on_connection_event(
225204
&mut self,
226-
_: Self::OutboundOpenInfo,
227-
e: ConnectionHandlerUpgrErr<
228-
<Self::OutboundProtocol as OutboundUpgrade<NegotiatedSubstream>>::Error,
205+
event: libp2p::swarm::handler::ConnectionEvent<
206+
Self::InboundProtocol,
207+
Self::OutboundProtocol,
208+
Self::InboundOpenInfo,
209+
Self::OutboundOpenInfo,
229210
>,
230211
) {
231-
warn!("Dial upgrade error {:?}", e);
232-
self.upgrade_errors.push_back(e);
233212
}
234213

214+
fn select<TProto2>(
215+
self,
216+
other: TProto2,
217+
) -> libp2p::swarm::ConnectionHandlerSelect<Self, TProto2>
218+
where
219+
Self: Sized,
220+
{
221+
return self;
222+
}
223+
224+
// fn map_in_event<TNewIn, TMap>(
225+
// self,
226+
// map: TMap,
227+
// ) -> libp2p::swarm::handler::MapInEvent<Self, TNewIn, TMap>
228+
// where
229+
// Self: Sized,
230+
// TMap: Fn(&TNewIn) -> Option<&Self::InEvent>,
231+
// {
232+
// libp2p::swarm::handler::MapInEvent::new(self, map)
233+
// }
234+
235+
// fn inject_fully_negotiated_inbound(
236+
// &mut self,
237+
// substream: <Self::InboundProtocol as InboundUpgrade<NegotiatedSubstream>>::Output,
238+
// _info: Self::InboundOpenInfo,
239+
// ) {
240+
// let protocol_id = substream.codec().protocol;
241+
// if self.protocol.is_none() {
242+
// self.protocol = Some(protocol_id);
243+
// }
244+
245+
// trace!("New inbound substream request: {:?}", protocol_id);
246+
// self.inbound_substreams
247+
// .push(Box::pin(inbound_substream(substream)));
248+
// }
249+
250+
// fn inject_fully_negotiated_outbound(
251+
// &mut self,
252+
// substream: <Self::OutboundProtocol as OutboundUpgrade<NegotiatedSubstream>>::Output,
253+
// message: Self::OutboundOpenInfo,
254+
// ) {
255+
// let protocol_id = substream.codec().protocol;
256+
// if self.protocol.is_none() {
257+
// self.protocol = Some(protocol_id);
258+
// }
259+
260+
// trace!("New outbound substream: {:?}", protocol_id);
261+
// self.outbound_substreams
262+
// .push(Box::pin(outbound_substream(substream, message)));
263+
// }
264+
265+
// fn inject_event(&mut self, message: BitswapHandlerIn) {
266+
// match message {
267+
// BitswapHandlerIn::Message(m, response) => {
268+
// self.send_queue.push_back((m, response));
269+
270+
// // sending a message, reset keepalive
271+
// self.keep_alive = KeepAlive::Until(Instant::now() + self.idle_timeout);
272+
// }
273+
// BitswapHandlerIn::Protect => {
274+
// self.keep_alive = KeepAlive::Yes;
275+
// }
276+
// BitswapHandlerIn::Unprotect => {
277+
// self.keep_alive =
278+
// KeepAlive::Until(Instant::now() + Duration::from_secs(INITIAL_KEEP_ALIVE));
279+
// }
280+
// }
281+
// }
282+
283+
// fn inject_dial_upgrade_error(
284+
// &mut self,
285+
// _: Self::OutboundOpenInfo,
286+
// e: ConnectionHandlerUpgrErr<
287+
// <Self::OutboundProtocol as OutboundUpgrade<NegotiatedSubstream>>::Error,
288+
// >,
289+
// ) {
290+
// warn!("Dial upgrade error {:?}", e);
291+
// self.upgrade_errors.push_back(e);
292+
// }
293+
235294
fn connection_keep_alive(&self) -> KeepAlive {
236295
self.keep_alive
237296
}

0 commit comments

Comments
 (0)