Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removes 'clear*' methods from the walletDb #5639

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 1 addition & 43 deletions ironfish/src/wallet/walletdb/walletdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export class WalletDB {
async removeAccount(account: Account, tx?: IDatabaseTransaction): Promise<void> {
await this.db.withTransaction(tx, async (tx) => {
await this.accounts.del(account.id, tx)
await this.clearBalance(account, tx)
await this.balances.clear(tx, account.prefixRange)
await this.accountIdsToCleanup.put(account.id, null, tx)
})
}
Expand Down Expand Up @@ -542,19 +542,6 @@ export class WalletDB {
await this.transactions.del([account.prefix, transactionHash], tx)
}

async clearTransactions(account: Account, tx?: IDatabaseTransaction): Promise<void> {
await this.transactions.clear(tx, account.prefixRange)
await this.timestampToTransactionHash.clear(tx, account.prefixRange)
}

async clearSequenceToNoteHash(account: Account, tx?: IDatabaseTransaction): Promise<void> {
await this.sequenceToNoteHash.clear(tx, account.prefixRange)
}

async clearNonChainNoteHashes(account: Account, tx?: IDatabaseTransaction): Promise<void> {
await this.nonChainNoteHashes.clear(tx, account.prefixRange)
}

async *getTransactionHashesBySequence(
account: Account,
tx?: IDatabaseTransaction,
Expand Down Expand Up @@ -658,20 +645,6 @@ export class WalletDB {
})
}

/*
* clears sequenceToNoteHash entries for all accounts for a given sequence
*/
async clearSequenceNoteHashes(sequence: number, tx?: IDatabaseTransaction): Promise<void> {
const encoding = this.sequenceToNoteHash.keyEncoding

const keyRange = StorageUtils.getPrefixesKeyRange(
encoding.serialize([Buffer.alloc(4, 0), [sequence, Buffer.alloc(0)]]),
encoding.serialize([Buffer.alloc(4, 255), [sequence, Buffer.alloc(0)]]),
)

await this.sequenceToNoteHash.clear(tx, keyRange)
}

async addUnspentNoteHash(
account: Account,
noteHash: Buffer,
Expand Down Expand Up @@ -1027,10 +1000,6 @@ export class WalletDB {
await this.decryptedNotes.del([account.prefix, noteHash], tx)
}

async clearDecryptedNotes(account: Account, tx?: IDatabaseTransaction): Promise<void> {
await this.decryptedNotes.clear(tx, account.prefixRange)
}

async *loadDecryptedNotes(
account: Account,
range?: DatabaseKeyRange,
Expand Down Expand Up @@ -1088,10 +1057,6 @@ export class WalletDB {
await this.balances.put([account.prefix, assetId], balance, tx)
}

async clearBalance(account: Account, tx?: IDatabaseTransaction): Promise<void> {
await this.balances.clear(tx, account.prefixRange)
}

async *loadExpiredTransactionHashes(
account: Account,
headSequence: number,
Expand Down Expand Up @@ -1221,13 +1186,6 @@ export class WalletDB {
await this.pendingTransactionHashes.del([account.prefix, [expiration, transactionHash]], tx)
}

async clearPendingTransactionHashes(
account: Account,
tx?: IDatabaseTransaction,
): Promise<void> {
await this.pendingTransactionHashes.clear(tx, account.prefixRange)
}

async forceCleanupDeletedAccounts(signal?: AbortSignal): Promise<void> {
return this.cleanupDeletedAccounts(Number.POSITIVE_INFINITY, signal)
}
Expand Down