Files
rippled/SlotImp_8cpp_source.html
2026-01-28 10:13:01 -08:00

258 lines
36 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>rippled: SlotImp.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">rippled
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.8 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function() { init_codefold(0); });
/* @license-end */
</script>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_a62226f9e3a6c7c5a3be455e2f87ae01.html">xrpld</a></li><li class="navelem"><a class="el" href="dir_89046728185f0c274a4164d3e2cb38fb.html">peerfinder</a></li><li class="navelem"><a class="el" href="dir_e9607b4c59cebecf2224e361d8d6d362.html">detail</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">SlotImp.cpp</div></div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span><span class="preprocessor">#include &lt;xrpld/peerfinder/PeerfinderManager.h&gt;</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno"> 2</span><span class="preprocessor">#include &lt;xrpld/peerfinder/detail/SlotImp.h&gt;</span></div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno"> 3</span><span class="preprocessor">#include &lt;xrpld/peerfinder/detail/Tuning.h&gt;</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno"> 4</span> </div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno"> 5</span><span class="keyword">namespace </span><a class="code hl_namespace" href="namespacexrpl.html">xrpl</a> {</div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno"> 6</span><span class="keyword">namespace </span>PeerFinder {</div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno"> 7</span> </div>
<div class="foldopen" id="foldopen00008" data-start="{" data-end="}">
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno"><a class="line" href="classxrpl_1_1PeerFinder_1_1SlotImp.html#a911314c986fefd60d999e9031e5105cc"> 8</a></span><a class="code hl_function" href="classxrpl_1_1PeerFinder_1_1SlotImp.html#a911314c986fefd60d999e9031e5105cc">SlotImp::SlotImp</a>(</div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno"> 9</span> <a class="code hl_class" href="classbeast_1_1IP_1_1Endpoint.html">beast::IP::Endpoint</a> <span class="keyword">const</span>&amp; local_endpoint,</div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno"> 10</span> <a class="code hl_class" href="classbeast_1_1IP_1_1Endpoint.html">beast::IP::Endpoint</a> <span class="keyword">const</span>&amp; remote_endpoint,</div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span> <span class="keywordtype">bool</span> <a class="code hl_function" href="namespacexrpl.html#a5fef07ca1fcf5dfaac42cd492a3c8969">fixed</a>,</div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span> <a class="code hl_class" href="classbeast_1_1abstract__clock.html">clock_type</a>&amp; clock)</div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno"> 13</span> : recent(clock)</div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"> 14</span> , m_inbound(true)</div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"> 15</span> , m_fixed(<a class="code hl_function" href="namespacexrpl.html#a5fef07ca1fcf5dfaac42cd492a3c8969">fixed</a>)</div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno"> 16</span> , m_reserved(false)</div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"> 17</span> , m_state(accept)</div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno"> 18</span> , m_remote_endpoint(remote_endpoint)</div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"> 19</span> , m_local_endpoint(local_endpoint)</div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span> , m_listening_port(unknownPort)</div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span> , checked(false)</div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span> , canAccept(false)</div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"> 23</span> , connectivityCheckInProgress(false)</div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span>{</div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"> 25</span>}</div>
</div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"> 26</span> </div>
<div class="foldopen" id="foldopen00027" data-start="{" data-end="}">
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"><a class="line" href="classxrpl_1_1PeerFinder_1_1SlotImp.html#ae07f602bb450c3c39e140bbe5e00ae81"> 27</a></span><a class="code hl_function" href="classxrpl_1_1PeerFinder_1_1SlotImp.html#a911314c986fefd60d999e9031e5105cc">SlotImp::SlotImp</a>(<a class="code hl_class" href="classbeast_1_1IP_1_1Endpoint.html">beast::IP::Endpoint</a> <span class="keyword">const</span>&amp; remote_endpoint, <span class="keywordtype">bool</span> <a class="code hl_function" href="namespacexrpl.html#a5fef07ca1fcf5dfaac42cd492a3c8969">fixed</a>, <a class="code hl_class" href="classbeast_1_1abstract__clock.html">clock_type</a>&amp; clock)</div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"> 28</span> : recent(clock)</div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span> , m_inbound(false)</div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span> , m_fixed(<a class="code hl_function" href="namespacexrpl.html#a5fef07ca1fcf5dfaac42cd492a3c8969">fixed</a>)</div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span> , m_reserved(false)</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> , m_state(connect)</div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span> , m_remote_endpoint(remote_endpoint)</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span> , m_listening_port(unknownPort)</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span> , checked(true)</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span> , canAccept(true)</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span> , connectivityCheckInProgress(false)</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"> 39</span>}</div>
</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="keywordtype">void</span></div>
<div class="foldopen" id="foldopen00042" data-start="{" data-end="}">
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"><a class="line" href="classxrpl_1_1PeerFinder_1_1SlotImp.html#a8c50ec31eca9d879fd9c4e48927a1775"> 42</a></span><a class="code hl_function" href="classxrpl_1_1PeerFinder_1_1SlotImp.html#a948dd075c496ead0821dd8b0493c7c2b">SlotImp::state</a>(<a class="code hl_enumeration" href="classxrpl_1_1PeerFinder_1_1Slot.html#a9f7f74456679552f34bba92f853b8132">State</a> state_)</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> <span class="comment">// Must go through activate() to set active state</span></div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span> XRPL_ASSERT(state_ != <a class="code hl_enumvalue" href="classxrpl_1_1PeerFinder_1_1Slot.html#a9f7f74456679552f34bba92f853b8132a94a1335e1416fcf0b7532c7bc7282e5e">active</a>, <span class="stringliteral">&quot;xrpl::PeerFinder::SlotImp::state : input state is not active&quot;</span>);</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"> 46</span> </div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> <span class="comment">// The state must be different</span></div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span> XRPL_ASSERT(</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> state_ != <a class="code hl_variable" href="classxrpl_1_1PeerFinder_1_1SlotImp.html#a27e1b518649e194e4017e8b92d63f870">m_state</a>,</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span> <span class="stringliteral">&quot;xrpl::PeerFinder::SlotImp::state : input state is different from &quot;</span></div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> <span class="stringliteral">&quot;current&quot;</span>);</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> </div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> <span class="comment">// You can&#39;t transition into the initial states</span></div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span> XRPL_ASSERT(</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> state_ != <a class="code hl_enumvalue" href="classxrpl_1_1PeerFinder_1_1Slot.html#a9f7f74456679552f34bba92f853b8132aaf593c8e49119e179957b9ff11b1053f">accept</a> &amp;&amp; state_ != <a class="code hl_enumvalue" href="classxrpl_1_1PeerFinder_1_1Slot.html#a9f7f74456679552f34bba92f853b8132a3b50c2305a01b45dd01951ad48bc2927">connect</a>, <span class="stringliteral">&quot;xrpl::PeerFinder::SlotImp::state : input state is not an initial&quot;</span>);</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> </div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> <span class="comment">// Can only become connected from outbound connect state</span></div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span> XRPL_ASSERT(</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> state_ != <a class="code hl_enumvalue" href="classxrpl_1_1PeerFinder_1_1Slot.html#a9f7f74456679552f34bba92f853b8132a253b58ea1b8331268fa056d1915fceb8">connected</a> || (!<a class="code hl_variable" href="classxrpl_1_1PeerFinder_1_1SlotImp.html#a1ef915e97ebc8f2cf99c5c869435640b">m_inbound</a> &amp;&amp; <a class="code hl_variable" href="classxrpl_1_1PeerFinder_1_1SlotImp.html#a27e1b518649e194e4017e8b92d63f870">m_state</a> == <a class="code hl_enumvalue" href="classxrpl_1_1PeerFinder_1_1Slot.html#a9f7f74456679552f34bba92f853b8132a3b50c2305a01b45dd01951ad48bc2927">connect</a>),</div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> <span class="stringliteral">&quot;xrpl::PeerFinder::SlotImp::state : input state is not connected an &quot;</span></div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> <span class="stringliteral">&quot;invalid state&quot;</span>);</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> </div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> <span class="comment">// Can&#39;t gracefully close on an outbound connection attempt</span></div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> XRPL_ASSERT(</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span> state_ != <a class="code hl_enumvalue" href="classxrpl_1_1PeerFinder_1_1Slot.html#a9f7f74456679552f34bba92f853b8132a86f6130f88e9406cff9c44276bcc91ff">closing</a> || <a class="code hl_variable" href="classxrpl_1_1PeerFinder_1_1SlotImp.html#a27e1b518649e194e4017e8b92d63f870">m_state</a> != <a class="code hl_enumvalue" href="classxrpl_1_1PeerFinder_1_1Slot.html#a9f7f74456679552f34bba92f853b8132a3b50c2305a01b45dd01951ad48bc2927">connect</a>,</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> <span class="stringliteral">&quot;xrpl::PeerFinder::SlotImp::state : input state is not closing an &quot;</span></div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> <span class="stringliteral">&quot;invalid state&quot;</span>);</div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> </div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> <a class="code hl_variable" href="classxrpl_1_1PeerFinder_1_1SlotImp.html#a27e1b518649e194e4017e8b92d63f870">m_state</a> = state_;</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span>}</div>
</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> </div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span><span class="keywordtype">void</span></div>
<div class="foldopen" id="foldopen00073" data-start="{" data-end="}">
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"><a class="line" href="classxrpl_1_1PeerFinder_1_1SlotImp.html#af7788f27378dfd8943dc9a99f9206ecf"> 73</a></span><a class="code hl_function" href="classxrpl_1_1PeerFinder_1_1SlotImp.html#af7788f27378dfd8943dc9a99f9206ecf">SlotImp::activate</a>(<a class="code hl_typedef" href="classbeast_1_1abstract__clock.html#a4e16832b0bdf9392c5138bbbde024d8e">clock_type::time_point</a> <span class="keyword">const</span>&amp; now)</div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span>{</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> <span class="comment">// Can only become active from the accept or connected state</span></div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> XRPL_ASSERT(<a class="code hl_variable" href="classxrpl_1_1PeerFinder_1_1SlotImp.html#a27e1b518649e194e4017e8b92d63f870">m_state</a> == <a class="code hl_enumvalue" href="classxrpl_1_1PeerFinder_1_1Slot.html#a9f7f74456679552f34bba92f853b8132aaf593c8e49119e179957b9ff11b1053f">accept</a> || <a class="code hl_variable" href="classxrpl_1_1PeerFinder_1_1SlotImp.html#a27e1b518649e194e4017e8b92d63f870">m_state</a> == <a class="code hl_enumvalue" href="classxrpl_1_1PeerFinder_1_1Slot.html#a9f7f74456679552f34bba92f853b8132a253b58ea1b8331268fa056d1915fceb8">connected</a>, <span class="stringliteral">&quot;xrpl::PeerFinder::SlotImp::activate : valid state&quot;</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> <a class="code hl_variable" href="classxrpl_1_1PeerFinder_1_1SlotImp.html#a27e1b518649e194e4017e8b92d63f870">m_state</a> = <a class="code hl_enumvalue" href="classxrpl_1_1PeerFinder_1_1Slot.html#a9f7f74456679552f34bba92f853b8132a94a1335e1416fcf0b7532c7bc7282e5e">active</a>;</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span> <a class="code hl_variable" href="classxrpl_1_1PeerFinder_1_1SlotImp.html#aa2cb51f94ac96161d288824c921dcbb6">whenAcceptEndpoints</a> = now;</div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span>}</div>
</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> </div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span><span class="comment">//------------------------------------------------------------------------------</span></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><a class="code hl_function" href="classxrpl_1_1PeerFinder_1_1Slot.html#aeec556253d943a10b57973ccc9e6e4b2">Slot::~Slot</a>() = <span class="keywordflow">default</span>;</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><span class="comment">//------------------------------------------------------------------------------</span></div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span> </div>
<div class="foldopen" id="foldopen00088" data-start="{" data-end="}">
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"><a class="line" href="classxrpl_1_1PeerFinder_1_1SlotImp_1_1recent__t.html#a958143f0fdbfa48b156a9d8d99f8d348"> 88</a></span><a class="code hl_function" href="classxrpl_1_1PeerFinder_1_1SlotImp_1_1recent__t.html#a958143f0fdbfa48b156a9d8d99f8d348">SlotImp::recent_t::recent_t</a>(<a class="code hl_class" href="classbeast_1_1abstract__clock.html">clock_type</a>&amp; clock) : cache(clock)</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>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno"> 91</span> </div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"> 92</span><span class="keywordtype">void</span></div>
<div class="foldopen" id="foldopen00093" data-start="{" data-end="}">
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno"><a class="line" href="classxrpl_1_1PeerFinder_1_1SlotImp_1_1recent__t.html#a08244d1ddc3c0fec2d011ff6d15ae379"> 93</a></span><a class="code hl_function" href="classxrpl_1_1PeerFinder_1_1SlotImp_1_1recent__t.html#a08244d1ddc3c0fec2d011ff6d15ae379">SlotImp::recent_t::insert</a>(<a class="code hl_class" href="classbeast_1_1IP_1_1Endpoint.html">beast::IP::Endpoint</a> <span class="keyword">const</span>&amp; ep, <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint32_t</a> hops)</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno"> 94</span>{</div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"> 95</span> <span class="keyword">auto</span> <span class="keyword">const</span> result(cache.emplace(ep, hops));</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> <span class="keywordflow">if</span> (!result.second)</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> <span class="comment">// NOTE Other logic depends on this &lt;= inequality.</span></div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno"> 99</span> <span class="keywordflow">if</span> (hops &lt;= result.first-&gt;second)</div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span> {</div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"> 101</span> result.first-&gt;second = hops;</div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"> 102</span> cache.touch(result.first);</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> }</div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno"> 105</span>}</div>
</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="keywordtype">bool</span></div>
<div class="foldopen" id="foldopen00108" data-start="{" data-end="}">
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"><a class="line" href="classxrpl_1_1PeerFinder_1_1SlotImp_1_1recent__t.html#aa65ecb71f04fed601ed06c1278eb7b7a"> 108</a></span><a class="code hl_function" href="classxrpl_1_1PeerFinder_1_1SlotImp_1_1recent__t.html#aa65ecb71f04fed601ed06c1278eb7b7a">SlotImp::recent_t::filter</a>(<a class="code hl_class" href="classbeast_1_1IP_1_1Endpoint.html">beast::IP::Endpoint</a> <span class="keyword">const</span>&amp; ep, <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint32_t</a> hops)</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> <span class="keyword">const</span> iter(cache.find(ep));</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span> <span class="keywordflow">if</span> (iter == cache.end())</div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span> <span class="comment">// We avoid sending an endpoint if we heard it</span></div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span> <span class="comment">// from them recently at the same or lower hop count.</span></div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> <span class="comment">// NOTE Other logic depends on this &lt;= inequality.</span></div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span> <span class="keywordflow">return</span> iter-&gt;second &lt;= hops;</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span>}</div>
</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="keywordtype">void</span></div>
<div class="foldopen" id="foldopen00120" data-start="{" data-end="}">
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"><a class="line" href="classxrpl_1_1PeerFinder_1_1SlotImp_1_1recent__t.html#a1d08d855f4dac03f567765d52b75d289"> 120</a></span><a class="code hl_function" href="classxrpl_1_1PeerFinder_1_1SlotImp_1_1recent__t.html#a1d08d855f4dac03f567765d52b75d289">SlotImp::recent_t::expire</a>()</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> <a class="code hl_function" href="namespacebeast.html#abb430a45381177561de02886079786ad">beast::expire</a>(cache, <a class="code hl_function" href="namespacexrpl_1_1PeerFinder_1_1Tuning.html#ac2519bc5a9e00d9731a7e9d41a6e6e35">Tuning::liveCacheSecondsToLive</a>);</div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"> 123</span>}</div>
</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 PeerFinder</span></div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span>} <span class="comment">// namespace xrpl</span></div>
<div class="ttc" id="aclassbeast_1_1IP_1_1Endpoint_html"><div class="ttname"><a href="classbeast_1_1IP_1_1Endpoint.html">beast::IP::Endpoint</a></div><div class="ttdoc">A version-independent IP address and port combination.</div><div class="ttdef"><b>Definition</b> <a href="IPEndpoint_8h_source.html#l00018">IPEndpoint.h:19</a></div></div>
<div class="ttc" id="aclassbeast_1_1abstract__clock_html"><div class="ttname"><a href="classbeast_1_1abstract__clock.html">beast::abstract_clock&lt; std::chrono::steady_clock &gt;</a></div></div>
<div class="ttc" id="aclassbeast_1_1abstract__clock_html_a4e16832b0bdf9392c5138bbbde024d8e"><div class="ttname"><a href="classbeast_1_1abstract__clock.html#a4e16832b0bdf9392c5138bbbde024d8e">beast::abstract_clock&lt; std::chrono::steady_clock &gt;::time_point</a></div><div class="ttdeci">typename Clock::time_point time_point</div><div class="ttdef"><b>Definition</b> <a href="abstract__clock_8h_source.html#l00041">abstract_clock.h:41</a></div></div>
<div class="ttc" id="aclassxrpl_1_1PeerFinder_1_1SlotImp_1_1recent__t_html_a08244d1ddc3c0fec2d011ff6d15ae379"><div class="ttname"><a href="classxrpl_1_1PeerFinder_1_1SlotImp_1_1recent__t.html#a08244d1ddc3c0fec2d011ff6d15ae379">xrpl::PeerFinder::SlotImp::recent_t::insert</a></div><div class="ttdeci">void insert(beast::IP::Endpoint const &amp;ep, std::uint32_t hops)</div><div class="ttdoc">Called for each valid endpoint received for a slot.</div><div class="ttdef"><b>Definition</b> <a href="SlotImp_8cpp_source.html#l00093">SlotImp.cpp:93</a></div></div>
<div class="ttc" id="aclassxrpl_1_1PeerFinder_1_1SlotImp_1_1recent__t_html_a1d08d855f4dac03f567765d52b75d289"><div class="ttname"><a href="classxrpl_1_1PeerFinder_1_1SlotImp_1_1recent__t.html#a1d08d855f4dac03f567765d52b75d289">xrpl::PeerFinder::SlotImp::recent_t::expire</a></div><div class="ttdeci">void expire()</div><div class="ttdef"><b>Definition</b> <a href="SlotImp_8cpp_source.html#l00120">SlotImp.cpp:120</a></div></div>
<div class="ttc" id="aclassxrpl_1_1PeerFinder_1_1SlotImp_1_1recent__t_html_a958143f0fdbfa48b156a9d8d99f8d348"><div class="ttname"><a href="classxrpl_1_1PeerFinder_1_1SlotImp_1_1recent__t.html#a958143f0fdbfa48b156a9d8d99f8d348">xrpl::PeerFinder::SlotImp::recent_t::recent_t</a></div><div class="ttdeci">recent_t(clock_type &amp;clock)</div><div class="ttdef"><b>Definition</b> <a href="SlotImp_8cpp_source.html#l00088">SlotImp.cpp:88</a></div></div>
<div class="ttc" id="aclassxrpl_1_1PeerFinder_1_1SlotImp_1_1recent__t_html_aa65ecb71f04fed601ed06c1278eb7b7a"><div class="ttname"><a href="classxrpl_1_1PeerFinder_1_1SlotImp_1_1recent__t.html#aa65ecb71f04fed601ed06c1278eb7b7a">xrpl::PeerFinder::SlotImp::recent_t::filter</a></div><div class="ttdeci">bool filter(beast::IP::Endpoint const &amp;ep, std::uint32_t hops)</div><div class="ttdoc">Returns true if we should not send endpoint to the slot.</div><div class="ttdef"><b>Definition</b> <a href="SlotImp_8cpp_source.html#l00108">SlotImp.cpp:108</a></div></div>
<div class="ttc" id="aclassxrpl_1_1PeerFinder_1_1SlotImp_html_a1ef915e97ebc8f2cf99c5c869435640b"><div class="ttname"><a href="classxrpl_1_1PeerFinder_1_1SlotImp.html#a1ef915e97ebc8f2cf99c5c869435640b">xrpl::PeerFinder::SlotImp::m_inbound</a></div><div class="ttdeci">bool const m_inbound</div><div class="ttdef"><b>Definition</b> <a href="SlotImp_8h_source.html#l00161">SlotImp.h:161</a></div></div>
<div class="ttc" id="aclassxrpl_1_1PeerFinder_1_1SlotImp_html_a27e1b518649e194e4017e8b92d63f870"><div class="ttname"><a href="classxrpl_1_1PeerFinder_1_1SlotImp.html#a27e1b518649e194e4017e8b92d63f870">xrpl::PeerFinder::SlotImp::m_state</a></div><div class="ttdeci">State m_state</div><div class="ttdef"><b>Definition</b> <a href="SlotImp_8h_source.html#l00164">SlotImp.h:164</a></div></div>
<div class="ttc" id="aclassxrpl_1_1PeerFinder_1_1SlotImp_html_a911314c986fefd60d999e9031e5105cc"><div class="ttname"><a href="classxrpl_1_1PeerFinder_1_1SlotImp.html#a911314c986fefd60d999e9031e5105cc">xrpl::PeerFinder::SlotImp::SlotImp</a></div><div class="ttdeci">SlotImp(beast::IP::Endpoint const &amp;local_endpoint, beast::IP::Endpoint const &amp;remote_endpoint, bool fixed, clock_type &amp;clock)</div><div class="ttdef"><b>Definition</b> <a href="SlotImp_8cpp_source.html#l00008">SlotImp.cpp:8</a></div></div>
<div class="ttc" id="aclassxrpl_1_1PeerFinder_1_1SlotImp_html_a948dd075c496ead0821dd8b0493c7c2b"><div class="ttname"><a href="classxrpl_1_1PeerFinder_1_1SlotImp.html#a948dd075c496ead0821dd8b0493c7c2b">xrpl::PeerFinder::SlotImp::state</a></div><div class="ttdeci">State state() const override</div><div class="ttdoc">Returns the state of the connection.</div><div class="ttdef"><b>Definition</b> <a href="SlotImp_8h_source.html#l00049">SlotImp.h:49</a></div></div>
<div class="ttc" id="aclassxrpl_1_1PeerFinder_1_1SlotImp_html_aa2cb51f94ac96161d288824c921dcbb6"><div class="ttname"><a href="classxrpl_1_1PeerFinder_1_1SlotImp.html#aa2cb51f94ac96161d288824c921dcbb6">xrpl::PeerFinder::SlotImp::whenAcceptEndpoints</a></div><div class="ttdeci">clock_type::time_point whenAcceptEndpoints</div><div class="ttdef"><b>Definition</b> <a href="SlotImp_8h_source.html#l00191">SlotImp.h:191</a></div></div>
<div class="ttc" id="aclassxrpl_1_1PeerFinder_1_1SlotImp_html_af7788f27378dfd8943dc9a99f9206ecf"><div class="ttname"><a href="classxrpl_1_1PeerFinder_1_1SlotImp.html#af7788f27378dfd8943dc9a99f9206ecf">xrpl::PeerFinder::SlotImp::activate</a></div><div class="ttdeci">void activate(clock_type::time_point const &amp;now)</div><div class="ttdef"><b>Definition</b> <a href="SlotImp_8cpp_source.html#l00073">SlotImp.cpp:73</a></div></div>
<div class="ttc" id="aclassxrpl_1_1PeerFinder_1_1Slot_html_a9f7f74456679552f34bba92f853b8132"><div class="ttname"><a href="classxrpl_1_1PeerFinder_1_1Slot.html#a9f7f74456679552f34bba92f853b8132">xrpl::PeerFinder::Slot::State</a></div><div class="ttdeci">State</div><div class="ttdef"><b>Definition</b> <a href="peerfinder_2Slot_8h_source.html#l00018">peerfinder/Slot.h:18</a></div></div>
<div class="ttc" id="aclassxrpl_1_1PeerFinder_1_1Slot_html_a9f7f74456679552f34bba92f853b8132a253b58ea1b8331268fa056d1915fceb8"><div class="ttname"><a href="classxrpl_1_1PeerFinder_1_1Slot.html#a9f7f74456679552f34bba92f853b8132a253b58ea1b8331268fa056d1915fceb8">xrpl::PeerFinder::Slot::connected</a></div><div class="ttdeci">@ connected</div><div class="ttdef"><b>Definition</b> <a href="peerfinder_2Slot_8h_source.html#l00018">peerfinder/Slot.h:18</a></div></div>
<div class="ttc" id="aclassxrpl_1_1PeerFinder_1_1Slot_html_a9f7f74456679552f34bba92f853b8132a3b50c2305a01b45dd01951ad48bc2927"><div class="ttname"><a href="classxrpl_1_1PeerFinder_1_1Slot.html#a9f7f74456679552f34bba92f853b8132a3b50c2305a01b45dd01951ad48bc2927">xrpl::PeerFinder::Slot::connect</a></div><div class="ttdeci">@ connect</div><div class="ttdef"><b>Definition</b> <a href="peerfinder_2Slot_8h_source.html#l00018">peerfinder/Slot.h:18</a></div></div>
<div class="ttc" id="aclassxrpl_1_1PeerFinder_1_1Slot_html_a9f7f74456679552f34bba92f853b8132a86f6130f88e9406cff9c44276bcc91ff"><div class="ttname"><a href="classxrpl_1_1PeerFinder_1_1Slot.html#a9f7f74456679552f34bba92f853b8132a86f6130f88e9406cff9c44276bcc91ff">xrpl::PeerFinder::Slot::closing</a></div><div class="ttdeci">@ closing</div><div class="ttdef"><b>Definition</b> <a href="peerfinder_2Slot_8h_source.html#l00018">peerfinder/Slot.h:18</a></div></div>
<div class="ttc" id="aclassxrpl_1_1PeerFinder_1_1Slot_html_a9f7f74456679552f34bba92f853b8132a94a1335e1416fcf0b7532c7bc7282e5e"><div class="ttname"><a href="classxrpl_1_1PeerFinder_1_1Slot.html#a9f7f74456679552f34bba92f853b8132a94a1335e1416fcf0b7532c7bc7282e5e">xrpl::PeerFinder::Slot::active</a></div><div class="ttdeci">@ active</div><div class="ttdef"><b>Definition</b> <a href="peerfinder_2Slot_8h_source.html#l00018">peerfinder/Slot.h:18</a></div></div>
<div class="ttc" id="aclassxrpl_1_1PeerFinder_1_1Slot_html_a9f7f74456679552f34bba92f853b8132aaf593c8e49119e179957b9ff11b1053f"><div class="ttname"><a href="classxrpl_1_1PeerFinder_1_1Slot.html#a9f7f74456679552f34bba92f853b8132aaf593c8e49119e179957b9ff11b1053f">xrpl::PeerFinder::Slot::accept</a></div><div class="ttdeci">@ accept</div><div class="ttdef"><b>Definition</b> <a href="peerfinder_2Slot_8h_source.html#l00018">peerfinder/Slot.h:18</a></div></div>
<div class="ttc" id="aclassxrpl_1_1PeerFinder_1_1Slot_html_aeec556253d943a10b57973ccc9e6e4b2"><div class="ttname"><a href="classxrpl_1_1PeerFinder_1_1Slot.html#aeec556253d943a10b57973ccc9e6e4b2">xrpl::PeerFinder::Slot::~Slot</a></div><div class="ttdeci">virtual ~Slot()=0</div></div>
<div class="ttc" id="ainteger_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint32_t</a></div></div>
<div class="ttc" id="anamespacebeast_html_abb430a45381177561de02886079786ad"><div class="ttname"><a href="namespacebeast.html#abb430a45381177561de02886079786ad">beast::expire</a></div><div class="ttdeci">std::enable_if&lt; is_aged_container&lt; AgedContainer &gt;::value, std::size_t &gt;::type expire(AgedContainer &amp;c, std::chrono::duration&lt; Rep, Period &gt; const &amp;age)</div><div class="ttdoc">Expire aged container items past the specified age.</div><div class="ttdef"><b>Definition</b> <a href="aged__container__utility_8h_source.html#l00014">aged_container_utility.h:14</a></div></div>
<div class="ttc" id="anamespacexrpl_1_1PeerFinder_1_1Tuning_html_ac2519bc5a9e00d9731a7e9d41a6e6e35"><div class="ttname"><a href="namespacexrpl_1_1PeerFinder_1_1Tuning.html#ac2519bc5a9e00d9731a7e9d41a6e6e35">xrpl::PeerFinder::Tuning::liveCacheSecondsToLive</a></div><div class="ttdeci">std::chrono::seconds constexpr liveCacheSecondsToLive(30)</div></div>
<div class="ttc" id="anamespacexrpl_html"><div class="ttname"><a href="namespacexrpl.html">xrpl</a></div><div class="ttdoc">Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.</div><div class="ttdef"><b>Definition</b> <a href="algorithm_8h_source.html#l00006">algorithm.h:6</a></div></div>
<div class="ttc" id="anamespacexrpl_html_a5fef07ca1fcf5dfaac42cd492a3c8969"><div class="ttname"><a href="namespacexrpl.html#a5fef07ca1fcf5dfaac42cd492a3c8969">xrpl::fixed</a></div><div class="ttdeci">static FunctionType fixed(Keylet const &amp;keylet)</div><div class="ttdef"><b>Definition</b> <a href="LedgerEntry_8cpp_source.html#l00035">LedgerEntry.cpp:35</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8
</small></address>
</body>
</html>