HomePhabricator

wallet: Avoid deserializing unused records when salvaging

Description

wallet: Avoid deserializing unused records when salvaging

Summary:
PR description:

When salvaging a wallet, the only things that matter are the private keys. It is not necessary to attempt to deserialize any other records, especially if those records are corrupted too.

This PR adds a KeyFilterFn function callback to ReadKeyValue that salvage uses to filter for only the records that it wants. Of course doing it this way also lets us do other filters in the future from other places should we so desire.

walletdb: Add KeyFilterFn to ReadKeyValue

Add a KeyFilterFn callback to ReadKeyValue which allows the caller to
specify which types to actually deserialize. A KeyFilterFn takes the
type as the parameter and returns a bool indicating whether
deserialization should continue.

wallet: filter for keys only before record deser in salvage

When salvaging a wallet, avoid deserializing any records that we don't
care about, i.e. filter for keys only before the deserialization.

This is a backport of core#19805

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D10176

Details

Provenance
Andrew Chow <achow101-github@achow101.com>Authored on Aug 25 2020, 17:10
PiRKCommitted on Sep 22 2021, 12:51
PiRKPushed on Sep 22 2021, 12:51
Reviewer
Restricted Project
Differential Revision
D10176: wallet: Avoid deserializing unused records when salvaging
Parents
rABC97af018aaa35: test: Remove unused lock arg from BitcoinTestFramework.wait_until
Branches
Unknown
Tags
Unknown