Skip to content

Commit

Permalink
Prevent failure to retrieve HF version if height is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
who-biz committed Jul 8, 2019
1 parent 7ffdf4d commit 6571eac
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/blockchain_db/lmdb/db_lmdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3226,12 +3226,17 @@ uint8_t BlockchainLMDB::get_hard_fork_version(uint64_t height) const
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
check_open();

if ( height == 0 ) {
const uint8_t version = 1;
return version; }

TXN_PREFIX_RDONLY();
RCURSOR(hf_versions);

MDB_val_copy<uint64_t> val_key(height);
MDB_val val_ret;
auto result = mdb_cursor_get(m_cur_hf_versions, &val_key, &val_ret, MDB_SET);

if (result == MDB_NOTFOUND || result)
throw0(DB_ERROR(lmdb_error("Error attempting to retrieve a hard fork version at height " + boost::lexical_cast<std::string>(height) + " from the db: ", result).c_str()));

Expand Down

0 comments on commit 6571eac

Please sign in to comment.