Skip to content

Commit 6aabcb0

Browse files
committed
Fix GOT SHARE log: use p2pool format with miner address, not hex hash160
p2pool format: Received good share: diff=1.63e+02 hash=57d2030a... miner=myT1aT2PpJs9JFDKJ31og7aYb6RBesXX9D Pass miner_address (parsed Stratum username with worker, without merged addrs) through ShareCreationParams for human-readable log output.
1 parent 1394249 commit 6aabcb0

3 files changed

Lines changed: 18 additions & 14 deletions

File tree

src/c2pool/c2pool_refactored.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,24 +2292,12 @@ int main(int argc, char* argv[]) {
22922292
auto share_target = chain::bits_to_target(
22932293
p.has_frozen_fields && p.frozen_bits ? p.frozen_bits : p.bits);
22942294
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! "
2295+
LOG_INFO << "Received good share: "
23082296
<< std::scientific << std::setprecision(2)
23092297
<< "diff=" << share_diff
23102298
<< std::defaultfloat
23112299
<< " hash=" << share_hash.GetHex()
2312-
<< " miner=" << miner_addr;
2300+
<< " miner=" << p.miner_address;
23132301
}
23142302
} catch (const std::exception& e) {
23152303
LOG_ERROR << "create_share_fn failed (before broadcast): " << e.what();

src/core/web_server.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4372,6 +4372,21 @@ nlohmann::json MiningInterface::mining_submit(const std::string& username, const
43724372
// unmodified — Python p2pool does NOT apply node fee to merged chains.
43734373
if (m_create_share_fn) {
43744374
ShareCreationParams params;
4375+
// Miner display name: PRIMARY_ADDR.WORKER (strip merged addrs, keep worker)
4376+
{
4377+
std::string display = username;
4378+
// Remove merged addresses (after first comma) but keep worker name (after last dot)
4379+
auto comma_pos = display.find(',');
4380+
std::string worker;
4381+
if (comma_pos != std::string::npos) {
4382+
// Check for worker name after the merged addresses
4383+
auto dot_pos = display.rfind('.');
4384+
if (dot_pos != std::string::npos && dot_pos > comma_pos)
4385+
worker = display.substr(dot_pos);
4386+
display = display.substr(0, comma_pos) + worker;
4387+
}
4388+
params.miner_address = display;
4389+
}
43754390

43764391
// Build P2PKH script from share_address (40-char hex hash160)
43774392
if (share_address.size() == 40) {

src/core/web_server.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ class MiningInterface : public jsonrpccxx::JsonRpc2Server
379379
// Hook: called by mining_submit() pool path to create a share in the tracker.
380380
// All block template data needed by create_local_share() is passed through.
381381
struct ShareCreationParams {
382+
std::string miner_address; // Stratum username (human-readable address)
382383
std::vector<unsigned char> payout_script;
383384
std::map<uint32_t, std::vector<unsigned char>> merged_addresses;
384385
uint32_t block_version{0};

0 commit comments

Comments
 (0)