further improves member function and attribute names

This commit is contained in:
Vito
2025-06-30 14:26:53 +02:00
parent dcb832ecf9
commit 99b2aa3702
7 changed files with 29 additions and 15 deletions

View File

@@ -450,7 +450,7 @@ public:
Slots::slots_map const& Slots::slots_map const&
getSlots() const getSlots() const
{ {
return slots_; return trustedSlots_;
} }
}; };

View File

@@ -104,7 +104,7 @@ public:
getSlots(bool trusted) const getSlots(bool trusted) const
{ {
if (trusted) if (trusted)
return slots_; return trustedSlots_;
return untrustedSlots_; return untrustedSlots_;
} }

View File

@@ -482,7 +482,14 @@ protected:
std::atomic_bool reduceRelayReady_{false}; std::atomic_bool reduceRelayReady_{false};
slots_map slots_; // Maintain an open number of slots for trusted validators to reduce
// duplicate traffic from trusted validators.
slots_map trustedSlots_;
// Maintain slots for untrusted validators to reduce duplicate traffic from
// untrusted validators. If enhanced squelching is enabled, the number of
// untrustedSlots_ is capped at reduce_relay::MAX_UNTRUSTED_SLOTS.
// Otherwise, there is no limit.
slots_map untrustedSlots_; slots_map untrustedSlots_;
SquelchHandler& handler_; // squelch/unsquelch handler SquelchHandler& handler_; // squelch/unsquelch handler

View File

@@ -1481,7 +1481,7 @@ OverlayImpl::updateSlotAndSquelch(
} }
void void
OverlayImpl::updateValidatorSlot( OverlayImpl::updateUntrustedValidatorSlot(
uint256 const& key, uint256 const& key,
PublicKey const& validator, PublicKey const& validator,
Peer::id_t peer) Peer::id_t peer)
@@ -1491,7 +1491,7 @@ OverlayImpl::updateValidatorSlot(
if (!strand_.running_in_this_thread()) if (!strand_.running_in_this_thread())
return post(strand_, [this, key, validator, peer]() { return post(strand_, [this, key, validator, peer]() {
updateValidatorSlot(key, validator, peer); updateUntrustedValidatorSlot(key, validator, peer);
}); });
slots_.updateUntrustedValidatorSlot(key, validator, peer, [&]() { slots_.updateUntrustedValidatorSlot(key, validator, peer, [&]() {

View File

@@ -427,7 +427,7 @@ public:
* @param peer Peer's id to update the slot for * @param peer Peer's id to update the slot for
*/ */
void void
updateValidatorSlot( updateUntrustedValidatorSlot(
uint256 const& key, uint256 const& key,
PublicKey const& validator, PublicKey const& validator,
Peer::id_t peer); Peer::id_t peer);

View File

@@ -2386,7 +2386,8 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMValidation> const& m)
TrafficCount::category::validation_untrusted, TrafficCount::category::validation_untrusted,
Message::messageSize(*m)); Message::messageSize(*m));
overlay_.updateValidatorSlot(key, val->getSignerPublic(), id_); overlay_.updateUntrustedValidatorSlot(
key, val->getSignerPublic(), id_);
// If the operator has specified that untrusted validations be // If the operator has specified that untrusted validations be
// dropped then this happens here I.e. before further wasting CPU // dropped then this happens here I.e. before further wasting CPU

View File

@@ -410,7 +410,10 @@ Slots::updateSlotAndSquelch(
{ {
JLOG(journal_.trace()) JLOG(journal_.trace())
<< "updateSlotAndSquelch: new slot " << Slice(validator); << "updateSlotAndSquelch: new slot " << Slice(validator);
auto it = slots_
// if enhanced squelching is disabled, keep untrusted validator slots
// separately from trusted ones
auto it = (isTrusted ? trustedSlots_ : untrustedSlots_)
.emplace(std::make_pair( .emplace(std::make_pair(
validator, validator,
Slot( Slot(
@@ -420,6 +423,7 @@ Slots::updateSlotAndSquelch(
isTrusted, isTrusted,
clock_))) clock_)))
.first; .first;
it->second.update(validator, id, callback); it->second.update(validator, id, callback);
} }
else else
@@ -511,21 +515,23 @@ Slots::updateConsideredValidator(PublicKey const& validator, Peer::id_t peer)
.peers = {peer}, .peers = {peer},
})); }));
return {}; return std::nullopt;
} }
// the validator idled. Don't update it, it will be cleaned later // the validator idled. Don't update it, it will be cleaned later
if (now - it->second.lastMessage > IDLED) if (now - it->second.lastMessage > IDLED)
return {}; return std::nullopt;
it->second.peers.insert(peer); it->second.peers.insert(peer);
it->second.lastMessage = now; it->second.lastMessage = now;
++it->second.count; ++it->second.count;
// if the validator has not met selection criteria yet
if (it->second.count < MAX_MESSAGE_THRESHOLD || if (it->second.count < MAX_MESSAGE_THRESHOLD ||
it->second.peers.size() < reduce_relay::MAX_SELECTED_PEERS) it->second.peers.size() < reduce_relay::MAX_SELECTED_PEERS)
return {}; {
return std::nullopt;
}
auto const key = it->first; auto const key = it->first;
consideredValidators_.erase(it); consideredValidators_.erase(it);
@@ -541,7 +547,7 @@ Slots::deletePeer(Peer::id_t id, bool erase)
slot.deletePeer(validator, id, erase); slot.deletePeer(validator, id, erase);
}; };
f(slots_); f(trustedSlots_);
f(untrustedSlots_); f(untrustedSlots_);
} }
@@ -573,7 +579,7 @@ Slots::deleteIdlePeers()
} }
}; };
f(slots_); f(trustedSlots_);
f(untrustedSlots_); f(untrustedSlots_);
// remove and squelch all validators that the selector deemed unsuitable // remove and squelch all validators that the selector deemed unsuitable
@@ -621,7 +627,7 @@ Slots::onWrite(beast::PropertyStream::Map& stream) const
{ {
beast::PropertyStream::Set set("trusted", slots); beast::PropertyStream::Set set("trusted", slots);
writeSlot(set, slots_); writeSlot(set, trustedSlots_);
} }
{ {