Skip to content

Commit

Permalink
db_lmdb: catch attempt to remove block from an empty blockchain
Browse files Browse the repository at this point in the history
It would probably have thrown when not finding a block at
height 2^64-1, but better make things clear.
  • Loading branch information
moneromooo-monero authored and warptangent committed Jan 5, 2015
1 parent eaaaada commit 4c2a452
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp
Expand Up @@ -207,6 +207,9 @@ void BlockchainLMDB::remove_block()
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
check_open();

if (m_height == 0)
throw0(BLOCK_DNE ("Attempting to remove block from an empty blockchain"));

MDB_val_copy<uint64_t> k(m_height - 1);
MDB_val h;
if (mdb_get(*m_write_txn, m_block_hashes, &k, &h))
Expand Down

0 comments on commit 4c2a452

Please sign in to comment.