Skip to content

Commit

Permalink
Add mining-sv2-proxy initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
jbesraa committed Dec 17, 2024
1 parent 33f3e9c commit 90bbb00
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion roles/Cargo.lock

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

1 change: 1 addition & 0 deletions roles/tests-integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ flate2 = "1.0.32"
jd_client = { path = "../jd-client" }
jd_server = { path = "../jd-server" }
key-utils = { path = "../../utils/key-utils" }
mining_proxy_sv2 = { path = "../mining-proxy" }
minreq = { version = "2.12.0", features = ["https"] }
once_cell = "1.19.0"
network_helpers_sv2 = { path = "../roles-utils/network-helpers", features =["with_tokio","with_buffer_pool"] }
Expand Down
28 changes: 28 additions & 0 deletions roles/tests-integration/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,3 +477,31 @@ pub async fn start_mining_device_sv1(upstream_addr: SocketAddr) {
});
tokio::time::sleep(std::time::Duration::from_secs(3)).await;
}

pub async fn start_mining_sv2_proxy(upstream: SocketAddr) -> SocketAddr {
use mining_proxy_sv2::{ChannelKind, UpstreamMiningValues};
let upstreams = vec![UpstreamMiningValues {
address: upstream.ip().to_string(),
port: upstream.port(),
pub_key: Secp256k1PublicKey::from_str(
"9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72",
)
.unwrap(),
channel_kind: ChannelKind::Extended,
}];
let mining_proxy_listening_address = get_available_address();
let config = mining_proxy_sv2::Configuration {
upstreams,
listen_address: mining_proxy_listening_address.ip().to_string(),
listen_mining_port: mining_proxy_listening_address.port(),
max_supported_version: 2,
min_supported_version: 2,
downstream_share_per_minute: 1.0,
expected_total_downstream_hr: 10_000.0,
reconnect: true,
};
tokio::spawn(async move {
mining_proxy_sv2::start_mining_proxy(config).await;
});
mining_proxy_listening_address
}

0 comments on commit 90bbb00

Please sign in to comment.