diff --git a/roles/jd-server/config-examples/jds-config-hosted-example.toml b/roles/jd-server/config-examples/jds-config-hosted-example.toml index 328cffd520..999a69ae35 100644 --- a/roles/jd-server/config-examples/jds-config-hosted-example.toml +++ b/roles/jd-server/config-examples/jds-config-hosted-example.toml @@ -1,3 +1,6 @@ +# Async Job Support +async_mining_allowed = true + # SRI Pool config authority_public_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" authority_secret_key = "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" diff --git a/roles/jd-server/config-examples/jds-config-local-example.toml b/roles/jd-server/config-examples/jds-config-local-example.toml index a3c7622aca..dc8ce0555d 100644 --- a/roles/jd-server/config-examples/jds-config-local-example.toml +++ b/roles/jd-server/config-examples/jds-config-local-example.toml @@ -1,3 +1,6 @@ +# Async Job Support +async_mining_allowed = true + # SRI Pool config authority_public_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" authority_secret_key = "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" diff --git a/roles/jd-server/src/lib/job_declarator/message_handler.rs b/roles/jd-server/src/lib/job_declarator/message_handler.rs index 96887bdd0e..b71eb96ca7 100644 --- a/roles/jd-server/src/lib/job_declarator/message_handler.rs +++ b/roles/jd-server/src/lib/job_declarator/message_handler.rs @@ -49,7 +49,7 @@ impl ParseClientJobDeclarationMessages for JobDeclaratorDownstream { request_id: message.request_id, mining_job_token: token.to_le_bytes().to_vec().try_into().unwrap(), coinbase_output_max_additional_size: 100, - async_mining_allowed: true, + async_mining_allowed: self.async_mining_allowed, coinbase_output: self.coinbase_output.clone().try_into().unwrap(), }; let message_enum = JobDeclaration::AllocateMiningJobTokenSuccess(message_success); diff --git a/roles/jd-server/src/lib/job_declarator/mod.rs b/roles/jd-server/src/lib/job_declarator/mod.rs index 6bbe7de694..24a116039f 100644 --- a/roles/jd-server/src/lib/job_declarator/mod.rs +++ b/roles/jd-server/src/lib/job_declarator/mod.rs @@ -47,6 +47,7 @@ pub struct AddTrasactionsToMempool { #[derive(Debug)] pub struct JobDeclaratorDownstream { + async_mining_allowed: bool, sender: Sender, receiver: Receiver, // TODO this should be computed for each new template so that fees are included @@ -70,6 +71,7 @@ pub struct JobDeclaratorDownstream { impl JobDeclaratorDownstream { pub fn new( + async_mining_allowed: bool, receiver: Receiver, sender: Sender, config: &Configuration, @@ -89,6 +91,7 @@ impl JobDeclaratorDownstream { .expect("Invalid coinbase output in config"); Self { + async_mining_allowed, receiver, sender, coinbase_output, @@ -477,14 +480,14 @@ impl JobDeclarator { let flag = setup_connection.flags; let is_valid = SetupConnection::check_flags( Protocol::JobDeclarationProtocol, - 1, + config.async_mining_allowed as u32, flag, ); if is_valid { let success_message = SetupConnectionSuccess { used_version: 2, - flags: 0b_0000_0000_0000_0000_0000_0000_0000_0001, + flags: (setup_connection.flags & 1u32), }; info!("Sending success message for proxy"); let sv2_frame: StdFrame = JdsMessages::Common(success_message.into()) @@ -495,6 +498,7 @@ impl JobDeclarator { let jddownstream = Arc::new(Mutex::new(JobDeclaratorDownstream::new( + (setup_connection.flags & 1u32) != 0u32, // this takes a bool instead of u32 receiver.clone(), sender.clone(), &config, diff --git a/roles/jd-server/src/lib/mod.rs b/roles/jd-server/src/lib/mod.rs index 5fb12c75eb..e71a3b4763 100644 --- a/roles/jd-server/src/lib/mod.rs +++ b/roles/jd-server/src/lib/mod.rs @@ -57,6 +57,8 @@ pub struct CoinbaseOutput { #[derive(Debug, Deserialize, Clone)] pub struct Configuration { + #[serde(default = "default_true")] + pub async_mining_allowed: bool, pub listen_jd_address: String, pub authority_public_key: Secp256k1PublicKey, pub authority_secret_key: Secp256k1SecretKey, @@ -70,6 +72,10 @@ pub struct Configuration { pub mempool_update_interval: Duration, } +fn default_true() -> bool { + true +} + fn duration_from_toml<'de, D>(deserializer: D) -> Result where D: serde::Deserializer<'de>,