Skip to content
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
4 changes: 3 additions & 1 deletion protocols/v2/roles-logic-sv2/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub enum Error {
NoValidJob,
NoValidTranslatorJob,
NoTemplateForId,
NoValidTemplate(String),
InvalidExtranonceSize(u16, u16),
PoisonLock(String),
InvalidBip34Bytes(Vec<u8>),
Expand Down Expand Up @@ -140,7 +141,8 @@ impl Display for Error {
NotFoundChannelId => write!(f, "No downstream has been registred for this channel id"),
NoValidJob => write!(f, "Impossible to create a standard job for channelA cause no valid job has been received from upstream yet"),
NoValidTranslatorJob => write!(f, "Impossible to create a extended job for channel cause no valid job has been received from upstream yet"),
NoTemplateForId => write!(f, "Impossible a template for the required job id"),
NoTemplateForId => write!(f, "Impossible to retrieve a template for the required job id"),
NoValidTemplate(e) => write!(f, "Impossible to retrieve a template for the required template id: {}", e),
PoisonLock(e) => write!(f, "Poison lock: {}", e),
InvalidBip34Bytes(e) => write!(f, "Invalid Bip34 bytes {:?}", e),
JobNotUpdated(ds_job_id, us_job_id) => write!(f, "Channel Factory did not update job: Downstream job id = {}, Upstream job id = {}", ds_job_id, us_job_id),
Expand Down
14 changes: 13 additions & 1 deletion roles/jd-client/src/lib/template_receiver/message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ impl ParseServerTemplateDistributionMessages for TemplateRx {
&mut self,
_m: RequestTransactionDataError,
) -> Result<SendTo, Error> {
todo!()
let m = RequestTransactionDataError {
template_id: _m.template_id,
error_code: _m.error_code.into_static(),
};
let error_code_string =
std::str::from_utf8(m.error_code.as_ref()).unwrap_or("unknown error code");
match error_code_string {
"template-id-not-found" => Err(Error::NoValidTemplate(error_code_string.to_string())),
"stale-template-id" => Ok(SendTo::None(Some(
TemplateDistribution::RequestTransactionDataError(m),
))),
_ => Err(Error::NoValidTemplate(error_code_string.to_string())),
}
}
}
5 changes: 4 additions & 1 deletion roles/jd-client/src/lib/template_receiver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use setup_connection::SetupConnectionHandler;
use std::{convert::TryInto, net::SocketAddr, sync::Arc};
use stratum_common::bitcoin::{consensus::Encodable, TxOut};
use tokio::task::AbortHandle;
use tracing::{error, info};
use tracing::{error, info, warn};

mod message_handler;
mod setup_connection;
Expand Down Expand Up @@ -264,6 +264,9 @@ impl TemplateRx {
.await;
}
}
Some(TemplateDistribution::RequestTransactionDataError(_)) => {
warn!("The prev_hash of the template requested to Template Provider no longer points to the latest tip. Continuing work on the updated template.")
}
_ => {
error!("{:?}", frame);
error!("{:?}", frame.payload());
Expand Down