This commit is contained in:
bthomee
2025-03-11 18:21:06 +00:00
parent 95e4a9d650
commit 4ba075f689
2527 changed files with 275798 additions and 275583 deletions

View File

@@ -99,110 +99,109 @@ $(function() {
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span><span class="preprocessor">#define RIPPLE_OVERLAY_SQUELCH_H_INCLUDED</span></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span> </div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"> 23</span><span class="preprocessor">#include &lt;xrpld/overlay/ReduceRelayCommon.h&gt;</span></div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span><span class="preprocessor">#include &lt;xrpl/basics/random.h&gt;</span></div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"> 25</span><span class="preprocessor">#include &lt;xrpl/beast/utility/Journal.h&gt;</span></div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"> 26</span><span class="preprocessor">#include &lt;xrpl/protocol/PublicKey.h&gt;</span></div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"> 27</span> </div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"> 28</span><span class="preprocessor">#include &lt;<a class="codeRef" href="http://en.cppreference.com/w/cpp/header/algorithm.html">algorithm</a>&gt;</span></div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span><span class="preprocessor">#include &lt;<a class="codeRef" href="http://en.cppreference.com/w/cpp/header/chrono.html">chrono</a>&gt;</span></div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span><span class="preprocessor">#include &lt;<a class="codeRef" href="http://en.cppreference.com/w/cpp/header/functional.html">functional</a>&gt;</span></div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span> </div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span><span class="keyword">namespace </span><a class="code hl_namespace" href="namespaceripple.html">ripple</a> {</div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span> </div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span><span class="keyword">namespace </span>reduce_relay {</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span> </div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> clock_type&gt;</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html"> 38</a></span><span class="keyword">class </span><a class="code hl_class" href="classripple_1_1reduce__relay_1_1Squelch.html">Squelch</a></div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span>{</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#a0ecfb21882093e86e4d4373250bec31b"> 40</a></span> <span class="keyword">using </span><a class="code hl_typedef" href="classripple_1_1reduce__relay_1_1Squelch.html#a0ecfb21882093e86e4d4373250bec31b">time_point</a> = <span class="keyword">typename</span> clock_type::time_point;</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> </div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span><span class="keyword">public</span>:</div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#af3ed37ca1b22b743b8aa41589a5123aa"> 43</a></span> <span class="keyword">explicit</span> <a class="code hl_function" href="classripple_1_1reduce__relay_1_1Squelch.html#af3ed37ca1b22b743b8aa41589a5123aa">Squelch</a>(<a class="code hl_class" href="classbeast_1_1Journal.html">beast::Journal</a> journal) : <a class="code hl_variable" href="classripple_1_1reduce__relay_1_1Squelch.html#a462728e9156c1189cbeae172cad917f2">journal_</a>(journal)</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"> 44</span> {</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span> }</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#a61e701b522c4a98c742f18e594a549f8"> 46</a></span> <span class="keyword">virtual</span> <a class="code hl_function" href="classripple_1_1reduce__relay_1_1Squelch.html#a61e701b522c4a98c742f18e594a549f8">~Squelch</a>() = <span class="keywordflow">default</span>;</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> </div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> <span class="keywordtype">bool</span></div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#a8797f435b1f3aeb44c5ad48e4ce3a353"> 54</a></span> <a class="code hl_function" href="classripple_1_1reduce__relay_1_1Squelch.html#a8797f435b1f3aeb44c5ad48e4ce3a353">addSquelch</a>(</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> <a class="code hl_class" href="classripple_1_1PublicKey.html">PublicKey</a> <span class="keyword">const</span>&amp; validator,</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/chrono/duration.html">std::chrono::seconds</a> <span class="keyword">const</span>&amp; squelchDuration);</div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> </div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> <span class="keywordtype">void</span></div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#ac1aefed79a18955197f5d7e8eaba7adc"> 62</a></span> <a class="code hl_function" href="classripple_1_1reduce__relay_1_1Squelch.html#ac1aefed79a18955197f5d7e8eaba7adc">removeSquelch</a>(<a class="code hl_class" href="classripple_1_1PublicKey.html">PublicKey</a> <span class="keyword">const</span>&amp; validator);</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> </div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> <span class="keywordtype">bool</span></div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#abdb06bd66661220922e647ad49ae4647"> 69</a></span> <a class="code hl_function" href="classripple_1_1reduce__relay_1_1Squelch.html#abdb06bd66661220922e647ad49ae4647">expireSquelch</a>(<a class="code hl_class" href="classripple_1_1PublicKey.html">PublicKey</a> <span class="keyword">const</span>&amp; validator);</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> </div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span><span class="keyword">private</span>:</div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#a5324a3cf61df6c46a7c6fd978aa517cc"> 74</a></span> <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/container/unordered_map.html">hash_map&lt;PublicKey, time_point&gt;</a> <a class="code hl_variable" href="classripple_1_1reduce__relay_1_1Squelch.html#a5324a3cf61df6c46a7c6fd978aa517cc">squelched_</a>;</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#a462728e9156c1189cbeae172cad917f2"> 75</a></span> <a class="code hl_class" href="classbeast_1_1Journal.html">beast::Journal</a> <span class="keyword">const</span> <a class="code hl_variable" href="classripple_1_1reduce__relay_1_1Squelch.html#a462728e9156c1189cbeae172cad917f2">journal_</a>;</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span>};</div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> </div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> clock_type&gt;</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span><span class="keywordtype">bool</span></div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#a8797f435b1f3aeb44c5ad48e4ce3a353"> 80</a></span><a class="code hl_function" href="classripple_1_1reduce__relay_1_1Squelch.html#a8797f435b1f3aeb44c5ad48e4ce3a353">Squelch&lt;clock_type&gt;::addSquelch</a>(</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> <a class="code hl_class" href="classripple_1_1PublicKey.html">PublicKey</a> <span class="keyword">const</span>&amp; validator,</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span> <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/chrono/duration.html">std::chrono::seconds</a> <span class="keyword">const</span>&amp; squelchDuration)</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span>{</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> <span class="keywordflow">if</span> (squelchDuration &gt;= <a class="code hl_variable" href="namespaceripple_1_1reduce__relay.html#a97d9582e500aeeec2dc554a14bcf9af0">MIN_UNSQUELCH_EXPIRE</a> &amp;&amp;</div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"> 85</span> squelchDuration &lt;= <a class="code hl_variable" href="namespaceripple_1_1reduce__relay.html#af6a298ebd3177be1776cf9be3e15db14">MAX_UNSQUELCH_EXPIRE_PEERS</a>)</div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"> 86</span> {</div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span> squelched_[validator] = clock_type::now() + squelchDuration;</div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"> 88</span> <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno"> 89</span> }</div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno"> 90</span> </div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno"> 91</span> JLOG(journal_.error()) &lt;&lt; <span class="stringliteral">&quot;squelch: invalid squelch duration &quot;</span></div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"> 92</span> &lt;&lt; squelchDuration.<a class="code hl_functionRef" href="http://en.cppreference.com/w/cpp/chrono/duration/count.html">count</a>();</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno"> 93</span> </div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno"> 94</span> <span class="comment">// unsquelch if invalid duration</span></div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"> 95</span> removeSquelch(validator);</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> </div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"> 97</span> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno"> 98</span>}</div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno"> 99</span> </div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> clock_type&gt;</div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"> 101</span><span class="keywordtype">void</span></div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#ac1aefed79a18955197f5d7e8eaba7adc"> 102</a></span><a class="code hl_function" href="classripple_1_1reduce__relay_1_1Squelch.html#ac1aefed79a18955197f5d7e8eaba7adc">Squelch&lt;clock_type&gt;::removeSquelch</a>(<a class="code hl_class" href="classripple_1_1PublicKey.html">PublicKey</a> <span class="keyword">const</span>&amp; validator)</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span>{</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno"> 104</span> squelched_.erase(validator);</div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno"> 105</span>}</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span> </div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> clock_type&gt;</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span><span class="keywordtype">bool</span></div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#abdb06bd66661220922e647ad49ae4647"> 109</a></span><a class="code hl_function" href="classripple_1_1reduce__relay_1_1Squelch.html#abdb06bd66661220922e647ad49ae4647">Squelch&lt;clock_type&gt;::expireSquelch</a>(<a class="code hl_class" href="classripple_1_1PublicKey.html">PublicKey</a> <span class="keyword">const</span>&amp; validator)</div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno"> 110</span>{</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span> <span class="keyword">auto</span> now = clock_type::now();</div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> </div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span> <span class="keyword">auto</span> <span class="keyword">const</span>&amp; it = squelched_.find(validator);</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span> <span class="keywordflow">if</span> (it == squelched_.end())</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (it-&gt;second &gt; now)</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</span> </div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"> 119</span> <span class="comment">// squelch expired</span></div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span> squelched_.erase(it);</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span> </div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno"> 122</span> <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"> 123</span>}</div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span> </div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"> 125</span>} <span class="comment">// namespace reduce_relay</span></div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span> </div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span>} <span class="comment">// namespace ripple</span></div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span> </div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span><span class="preprocessor">#endif </span><span class="comment">// RIPPLED_SQUELCH_H</span></div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span><span class="preprocessor">#include &lt;xrpl/beast/utility/Journal.h&gt;</span></div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"> 25</span><span class="preprocessor">#include &lt;xrpl/protocol/PublicKey.h&gt;</span></div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"> 26</span> </div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"> 27</span><span class="preprocessor">#include &lt;<a class="codeRef" href="http://en.cppreference.com/w/cpp/header/algorithm.html">algorithm</a>&gt;</span></div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"> 28</span><span class="preprocessor">#include &lt;<a class="codeRef" href="http://en.cppreference.com/w/cpp/header/chrono.html">chrono</a>&gt;</span></div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span><span class="preprocessor">#include &lt;<a class="codeRef" href="http://en.cppreference.com/w/cpp/header/functional.html">functional</a>&gt;</span></div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span> </div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span><span class="keyword">namespace </span><a class="code hl_namespace" href="namespaceripple.html">ripple</a> {</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> </div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span><span class="keyword">namespace </span>reduce_relay {</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span> </div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> clock_type&gt;</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html"> 37</a></span><span class="keyword">class </span><a class="code hl_class" href="classripple_1_1reduce__relay_1_1Squelch.html">Squelch</a></div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span>{</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#a0ecfb21882093e86e4d4373250bec31b"> 39</a></span> <span class="keyword">using </span><a class="code hl_typedef" href="classripple_1_1reduce__relay_1_1Squelch.html#a0ecfb21882093e86e4d4373250bec31b">time_point</a> = <span class="keyword">typename</span> clock_type::time_point;</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span> </div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span><span class="keyword">public</span>:</div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#af3ed37ca1b22b743b8aa41589a5123aa"> 42</a></span> <span class="keyword">explicit</span> <a class="code hl_function" href="classripple_1_1reduce__relay_1_1Squelch.html#af3ed37ca1b22b743b8aa41589a5123aa">Squelch</a>(<a class="code hl_class" href="classbeast_1_1Journal.html">beast::Journal</a> journal) : <a class="code hl_variable" href="classripple_1_1reduce__relay_1_1Squelch.html#a462728e9156c1189cbeae172cad917f2">journal_</a>(journal)</div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span> {</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"> 44</span> }</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#a61e701b522c4a98c742f18e594a549f8"> 45</a></span> <span class="keyword">virtual</span> <a class="code hl_function" href="classripple_1_1reduce__relay_1_1Squelch.html#a61e701b522c4a98c742f18e594a549f8">~Squelch</a>() = <span class="keywordflow">default</span>;</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"> 46</span> </div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> <span class="keywordtype">bool</span></div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#a8797f435b1f3aeb44c5ad48e4ce3a353"> 53</a></span> <a class="code hl_function" href="classripple_1_1reduce__relay_1_1Squelch.html#a8797f435b1f3aeb44c5ad48e4ce3a353">addSquelch</a>(</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span> <a class="code hl_class" href="classripple_1_1PublicKey.html">PublicKey</a> <span class="keyword">const</span>&amp; validator,</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/chrono/duration.html">std::chrono::seconds</a> <span class="keyword">const</span>&amp; squelchDuration);</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> </div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> <span class="keywordtype">void</span></div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#ac1aefed79a18955197f5d7e8eaba7adc"> 61</a></span> <a class="code hl_function" href="classripple_1_1reduce__relay_1_1Squelch.html#ac1aefed79a18955197f5d7e8eaba7adc">removeSquelch</a>(<a class="code hl_class" href="classripple_1_1PublicKey.html">PublicKey</a> <span class="keyword">const</span>&amp; validator);</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> </div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> <span class="keywordtype">bool</span></div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#abdb06bd66661220922e647ad49ae4647"> 68</a></span> <a class="code hl_function" href="classripple_1_1reduce__relay_1_1Squelch.html#abdb06bd66661220922e647ad49ae4647">expireSquelch</a>(<a class="code hl_class" href="classripple_1_1PublicKey.html">PublicKey</a> <span class="keyword">const</span>&amp; validator);</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> </div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span><span class="keyword">private</span>:</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#a5324a3cf61df6c46a7c6fd978aa517cc"> 73</a></span> <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/container/unordered_map.html">hash_map&lt;PublicKey, time_point&gt;</a> <a class="code hl_variable" href="classripple_1_1reduce__relay_1_1Squelch.html#a5324a3cf61df6c46a7c6fd978aa517cc">squelched_</a>;</div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#a462728e9156c1189cbeae172cad917f2"> 74</a></span> <a class="code hl_class" href="classbeast_1_1Journal.html">beast::Journal</a> <span class="keyword">const</span> <a class="code hl_variable" href="classripple_1_1reduce__relay_1_1Squelch.html#a462728e9156c1189cbeae172cad917f2">journal_</a>;</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span>};</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> </div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> clock_type&gt;</div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span><span class="keywordtype">bool</span></div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#a8797f435b1f3aeb44c5ad48e4ce3a353"> 79</a></span><a class="code hl_function" href="classripple_1_1reduce__relay_1_1Squelch.html#a8797f435b1f3aeb44c5ad48e4ce3a353">Squelch&lt;clock_type&gt;::addSquelch</a>(</div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> <a class="code hl_class" href="classripple_1_1PublicKey.html">PublicKey</a> <span class="keyword">const</span>&amp; validator,</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/chrono/duration.html">std::chrono::seconds</a> <span class="keyword">const</span>&amp; squelchDuration)</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span>{</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span> <span class="keywordflow">if</span> (squelchDuration &gt;= <a class="code hl_variable" href="namespaceripple_1_1reduce__relay.html#a97d9582e500aeeec2dc554a14bcf9af0">MIN_UNSQUELCH_EXPIRE</a> &amp;&amp;</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> squelchDuration &lt;= <a class="code hl_variable" href="namespaceripple_1_1reduce__relay.html#af6a298ebd3177be1776cf9be3e15db14">MAX_UNSQUELCH_EXPIRE_PEERS</a>)</div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"> 85</span> {</div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"> 86</span> squelched_[validator] = clock_type::now() + squelchDuration;</div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span> <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"> 88</span> }</div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno"> 89</span> </div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno"> 90</span> JLOG(journal_.error()) &lt;&lt; <span class="stringliteral">&quot;squelch: invalid squelch duration &quot;</span></div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno"> 91</span> &lt;&lt; squelchDuration.<a class="code hl_functionRef" href="http://en.cppreference.com/w/cpp/chrono/duration/count.html">count</a>();</div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"> 92</span> </div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno"> 93</span> <span class="comment">// unsquelch if invalid duration</span></div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno"> 94</span> removeSquelch(validator);</div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"> 95</span> </div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"> 97</span>}</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno"> 98</span> </div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno"> 99</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> clock_type&gt;</div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span><span class="keywordtype">void</span></div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#ac1aefed79a18955197f5d7e8eaba7adc"> 101</a></span><a class="code hl_function" href="classripple_1_1reduce__relay_1_1Squelch.html#ac1aefed79a18955197f5d7e8eaba7adc">Squelch&lt;clock_type&gt;::removeSquelch</a>(<a class="code hl_class" href="classripple_1_1PublicKey.html">PublicKey</a> <span class="keyword">const</span>&amp; validator)</div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"> 102</span>{</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span> squelched_.erase(validator);</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno"> 104</span>}</div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno"> 105</span> </div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> clock_type&gt;</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span><span class="keywordtype">bool</span></div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"><a class="line" href="classripple_1_1reduce__relay_1_1Squelch.html#abdb06bd66661220922e647ad49ae4647"> 108</a></span><a class="code hl_function" href="classripple_1_1reduce__relay_1_1Squelch.html#abdb06bd66661220922e647ad49ae4647">Squelch&lt;clock_type&gt;::expireSquelch</a>(<a class="code hl_class" href="classripple_1_1PublicKey.html">PublicKey</a> <span class="keyword">const</span>&amp; validator)</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span>{</div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno"> 110</span> <span class="keyword">auto</span> now = clock_type::now();</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span> </div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> <span class="keyword">auto</span> <span class="keyword">const</span>&amp; it = squelched_.find(validator);</div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span> <span class="keywordflow">if</span> (it == squelched_.end())</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span> <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (it-&gt;second &gt; now)</div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span> </div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</span> <span class="comment">// squelch expired</span></div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"> 119</span> squelched_.erase(it);</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span> </div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span> <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno"> 122</span>}</div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"> 123</span> </div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span>} <span class="comment">// namespace reduce_relay</span></div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"> 125</span> </div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span>} <span class="comment">// namespace ripple</span></div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span> </div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span><span class="preprocessor">#endif </span><span class="comment">// RIPPLED_SQUELCH_H</span></div>
<div class="ttc" id="aalgorithm_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/header/algorithm.html">algorithm</a></div></div>
<div class="ttc" id="achrono_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/header/chrono.html">chrono</a></div></div>
<div class="ttc" id="aclassbeast_1_1Journal_html"><div class="ttname"><a href="classbeast_1_1Journal.html">beast::Journal</a></div><div class="ttdoc">A generic endpoint for log messages.</div><div class="ttdef"><b>Definition:</b> <a href="Journal_8h_source.html#l00058">Journal.h:59</a></div></div>
<div class="ttc" id="aclassbeast_1_1Journal_html"><div class="ttname"><a href="classbeast_1_1Journal.html">beast::Journal</a></div><div class="ttdoc">A generic endpoint for log messages.</div><div class="ttdef"><b>Definition:</b> <a href="Journal_8h_source.html#l00059">Journal.h:60</a></div></div>
<div class="ttc" id="aclassripple_1_1PublicKey_html"><div class="ttname"><a href="classripple_1_1PublicKey.html">ripple::PublicKey</a></div><div class="ttdoc">A public key.</div><div class="ttdef"><b>Definition:</b> <a href="PublicKey_8h_source.html#l00061">PublicKey.h:62</a></div></div>
<div class="ttc" id="aclassripple_1_1reduce__relay_1_1Squelch_html"><div class="ttname"><a href="classripple_1_1reduce__relay_1_1Squelch.html">ripple::reduce_relay::Squelch</a></div><div class="ttdoc">Maintains squelching of relaying messages from validators.</div><div class="ttdef"><b>Definition:</b> <a href="Squelch_8h_source.html#l00038">Squelch.h:39</a></div></div>
<div class="ttc" id="aclassripple_1_1reduce__relay_1_1Squelch_html_a0ecfb21882093e86e4d4373250bec31b"><div class="ttname"><a href="classripple_1_1reduce__relay_1_1Squelch.html#a0ecfb21882093e86e4d4373250bec31b">ripple::reduce_relay::Squelch::time_point</a></div><div class="ttdeci">typename clock_type::time_point time_point</div><div class="ttdef"><b>Definition:</b> <a href="Squelch_8h_source.html#l00040">Squelch.h:40</a></div></div>
<div class="ttc" id="aclassripple_1_1reduce__relay_1_1Squelch_html_a462728e9156c1189cbeae172cad917f2"><div class="ttname"><a href="classripple_1_1reduce__relay_1_1Squelch.html#a462728e9156c1189cbeae172cad917f2">ripple::reduce_relay::Squelch::journal_</a></div><div class="ttdeci">beast::Journal const journal_</div><div class="ttdef"><b>Definition:</b> <a href="Squelch_8h_source.html#l00075">Squelch.h:75</a></div></div>
<div class="ttc" id="aclassripple_1_1reduce__relay_1_1Squelch_html_a5324a3cf61df6c46a7c6fd978aa517cc"><div class="ttname"><a href="classripple_1_1reduce__relay_1_1Squelch.html#a5324a3cf61df6c46a7c6fd978aa517cc">ripple::reduce_relay::Squelch::squelched_</a></div><div class="ttdeci">hash_map&lt; PublicKey, time_point &gt; squelched_</div><div class="ttdoc">Maintains the list of squelched relaying to downstream peers.</div><div class="ttdef"><b>Definition:</b> <a href="Squelch_8h_source.html#l00074">Squelch.h:74</a></div></div>
<div class="ttc" id="aclassripple_1_1reduce__relay_1_1Squelch_html"><div class="ttname"><a href="classripple_1_1reduce__relay_1_1Squelch.html">ripple::reduce_relay::Squelch</a></div><div class="ttdoc">Maintains squelching of relaying messages from validators.</div><div class="ttdef"><b>Definition:</b> <a href="Squelch_8h_source.html#l00037">Squelch.h:38</a></div></div>
<div class="ttc" id="aclassripple_1_1reduce__relay_1_1Squelch_html_a0ecfb21882093e86e4d4373250bec31b"><div class="ttname"><a href="classripple_1_1reduce__relay_1_1Squelch.html#a0ecfb21882093e86e4d4373250bec31b">ripple::reduce_relay::Squelch::time_point</a></div><div class="ttdeci">typename clock_type::time_point time_point</div><div class="ttdef"><b>Definition:</b> <a href="Squelch_8h_source.html#l00039">Squelch.h:39</a></div></div>
<div class="ttc" id="aclassripple_1_1reduce__relay_1_1Squelch_html_a462728e9156c1189cbeae172cad917f2"><div class="ttname"><a href="classripple_1_1reduce__relay_1_1Squelch.html#a462728e9156c1189cbeae172cad917f2">ripple::reduce_relay::Squelch::journal_</a></div><div class="ttdeci">beast::Journal const journal_</div><div class="ttdef"><b>Definition:</b> <a href="Squelch_8h_source.html#l00074">Squelch.h:74</a></div></div>
<div class="ttc" id="aclassripple_1_1reduce__relay_1_1Squelch_html_a5324a3cf61df6c46a7c6fd978aa517cc"><div class="ttname"><a href="classripple_1_1reduce__relay_1_1Squelch.html#a5324a3cf61df6c46a7c6fd978aa517cc">ripple::reduce_relay::Squelch::squelched_</a></div><div class="ttdeci">hash_map&lt; PublicKey, time_point &gt; squelched_</div><div class="ttdoc">Maintains the list of squelched relaying to downstream peers.</div><div class="ttdef"><b>Definition:</b> <a href="Squelch_8h_source.html#l00073">Squelch.h:73</a></div></div>
<div class="ttc" id="aclassripple_1_1reduce__relay_1_1Squelch_html_a61e701b522c4a98c742f18e594a549f8"><div class="ttname"><a href="classripple_1_1reduce__relay_1_1Squelch.html#a61e701b522c4a98c742f18e594a549f8">ripple::reduce_relay::Squelch::~Squelch</a></div><div class="ttdeci">virtual ~Squelch()=default</div></div>
<div class="ttc" id="aclassripple_1_1reduce__relay_1_1Squelch_html_a8797f435b1f3aeb44c5ad48e4ce3a353"><div class="ttname"><a href="classripple_1_1reduce__relay_1_1Squelch.html#a8797f435b1f3aeb44c5ad48e4ce3a353">ripple::reduce_relay::Squelch::addSquelch</a></div><div class="ttdeci">bool addSquelch(PublicKey const &amp;validator, std::chrono::seconds const &amp;squelchDuration)</div><div class="ttdoc">Squelch validation/proposal relaying for the validator.</div><div class="ttdef"><b>Definition:</b> <a href="Squelch_8h_source.html#l00080">Squelch.h:80</a></div></div>
<div class="ttc" id="aclassripple_1_1reduce__relay_1_1Squelch_html_abdb06bd66661220922e647ad49ae4647"><div class="ttname"><a href="classripple_1_1reduce__relay_1_1Squelch.html#abdb06bd66661220922e647ad49ae4647">ripple::reduce_relay::Squelch::expireSquelch</a></div><div class="ttdeci">bool expireSquelch(PublicKey const &amp;validator)</div><div class="ttdoc">Remove expired squelch.</div><div class="ttdef"><b>Definition:</b> <a href="Squelch_8h_source.html#l00109">Squelch.h:109</a></div></div>
<div class="ttc" id="aclassripple_1_1reduce__relay_1_1Squelch_html_ac1aefed79a18955197f5d7e8eaba7adc"><div class="ttname"><a href="classripple_1_1reduce__relay_1_1Squelch.html#ac1aefed79a18955197f5d7e8eaba7adc">ripple::reduce_relay::Squelch::removeSquelch</a></div><div class="ttdeci">void removeSquelch(PublicKey const &amp;validator)</div><div class="ttdoc">Remove the squelch.</div><div class="ttdef"><b>Definition:</b> <a href="Squelch_8h_source.html#l00102">Squelch.h:102</a></div></div>
<div class="ttc" id="aclassripple_1_1reduce__relay_1_1Squelch_html_af3ed37ca1b22b743b8aa41589a5123aa"><div class="ttname"><a href="classripple_1_1reduce__relay_1_1Squelch.html#af3ed37ca1b22b743b8aa41589a5123aa">ripple::reduce_relay::Squelch::Squelch</a></div><div class="ttdeci">Squelch(beast::Journal journal)</div><div class="ttdef"><b>Definition:</b> <a href="Squelch_8h_source.html#l00043">Squelch.h:43</a></div></div>
<div class="ttc" id="aclassripple_1_1reduce__relay_1_1Squelch_html_a8797f435b1f3aeb44c5ad48e4ce3a353"><div class="ttname"><a href="classripple_1_1reduce__relay_1_1Squelch.html#a8797f435b1f3aeb44c5ad48e4ce3a353">ripple::reduce_relay::Squelch::addSquelch</a></div><div class="ttdeci">bool addSquelch(PublicKey const &amp;validator, std::chrono::seconds const &amp;squelchDuration)</div><div class="ttdoc">Squelch validation/proposal relaying for the validator.</div><div class="ttdef"><b>Definition:</b> <a href="Squelch_8h_source.html#l00079">Squelch.h:79</a></div></div>
<div class="ttc" id="aclassripple_1_1reduce__relay_1_1Squelch_html_abdb06bd66661220922e647ad49ae4647"><div class="ttname"><a href="classripple_1_1reduce__relay_1_1Squelch.html#abdb06bd66661220922e647ad49ae4647">ripple::reduce_relay::Squelch::expireSquelch</a></div><div class="ttdeci">bool expireSquelch(PublicKey const &amp;validator)</div><div class="ttdoc">Remove expired squelch.</div><div class="ttdef"><b>Definition:</b> <a href="Squelch_8h_source.html#l00108">Squelch.h:108</a></div></div>
<div class="ttc" id="aclassripple_1_1reduce__relay_1_1Squelch_html_ac1aefed79a18955197f5d7e8eaba7adc"><div class="ttname"><a href="classripple_1_1reduce__relay_1_1Squelch.html#ac1aefed79a18955197f5d7e8eaba7adc">ripple::reduce_relay::Squelch::removeSquelch</a></div><div class="ttdeci">void removeSquelch(PublicKey const &amp;validator)</div><div class="ttdoc">Remove the squelch.</div><div class="ttdef"><b>Definition:</b> <a href="Squelch_8h_source.html#l00101">Squelch.h:101</a></div></div>
<div class="ttc" id="aclassripple_1_1reduce__relay_1_1Squelch_html_af3ed37ca1b22b743b8aa41589a5123aa"><div class="ttname"><a href="classripple_1_1reduce__relay_1_1Squelch.html#af3ed37ca1b22b743b8aa41589a5123aa">ripple::reduce_relay::Squelch::Squelch</a></div><div class="ttdeci">Squelch(beast::Journal journal)</div><div class="ttdef"><b>Definition:</b> <a href="Squelch_8h_source.html#l00042">Squelch.h:42</a></div></div>
<div class="ttc" id="acount_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/chrono/duration/count.html">std::chrono::seconds::count</a></div><div class="ttdeci">T count(T... args)</div></div>
<div class="ttc" id="aduration_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/chrono/duration.html">std::chrono::seconds</a></div></div>
<div class="ttc" id="afunctional_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/header/functional.html">functional</a></div></div>