Skip to content

Commit 8ec800f

Browse files
committed
Check idle peers every 4 seconds
Charge for bad TMSquelch Update comments
1 parent 9381c66 commit 8ec800f

File tree

6 files changed

+22
-16
lines changed

6 files changed

+22
-16
lines changed

src/ripple/app/misc/HashRouter.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ HashRouter::addSuppression(uint256 const& key)
5050
bool
5151
HashRouter::addSuppressionPeer(uint256 const& key, PeerShortID peer)
5252
{
53-
auto [added, _] = addSuppressionPeerWithStatus(key, peer);
54-
return added;
53+
return addSuppressionPeerWithStatus(key, peer).first;
5554
}
5655

5756
std::pair<bool, std::optional<Stopwatch::time_point>>

src/ripple/core/Config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class Config : public BasicConfig
179179
// Thread pool configuration
180180
std::size_t WORKERS = 0;
181181

182-
// Reduce-relay
182+
// Reduce-relay - these parameters are experimental.
183183
// Enable reduce-relay functionality
184184
bool REDUCE_RELAY_ENABLE = false;
185185
// Send squelch message to peers

src/ripple/overlay/Overlay.h

+12-10
Original file line numberDiff line numberDiff line change
@@ -147,22 +147,24 @@ class Overlay : public Stoppable, public beast::PropertyStream::Source
147147
virtual void
148148
broadcast(protocol::TMValidation& m) = 0;
149149

150-
/** Relay a proposal. Return set
151-
* of peers, which have already seen the
152-
* message; i.e. the message has been
153-
* received from these peers and added
154-
* to the hash router */
150+
/** Relay a proposal.
151+
* @param m the serialized proposal
152+
* @param uid the id used to identify this proposal
153+
* @param validator The pubkey of the validator that issued this proposal
154+
* @return the set of peers which have already sent us this proposal
155+
*/
155156
virtual std::set<Peer::id_t>
156157
relay(
157158
protocol::TMProposeSet& m,
158159
uint256 const& uid,
159160
PublicKey const& validator) = 0;
160161

161-
/** Relay a validation. Return set
162-
* of peers, which have already seen the
163-
* message; i.e. the message has been
164-
* received from these peers and added
165-
* to the hash router */
162+
/** Relay a validation.
163+
* @param m the serialized validation
164+
* @param uid the id used to identify this validation
165+
* @param validator The pubkey of the validator that issued this validation
166+
* @return the set of peers which have already sent us this validation
167+
*/
166168
virtual std::set<Peer::id_t>
167169
relay(
168170
protocol::TMValidation& m,

src/ripple/overlay/impl/OverlayImpl.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,13 @@ OverlayImpl::Timer::on_timer(error_code ec)
9999
overlay_.m_peerFinder->once_per_second();
100100
overlay_.sendEndpoints();
101101
overlay_.autoConnect();
102-
overlay_.deleteIdlePeers();
103102

104103
if ((++overlay_.timer_count_ % Tuning::checkSeconds) == 0)
105104
overlay_.check();
106105

106+
if ((overlay_.timer_count_ % Tuning::checkIdlePeers) == 0)
107+
overlay_.deleteIdlePeers();
108+
107109
timer_.expires_from_now(std::chrono::seconds(1));
108110
timer_.async_wait(overlay_.strand_.wrap(std::bind(
109111
&Timer::on_timer, shared_from_this(), std::placeholders::_1)));

src/ripple/overlay/impl/PeerImp.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2358,14 +2358,14 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMSquelch> const& m)
23582358
{
23592359
if (!m->has_validatorpubkey())
23602360
{
2361-
JLOG(p_journal_.debug()) << "onMessage: TMSquelch, missing public key";
2361+
charge(Resource::feeBadData);
23622362
return;
23632363
}
23642364
auto validator = m->validatorpubkey();
23652365
auto const slice{makeSlice(validator)};
23662366
if (!publicKeyType(slice))
23672367
{
2368-
JLOG(p_journal_.debug()) << "onMessage: TMSquelch, invalid public key";
2368+
charge(Resource::feeBadData);
23692369
return;
23702370
}
23712371
PublicKey key(slice);

src/ripple/overlay/impl/Tuning.h

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ enum {
7171

7272
/** How often to log send queue size */
7373
sendQueueLogFreq = 64,
74+
75+
/** How often we check for idle peers (seconds) */
76+
checkIdlePeers = 4,
7477
};
7578

7679
/** The threshold above which we treat a peer connection as high latency */

0 commit comments

Comments
 (0)