db_lmdb: catch attempt to remove block from an empty blockchain

It would probably have thrown when not finding a block at
height 2^64-1, but better make things clear.
This commit is contained in:
moneromooo-monero 2014-12-12 23:20:41 +00:00 committed by warptangent
parent eaaaada797
commit 4c2a45288a
1 changed files with 3 additions and 0 deletions

View File

@ -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))