mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-09 02:59:31 +08:00
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:
@@ -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()};
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -364,7 +364,7 @@ struct StringContentsSerializer {
|
||||
{
|
||||
str.clear();
|
||||
uint8_t c{0};
|
||||
while (!s.eof()) {
|
||||
while (!s.empty()) {
|
||||
s >> c;
|
||||
str.push_back(c);
|
||||
}
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user