streams: Remove confusing DataStream::in_avail()
What changed, and why it matters
This commit is a simple code cleanup: it removes a confusing alias named `in_avail()` from a data stream class and replaces its only use with a direct call to `size()`. There is no security issue here.
No security action needed. Treat as normal refactoring cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch removes DataStream::in_avail(), which was just returning size() after casting it to int. The single caller in ProcessPong is updated to call size() directly. The commit message explicitly frames this as a readability/maintainability improvement, not a security fix.
Changed components
src/streams.hsrc/net_processing.cppInspect captured patch +1 / −4
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 69304784..b870df66 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 6ef9d164..96cea55e 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<value_type> dst)
{
if (dst.size() == 0) return;
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.