Skip to content

Commit

Permalink
Merge pull request stratum-mining#1378 from Shourya742/2025-01-22-let…
Browse files Browse the repository at this point in the history
…-pool-wait-for-template-provider

Add retry logic to ensure the pool waits and connect to TP
  • Loading branch information
plebhash authored Jan 22, 2025
2 parents 4df7355 + 2d45c62 commit 150360c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions roles/pool/src/lib/template_receiver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use roles_logic_sv2::{
};
use std::{convert::TryInto, net::SocketAddr, sync::Arc};
use tokio::{net::TcpStream, task};
use tracing::info;
use tracing::{info, warn};

mod message_handler;
mod setup_connection;
Expand All @@ -45,7 +45,15 @@ impl TemplateRx {
coinbase_out_len: u32,
expected_tp_authority_public_key: Option<Secp256k1PublicKey>,
) -> PoolResult<()> {
let stream = TcpStream::connect(address).await?;
let stream = loop {
match TcpStream::connect(address).await {
Ok(stream) => break stream,
Err(err) => {
warn!("Failed to connect to {}: {}. Retrying...", address, err);
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
}
}
};
info!("Connected to template distribution server at {}", address);

let initiator = match expected_tp_authority_public_key {
Expand Down

0 comments on commit 150360c

Please sign in to comment.