Skip to content

Commit

Permalink
wdb-migration: skip already migrated parts in TXCountTimeIndex.
Browse files Browse the repository at this point in the history
  • Loading branch information
nodech committed Sep 23, 2024
1 parent 4283253 commit 9165139
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/wallet/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,7 @@ class MigrateTXCountTimeIndex extends AbstractMigration {
const [height] = this.layout.wdb.h.decode(key);
const hash = value.slice(0, 32);

// Skip if already migrated.
if (value.length === 40)
continue;

Expand Down Expand Up @@ -958,6 +959,8 @@ class MigrateTXCountTimeIndex extends AbstractMigration {
lte: txlayout.m.max()
});

// Here we don't need to skip as the old time index
// is getting cleaned up in the same migration.
for await (const {key} of txsByOldTime) {
const [, txHash] = txlayout.m.decode(key);
await this.migrateTX(bucket, wid, txHash);
Expand All @@ -978,6 +981,11 @@ class MigrateTXCountTimeIndex extends AbstractMigration {

async migrateTX(bucket, wid, txHash, block, extra) {
const txlayout = this.layout.txdb;

// Skip if already migrated.
if (await bucket.get(txlayout.y.encode(txHash)))
return;

const batch = bucket.batch();
/** @type {Set<Number>} */
const accounts = new Set();
Expand Down

0 comments on commit 9165139

Please sign in to comment.