Skip to content

Commit b3a2b8c

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#22849: Remove unused SERIALIZE_METHODS for CBanEntry
fa3bd9d Remove CBanEntry::SetNull (MarcoFalke) fab53ff Remove unused SERIALIZE_METHODS for CBanEntry (MarcoFalke) Pull request description: It would be confusing to keep unused and dead code. ACKs for top commit: ryanofsky: Code review ACK fa3bd9d. theStack: Code-review ACK fa3bd9d Tree-SHA512: 85ab8de2ad1ada08e745806f2992def08bf8ead268caed7700a9fc61e3c7646e4ed7ae50a6d591c5bb9467f8999ea063ce5b5bd4fa0d58d8fc9d89e5a91f35a5
2 parents 70676e4 + fa3bd9d commit b3a2b8c

File tree

3 files changed

+7
-46
lines changed

3 files changed

+7
-46
lines changed

src/addrdb.h

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88

99
#include <fs.h>
1010
#include <net_types.h> // For banmap_t
11-
#include <serialize.h>
1211
#include <univalue.h>
1312

14-
#include <string>
1513
#include <vector>
1614

1715
class CAddress;
@@ -21,21 +19,15 @@ class CDataStream;
2119
class CBanEntry
2220
{
2321
public:
24-
static const int CURRENT_VERSION=1;
25-
int nVersion;
26-
int64_t nCreateTime;
27-
int64_t nBanUntil;
22+
static constexpr int CURRENT_VERSION{1};
23+
int nVersion{CBanEntry::CURRENT_VERSION};
24+
int64_t nCreateTime{0};
25+
int64_t nBanUntil{0};
2826

29-
CBanEntry()
30-
{
31-
SetNull();
32-
}
27+
CBanEntry() {}
3328

3429
explicit CBanEntry(int64_t nCreateTimeIn)
35-
{
36-
SetNull();
37-
nCreateTime = nCreateTimeIn;
38-
}
30+
: nCreateTime{nCreateTimeIn} {}
3931

4032
/**
4133
* Create a ban entry from JSON.
@@ -44,19 +36,6 @@ class CBanEntry
4436
*/
4537
explicit CBanEntry(const UniValue& json);
4638

47-
SERIALIZE_METHODS(CBanEntry, obj)
48-
{
49-
uint8_t ban_reason = 2; //! For backward compatibility
50-
READWRITE(obj.nVersion, obj.nCreateTime, obj.nBanUntil, ban_reason);
51-
}
52-
53-
void SetNull()
54-
{
55-
nVersion = CBanEntry::CURRENT_VERSION;
56-
nCreateTime = 0;
57-
nBanUntil = 0;
58-
}
59-
6039
/**
6140
* Generate a JSON representation of this ban entry.
6241
* @return JSON suitable for passing to the `CBanEntry(const UniValue&)` constructor.

src/test/fuzz/addrdb.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,6 @@ FUZZ_TARGET(addrdb)
1818
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
1919

2020
// The point of this code is to exercise all CBanEntry constructors.
21-
const CBanEntry ban_entry = [&] {
22-
switch (fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 2)) {
23-
case 0:
24-
return CBanEntry{fuzzed_data_provider.ConsumeIntegral<int64_t>()};
25-
break;
26-
case 1: {
27-
const std::optional<CBanEntry> ban_entry = ConsumeDeserializable<CBanEntry>(fuzzed_data_provider);
28-
if (ban_entry) {
29-
return *ban_entry;
30-
}
31-
break;
32-
}
33-
}
34-
return CBanEntry{};
35-
}();
21+
const CBanEntry ban_entry{fuzzed_data_provider.ConsumeIntegral<int64_t>()};
3622
(void)ban_entry; // currently unused
3723
}

src/test/fuzz/deserialize.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,6 @@ FUZZ_TARGET_DESERIALIZE(blockheader_deserialize, {
195195
CBlockHeader bh;
196196
DeserializeFromFuzzingInput(buffer, bh);
197197
})
198-
FUZZ_TARGET_DESERIALIZE(banentry_deserialize, {
199-
CBanEntry be;
200-
DeserializeFromFuzzingInput(buffer, be);
201-
})
202198
FUZZ_TARGET_DESERIALIZE(txundo_deserialize, {
203199
CTxUndo tu;
204200
DeserializeFromFuzzingInput(buffer, tu);

0 commit comments

Comments
 (0)