Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix network helper panic if peer close connection #899

Merged
merged 2 commits into from
May 7, 2024
Merged
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
2 changes: 1 addition & 1 deletion examples/ping-pong-with-noise/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async-std="1.8.0"
bytes = "1.0.1"
binary_sv2 = { version = "^1.0.0", path = "../../protocols/v2/binary-sv2/binary-sv2" }
codec_sv2 = { version = "^1.0.0", path = "../../protocols/v2/codec-sv2", features=["noise_sv2"] }
network_helpers_sv2 = { version = "^1.0.0", path = "../../roles/roles-utils/network-helpers", features=["async_std"] }
network_helpers_sv2 = { version = "^2.0.0", path = "../../roles/roles-utils/network-helpers", features=["async_std"] }
key-utils = { version = "^1.0.0", path = "../../utils/key-utils" }

[features]
Expand Down
74 changes: 36 additions & 38 deletions roles/Cargo.lock

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

4 changes: 2 additions & 2 deletions roles/jd-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jd_client"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
description = "TODO"
license = "MIT OR Apache-2.0"
Expand All @@ -18,7 +18,7 @@ binary_sv2 = { version = "^1.0.0", path = "../../protocols/v2/binary-sv2/binary-
buffer_sv2 = { version = "^1.0.0", path = "../../utils/buffer" }
codec_sv2 = { version = "^1.0.1", path = "../../protocols/v2/codec-sv2", features = ["noise_sv2", "with_buffer_pool"] }
framing_sv2 = { version = "^1.0.0", path = "../../protocols/v2/framing-sv2" }
network_helpers_sv2 = { version = "1.0.0", path = "../roles-utils/network-helpers", features=["with_tokio", "with_buffer_pool"] }
network_helpers_sv2 = { version = "2.0.0", path = "../roles-utils/network-helpers", features=["with_tokio", "with_buffer_pool"] }
roles_logic_sv2 = { version = "^1.0.0", path = "../../protocols/v2/roles-logic-sv2" }
serde = { version = "1.0.89", default-features = false, features = ["derive", "alloc"] }
futures = "0.3.25"
Expand Down
4 changes: 2 additions & 2 deletions roles/jd-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jd_server"
version = "0.1.0"
version = "0.1.1"
edition = "2018"
license = "MIT OR Apache-2.0"
repository = "https://github.com/stratum-mining/stratum"
Expand All @@ -16,7 +16,7 @@ binary_sv2 = { version = "^1.0.0", path = "../../protocols/v2/binary-sv2/binary-
buffer_sv2 = { version = "^1.0.0", path = "../../utils/buffer" }
codec_sv2 = { version = "^1.0.1", path = "../../protocols/v2/codec-sv2", features = ["noise_sv2"] }
const_sv2 = { version = "^1.0.0", path = "../../protocols/v2/const-sv2" }
network_helpers_sv2 = { version = "1.0.0", path = "../roles-utils/network-helpers", features = ["with_tokio"] }
network_helpers_sv2 = { version = "2.0.0", path = "../roles-utils/network-helpers", features = ["with_tokio"] }
noise_sv2 = { version = "1.1.0", path = "../../protocols/v2/noise-sv2" }
rand = "0.8.4"
roles_logic_sv2 = { version = "^1.0.0", path = "../../protocols/v2/roles-logic-sv2" }
Expand Down
4 changes: 2 additions & 2 deletions roles/mining-proxy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mining_proxy_sv2"
version = "0.1.0"
version = "0.1.1"
authors = ["user"]
edition = "2018"
description = "SV2 mining proxy role"
Expand All @@ -20,7 +20,7 @@ buffer_sv2 = { version = "^1.0.0", path = "../../utils/buffer" }
codec_sv2 = { version = "^1.0.1", path = "../../protocols/v2/codec-sv2", features = ["noise_sv2", "with_buffer_pool"] }
const_sv2 = { version = "^1.0.0", path = "../../protocols/v2/const-sv2" }
futures = "0.3.19"
network_helpers_sv2 = {version = "1.0.0", path = "../roles-utils/network-helpers", features = ["with_tokio","with_buffer_pool"] }
network_helpers_sv2 = {version = "2.0.0", path = "../roles-utils/network-helpers", features = ["with_tokio","with_buffer_pool"] }
once_cell = "1.12.0"
roles_logic_sv2 = { version = "^1.0.0", path = "../../protocols/v2/roles-logic-sv2" }
serde = { version = "1.0.89", features = ["derive", "alloc"], default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions roles/pool/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pool_sv2"
version = "0.1.0"
version = "0.1.1"
edition = "2018"
description = "SV2 pool role"
license = "MIT OR Apache-2.0"
Expand All @@ -17,7 +17,7 @@ binary_sv2 = { version = "^1.0.0", path = "../../protocols/v2/binary-sv2/binary-
buffer_sv2 = { version = "^1.0.0", path = "../../utils/buffer" }
codec_sv2 = { version = "^1.0.1", path = "../../protocols/v2/codec-sv2", features = ["noise_sv2"] }
const_sv2 = { version = "^1.0.0", path = "../../protocols/v2/const-sv2" }
network_helpers_sv2 = { version = "1.0.0", path = "../roles-utils/network-helpers", features =["with_tokio","with_buffer_pool"] }
network_helpers_sv2 = { version = "2.0.0", path = "../roles-utils/network-helpers", features =["with_tokio","with_buffer_pool"] }
noise_sv2 = { version = "1.1.0", path = "../../protocols/v2/noise-sv2" }
rand = "0.8.4"
roles_logic_sv2 = { version = "^1.0.0", path = "../../protocols/v2/roles-logic-sv2" }
Expand Down
2 changes: 1 addition & 1 deletion roles/roles-utils/network-helpers/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "network_helpers_sv2"
version = "1.0.1"
version = "2.0.0"
authors = ["fi3 <[email protected]>"]
edition = "2018"
description = "Networking utils for SV2 roles"
Expand Down
2 changes: 2 additions & 0 deletions roles/roles-utils/network-helpers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ pub enum Error {
CodecError(CodecError),
RecvError,
SendError,
// This means that a socket that was supposed to be opened have been closed, likley by the peer
SocketClosed,
}

impl From<CodecError> for Error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl Connection {
),
Error,
> {
let address = stream.peer_addr().unwrap();
let address = stream.peer_addr().map_err(|_| Error::SocketClosed)?;
let (mut reader, writer) = (stream.clone(), stream.clone());

let (sender_incoming, receiver_incoming): (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Connection {
),
Error,
> {
let address = stream.peer_addr().unwrap();
let address = stream.peer_addr().map_err(|_| Error::SocketClosed)?;

let (mut reader, mut writer) = stream.into_split();

Expand Down
4 changes: 2 additions & 2 deletions roles/test-utils/mining-device/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mining-device"
version = "0.1.0"
version = "0.1.1"
edition = "2018"
publish = false

Expand All @@ -14,7 +14,7 @@ const_sv2 = { version = "1.0.0", path = "../../../protocols/v2/const-sv2" }
async-channel = "1.5.1"
async-std={version = "1.8.0", features = ["attributes"]}
binary_sv2 = { version = "1.0.0", path = "../../../protocols/v2/binary-sv2/binary-sv2" }
network_helpers_sv2 = { version = "1.0.0", path = "../../roles-utils/network-helpers", features=["async_std"] }
network_helpers_sv2 = { version = "2.0.0", path = "../../roles-utils/network-helpers", features=["async_std"] }
buffer_sv2 = { version = "1.0.0", path = "../../../utils/buffer"}
async-recursion = "0.3.2"
rand = "0.8.4"
Expand Down
Loading
Loading