mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
264 lines
37 KiB
HTML
264 lines
37 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: SHAMapNodeID.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&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&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&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_90ffdbabf412cfdffe6b2193e0ce938a.html">libxrpl</a></li><li class="navelem"><a class="el" href="dir_1cf8fc3bc79b026bd5b725d287fb7808.html">shamap</a></li> </ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="headertitle"><div class="title">SHAMapNodeID.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 <xrpl/beast/core/LexicalCast.h></span></div>
|
|
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno"> 2</span><span class="preprocessor">#include <xrpl/beast/utility/instrumentation.h></span></div>
|
|
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno"> 3</span><span class="preprocessor">#include <xrpl/protocol/Serializer.h></span></div>
|
|
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno"> 4</span><span class="preprocessor">#include <xrpl/shamap/SHAMap.h></span></div>
|
|
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno"> 5</span><span class="preprocessor">#include <xrpl/shamap/SHAMapNodeID.h></span></div>
|
|
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno"> 6</span> </div>
|
|
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno"> 7</span><span class="keyword">namespace </span><a class="code hl_namespace" href="namespaceripple.html">ripple</a> {</div>
|
|
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno"> 8</span> </div>
|
|
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno"> 9</span><span class="keyword">static</span> <a class="code hl_typedef" href="namespaceripple.html#a356c68147333a9a48a344718038576d9">uint256</a> <span class="keyword">const</span>&</div>
|
|
<div class="foldopen" id="foldopen00010" data-start="{" data-end="}">
|
|
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno"><a class="line" href="namespaceripple.html#a9d1e8c14112c6d8c126307e128ff7b4f"> 10</a></span><a class="code hl_function" href="namespaceripple.html#a9d1e8c14112c6d8c126307e128ff7b4f">depthMask</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> depth)</div>
|
|
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span>{</div>
|
|
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span> <span class="keyword">enum</span> { mask_size = 65 };</div>
|
|
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno"> 13</span> </div>
|
|
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"> 14</span> <span class="keyword">struct </span>masks_t</div>
|
|
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"> 15</span> {</div>
|
|
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno"> 16</span> <a class="code hl_class" href="classripple_1_1base__uint.html">uint256</a> entry[mask_size];</div>
|
|
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"> 17</span> </div>
|
|
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno"> 18</span> masks_t()</div>
|
|
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"> 19</span> {</div>
|
|
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span> <a class="code hl_class" href="classripple_1_1base__uint.html">uint256</a> selector;</div>
|
|
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < mask_size - 1; i += 2)</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> entry[i] = selector;</div>
|
|
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span> *(selector.<a class="code hl_function" href="classripple_1_1base__uint.html#a2ffd09234d574e5554c5d84199a9f287">begin</a>() + (i / 2)) = 0xF0;</div>
|
|
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"> 25</span> entry[i + 1] = selector;</div>
|
|
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"> 26</span> *(selector.<a class="code hl_function" href="classripple_1_1base__uint.html#a2ffd09234d574e5554c5d84199a9f287">begin</a>() + (i / 2)) = 0xFF;</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> entry[mask_size - 1] = selector;</div>
|
|
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</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> </div>
|
|
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> <span class="keyword">static</span> masks_t <span class="keyword">const</span> masks;</div>
|
|
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span> <span class="keywordflow">return</span> masks.entry[depth];</div>
|
|
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span>}</div>
|
|
</div>
|
|
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span> </div>
|
|
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span><span class="comment">// canonicalize the hash to a node ID for this depth</span></div>
|
|
<div class="foldopen" id="foldopen00037" data-start="{" data-end="}">
|
|
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"><a class="line" href="classripple_1_1SHAMapNodeID.html#a07d89225c82c518e88d15b2ed3138ca5"> 37</a></span><a class="code hl_function" href="classripple_1_1SHAMapNodeID.html#ab778be2116f66638981a7e9c0dd9ac6b">SHAMapNodeID::SHAMapNodeID</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> depth, <a class="code hl_class" href="classripple_1_1base__uint.html">uint256</a> <span class="keyword">const</span>& hash)</div>
|
|
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span> : id_(hash), depth_(depth)</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"> 40</span> XRPL_ASSERT(</div>
|
|
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> depth <= <a class="code hl_variable" href="classripple_1_1SHAMap.html#a16961b82bb1c661845b14c88b4e80dc3">SHAMap::leafDepth</a>,</div>
|
|
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span> <span class="stringliteral">"ripple::SHAMapNodeID::SHAMapNodeID : maximum depth input"</span>);</div>
|
|
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span> XRPL_ASSERT(</div>
|
|
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"> 44</span> <a class="code hl_variable" href="classripple_1_1SHAMapNodeID.html#a7cff46032ca875e7f9beaeade09e1c9f">id_</a> == (<a class="code hl_variable" href="classripple_1_1SHAMapNodeID.html#a7cff46032ca875e7f9beaeade09e1c9f">id_</a> & <a class="code hl_function" href="namespaceripple.html#a9d1e8c14112c6d8c126307e128ff7b4f">depthMask</a>(depth)),</div>
|
|
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span> <span class="stringliteral">"ripple::SHAMapNodeID::SHAMapNodeID : hash and depth inputs do match"</span>);</div>
|
|
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"> 46</span>}</div>
|
|
</div>
|
|
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> </div>
|
|
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span><a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a></div>
|
|
<div class="foldopen" id="foldopen00049" data-start="{" data-end="}">
|
|
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"><a class="line" href="classripple_1_1SHAMapNodeID.html#a60517c4d78ae36f53c01b84865d5ba7e"> 49</a></span><a class="code hl_function" href="classripple_1_1SHAMapNodeID.html#a60517c4d78ae36f53c01b84865d5ba7e">SHAMapNodeID::getRawString</a>()<span class="keyword"> const</span></div>
|
|
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span><span class="keyword"></span>{</div>
|
|
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> <a class="code hl_class" href="classripple_1_1Serializer.html">Serializer</a> s(33);</div>
|
|
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> s.<a class="code hl_function" href="classripple_1_1Serializer.html#a96daec54ca0c8ec7f6e7e683e9abbe0e">addBitString</a>(<a class="code hl_variable" href="classripple_1_1SHAMapNodeID.html#a7cff46032ca875e7f9beaeade09e1c9f">id_</a>);</div>
|
|
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> s.<a class="code hl_function" href="classripple_1_1Serializer.html#ab6de064efbc9b2efaeff2b069a02b644">add8</a>(<a class="code hl_variable" href="classripple_1_1SHAMapNodeID.html#aea1b5520b7d49f8dd05211bbec6465eb">depth_</a>);</div>
|
|
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span> <span class="keywordflow">return</span> s.<a class="code hl_function" href="classripple_1_1Serializer.html#afb9f001046e4767db6780bbee86d93c3">getString</a>();</div>
|
|
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span>}</div>
|
|
</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><a class="code hl_class" href="classripple_1_1SHAMapNodeID.html">SHAMapNodeID</a></div>
|
|
<div class="foldopen" id="foldopen00058" data-start="{" data-end="}">
|
|
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"><a class="line" href="classripple_1_1SHAMapNodeID.html#a23e606ffcd8a863d0f678f040001aedf"> 58</a></span><a class="code hl_function" href="classripple_1_1SHAMapNodeID.html#a23e606ffcd8a863d0f678f040001aedf">SHAMapNodeID::getChildNodeID</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> m)<span class="keyword"> const</span></div>
|
|
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span><span class="keyword"></span>{</div>
|
|
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> XRPL_ASSERT(</div>
|
|
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> m < <a class="code hl_variable" href="classripple_1_1SHAMap.html#af8599964238eb94d795606f220654db9">SHAMap::branchFactor</a>,</div>
|
|
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> <span class="stringliteral">"ripple::SHAMapNodeID::getChildNodeID : valid branch input"</span>);</div>
|
|
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> </div>
|
|
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> <span class="comment">// A SHAMap has exactly 65 levels, so nodes must not exceed that</span></div>
|
|
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span> <span class="comment">// depth; if they do, this breaks the invariant of never allowing</span></div>
|
|
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> <span class="comment">// the construction of a SHAMapNodeID at an invalid depth. We assert</span></div>
|
|
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> <span class="comment">// to catch this in debug builds.</span></div>
|
|
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> <span class="comment">//</span></div>
|
|
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> <span class="comment">// We throw (but never assert) if the node is at level 64, since</span></div>
|
|
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> <span class="comment">// entries at that depth are leaf nodes and have no children and even</span></div>
|
|
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> <span class="comment">// constructing a child node from them would break the above invariant.</span></div>
|
|
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> XRPL_ASSERT(</div>
|
|
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> <a class="code hl_variable" href="classripple_1_1SHAMapNodeID.html#aea1b5520b7d49f8dd05211bbec6465eb">depth_</a> <= <a class="code hl_variable" href="classripple_1_1SHAMap.html#a16961b82bb1c661845b14c88b4e80dc3">SHAMap::leafDepth</a>,</div>
|
|
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> <span class="stringliteral">"ripple::SHAMapNodeID::getChildNodeID : maximum leaf depth"</span>);</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> <span class="keywordflow">if</span> (<a class="code hl_variable" href="classripple_1_1SHAMapNodeID.html#aea1b5520b7d49f8dd05211bbec6465eb">depth_</a> >= <a class="code hl_variable" href="classripple_1_1SHAMap.html#a16961b82bb1c661845b14c88b4e80dc3">SHAMap::leafDepth</a>)</div>
|
|
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> Throw<std::logic_error>(</div>
|
|
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span> <span class="stringliteral">"Request for child node ID of "</span> + <a class="code hl_function" href="namespaceripple.html#ac124fe6744b7fe887dec949b56b16d50">to_string</a>(*<span class="keyword">this</span>));</div>
|
|
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span> </div>
|
|
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="classripple_1_1SHAMapNodeID.html#a7cff46032ca875e7f9beaeade09e1c9f">id_</a> != (<a class="code hl_variable" href="classripple_1_1SHAMapNodeID.html#a7cff46032ca875e7f9beaeade09e1c9f">id_</a> & <a class="code hl_function" href="namespaceripple.html#a9d1e8c14112c6d8c126307e128ff7b4f">depthMask</a>(<a class="code hl_variable" href="classripple_1_1SHAMapNodeID.html#aea1b5520b7d49f8dd05211bbec6465eb">depth_</a>)))</div>
|
|
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> Throw<std::logic_error>(<span class="stringliteral">"Incorrect mask for "</span> + <a class="code hl_function" href="namespaceripple.html#ac124fe6744b7fe887dec949b56b16d50">to_string</a>(*<span class="keyword">this</span>));</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> <a class="code hl_class" href="classripple_1_1SHAMapNodeID.html">SHAMapNodeID</a> node{<a class="code hl_variable" href="classripple_1_1SHAMapNodeID.html#aea1b5520b7d49f8dd05211bbec6465eb">depth_</a> + 1, <a class="code hl_variable" href="classripple_1_1SHAMapNodeID.html#a7cff46032ca875e7f9beaeade09e1c9f">id_</a>};</div>
|
|
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> node.id_.<a class="code hl_function" href="classripple_1_1base__uint.html#a2ffd09234d574e5554c5d84199a9f287">begin</a>()[<a class="code hl_variable" href="classripple_1_1SHAMapNodeID.html#aea1b5520b7d49f8dd05211bbec6465eb">depth_</a> / 2] |= (<a class="code hl_variable" href="classripple_1_1SHAMapNodeID.html#aea1b5520b7d49f8dd05211bbec6465eb">depth_</a> & 1) ? m : (m << 4);</div>
|
|
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"> 85</span> <span class="keywordflow">return</span> node;</div>
|
|
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"> 86</span>}</div>
|
|
</div>
|
|
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span> </div>
|
|
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"> 88</span>[[nodiscard]] <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/utility/optional.html">std::optional<SHAMapNodeID></a></div>
|
|
<div class="foldopen" id="foldopen00089" data-start="{" data-end="}">
|
|
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno"><a class="line" href="namespaceripple.html#a34ca82369c1b5a3fb627089495c74928"> 89</a></span><a class="code hl_function" href="namespaceripple.html#a34ca82369c1b5a3fb627089495c74928">deserializeSHAMapNodeID</a>(<span class="keywordtype">void</span> <span class="keyword">const</span>* data, <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/types/size_t.html">std::size_t</a> size)</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> <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/utility/optional.html">std::optional<SHAMapNodeID></a> ret;</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="keywordflow">if</span> (size == 33)</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="keywordtype">unsigned</span> <span class="keywordtype">int</span> depth = *(<span class="keyword">static_cast<</span><span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> const*<span class="keyword">></span>(data) + 32);</div>
|
|
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> <span class="keywordflow">if</span> (depth <= <a class="code hl_variable" href="classripple_1_1SHAMap.html#a16961b82bb1c661845b14c88b4e80dc3">SHAMap::leafDepth</a>)</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="keyword">auto</span> <span class="keyword">const</span> <span class="keywordtype">id</span> = <a class="code hl_function" href="classripple_1_1base__uint.html#a4e9de7a706374a3d016b89c9ecb4f80d">uint256::fromVoid</a>(data);</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="keywordflow">if</span> (<span class="keywordtype">id</span> == (<span class="keywordtype">id</span> & <a class="code hl_function" href="namespaceripple.html#a9d1e8c14112c6d8c126307e128ff7b4f">depthMask</a>(depth)))</div>
|
|
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"> 101</span> ret.<a class="code hl_functionRef" href="http://en.cppreference.com/w/cpp/utility/optional/emplace.html">emplace</a>(depth, <span class="keywordtype">id</span>);</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> }</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> <span class="keywordflow">return</span> ret;</div>
|
|
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span>}</div>
|
|
</div>
|
|
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span> </div>
|
|
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span>[[nodiscard]] <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span></div>
|
|
<div class="foldopen" id="foldopen00109" data-start="{" data-end="}">
|
|
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"><a class="line" href="namespaceripple.html#abab985fadeb4b5746ed662c2540f4da5"> 109</a></span><a class="code hl_function" href="namespaceripple.html#abab985fadeb4b5746ed662c2540f4da5">selectBranch</a>(<a class="code hl_class" href="classripple_1_1SHAMapNodeID.html">SHAMapNodeID</a> <span class="keyword">const</span>& <span class="keywordtype">id</span>, <a class="code hl_class" href="classripple_1_1base__uint.html">uint256</a> <span class="keyword">const</span>& hash)</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> <span class="keyword">const</span> depth = <span class="keywordtype">id</span>.getDepth();</div>
|
|
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> <span class="keyword">auto</span> branch = <span class="keyword">static_cast<</span><span class="keywordtype">unsigned</span> <span class="keywordtype">int</span><span class="keyword">></span>(*(hash.<a class="code hl_function" href="classripple_1_1base__uint.html#a2ffd09234d574e5554c5d84199a9f287">begin</a>() + (depth / 2)));</div>
|
|
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span> </div>
|
|
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span> <span class="keywordflow">if</span> (depth & 1)</div>
|
|
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> branch &= 0xf;</div>
|
|
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span> <span class="keywordflow">else</span></div>
|
|
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span> branch >>= 4;</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> XRPL_ASSERT(</div>
|
|
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span> branch < <a class="code hl_variable" href="classripple_1_1SHAMap.html#af8599964238eb94d795606f220654db9">SHAMap::branchFactor</a>, <span class="stringliteral">"ripple::selectBranch : maximum result"</span>);</div>
|
|
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span> <span class="keywordflow">return</span> branch;</div>
|
|
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno"> 122</span>}</div>
|
|
</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>SHAMapNodeID</div>
|
|
<div class="foldopen" id="foldopen00125" data-start="{" data-end="}">
|
|
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"><a class="line" href="classripple_1_1SHAMapNodeID.html#a9ff9dfe2cb92d0b3d5a52ad6e3541416"> 125</a></span><a class="code hl_function" href="classripple_1_1SHAMapNodeID.html#a9ff9dfe2cb92d0b3d5a52ad6e3541416">SHAMapNodeID::createID</a>(<span class="keywordtype">int</span> depth, <a class="code hl_class" href="classripple_1_1base__uint.html">uint256</a> <span class="keyword">const</span>& key)</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> XRPL_ASSERT(</div>
|
|
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span> (depth >= 0) && (depth < 65),</div>
|
|
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span> <span class="stringliteral">"ripple::SHAMapNodeID::createID : valid branch input"</span>);</div>
|
|
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span> <span class="keywordflow">return</span> <a class="code hl_function" href="classripple_1_1SHAMapNodeID.html#ab778be2116f66638981a7e9c0dd9ac6b">SHAMapNodeID</a>(depth, key & <a class="code hl_function" href="namespaceripple.html#a9d1e8c14112c6d8c126307e128ff7b4f">depthMask</a>(depth));</div>
|
|
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span>}</div>
|
|
</div>
|
|
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span> </div>
|
|
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"> 133</span>} <span class="comment">// namespace ripple</span></div>
|
|
<div class="ttc" id="abasic_string_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a></div></div>
|
|
<div class="ttc" id="aclassripple_1_1SHAMapNodeID_html"><div class="ttname"><a href="classripple_1_1SHAMapNodeID.html">ripple::SHAMapNodeID</a></div><div class="ttdoc">Identifies a node inside a SHAMap.</div><div class="ttdef"><b>Definition</b> <a href="SHAMapNodeID_8h_source.html#l00014">SHAMapNodeID.h:15</a></div></div>
|
|
<div class="ttc" id="aclassripple_1_1SHAMapNodeID_html_a23e606ffcd8a863d0f678f040001aedf"><div class="ttname"><a href="classripple_1_1SHAMapNodeID.html#a23e606ffcd8a863d0f678f040001aedf">ripple::SHAMapNodeID::getChildNodeID</a></div><div class="ttdeci">SHAMapNodeID getChildNodeID(unsigned int m) const</div><div class="ttdef"><b>Definition</b> <a href="SHAMapNodeID_8cpp_source.html#l00058">SHAMapNodeID.cpp:58</a></div></div>
|
|
<div class="ttc" id="aclassripple_1_1SHAMapNodeID_html_a60517c4d78ae36f53c01b84865d5ba7e"><div class="ttname"><a href="classripple_1_1SHAMapNodeID.html#a60517c4d78ae36f53c01b84865d5ba7e">ripple::SHAMapNodeID::getRawString</a></div><div class="ttdeci">std::string getRawString() const</div><div class="ttdef"><b>Definition</b> <a href="SHAMapNodeID_8cpp_source.html#l00049">SHAMapNodeID.cpp:49</a></div></div>
|
|
<div class="ttc" id="aclassripple_1_1SHAMapNodeID_html_a7cff46032ca875e7f9beaeade09e1c9f"><div class="ttname"><a href="classripple_1_1SHAMapNodeID.html#a7cff46032ca875e7f9beaeade09e1c9f">ripple::SHAMapNodeID::id_</a></div><div class="ttdeci">uint256 id_</div><div class="ttdef"><b>Definition</b> <a href="SHAMapNodeID_8h_source.html#l00017">SHAMapNodeID.h:17</a></div></div>
|
|
<div class="ttc" id="aclassripple_1_1SHAMapNodeID_html_a9ff9dfe2cb92d0b3d5a52ad6e3541416"><div class="ttname"><a href="classripple_1_1SHAMapNodeID.html#a9ff9dfe2cb92d0b3d5a52ad6e3541416">ripple::SHAMapNodeID::createID</a></div><div class="ttdeci">static SHAMapNodeID createID(int depth, uint256 const &key)</div><div class="ttdoc">Create a SHAMapNodeID of a node with the depth of the node and the key of a leaf.</div><div class="ttdef"><b>Definition</b> <a href="SHAMapNodeID_8cpp_source.html#l00125">SHAMapNodeID.cpp:125</a></div></div>
|
|
<div class="ttc" id="aclassripple_1_1SHAMapNodeID_html_ab778be2116f66638981a7e9c0dd9ac6b"><div class="ttname"><a href="classripple_1_1SHAMapNodeID.html#ab778be2116f66638981a7e9c0dd9ac6b">ripple::SHAMapNodeID::SHAMapNodeID</a></div><div class="ttdeci">SHAMapNodeID()=default</div></div>
|
|
<div class="ttc" id="aclassripple_1_1SHAMapNodeID_html_aea1b5520b7d49f8dd05211bbec6465eb"><div class="ttname"><a href="classripple_1_1SHAMapNodeID.html#aea1b5520b7d49f8dd05211bbec6465eb">ripple::SHAMapNodeID::depth_</a></div><div class="ttdeci">unsigned int depth_</div><div class="ttdef"><b>Definition</b> <a href="SHAMapNodeID_8h_source.html#l00018">SHAMapNodeID.h:18</a></div></div>
|
|
<div class="ttc" id="aclassripple_1_1SHAMap_html_a16961b82bb1c661845b14c88b4e80dc3"><div class="ttname"><a href="classripple_1_1SHAMap.html#a16961b82bb1c661845b14c88b4e80dc3">ripple::SHAMap::leafDepth</a></div><div class="ttdeci">static constexpr unsigned int leafDepth</div><div class="ttdoc">The depth of the hash map: data is only present in the leaves.</div><div class="ttdef"><b>Definition</b> <a href="SHAMap_8h_source.html#l00102">SHAMap.h:102</a></div></div>
|
|
<div class="ttc" id="aclassripple_1_1SHAMap_html_af8599964238eb94d795606f220654db9"><div class="ttname"><a href="classripple_1_1SHAMap.html#af8599964238eb94d795606f220654db9">ripple::SHAMap::branchFactor</a></div><div class="ttdeci">static constexpr unsigned int branchFactor</div><div class="ttdoc">Number of children each non-leaf node has (the 'radix tree' part of the map)</div><div class="ttdef"><b>Definition</b> <a href="SHAMap_8h_source.html#l00098">SHAMap.h:98</a></div></div>
|
|
<div class="ttc" id="aclassripple_1_1Serializer_html"><div class="ttname"><a href="classripple_1_1Serializer.html">ripple::Serializer</a></div><div class="ttdef"><b>Definition</b> <a href="Serializer_8h_source.html#l00021">Serializer.h:22</a></div></div>
|
|
<div class="ttc" id="aclassripple_1_1Serializer_html_a96daec54ca0c8ec7f6e7e683e9abbe0e"><div class="ttname"><a href="classripple_1_1Serializer.html#a96daec54ca0c8ec7f6e7e683e9abbe0e">ripple::Serializer::addBitString</a></div><div class="ttdeci">int addBitString(base_uint< Bits, Tag > const &v)</div><div class="ttdef"><b>Definition</b> <a href="Serializer_8h_source.html#l00112">Serializer.h:112</a></div></div>
|
|
<div class="ttc" id="aclassripple_1_1Serializer_html_ab6de064efbc9b2efaeff2b069a02b644"><div class="ttname"><a href="classripple_1_1Serializer.html#ab6de064efbc9b2efaeff2b069a02b644">ripple::Serializer::add8</a></div><div class="ttdeci">int add8(unsigned char i)</div><div class="ttdef"><b>Definition</b> <a href="Serializer_8cpp_source.html#l00143">Serializer.cpp:143</a></div></div>
|
|
<div class="ttc" id="aclassripple_1_1Serializer_html_afb9f001046e4767db6780bbee86d93c3"><div class="ttname"><a href="classripple_1_1Serializer.html#afb9f001046e4767db6780bbee86d93c3">ripple::Serializer::getString</a></div><div class="ttdeci">std::string getString() const</div><div class="ttdef"><b>Definition</b> <a href="Serializer_8h_source.html#l00219">Serializer.h:219</a></div></div>
|
|
<div class="ttc" id="aclassripple_1_1base__uint_html"><div class="ttname"><a href="classripple_1_1base__uint.html">ripple::base_uint< 256 ></a></div></div>
|
|
<div class="ttc" id="aclassripple_1_1base__uint_html_a2ffd09234d574e5554c5d84199a9f287"><div class="ttname"><a href="classripple_1_1base__uint.html#a2ffd09234d574e5554c5d84199a9f287">ripple::base_uint::begin</a></div><div class="ttdeci">iterator begin()</div><div class="ttdef"><b>Definition</b> <a href="base__uint_8h_source.html#l00117">base_uint.h:117</a></div></div>
|
|
<div class="ttc" id="aclassripple_1_1base__uint_html_a4e9de7a706374a3d016b89c9ecb4f80d"><div class="ttname"><a href="classripple_1_1base__uint.html#a4e9de7a706374a3d016b89c9ecb4f80d">ripple::base_uint< 256 >::fromVoid</a></div><div class="ttdeci">static base_uint fromVoid(void const *data)</div><div class="ttdef"><b>Definition</b> <a href="base__uint_8h_source.html#l00300">base_uint.h:300</a></div></div>
|
|
<div class="ttc" id="aemplace_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/utility/optional/emplace.html">std::optional::emplace</a></div><div class="ttdeci">T emplace(T... args)</div></div>
|
|
<div class="ttc" id="anamespaceripple_html"><div class="ttname"><a href="namespaceripple.html">ripple</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="anamespaceripple_html_a34ca82369c1b5a3fb627089495c74928"><div class="ttname"><a href="namespaceripple.html#a34ca82369c1b5a3fb627089495c74928">ripple::deserializeSHAMapNodeID</a></div><div class="ttdeci">std::optional< SHAMapNodeID > deserializeSHAMapNodeID(void const *data, std::size_t size)</div><div class="ttdoc">Return an object representing a serialized SHAMap Node ID.</div><div class="ttdef"><b>Definition</b> <a href="SHAMapNodeID_8cpp_source.html#l00089">SHAMapNodeID.cpp:89</a></div></div>
|
|
<div class="ttc" id="anamespaceripple_html_a356c68147333a9a48a344718038576d9"><div class="ttname"><a href="namespaceripple.html#a356c68147333a9a48a344718038576d9">ripple::uint256</a></div><div class="ttdeci">base_uint< 256 > uint256</div><div class="ttdef"><b>Definition</b> <a href="base__uint_8h_source.html#l00539">base_uint.h:539</a></div></div>
|
|
<div class="ttc" id="anamespaceripple_html_a9d1e8c14112c6d8c126307e128ff7b4f"><div class="ttname"><a href="namespaceripple.html#a9d1e8c14112c6d8c126307e128ff7b4f">ripple::depthMask</a></div><div class="ttdeci">static uint256 const & depthMask(unsigned int depth)</div><div class="ttdef"><b>Definition</b> <a href="SHAMapNodeID_8cpp_source.html#l00010">SHAMapNodeID.cpp:10</a></div></div>
|
|
<div class="ttc" id="anamespaceripple_html_abab985fadeb4b5746ed662c2540f4da5"><div class="ttname"><a href="namespaceripple.html#abab985fadeb4b5746ed662c2540f4da5">ripple::selectBranch</a></div><div class="ttdeci">unsigned int selectBranch(SHAMapNodeID const &id, uint256 const &hash)</div><div class="ttdoc">Returns the branch that would contain the given hash.</div><div class="ttdef"><b>Definition</b> <a href="SHAMapNodeID_8cpp_source.html#l00109">SHAMapNodeID.cpp:109</a></div></div>
|
|
<div class="ttc" id="anamespaceripple_html_ac124fe6744b7fe887dec949b56b16d50"><div class="ttname"><a href="namespaceripple.html#ac124fe6744b7fe887dec949b56b16d50">ripple::to_string</a></div><div class="ttdeci">std::string to_string(base_uint< Bits, Tag > const &a)</div><div class="ttdef"><b>Definition</b> <a href="base__uint_8h_source.html#l00611">base_uint.h:611</a></div></div>
|
|
<div class="ttc" id="aoptional_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/utility/optional.html">std::optional</a></div></div>
|
|
<div class="ttc" id="asize_t_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/types/size_t.html">std::size_t</a></div></div>
|
|
</div><!-- fragment --></div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated by <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>
|