Skip to content

Commit 1394249

Browse files
committed
GOT SHARE log: match p2pool style (diff=, hash=, miner=)
1 parent fd42ad2 commit 1394249

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

src/c2pool/c2pool_refactored.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,10 +2288,29 @@ int main(int argc, char* argv[]) {
22882288
LOG_ERROR << "broadcast_share failed: " << e.what();
22892289
}
22902290

2291-
LOG_INFO << "GOT SHARE! " << share_hash.GetHex().substr(0, 8)
2292-
<< " prev " << prev_share.GetHex().substr(0, 8)
2293-
<< " subsidy=" << p.subsidy
2294-
<< " merged=" << merged_addrs.size();
2291+
{
2292+
auto share_target = chain::bits_to_target(
2293+
p.has_frozen_fields && p.frozen_bits ? p.frozen_bits : p.bits);
2294+
double share_diff = chain::target_to_difficulty(share_target);
2295+
// Extract primary address from username
2296+
std::string miner_addr;
2297+
for (const auto& [script, _] : p.merged_addresses) { (void)_; }
2298+
// Use the payout script hash160 as miner identifier
2299+
if (p.payout_script.size() == 25 &&
2300+
p.payout_script[0] == 0x76 && p.payout_script[1] == 0xa9) {
2301+
static const char* HX = "0123456789abcdef";
2302+
for (int i = 3; i < 23 && i < (int)p.payout_script.size(); ++i) {
2303+
miner_addr += HX[p.payout_script[i] >> 4];
2304+
miner_addr += HX[p.payout_script[i] & 0xf];
2305+
}
2306+
}
2307+
LOG_INFO << "GOT SHARE! "
2308+
<< std::scientific << std::setprecision(2)
2309+
<< "diff=" << share_diff
2310+
<< std::defaultfloat
2311+
<< " hash=" << share_hash.GetHex()
2312+
<< " miner=" << miner_addr;
2313+
}
22952314
} catch (const std::exception& e) {
22962315
LOG_ERROR << "create_share_fn failed (before broadcast): " << e.what();
22972316
}

0 commit comments

Comments
 (0)