Skip to content

Commit

Permalink
Make isFloodMessage static
Browse files Browse the repository at this point in the history
  • Loading branch information
marta-lokhova committed Apr 20, 2024
1 parent 2adc476 commit f4b2002
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/overlay/FlowControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ bool
FlowControl::maybeSendMessage(std::shared_ptr<StellarMessage const> msg)
{
ZoneScoped;
if (mApp.getOverlayManager().isFloodMessage(*msg))
if (OverlayManager::isFloodMessage(*msg))
{
addMsgAndMaybeTrimQueue(msg);
maybeSendNextBatch();
Expand Down
6 changes: 3 additions & 3 deletions src/overlay/FlowControlCapacity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void
FlowControlCapacity::lockOutboundCapacity(StellarMessage const& msg)
{
ZoneScoped;
if (mApp.getOverlayManager().isFloodMessage(msg))
if (OverlayManager::isFloodMessage(msg))
{
releaseAssert(hasOutboundCapacity(msg));
mOutboundCapacity -= getMsgResourceCount(msg);
Expand All @@ -152,7 +152,7 @@ FlowControlCapacity::lockLocalCapacity(StellarMessage const& msg)
*mCapacity.mTotalCapacity -= msgResources;
}

if (mApp.getOverlayManager().isFloodMessage(msg))
if (OverlayManager::isFloodMessage(msg))
{
// No capacity to process flood message
if (mCapacity.mFloodCapacity < msgResources)
Expand Down Expand Up @@ -182,7 +182,7 @@ FlowControlCapacity::releaseLocalCapacity(StellarMessage const& msg)
*mCapacity.mTotalCapacity += resourcesFreed;
}

if (mApp.getOverlayManager().isFloodMessage(msg))
if (OverlayManager::isFloodMessage(msg))
{
if (mCapacity.mFloodCapacity == 0)
{
Expand Down
3 changes: 1 addition & 2 deletions src/overlay/OverlayManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class OverlayManager

// Drop all PeerRecords from the Database
static void dropAll(Database& db);
static bool isFloodMessage(StellarMessage const& msg);

// Flush all FloodGate and ItemFetcher state for ledgers older than
// `ledgerSeq`.
Expand Down Expand Up @@ -141,8 +142,6 @@ class OverlayManager
virtual bool isPossiblyPreferred(std::string const& ip) const = 0;
virtual bool haveSpaceForConnection(std::string const& ip) const = 0;

virtual bool isFloodMessage(StellarMessage const& msg) = 0;

// Return the current in-memory set of inbound pending peers.
virtual std::vector<Peer::pointer> const&
getInboundPendingPeers() const = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/overlay/OverlayManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ OverlayManagerImpl::isPreferred(Peer* peer) const
}

bool
OverlayManagerImpl::isFloodMessage(StellarMessage const& msg)
OverlayManager::isFloodMessage(StellarMessage const& msg)
{
return msg.type() == SCP_MESSAGE || msg.type() == TRANSACTION ||
msg.type() == FLOOD_DEMAND || msg.type() == FLOOD_ADVERT;
Expand Down
1 change: 0 additions & 1 deletion src/overlay/OverlayManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ class OverlayManagerImpl : public OverlayManager

bool acceptAuthenticatedPeer(Peer::pointer peer) override;
bool isPreferred(Peer* peer) const override;
bool isFloodMessage(StellarMessage const& msg) override;
std::vector<Peer::pointer> const& getInboundPendingPeers() const override;
std::vector<Peer::pointer> const& getOutboundPendingPeers() const override;
std::vector<Peer::pointer> getPendingPeers() const override;
Expand Down

0 comments on commit f4b2002

Please sign in to comment.