Skip to content

Commit

Permalink
Fix fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Shourya742 committed Jul 6, 2024
1 parent 857122a commit 4ff0ca3
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions roles/jd-server/src/lib/job_declarator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ use super::{error::JdsError, mempool::JDsMempool, status, Configuration, EitherF
use async_channel::{Receiver, Sender};
use binary_sv2::{B0255, U256};
use codec_sv2::{HandshakeRole, Responder};
use core::panic;
use error_handling::handle_result;
use key_utils::{Secp256k1PublicKey, Secp256k1SecretKey, SignatureService};
use network_helpers_sv2::noise_connection_tokio::Connection;
use nohash_hasher::BuildNoHashHasher;
use roles_logic_sv2::{
common_messages_sv2::{Protocol, SetupConnection, SetupConnectionError, SetupConnectionSuccess}, handlers::job_declaration::{ParseClientJobDeclarationMessages, SendTo}, job_declaration_sv2::{DeclareMiningJob, SubmitSolutionJd}, parsers::{ JobDeclaration, PoolMessages as JdsMessages}, utils::{Id, Mutex}
common_messages_sv2::{
Protocol, SetupConnection, SetupConnectionError, SetupConnectionSuccess,
},
handlers::job_declaration::{ParseClientJobDeclarationMessages, SendTo},
job_declaration_sv2::{DeclareMiningJob, SubmitSolutionJd},
parsers::{JobDeclaration, PoolMessages as JdsMessages},
utils::{Id, Mutex},
};
use core::panic;
use std::{collections::HashMap, convert::TryInto, sync::Arc};
use tokio::{net::TcpListener, time::Duration};
use tracing::{debug, error, info};
Expand Down Expand Up @@ -452,15 +458,15 @@ impl JobDeclarator {
Ok(EitherFrame::Sv2(s)) => {
debug!("Got sv2 message: {:?}", s);
s
},
}
Ok(EitherFrame::HandShake(s)) => {
error!(
"Got unexpected handshake message from upstream: {:?} at {}",
s, address
);
continue;
},
Err(e)=>{
}
Err(e) => {
error!("Error receiving message: {:?}", e);
continue;
}
Expand All @@ -469,22 +475,31 @@ impl JobDeclarator {
let payload = incoming.payload();
let flag = payload[5] as u32;

let is_valid = SetupConnection::check_flags(Protocol::JobDeclarationProtocol, flag, 1);
let is_valid =
SetupConnection::check_flags(Protocol::JobDeclarationProtocol, flag, 1);

let sv2_frame: StdFrame = if is_valid {
let success_message = SetupConnectionSuccess {
used_version: 2,
flags: 0b_0000_0000_0000_0000_0000_0000_0000_0001,
};
info!("Sending success message for proxy");
JdsMessages::Common(success_message.into()).try_into().unwrap()
JdsMessages::Common(success_message.into())
.try_into()
.unwrap()
} else {
let error_message = SetupConnectionError {
flags: flag,
error_code: "unsupported-feature-flags".to_string().into_bytes().try_into().unwrap(),
error_code: "unsupported-feature-flags"
.to_string()
.into_bytes()
.try_into()
.unwrap(),
};
info!("Sending error message for proxy");
JdsMessages::Common(error_message.into()).try_into().unwrap()
JdsMessages::Common(error_message.into())
.try_into()
.unwrap()
};

let sv2_frame = sv2_frame.into();
Expand Down Expand Up @@ -513,4 +528,4 @@ impl JobDeclarator {
}
}
}
}
}

0 comments on commit 4ff0ca3

Please sign in to comment.