From 1521f39244cd7121dc3fd3a00fe146be24120cc5 Mon Sep 17 00:00:00 2001 From: zeroqn Date: Wed, 29 Apr 2020 20:11:22 +0800 Subject: [PATCH] chore(network): upgrade tentacle (#265) * chore(network): upgrade tentacle * fix(network): compilation after upgraded tentacle --- core/network/Cargo.toml | 8 ++++---- core/network/src/connection/keeper.rs | 7 +++---- core/network/src/connection/mod.rs | 16 ++++++++-------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/core/network/Cargo.toml b/core/network/Cargo.toml index 8b8d1ec60..4983160b0 100644 --- a/core/network/Cargo.toml +++ b/core/network/Cargo.toml @@ -24,10 +24,10 @@ rand = "0.7" serde = "1.0" serde_derive = "1.0" snap = "0.2" -tentacle = { git = "https://github.com/zeroqn/p2p", branch = "muta-disc", features = [ "flatc" ]} -tentacle-ping = { git = "https://github.com/zeroqn/p2p", branch = "muta-disc", features = [ "flatc" ]} -tentacle-discovery = { git = "https://github.com/zeroqn/p2p", branch = "muta-disc", features = [ "flatc" ]} -tentacle-identify = { git = "https://github.com/zeroqn/p2p", branch = "muta-disc", features = [ "flatc" ]} +tentacle = { git = "https://github.com/zeroqn/p2p", rev = "77b9f391", features = [ "flatc" ]} +tentacle-ping = { git = "https://github.com/zeroqn/p2p", rev = "77b9f391", features = [ "flatc" ]} +tentacle-discovery = { git = "https://github.com/zeroqn/p2p", rev = "77b9f391", features = [ "flatc" ]} +tentacle-identify = { git = "https://github.com/zeroqn/p2p", rev = "77b9f391", features = [ "flatc" ]} tokio = { version = "0.2", features = ["macros", "rt-core"]} hostname = "0.3" diff --git a/core/network/src/connection/keeper.rs b/core/network/src/connection/keeper.rs index 1042a84a8..111bf8814 100644 --- a/core/network/src/connection/keeper.rs +++ b/core/network/src/connection/keeper.rs @@ -100,10 +100,9 @@ impl ConnectionServiceKeeper { PeerIdNotMatch => ConnectionErrorKind::PeerIdNotMatch, DNSResolverError(e) => ConnectionErrorKind::DNSResolver(Box::new(e)), HandshakeError(e) => ConnectionErrorKind::SecioHandshake(Box::new(e)), - ServiceProtoHandleBlock - | SessionProtoHandleBlock(_) - | ServiceProtoHandleAbnormallyClosed - | SessionProtoHandleAbnormallyClosed(_) => ConnectionErrorKind::ProtocolHandle, + ProtoHandleBlock(_) | ProtoHandleAbnormallyClosed(_) => { + ConnectionErrorKind::ProtocolHandle + } }; let connect_failed = PeerManagerEvent::ConnectFailed { addr, kind }; diff --git a/core/network/src/connection/mod.rs b/core/network/src/connection/mod.rs index 91cb0ab16..e1a5bd876 100644 --- a/core/network/src/connection/mod.rs +++ b/core/network/src/connection/mod.rs @@ -75,14 +75,6 @@ impl ConnectionService

{ yamux_config.accept_backlog = max; } - if let Some(size) = config.send_buffer_size { - yamux_config.send_buffer_size = size; - } - - if let Some(size) = config.recv_buffer_size { - yamux_config.recv_buffer_size = size; - } - if let Some(timeout) = config.write_timeout { yamux_config.connection_write_timeout = Duration::from_secs(timeout); } @@ -93,6 +85,14 @@ impl ConnectionService

{ builder = builder.max_frame_length(max); } + if let Some(size) = config.send_buffer_size { + builder = builder.set_send_buffer_size(size); + } + + if let Some(size) = config.recv_buffer_size { + builder = builder.set_recv_buffer_size(size); + } + for proto_meta in protocol.metas().into_iter() { debug!("network: connection: insert protocol {}", proto_meta.name()); builder = builder.insert_protocol(proto_meta);