Skip to content

Commit

Permalink
chore: fix clippy (#6816)
Browse files Browse the repository at this point in the history
Description
---
Fix clippy 

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Chores**
- Enhanced the database update process to apply migrations sequentially,
ensuring reliable and comprehensive updates.
- Improved logging for clearer reporting of version changes during
migrations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
SWvheerden authored Feb 27, 2025
1 parent b3dc63f commit 64865c1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2878,29 +2878,29 @@ fn run_migrations(db: &LMDBDatabase) -> Result<(), ChainStorageError> {

let k = MetadataKey::MigrationVersion;
let val = lmdb_get::<_, MetadataValue>(&txn, &db.metadata_db, &k.as_u32())?;
let mut n = match val {
let last_migrated_version = match val {
Some(MetadataValue::MigrationVersion(n)) => n,
Some(_) | None => 0,
};
info!(
target: LOG_TARGET,
"Blockchain database is at v{} (required version: {})", n, MIGRATION_VERSION
"Blockchain database is at v{} (required version: {})", last_migrated_version, MIGRATION_VERSION
);
drop(txn);

if n < MIGRATION_VERSION {
for i in last_migrated_version..=MIGRATION_VERSION {
// Add migrations here
if n < 2 {
if i == 1 {
let txn = db.write_transaction()?;
info!(target: LOG_TARGET, "Clearing bad blocks list due to median timestamp bug in nextnet");
let rows_affected = lmdb_clear(&txn, &db.bad_blocks)?;
txn.commit()?;
info!(target: LOG_TARGET, "Removed {} rows from bad blocks", rows_affected);
n = 2;
}

}
if last_migrated_version != MIGRATION_VERSION {
let txn = db.write_transaction()?;
info!(target: LOG_TARGET, "Migrated database to version {}", n);
info!(target: LOG_TARGET, "Migrated database to version {}", MIGRATION_VERSION);
lmdb_replace(
&txn,
&db.metadata_db,
Expand Down

0 comments on commit 64865c1

Please sign in to comment.