Skip to content

Commit

Permalink
Refactor: Remove unused FlatFilePos::SetNull
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke committed Mar 21, 2023
1 parent 40e1c4d commit fa67b81
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
7 changes: 3 additions & 4 deletions src/flatfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

struct FlatFilePos
{
int nFile;
unsigned int nPos;
int nFile{-1};
unsigned int nPos{0};

SERIALIZE_METHODS(FlatFilePos, obj) { READWRITE(VARINT_MODE(obj.nFile, VarIntMode::NONNEGATIVE_SIGNED), VARINT(obj.nPos)); }

FlatFilePos() : nFile(-1), nPos(0) {}
FlatFilePos() {}

FlatFilePos(int nFileIn, unsigned int nPosIn) :
nFile(nFileIn),
Expand All @@ -33,7 +33,6 @@ struct FlatFilePos
return !(a == b);
}

void SetNull() { nFile = -1; nPos = 0; }
bool IsNull() const { return (nFile == -1); }

std::string ToString() const;
Expand Down
12 changes: 2 additions & 10 deletions src/index/disktxpos.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

struct CDiskTxPos : public FlatFilePos
{
unsigned int nTxOffset; // after header
unsigned int nTxOffset{0}; // after header

SERIALIZE_METHODS(CDiskTxPos, obj)
{
Expand All @@ -21,15 +21,7 @@ struct CDiskTxPos : public FlatFilePos
CDiskTxPos(const FlatFilePos &blockIn, unsigned int nTxOffsetIn) : FlatFilePos(blockIn.nFile, blockIn.nPos), nTxOffset(nTxOffsetIn) {
}

CDiskTxPos() {
SetNull();
}

void SetNull() {
FlatFilePos::SetNull();
nTxOffset = 0;
}
CDiskTxPos() {}
};


#endif // BITCOIN_INDEX_DISKTXPOS_H
3 changes: 3 additions & 0 deletions src/test/flatfile_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ BOOST_AUTO_TEST_CASE(flatfile_filename)

FlatFileSeq seq2(data_dir / "a", "b", 16 * 1024);
BOOST_CHECK_EQUAL(seq2.FileName(pos), data_dir / "a" / "b00456.dat");

// Check default constructor IsNull
assert(FlatFilePos{}.IsNull());
}

BOOST_AUTO_TEST_CASE(flatfile_open)
Expand Down
2 changes: 0 additions & 2 deletions src/test/fuzz/flatfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,4 @@ FUZZ_TARGET(flatfile)
assert((*flat_file_pos == *another_flat_file_pos) != (*flat_file_pos != *another_flat_file_pos));
}
(void)flat_file_pos->ToString();
flat_file_pos->SetNull();
assert(flat_file_pos->IsNull());
}

0 comments on commit fa67b81

Please sign in to comment.