Skip to content

Commit

Permalink
wallet: switch zap to new indexes.
Browse files Browse the repository at this point in the history
  • Loading branch information
nodech committed Mar 28, 2024
1 parent 333b4ed commit 2a3f3e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions lib/wallet/txdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -4127,7 +4127,6 @@ class TXDB {

/**
* Zap pending transactions older than `age`.
* @deprecated - Update
* @param {Number} acct
* @param {Number} age - Age delta.
* @returns {Promise<Hash[]>} - zapped tx hashes.
Expand All @@ -4137,26 +4136,27 @@ class TXDB {
assert((age >>> 0) === age);

const now = this.nowFn();
const options = {
time: now - age,
limit: Math.min(100, this.maxTxs),
reverse: true
};

const txs = await this.getRange(acct, {
start: 0,
end: now - age
});
let txs = await this.listUnconfirmedByTime(acct, options);

const hashes = [];

for (const wtx of txs) {
if (wtx.height !== -1)
continue;

assert(now - wtx.mtime >= age);
while (txs.length) {
for (const wtx of txs) {
this.logger.debug('Zapping TX: %h (%d)',
wtx.hash, this.wid);

this.logger.debug('Zapping TX: %x (%d)',
wtx.tx.hash(), this.wid);
await this.remove(wtx.hash);

await this.remove(wtx.hash);
hashes.push(wtx.hash);
}

hashes.push(wtx.hash);
txs = await this.listUnconfirmedByTime(acct, options);
}

return hashes;
Expand Down
2 changes: 1 addition & 1 deletion test/wallet-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3680,7 +3680,7 @@ describe('Wallet', function() {
});
});

describe('Zap Wallet', function () {
describe('Wallet Zap', function () {
const DEFAULT = 'default';
const ALT = 'alt';

Expand Down

0 comments on commit 2a3f3e6

Please sign in to comment.