HomePhabricator

banman: save the banlist in a JSON format on disk

Description

banman: save the banlist in a JSON format on disk

Summary:

Save the banlist in banlist.json instead of banlist.dat.

This makes it possible to store Tor v3 entries in the banlist on disk
(and any other addresses that cannot be serialized in addrv1 format).

Only read banlist.dat if it exists and banlist.json does not
exist (first start after an upgrade).

Supersedes https://github.com/bitcoin/bitcoin/pull/20904
Resolves https://github.com/bitcoin/bitcoin/issues/19748

test: ensure banlist can be read from disk after restart

With banlist.dat (being written in addrv1 format) if we would try to
write a Tor v3 subnet, it would serialize as a dummy-all-0s IPv6
address and subsequently, when deserialized will not result in the same
subnet.

This problem does not exist with banlist.json where the data is saved
in textual, human-readable form.

Backport note: this will also help reduce the number of instance of serializing CAddresses (with its complicated net vs disk rules) after we completely drop banlist.dat

This is a backport of core#20966

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

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

Details

Provenance
Vasil Dimov <vd@FreeBSD.org>Authored on Jan 14 2021, 08:33
PiRKCommitted on Dec 16 2025, 15:05
PiRKPushed on Dec 16 2025, 15:05
Reviewer
Restricted Project
Differential Revision
D19134: banman: save the banlist in a JSON format on disk
Parents
rABCd03d94ec2dc3: net: allow CSubNet of non-IP networks
Branches
Unknown
Tags
Unknown