Skip to content

Commit

Permalink
dont use toml
Browse files Browse the repository at this point in the history
  • Loading branch information
jbesraa committed Aug 5, 2024
1 parent 3255adc commit c0dbde4
Show file tree
Hide file tree
Showing 12 changed files with 350 additions and 198 deletions.
42 changes: 23 additions & 19 deletions roles/Cargo.lock

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

70 changes: 0 additions & 70 deletions roles/jd-client/config-examples/integration-tests.toml

This file was deleted.

2 changes: 0 additions & 2 deletions roles/jd-client/src/lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ pub mod template_receiver;
pub mod upstream_sv2;

pub use proxy_config::ProxyConfig;
#[allow(unused_imports)]
pub use toml;

use std::{sync::atomic::AtomicBool, time::Duration};

Expand Down
49 changes: 49 additions & 0 deletions roles/jd-client/src/lib/proxy_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ pub struct CoinbaseOutput {
output_script_value: String,
}

impl CoinbaseOutput {
pub fn new(output_script_type: String, output_script_value: String) -> Self {
Self {
output_script_type,
output_script_value,
}
}
}

impl TryFrom<&CoinbaseOutput> for CoinbaseOutput_ {
type Error = Error;

Expand Down Expand Up @@ -45,6 +54,46 @@ pub struct ProxyConfig {
pub test_only_do_not_send_solution_to_tp: Option<bool>,
}

impl ProxyConfig {
pub fn new(
downstream_address: String,
downstream_port: u16,
max_supported_version: u16,
min_supported_version: u16,
min_extranonce2_size: u16,
withhold: bool,
authority_public_key: Secp256k1PublicKey,
authority_secret_key: Secp256k1SecretKey,
cert_validity_sec: u64,
tp_address: String,
tp_authority_public_key: Option<Secp256k1PublicKey>,
retry: u32,
upstreams: Vec<Upstream>,
timeout: Duration,
coinbase_outputs: Vec<CoinbaseOutput>,
) -> Self {
Self {
downstream_address,
downstream_port,
max_supported_version,
min_supported_version,
min_extranonce2_size,
withhold,
authority_public_key,
authority_secret_key,
cert_validity_sec,
tp_address,
tp_authority_public_key,
retry,
upstreams,
timeout,
coinbase_outputs,
test_only_do_not_send_solution_to_tp: None,
}

}
}

#[derive(Debug, Deserialize, Clone)]
pub struct Upstream {
pub authority_pubkey: Secp256k1PublicKey,
Expand Down
23 changes: 3 additions & 20 deletions roles/jd-server/config-examples/jds-config-hosted-example.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
# SRI Pool config
authority_public_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72"
authority_secret_key = "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n"
cert_validity_sec = 3600

# List of coinbase outputs used to build the coinbase tx
# ! Right now only one output is supported, so comment all the ones you don't need !
# For P2PK, P2PKH, P2WPKH, P2TR a public key is needed. For P2SH and P2WSH, a redeem script is needed.
coinbase_outputs = [
#{ output_script_type = "P2PK", output_script_value = "0372c47307e5b75ce365daf835f226d246c5a7a92fe24395018d5552123354f086" },
#{ output_script_type = "P2PKH", output_script_value = "0372c47307e5b75ce365daf835f226d246c5a7a92fe24395018d5552123354f086" },
#{ output_script_type = "P2SH", output_script_value = "00142ef89234bc95136eb9e6fee9d32722ebd8c1f0ab" },
#{ output_script_type = "P2WSH", output_script_value = "00142ef89234bc95136eb9e6fee9d32722ebd8c1f0ab" },
{ output_script_type = "P2WPKH", output_script_value = "036adc3bdf21e6f9a0f0fb0066bf517e5b7909ed1563d6958a10993849a7554075" },
#{ output_script_type = "P2TR", output_script_value = "036adc3bdf21e6f9a0f0fb0066bf517e5b7909ed1563d6958a10993849a7554075" },
]

# SRI Pool JD config
listen_jd_address = "0.0.0.0:34264"
# RPC config for mempool (it can be also the same TP if correctly configured)
core_rpc_url = "http://75.119.150.111"
core_rpc_port = 48332
core_rpc_user = "username"
core_rpc_pass = "password"
# Time interval used for JDS mempool update
[mempool_update_interval]
unit = "secs"
value = 1
coinbase_outputs = [
{ output_script_type = "P2WPKH", output_script_value = "036adc3bdf21e6f9a0f0fb0066bf517e5b7909ed1563d6958a10993849a7554075" },
]
37 changes: 37 additions & 0 deletions roles/jd-server/src/lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,15 @@ pub struct CoinbaseOutput {
output_script_value: String,
}

impl CoinbaseOutput {
pub fn new(output_script_type: String, output_script_value: String) -> Self {
Self {
output_script_type,
output_script_value,
}
}
}

#[derive(Debug, Deserialize, Clone)]
pub struct Configuration {
pub listen_jd_address: String,
Expand All @@ -249,6 +258,34 @@ pub struct Configuration {
pub mempool_update_interval: Duration,
}

impl Configuration {
pub fn new(
listen_jd_address: String,
authority_public_key: Secp256k1PublicKey,
authority_secret_key: Secp256k1SecretKey,
cert_validity_sec: u64,
coinbase_outputs: Vec<CoinbaseOutput>,
core_rpc_url: String,
core_rpc_port: u16,
core_rpc_user: String,
core_rpc_pass: String,
mempool_update_interval: Duration,
) -> Self {
Self {
listen_jd_address,
authority_public_key,
authority_secret_key,
cert_validity_sec,
coinbase_outputs,
core_rpc_url,
core_rpc_port,
core_rpc_user,
core_rpc_pass,
mempool_update_interval,
}
}
}

fn duration_from_toml<'de, D>(deserializer: D) -> Result<Duration, D::Error>
where
D: serde::Deserializer<'de>,
Expand Down
28 changes: 0 additions & 28 deletions roles/pool/config-examples/integration-tests.toml

This file was deleted.

37 changes: 37 additions & 0 deletions roles/pool/src/lib/mining_pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ pub struct CoinbaseOutput {
output_script_value: String,
}

impl CoinbaseOutput {
pub fn new(output_script_type: String, output_script_value: String) -> Self {
Self {
output_script_type,
output_script_value,
}
}
}

impl TryFrom<&CoinbaseOutput> for CoinbaseOutput_ {
type Error = Error;

Expand Down Expand Up @@ -96,6 +105,34 @@ pub struct Configuration {
pub test_only_listen_adress_plain: String,
}

impl Configuration {
pub fn new(
listen_address: String,
tp_address: String,
tp_authority_public_key: Option<Secp256k1PublicKey>,
authority_public_key: Secp256k1PublicKey,
authority_secret_key: Secp256k1SecretKey,
cert_validity_sec: u64,
coinbase_outputs: Vec<CoinbaseOutput>,
pool_signature: String,
#[cfg(feature = "test_only_allow_unencrypted")]
test_only_listen_adress_plain: String,
) -> Self {
Self {
listen_address,
tp_address,
tp_authority_public_key,
authority_public_key,
authority_secret_key,
cert_validity_sec,
coinbase_outputs,
pool_signature,
#[cfg(feature = "test_only_allow_unencrypted")]
test_only_listen_adress_plain,
}
}
}

#[derive(Debug)]
pub struct Downstream {
// Either group or channel id
Expand Down
Loading

0 comments on commit c0dbde4

Please sign in to comment.