Skip to content

Commit

Permalink
Revert "Fix stack overflow when printing a SubstreamRef"
Browse files Browse the repository at this point in the history
This reverts commit ec774ec.
  • Loading branch information
dvdplm committed Oct 12, 2018
1 parent 6792e3b commit 3015a1e
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 18 deletions.
5 changes: 2 additions & 3 deletions core/src/muxing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,9 @@ impl<P> fmt::Debug for SubstreamRef<P>
where
P: Deref,
P::Target: StreamMuxer,
<P::Target as StreamMuxer>::Substream: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "Substream({:?})", self.substream)
f.write_str("SubstreamRef")
}
}

Expand Down Expand Up @@ -557,6 +556,6 @@ mod tests {
substream_from_ref(&muxer, s)
};
let s = format!("{:?}", substream).to_string();
assert_eq!(s, "Substream(Some(DummySubstream))");
assert_eq!(s, "SubstreamRef");
}
}
1 change: 0 additions & 1 deletion core/src/nodes/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ impl<TInEvent, TOutEvent> CollectionStream<TInEvent, TOutEvent> {
TOutEvent: Send + 'static,
THandler::OutboundOpenInfo: Send + 'static, // TODO: shouldn't be required?
TMuxer: StreamMuxer + Send + Sync + 'static, // TODO: Send + Sync + 'static shouldn't be required
TMuxer::Substream: fmt::Debug,
TMuxer::OutboundSubstream: Send + 'static, // TODO: shouldn't be required
{
let id = self.inner.add_reach_attempt(future, handler);
Expand Down
2 changes: 0 additions & 2 deletions core/src/nodes/handled_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use muxing::StreamMuxer;
use nodes::node::{NodeEvent, NodeStream, Substream};
use futures::prelude::*;
use std::fmt;
use std::io::Error as IoError;
use Multiaddr;

Expand Down Expand Up @@ -192,7 +191,6 @@ where
impl<TMuxer, TAddrFut, THandler> Stream for HandledNode<TMuxer, TAddrFut, THandler>
where
TMuxer: StreamMuxer,
TMuxer::Substream: fmt::Debug,
THandler: NodeHandler<Substream<TMuxer>>,
TAddrFut: Future<Item = Multiaddr, Error = IoError>,
{
Expand Down
2 changes: 0 additions & 2 deletions core/src/nodes/handled_node_tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ impl<TInEvent, TOutEvent> HandledNodesTasks<TInEvent, TOutEvent> {
TOutEvent: Send + 'static,
THandler::OutboundOpenInfo: Send + 'static, // TODO: shouldn't be required?
TMuxer: StreamMuxer + Send + Sync + 'static, // TODO: Send + Sync + 'static shouldn't be required
TMuxer::Substream: fmt::Debug,
TMuxer::OutboundSubstream: Send + 'static, // TODO: shouldn't be required
{
let task_id = self.next_task_id;
Expand Down Expand Up @@ -346,7 +345,6 @@ impl<TFut, TMuxer, TAddrFut, THandler, TInEvent, TOutEvent> Future for
NodeTask<TFut, TMuxer, TAddrFut, THandler, TInEvent, TOutEvent>
where
TMuxer: StreamMuxer,
TMuxer::Substream: fmt::Debug,
TFut: Future<Item = ((PeerId, TMuxer), TAddrFut), Error = IoError>,
TAddrFut: Future<Item = Multiaddr, Error = IoError>,
THandler: NodeHandler<Substream<TMuxer>, InEvent = TInEvent, OutEvent = TOutEvent>,
Expand Down
2 changes: 0 additions & 2 deletions core/src/nodes/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ pub type Substream<TMuxer> = muxing::SubstreamRef<Arc<TMuxer>>;
pub enum NodeEvent<TMuxer, TUserData>
where
TMuxer: muxing::StreamMuxer,
TMuxer::Substream: fmt::Debug,
{
/// The multiaddress future of the node has been resolved.
///
Expand Down Expand Up @@ -203,7 +202,6 @@ where
impl<TMuxer, TAddrFut, TUserData> Stream for NodeStream<TMuxer, TAddrFut, TUserData>
where
TMuxer: muxing::StreamMuxer,
TMuxer::Substream: fmt::Debug,
TAddrFut: Future<Item = Multiaddr, Error = IoError>,
{
type Item = NodeEvent<TMuxer, TUserData>;
Expand Down
11 changes: 4 additions & 7 deletions core/src/nodes/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use nodes::listeners::{ListenersEvent, ListenersStream};
use nodes::node::Substream;
use std::collections::hash_map::{Entry, OccupiedEntry};
use std::io::{Error as IoError, ErrorKind as IoErrorKind};
use std::fmt;
use void::Void;
use {Endpoint, Multiaddr, PeerId, Transport};

Expand Down Expand Up @@ -348,7 +347,7 @@ where
TTrans::MultiaddrFuture: Send + 'static,
TMuxer: StreamMuxer + Send + Sync + 'static,
TMuxer::OutboundSubstream: Send,
TMuxer::Substream: Send + fmt::Debug,
TMuxer::Substream: Send,
TInEvent: Send + 'static,
TOutEvent: Send + 'static,
{
Expand Down Expand Up @@ -434,7 +433,7 @@ where
TTrans::MultiaddrFuture: Send + 'static,
TMuxer: StreamMuxer + Send + Sync + 'static,
TMuxer::OutboundSubstream: Send,
TMuxer::Substream: Send + fmt::Debug,
TMuxer::Substream: Send,
TInEvent: Send + 'static,
TOutEvent: Send + 'static,
{
Expand Down Expand Up @@ -468,7 +467,7 @@ where
TTrans::ListenerUpgrade: Send + 'static,
TMuxer: StreamMuxer + Send + Sync + 'static,
TMuxer::OutboundSubstream: Send,
TMuxer::Substream: Send + fmt::Debug,
TMuxer::Substream: Send,
TInEvent: Send + 'static,
TOutEvent: Send + 'static,
THandlerBuild: HandlerFactory<Handler = THandler>,
Expand Down Expand Up @@ -810,7 +809,6 @@ impl<'a, TTrans, TMuxer, TInEvent, TOutEvent, THandler, THandlerBuild>
where
TTrans: Transport<Output = (PeerId, TMuxer)>,
TMuxer: StreamMuxer,
TMuxer::Substream: fmt::Debug,
THandlerBuild: HandlerFactory<Handler = THandler>,
THandler: NodeHandler<Substream<TMuxer>, InEvent = TInEvent, OutEvent = TOutEvent> + Send + 'static,
THandler::OutboundOpenInfo: Send + 'static, // TODO: shouldn't be necessary
Expand Down Expand Up @@ -1028,7 +1026,6 @@ impl<'a, TTrans, TInEvent, TOutEvent, TMuxer, THandler, THandlerBuild>
where
TTrans: Transport<Output = (PeerId, TMuxer)>,
TMuxer: StreamMuxer,
TMuxer::Substream: fmt::Debug,
THandlerBuild: HandlerFactory<Handler = THandler>,
THandler: NodeHandler<Substream<TMuxer>, InEvent = TInEvent, OutEvent = TOutEvent> + Send + 'static,
THandler::OutboundOpenInfo: Send + 'static, // TODO: shouldn't be necessary
Expand Down Expand Up @@ -1115,7 +1112,7 @@ where
TTrans::ListenerUpgrade: Send + 'static,
TMuxer: StreamMuxer + Send + Sync + 'static,
TMuxer::OutboundSubstream: Send,
TMuxer::Substream: Send + fmt::Debug,
TMuxer::Substream: Send,
TInEvent: Send + 'static,
TOutEvent: Send + 'static,
THandlerBuild: HandlerFactory<Handler = THandler>,
Expand Down
1 change: 0 additions & 1 deletion core/src/tests/dummy_muxer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use muxing::{StreamMuxer, Shutdown};
use futures::prelude::*;

/// Substream type
#[derive(Debug)]
pub struct DummySubstream {}

/// OutboundSubstream type
Expand Down
1 change: 1 addition & 0 deletions muxers/yamux/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,4 @@ where
future::ok((Yamux::new(i, self.0, mode), remote))
}
}

0 comments on commit 3015a1e

Please sign in to comment.