HomePhabricator

Raise InitError when peers.dat is invalid or corrupted

Description

Raise InitError when peers.dat is invalid or corrupted

Summary:

peers.dat is silently erased when it can not be parsed or when it appears corrupted. Fix that by notifying the user. This might help in the following examples:

 - The user provided the database, but picked the wrong one.
 - A future version of Bitcoin Core wrote the file and it can't be read.
 - The file was corrupted by a logic bug in Bitcoin Core.
 - The file was corrupted by a disk failure.

Backport of core#22762.

Also cherry-picks a commit from PR22697 that is now required for the addrman_tests to pass, and for which the rationale is still trivially correct:
https://github.com/bitcoin/bitcoin/pull/22697/commits/ed9ba8af08f857bda3ce2f77413317374c22d7b4

Test Plan:

ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

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

Details

Provenance
MarcoFalke <falke.marco@gmail.com>Authored on Aug 21 2021, 11:49
FabienCommitted on Oct 19 2022, 16:41
FabienPushed on Oct 19 2022, 16:41
Reviewer
Restricted Project
Differential Revision
D12308: Raise InitError when peers.dat is invalid or corrupted
Parents
rABC9f83b8b17167: Remove confusing CAddrDB
Branches
Unknown
Tags
Unknown