Skip to content

Commit

Permalink
fix(core): only resize db if migration is required
Browse files Browse the repository at this point in the history
  • Loading branch information
sdbondi committed Oct 11, 2022
1 parent 702658c commit e6def7f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2618,7 +2618,7 @@ fn run_migrations(db: &LMDBDatabase) -> Result<(), ChainStorageError> {
Ok(())
}

// TODO: remove
// TODO: this is a temporary fix, remove
mod tari_script_execution_stack_bug_migration {
use serde::{Deserialize, Serialize};
use tari_common_types::types::{ComSignature, PublicKey};
Expand All @@ -2632,6 +2632,15 @@ mod tari_script_execution_stack_bug_migration {
};

pub fn migrate(db: &LMDBDatabase) -> Result<(), ChainStorageError> {
{
let txn = db.write_transaction()?;
// Only perform migration if necessary
if fetch_metadata(&txn, &db.metadata_db)?.height_of_longest_chain() == 0 ||
lmdb_len(&txn, &db.inputs_db)? == 0
{
return Ok(());
}
}
unsafe {
LMDBStore::resize(&db.env, &LMDBConfig::new(0, 1024 * 1024 * 1024, 0))?;
}
Expand Down

0 comments on commit e6def7f

Please sign in to comment.