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 committed 2026-02-02 17:55:10 +01:00
1 parent fa879db735
commit fa20bc2ec2
5 files changed
+4 -5

No files matched your search

+1 -1
View File
@@ -202,7 +202,7 @@ static std::vector<CAddress> ConvertSeeds(const std::vector<uint8_t> &vSeedsIn)
std::vector<CAddress> vSeedsOut; std::vector<CAddress> vSeedsOut;
FastRandomContext rng; FastRandomContext rng;
ParamsStream s{DataStream{vSeedsIn}, CAddress::V2_NETWORK}; ParamsStream s{DataStream{vSeedsIn}, CAddress::V2_NETWORK};
while (!s.eof()) { while (!s.empty()) {
CService endpoint; CService endpoint;
s >> endpoint; s >> endpoint;
CAddress addr{endpoint, SeedsServiceFlags()}; CAddress addr{endpoint, SeedsServiceFlags()};
+1 -1
View File
@@ -1127,7 +1127,7 @@ public:
void write(std::span<const std::byte> src) { GetStream().write(src); } void write(std::span<const std::byte> src) { GetStream().write(src); }
void read(std::span<std::byte> dst) { GetStream().read(dst); } void read(std::span<std::byte> dst) { GetStream().read(dst); }
void ignore(size_t num) { GetStream().ignore(num); } 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(); } size_t size() const { return GetStream().size(); }
//! Get reference to stream parameters. //! Get reference to stream parameters.
-1
View File
@@ -195,7 +195,6 @@ public:
// //
// Stream subset // Stream subset
// //
bool eof() const { return size() == 0; }
int in_avail() const { return size(); } int in_avail() const { return size(); }
void read(std::span<value_type> dst) void read(std::span<value_type> dst)
+1 -1
View File
@@ -364,7 +364,7 @@ struct StringContentsSerializer {
{ {
str.clear(); str.clear();
uint8_t c{0}; uint8_t c{0};
while (!s.eof()) { while (!s.empty()) {
s >> c; s >> c;
str.push_back(c); str.push_back(c);
} }
+1 -1
View File
@@ -377,7 +377,7 @@ bool LoadCryptedKey(CWallet* pwallet, DataStream& ssKey, DataStream& ssValue, st
// Get the checksum and check it // Get the checksum and check it
bool checksum_valid = false; bool checksum_valid = false;
if (!ssValue.eof()) { if (!ssValue.empty()) {
uint256 checksum; uint256 checksum;
ssValue >> checksum; ssValue >> checksum;
if (!(checksum_valid = Hash(vchPrivKey) == checksum)) { if (!(checksum_valid = Hash(vchPrivKey) == checksum)) {