From fa204100e1456b14978071064112fce2acc527a6 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Fri, 24 Apr 2026 12:36:02 +0200 Subject: [PATCH] streams: Remove confusing DataStream::in_avail() The alias of the size() method is confusing, because: * It claims to be part of the Bitcoin Core stream subset (streams interface), but this is not used by any other stream interface. Mostly the `write(std::span)` and `read(std::span)` define the stream interface. * It casts the size_t to i32, but the only place that calls the function casts that back to size_t. * Providing this alias for size() without a proper reason is confusing. Fix all issues by removing it and using the size() method. --- src/net_processing.cpp | 2 +- src/streams.h | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 6930478421b..b870df66c1e 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -5557,7 +5557,7 @@ bool PeerManagerImpl::RejectIncomingTxs(const CNode& peer) const void PeerManagerImpl::ProcessPong(CNode& pfrom, Peer& peer, const NodeClock::time_point ping_end, DataStream& vRecv) { uint64_t nonce = 0; - size_t nAvail = vRecv.in_avail(); + const size_t nAvail{vRecv.size()}; bool bPingFinished = false; std::string sProblem; diff --git a/src/streams.h b/src/streams.h index 6ef9d164494..96cea55eb49 100644 --- a/src/streams.h +++ b/src/streams.h @@ -188,7 +188,6 @@ public: return std::string{UCharCast(data()), UCharCast(data() + size())}; } - // // Vector subset // @@ -209,8 +208,6 @@ public: // // Stream subset // - int in_avail() const { return size(); } - void read(std::span dst) { if (dst.size() == 0) return;