Skip to content

Commit

Permalink
Merge bitcoin#22849: Remove unused SERIALIZE_METHODS for CBanEntry
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MarcoFalke committed Sep 1, 2021
2 parents 70676e4 + fa3bd9d commit b3a2b8c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 46 deletions.
33 changes: 6 additions & 27 deletions src/addrdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@

#include <fs.h>
#include <net_types.h> // For banmap_t
#include <serialize.h>
#include <univalue.h>

#include <string>
#include <vector>

class CAddress;
Expand All @@ -21,21 +19,15 @@ class CDataStream;
class CBanEntry
{
public:
static const int CURRENT_VERSION=1;
int nVersion;
int64_t nCreateTime;
int64_t nBanUntil;
static constexpr int CURRENT_VERSION{1};
int nVersion{CBanEntry::CURRENT_VERSION};
int64_t nCreateTime{0};
int64_t nBanUntil{0};

CBanEntry()
{
SetNull();
}
CBanEntry() {}

explicit CBanEntry(int64_t nCreateTimeIn)
{
SetNull();
nCreateTime = nCreateTimeIn;
}
: nCreateTime{nCreateTimeIn} {}

/**
* Create a ban entry from JSON.
Expand All @@ -44,19 +36,6 @@ class CBanEntry
*/
explicit CBanEntry(const UniValue& json);

SERIALIZE_METHODS(CBanEntry, obj)
{
uint8_t ban_reason = 2; //! For backward compatibility
READWRITE(obj.nVersion, obj.nCreateTime, obj.nBanUntil, ban_reason);
}

void SetNull()
{
nVersion = CBanEntry::CURRENT_VERSION;
nCreateTime = 0;
nBanUntil = 0;
}

/**
* Generate a JSON representation of this ban entry.
* @return JSON suitable for passing to the `CBanEntry(const UniValue&)` constructor.
Expand Down
16 changes: 1 addition & 15 deletions src/test/fuzz/addrdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,6 @@ FUZZ_TARGET(addrdb)
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());

// The point of this code is to exercise all CBanEntry constructors.
const CBanEntry ban_entry = [&] {
switch (fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 2)) {
case 0:
return CBanEntry{fuzzed_data_provider.ConsumeIntegral<int64_t>()};
break;
case 1: {
const std::optional<CBanEntry> ban_entry = ConsumeDeserializable<CBanEntry>(fuzzed_data_provider);
if (ban_entry) {
return *ban_entry;
}
break;
}
}
return CBanEntry{};
}();
const CBanEntry ban_entry{fuzzed_data_provider.ConsumeIntegral<int64_t>()};
(void)ban_entry; // currently unused
}
4 changes: 0 additions & 4 deletions src/test/fuzz/deserialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,6 @@ FUZZ_TARGET_DESERIALIZE(blockheader_deserialize, {
CBlockHeader bh;
DeserializeFromFuzzingInput(buffer, bh);
})
FUZZ_TARGET_DESERIALIZE(banentry_deserialize, {
CBanEntry be;
DeserializeFromFuzzingInput(buffer, be);
})
FUZZ_TARGET_DESERIALIZE(txundo_deserialize, {
CTxUndo tu;
DeserializeFromFuzzingInput(buffer, tu);
Expand Down

0 comments on commit b3a2b8c

Please sign in to comment.