Page MenuHomePhabricator

Raise InitError when peers.dat is invalid or corrupted
ClosedPublic

Authored by Fabien on Oct 19 2022, 14:11.

Details

Reviewers
PiRK
Group Reviewers
Restricted Project
Commits
rABCdc148fa4ac85: 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