refactor: Use empty() over eof() in the streams interface

End-of-file does not really make sense for streams that wrap buffers. So
replace it by the equivalent empty() checks.
This commit is contained in:
MarcoFalke
2026-02-02 17:56:13 +01:00
parent fa879db735
commit fa20bc2ec2
5 changed files with 4 additions and 5 deletions

View File

@@ -202,7 +202,7 @@ static std::vector<CAddress> ConvertSeeds(const std::vector<uint8_t> &vSeedsIn)
std::vector<CAddress> vSeedsOut;
FastRandomContext rng;
ParamsStream s{DataStream{vSeedsIn}, CAddress::V2_NETWORK};
while (!s.eof()) {
while (!s.empty()) {
CService endpoint;
s >> endpoint;
CAddress addr{endpoint, SeedsServiceFlags()};

View File

@@ -1127,7 +1127,7 @@ public:
void write(std::span<const std::byte> src) { GetStream().write(src); }
void read(std::span<std::byte> dst) { GetStream().read(dst); }
void ignore(size_t num) { GetStream().ignore(num); }
bool eof() const { return GetStream().eof(); }
bool empty() const { return GetStream().empty(); }
size_t size() const { return GetStream().size(); }
//! Get reference to stream parameters.

View File

@@ -195,7 +195,6 @@ public:
//
// Stream subset
//
bool eof() const { return size() == 0; }
int in_avail() const { return size(); }
void read(std::span<value_type> dst)

View File

@@ -364,7 +364,7 @@ struct StringContentsSerializer {
{
str.clear();
uint8_t c{0};
while (!s.eof()) {
while (!s.empty()) {
s >> c;
str.push_back(c);
}

View File

@@ -377,7 +377,7 @@ bool LoadCryptedKey(CWallet* pwallet, DataStream& ssKey, DataStream& ssValue, st
// Get the checksum and check it
bool checksum_valid = false;
if (!ssValue.eof()) {
if (!ssValue.empty()) {
uint256 checksum;
ssValue >> checksum;
if (!(checksum_valid = Hash(vchPrivKey) == checksum)) {