Skip to content

Commit fd11df9

Browse files
committed
Genesis bootstrap: use max_target when sharechain is empty
When share_bits==0 (empty chain), miners couldn't create shares because the bits guard blocked share creation and VARDIFF had no floor reference. Fix: fall back to m_share_max_bits (or hardcoded 0x1e0fffff for LTC testnet) when share_bits is zero. This matches p2pool's behavior of setting desired_share_target = 2**256-1 when chain is empty, allowing miners to create genesis shares immediately. Also applies max_target as VARDIFF floor during bootstrap — prevents miners from working at uselessly low difficulty when no share target reference exists.
1 parent 3a4d0a4 commit fd11df9

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/core/stratum_server.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ void StratumSession::process_message(std::size_t bytes_read)
198198
// Floor initial difficulty at share target so miner doesn't waste
199199
// bandwidth submitting solutions that can never become real shares.
200200
uint32_t sb = mining_interface_->m_share_bits.load();
201+
if (sb == 0) sb = mining_interface_->m_share_max_bits.load(); // bootstrap: use max target
201202
if (sb != 0) {
202203
double share_diff = chain::target_to_difficulty(chain::bits_to_target(sb));
203204
if (initial_diff < share_diff)

src/core/web_server.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4442,6 +4442,14 @@ nlohmann::json MiningInterface::mining_submit(const std::string& username, const
44424442
params.prev_share_hash = job->prev_share_hash;
44434443
}
44444444

4445+
// Bootstrap: when chain is empty (bits==0), use max_target
4446+
// so miners can create genesis shares immediately.
4447+
// P2Pool sets desired_share_target = 2**256-1 when chain is empty.
4448+
if (params.bits == 0) {
4449+
params.bits = m_share_max_bits.load();
4450+
if (params.bits == 0)
4451+
params.bits = 0x1e0fffff; // fallback: easiest LTC testnet target
4452+
}
44454453
if (!params.payout_script.empty() && params.bits != 0) {
44464454
m_create_share_fn(params);
44474455
}

0 commit comments

Comments
 (0)