Skip to content

Commit cd32e10

Browse files
committed
Fix PPLNS: use raw chain head, not verified — pay all miners from start
Critical bug: best_share_hash() returned the verified chain's best head. With slow verification (132/984 shares), PPLNS only saw one miner's shares and blocks only paid that miner — effectively stealing from other miners. p2pool uses tracker.items (raw chain) for PPLNS, not tracker.verified. Verification is for detecting bad shares/peers, not restricting payouts. Fix: always return the tallest raw chain head for PPLNS computation. This ensures all miners get their fair share from the first block found, even if verification hasn't caught up yet.
1 parent 724dc22 commit cd32e10

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/impl/ltc/node.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -508,15 +508,17 @@ void NodeImpl::broadcast_share(const uint256& share_hash)
508508

509509
uint256 NodeImpl::best_share_hash()
510510
{
511-
// Return the cached result from the most recent think() cycle.
512-
// Falls back to O(heads) scan only when think() hasn't run yet.
513-
if (!m_best_share_hash.IsNull())
514-
return m_best_share_hash;
515-
511+
// p2pool uses the RAW chain (tracker.items) for PPLNS, not the verified
512+
// chain. This ensures all miners get paid from the first block, even if
513+
// verification hasn't caught up yet. Verification is for detecting bad
514+
// shares/peers, not for restricting PPLNS distribution.
515+
//
516+
// Always return the tallest raw chain head. The verified best (from
517+
// think()) is used for peer scoring and ban decisions, not for payouts.
516518
if (!m_chain || m_chain->size() == 0)
517519
return uint256::ZERO;
518520

519-
// Pick the head with the greatest height
521+
// Pick the head with the greatest height in the RAW chain
520522
uint256 best;
521523
int32_t best_height = -1;
522524
for (const auto& [head_hash, tail_hash] : m_chain->get_heads())

0 commit comments

Comments
 (0)