Page MenuHomePhabricator

wallet: Avoid deserializing unused records when salvaging
ClosedPublic

Authored by PiRK on Sep 22 2021, 08:51.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCf9d3967c192d: 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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable