Ensure we don't produce a HF block with garbage from the db

Fix edge case where the block producer has garbage in the db: the code
that clears it happens when we *accept* the block, but we can end up
here before then, when we produce the block, so just return empty in
such a case.
This commit is contained in:
Jason Rhinelander 2022-05-25 16:55:38 -03:00
parent 4848cacec8
commit fd4ca4a57c
No known key found for this signature in database
GPG Key ID: C4992CE7A88D4262
1 changed files with 4 additions and 1 deletions

View File

@ -189,7 +189,10 @@ namespace cryptonote {
std::optional<std::vector<cryptonote::batch_sn_payment>> BlockchainSQLite::get_sn_payments(uint64_t block_height) {
LOG_PRINT_L3("BlockchainDB_SQLITE::" << __func__);
if (block_height == 0)
// <= here because we might have crap in the db that we don't clear until we actually add the HF
// block later on. (This is a pretty slim edge case that happened on devnet and is probably
// virtually impossible on mainnet).
if (block_height <= cryptonote::get_hard_fork_heights(m_nettype, hf::hf19_reward_batching).first.value_or(0))
return std::nullopt;
const auto& conf = get_config(m_nettype);