Fix crash when stratum miners submit with stale templates
Added bounds check in get_hashing_blob_nolock() to handle empty m_transactionHashes when old/stale template slots are accessed. Returns 0 and logs at level 3 instead of vector out-of-bounds crash. Primarily affects external stratum miners that may hold onto old job IDs across template updates
This commit is contained in:
@@ -1576,8 +1576,14 @@ uint32_t BlockTemplate::get_hashing_blob_nolock(uint32_t extra_nonce, uint8_t* b
|
|||||||
hash miner_tx_hash = calc_miner_tx_hash(extra_nonce);
|
hash miner_tx_hash = calc_miner_tx_hash(extra_nonce);
|
||||||
const size_t num_hashes = m_transactionHashes.size() / HASH_SIZE;
|
const size_t num_hashes = m_transactionHashes.size() / HASH_SIZE;
|
||||||
|
|
||||||
|
if (num_hashes == 0) {
|
||||||
|
LOGERR(3, "get_hashing_blob_nolock: m_transactionHashes is empty");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<hash> hashes(num_hashes);
|
std::vector<hash> hashes(num_hashes);
|
||||||
hashes[0] = miner_tx_hash; // miner tx with current extra_nonce
|
hashes[0] = miner_tx_hash; // miner tx with current extra_nonce
|
||||||
|
|
||||||
for (size_t i = 1; i < num_hashes; ++i) {
|
for (size_t i = 1; i < num_hashes; ++i) {
|
||||||
memcpy(hashes[i].h, m_transactionHashes.data() + i * HASH_SIZE, HASH_SIZE);
|
memcpy(hashes[i].h, m_transactionHashes.data() + i * HASH_SIZE, HASH_SIZE);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user