From 2a804c2d9736e91271b3209fbc41080c67c100da Mon Sep 17 00:00:00 2001 From: bitflash-maintainer Date: Wed, 2 Sep 2026 06:49:28 +0000 Subject: worker: log the chain a pool job builds on, not just its id --- src/main.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 7b3e555..3de3db0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4040,8 +4040,29 @@ connected: jobShared.jobSeq++; jobShared.haveJob = true; } - LogPrint("worker", "[pool->worker] new job %s received\n", - jobId.c_str()); + // Log the chain position the pool is + // building on, so a stale or private + // fork is auditable from worker logs. + // The prevhash comes from the header we + // actually hash (== p[2] of the notify); + // a brief cs_main lookup is safe here -- + // this thread holds no other lock. + uint256 hashPrev; + memcpy(&hashPrev, header + 4, 32); + int nPrevHeight = -1; + CRITICAL_BLOCK(cs_main) + { + map::iterator mi = mapBlockIndex.find(hashPrev); + if (mi != mapBlockIndex.end()) + nPrevHeight = (*mi).second->nHeight; + } + if (nPrevHeight >= 0) + LogPrint("worker", "[pool->worker] new job %s received, prevhash %s (known, job height %d)\n", + jobId.c_str(), hashPrev.GetHex().c_str(), + nPrevHeight + 1); + else + LogPrint("worker", "[pool->worker] new job %s received, prevhash %s (unknown to our chain)\n", + jobId.c_str(), hashPrev.GetHex().c_str()); SetParticipantMiningStatus("hashing job " + jobId); } } -- cgit v1.2.3