From 5b8dd452618ae56d2437779961cf26e71a53b17d Mon Sep 17 00:00:00 2001 From: Vito <5780819+Tapanito@users.noreply.github.com> Date: Thu, 31 Jul 2025 11:42:13 +0200 Subject: [PATCH] clean up imports, and typos --- src/xrpld/overlay/Slot.h | 12 +---------- src/xrpld/overlay/SquelchStore.h | 2 -- src/xrpld/overlay/detail/PeerImp.cpp | 9 ++++---- src/xrpld/overlay/detail/PeerImp.h | 1 + src/xrpld/overlay/detail/Slot.cpp | 26 +++++++++++++++++------ src/xrpld/overlay/detail/SquelchStore.cpp | 4 +--- 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/xrpld/overlay/Slot.h b/src/xrpld/overlay/Slot.h index 2e4b94db52..5439c52372 100644 --- a/src/xrpld/overlay/Slot.h +++ b/src/xrpld/overlay/Slot.h @@ -33,7 +33,6 @@ #include #include -#include #include namespace ripple { @@ -200,16 +199,7 @@ private: std::string formatLogMessage(PublicKey const& validator, std::optional id) - const - { - std::stringstream ss; - ss << "validator: " << toBase58(TokenType::NodePublic, validator); - if (id) - ss << " peer: " << *id; - ss << " trusted: " << isTrusted_; - ss << " slot_state: " << to_string(getState()); - return ss.str(); - } + const; /** * @brief Processes a message from a peer and updates the slot's state. diff --git a/src/xrpld/overlay/SquelchStore.h b/src/xrpld/overlay/SquelchStore.h index 4d0bc03921..7b313cff14 100644 --- a/src/xrpld/overlay/SquelchStore.h +++ b/src/xrpld/overlay/SquelchStore.h @@ -20,8 +20,6 @@ #ifndef RIPPLE_OVERLAY_SQUELCH_H_INCLUDED #define RIPPLE_OVERLAY_SQUELCH_H_INCLUDED -#include - #include #include #include diff --git a/src/xrpld/overlay/detail/PeerImp.cpp b/src/xrpld/overlay/detail/PeerImp.cpp index 024a26d33b..2c804eff69 100644 --- a/src/xrpld/overlay/detail/PeerImp.cpp +++ b/src/xrpld/overlay/detail/PeerImp.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -2396,14 +2395,16 @@ PeerImp::onMessage(std::shared_ptr const& m) TrafficCount::category::validation_untrusted, Message::messageSize(*m)); - overlay_.updateUntrustedValidatorSlot( - key, val->getSignerPublic(), id_); - // If the operator has specified that untrusted validations be // dropped then this happens here I.e. before further wasting CPU // verifying the signature of an untrusted key + // TODO: Deprecate RELAY_UNTRUSTED_VALIDATIONS config once enhanced + // squelching is the defacto routing algorithm. if (app_.config().RELAY_UNTRUSTED_VALIDATIONS == -1) return; + + overlay_.updateUntrustedValidatorSlot( + key, val->getSignerPublic(), id_); } if (!isTrusted && (tracking_.load() == Tracking::diverged)) diff --git a/src/xrpld/overlay/detail/PeerImp.h b/src/xrpld/overlay/detail/PeerImp.h index 3e657e33db..7a0f99128c 100644 --- a/src/xrpld/overlay/detail/PeerImp.h +++ b/src/xrpld/overlay/detail/PeerImp.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include diff --git a/src/xrpld/overlay/detail/Slot.cpp b/src/xrpld/overlay/detail/Slot.cpp index 6030c4080f..da91e791bf 100644 --- a/src/xrpld/overlay/detail/Slot.cpp +++ b/src/xrpld/overlay/detail/Slot.cpp @@ -34,6 +34,7 @@ #include #include #include +#include namespace ripple { namespace reduce_relay { @@ -309,6 +310,19 @@ Slot::initCounting() } } +std::string +Slot::formatLogMessage(PublicKey const& validator, std::optional id) + const +{ + std::stringstream ss; + ss << "validator: " << toBase58(TokenType::NodePublic, validator); + if (id) + ss << " peer: " << *id; + ss << " trusted: " << isTrusted_; + ss << " slot_state: " << to_string(getState()); + return ss.str(); +} + // --------------------------------- Slots --------------------------------- // bool @@ -377,7 +391,7 @@ Slots::updateSlotAndSquelch( uint256 const& key, PublicKey const& validator, Peer::id_t id, - typename Slot::ignored_squelch_callback callback, + typename Slot::ignored_squelch_callback report, bool isTrusted) { if (expireAndIsPeerMessageCached(key, id)) @@ -401,7 +415,7 @@ Slots::updateSlotAndSquelch( clock_))) .first; - it->second.update(validator, id, callback); + it->second.update(validator, id, report); } else { @@ -412,7 +426,7 @@ Slots::updateSlotAndSquelch( if (it == untrustedSlots_.end()) return; - it->second.update(validator, id, callback); + it->second.update(validator, id, report); } } @@ -421,21 +435,21 @@ Slots::updateUntrustedValidatorSlot( uint256 const& key, PublicKey const& validator, Peer::id_t id, - typename Slot::ignored_squelch_callback callback) + typename Slot::ignored_squelch_callback report) { // We received a message from an already selected validator // we can ignore this message if (untrustedSlots_.find(validator) != untrustedSlots_.end()) return; - // We received a message from an already squelched validator. + // Did we receive a message from an already squelched validator? // This could happen in few cases: // 1. It happened so that the squelch for a particular peer expired // before our local squelch. // 2. We receive a message from a new peer that did not receive the // squelch request. // 3. The peer is ignoring our squelch request and we have not sent - // the controll message in a while. + // the control message in a while. // In all of these cases we can only send them a squelch request again. if (expireAndIsValidatorSquelched(validator)) { diff --git a/src/xrpld/overlay/detail/SquelchStore.cpp b/src/xrpld/overlay/detail/SquelchStore.cpp index a4e5dc8e5c..2184aa1b20 100644 --- a/src/xrpld/overlay/detail/SquelchStore.cpp +++ b/src/xrpld/overlay/detail/SquelchStore.cpp @@ -17,7 +17,6 @@ */ //============================================================================== -#include #include #include @@ -27,7 +26,6 @@ #include #include -#include namespace ripple { @@ -45,7 +43,7 @@ SquelchStore::handleSquelch( if (squelch) { - // This should never trigger. The squelh duration is validated in + // This should never trigger. The squelch duration is validated in // PeerImp.onMessage(TMSquelch). However, if somehow invalid duration is // passed, log is as an error if ((duration < reduce_relay::MIN_UNSQUELCH_EXPIRE ||