Skip to content
Draft
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
6 changes: 3 additions & 3 deletions nomium/shares-logger/src/services/share_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ impl ShareProcessor {
ntime: u32,
version: u32,
hash: [u8; 32],
downstream_target: Target,
extranonce: Vec<u8>,
user_identity_json: String,
share_status: ShareStatus,
) -> ShareLog {
let worker_identity: Value = serde_json::from_str(&user_identity_json)
.unwrap_or_else(|_| json!({
Expand All @@ -42,7 +42,7 @@ impl ShareProcessor {
hash_bytes.reverse();
let difficulty = DifficultyService::calculate_difficulty_from_hash(&hash_bytes);

let status = ShareStatus::NetworkValid;
//let status = ShareStatus::NetworkValid;

ShareLog::new(
channel_id,
Expand All @@ -52,7 +52,7 @@ impl ShareProcessor {
ntime,
version,
hash_bytes.to_vec(),
status,
share_status,
extranonce,
difficulty,
user_identity,
Expand Down
18 changes: 15 additions & 3 deletions protocols/v2/roles-logic-sv2/src/channel_logic/channel_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use std::{collections::HashMap, convert::TryInto, sync::Arc};
use template_distribution_sv2::{NewTemplate, SetNewPrevHash as SetNewPrevHashFromTp};

use tracing::{debug, error, info, trace, warn};
use std::backtrace::Backtrace;

use stratum_common::{
bitcoin,
Expand All @@ -30,6 +29,8 @@ use stratum_common::{
},
};

use shares_logger::models::ShareStatus;

/// A stripped type of `SetCustomMiningJob` without the (`channel_id, `request_id` and `token`)
/// fields
#[derive(Debug)]
Expand Down Expand Up @@ -831,13 +832,25 @@ impl ChannelFactory {
let hash_ = header.block_hash();
let hash = hash_.as_hash().into_inner();



// NOMIUM share_log injection ----
let user_identity = match &m {
Share::Extended(share) => std::str::from_utf8(share.user_identity.as_ref())
.unwrap_or("invalid_utf8")
.to_string(),
Share::Standard(_) => panic!("Expected Extended share, got Standard"),
};
let share_hash: Target = hash.into(); //todo (?) - move to shares_logger (?)
let share_status = if share_hash <= bitcoin_target {
ShareStatus::NetworkValid
} else if share_hash <= upstream_target {
ShareStatus::PoolValid
} else if share_hash <= downstream_target {
ShareStatus::MinerValid
} else {
ShareStatus::Invalid
};
match self.kind {
ExtendedChannelKind::Pool => {
/* let share_log = shares_logger::services::share_processor::ShareProcessor::prepare_share_log(
Expand All @@ -848,7 +861,6 @@ impl ChannelFactory {
m.get_n_time(),
m.get_version(),
hash,
downstream_target.clone(),
extranonce.to_vec(),
user_identity,
); */
Expand All @@ -864,9 +876,9 @@ impl ChannelFactory {
m.get_n_time(),
m.get_version(),
hash,
downstream_target.clone(),
extranonce.to_vec(),
user_identity,
share_status,
);
info!("Calling share logging for PROXY");
shares_logger::log_share(share_log);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ min_extranonce2_size = 8
# min_individual_miner_hashrate=100_000.0
min_individual_miner_hashrate=15_000_000.0
# target number of shares per minute the miner should be sending
shares_per_minute = 10.0
shares_per_minute = 20.0

[upstream_difficulty_config]
# interval in seconds to elapse before updating channel hashrate with the pool
Expand Down
25 changes: 25 additions & 0 deletions roles/translator/src/lib/downstream_sv1/downstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,31 @@ impl IsServer<'static> for Downstream {

true
} else {
// NOMIUM share_log injection ----
let worker_identity = shares_logger::worker_name_store::get_worker_identity(&request.user_name)
.map(|id| serde_json::json!({
"worker_name": id.worker_name,
"worker_id": id.worker_id
}).to_string())
.expect("Worker should be authorized");

let share_log = shares_logger::services::share_processor::ShareProcessor::prepare_share_log(
1,
0,
request.job_id.parse().unwrap_or(0),
request.nonce.0,
request.time.0,
match &request.version_bits {
Some(v) => v.0,
None => 0,
},
[0u8; 32],
vec![],
worker_identity,
shares_logger::models::ShareStatus::Invalid
);
shares_logger::log_share(share_log);
// NOMIUM share_log injection ----
false
}
}
Expand Down