forked from XRPLF/rippled
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAccountID_8cpp_source.html
275 lines (273 loc) · 42.1 KB
/
AccountID_8cpp_source.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<!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">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>rippled: AccountID.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 style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">rippled
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @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:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- 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">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_df9c78dcf3f59a33b12284f95992a64b.html">ripple</a></li><li class="navelem"><a class="el" href="dir_1e765e6a8d5970800a535eb2615ec474.html">protocol</a></li><li class="navelem"><a class="el" href="dir_41c387a0f328eeb295307369675c1162.html">impl</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">AccountID.cpp</div> </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">//------------------------------------------------------------------------------</span></div>
<div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment">/*</span></div>
<div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment"> This file is part of rippled: https://github.com/ripple/rippled</span></div>
<div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment"> Copyright (c) 2012, 2013 Ripple Labs Inc.</span></div>
<div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment"></span> </div>
<div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment"> Permission to use, copy, modify, and/or distribute this software for any</span></div>
<div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment"> purpose with or without fee is hereby granted, provided that the above</span></div>
<div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment"> copyright notice and this permission notice appear in all copies.</span></div>
<div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment"></span> </div>
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment"> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES</span></div>
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment"> WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF</span></div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment"> MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR</span></div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="comment"> ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES</span></div>
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="comment"> WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN</span></div>
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="comment"> ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF</span></div>
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="comment"> OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</span></div>
<div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="comment">*/</span></div>
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="comment">//==============================================================================</span></div>
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span>  </div>
<div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="preprocessor">#include <ripple/protocol/AccountID.h></span></div>
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span> <span class="preprocessor">#include <ripple/protocol/PublicKey.h></span></div>
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span> <span class="preprocessor">#include <ripple/protocol/digest.h></span></div>
<div class="line"><a name="l00023"></a><span class="lineno"> 23</span> <span class="preprocessor">#include <ripple/protocol/tokens.h></span></div>
<div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="preprocessor">#include <<a class="codeRef" href="http://en.cppreference.com/w/cpp/header/cstring.html">cstring</a>></span></div>
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span>  </div>
<div class="line"><a name="l00026"></a><span class="lineno"> 26</span> <span class="keyword">namespace </span><a class="code" href="namespaceripple.html">ripple</a> {</div>
<div class="line"><a name="l00027"></a><span class="lineno"> 27</span>  </div>
<div class="line"><a name="l00028"></a><span class="lineno"> 28</span> <a class="codeRef" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a></div>
<div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="namespaceripple.html#a08a13b62b18272366f788632359e8793"> 29</a></span> <a class="code" href="namespaceripple.html#a08a13b62b18272366f788632359e8793">toBase58</a>(<a class="code" href="classripple_1_1base__uint.html">AccountID</a> <span class="keyword">const</span>& v)</div>
<div class="line"><a name="l00030"></a><span class="lineno"> 30</span> {</div>
<div class="line"><a name="l00031"></a><span class="lineno"> 31</span>  <span class="keywordflow">return</span> <a class="code" href="namespaceripple.html#a4c70c1f85ccff1b830f4bda1becb21b4">encodeBase58Token</a>(<a class="code" href="namespaceripple.html#a1bf8df553d36589191c8057c136cce03aba430b63631349ab773285535e878405">TokenType::AccountID</a>, v.<a class="code" href="classripple_1_1base__uint.html#a5342507fe2fb5ac55d578e7e98863f70">data</a>(), v.<a class="code" href="classripple_1_1base__uint.html#adbe18ef92b677603e8539b3a77c064b0">size</a>());</div>
<div class="line"><a name="l00032"></a><span class="lineno"> 32</span> }</div>
<div class="line"><a name="l00033"></a><span class="lineno"> 33</span>  </div>
<div class="line"><a name="l00034"></a><span class="lineno"> 34</span> <span class="keyword">template</span> <></div>
<div class="line"><a name="l00035"></a><span class="lineno"> 35</span> <a class="codeRef" href="http://en.cppreference.com/w/cpp/utility/optional.html">std::optional<AccountID></a></div>
<div class="line"><a name="l00036"></a><span class="lineno"><a class="line" href="namespaceripple.html#a6ed6129376e1d37ef607c2697f5b9d6a"> 36</a></span> <a class="code" href="namespaceripple.html#a6ed6129376e1d37ef607c2697f5b9d6a">parseBase58</a>(<a class="codeRef" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> <span class="keyword">const</span>& s)</div>
<div class="line"><a name="l00037"></a><span class="lineno"> 37</span> {</div>
<div class="line"><a name="l00038"></a><span class="lineno"> 38</span>  <span class="keyword">auto</span> <span class="keyword">const</span> result = <a class="code" href="namespaceripple.html#a9952e5a413358e9a647b31c86c5835ff">decodeBase58Token</a>(s, <a class="code" href="namespaceripple.html#a1bf8df553d36589191c8057c136cce03aba430b63631349ab773285535e878405">TokenType::AccountID</a>);</div>
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span>  <span class="keywordflow">if</span> (result.size() != <a class="code" href="classripple_1_1base__uint.html#a4b9e8d36a37963d48be8f081d99257bf">AccountID::bytes</a>)</div>
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span>  <span class="keywordflow">return</span> std::nullopt;</div>
<div class="line"><a name="l00041"></a><span class="lineno"> 41</span>  <span class="keywordflow">return</span> <a class="code" href="classripple_1_1base__uint.html">AccountID</a>{result};</div>
<div class="line"><a name="l00042"></a><span class="lineno"> 42</span> }</div>
<div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  </div>
<div class="line"><a name="l00044"></a><span class="lineno"> 44</span> <span class="comment">//------------------------------------------------------------------------------</span></div>
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span> <span class="comment">/*</span></div>
<div class="line"><a name="l00046"></a><span class="lineno"> 46</span> <span class="comment"> Calculation of the Account ID</span></div>
<div class="line"><a name="l00047"></a><span class="lineno"> 47</span> <span class="comment"></span> </div>
<div class="line"><a name="l00048"></a><span class="lineno"> 48</span> <span class="comment"> The AccountID is a 160-bit identifier that uniquely</span></div>
<div class="line"><a name="l00049"></a><span class="lineno"> 49</span> <span class="comment"> distinguishes an account. The account may or may not</span></div>
<div class="line"><a name="l00050"></a><span class="lineno"> 50</span> <span class="comment"> exist in the ledger. Even for accounts that are not in</span></div>
<div class="line"><a name="l00051"></a><span class="lineno"> 51</span> <span class="comment"> the ledger, cryptographic operations may be performed</span></div>
<div class="line"><a name="l00052"></a><span class="lineno"> 52</span> <span class="comment"> which affect the ledger. For example, designating an</span></div>
<div class="line"><a name="l00053"></a><span class="lineno"> 53</span> <span class="comment"> account not in the ledger as a regular key for an</span></div>
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span> <span class="comment"> account that is in the ledger.</span></div>
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span> <span class="comment"></span> </div>
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span> <span class="comment"> Why did we use half of SHA512 for most things but then</span></div>
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span> <span class="comment"> SHA256 followed by RIPEMD160 for account IDs? Why didn't</span></div>
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span> <span class="comment"> we do SHA512 half then RIPEMD160? Or even SHA512 then RIPEMD160?</span></div>
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span> <span class="comment"> For that matter why RIPEMD160 at all why not just SHA512 and keep</span></div>
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span> <span class="comment"> only 160 bits?</span></div>
<div class="line"><a name="l00061"></a><span class="lineno"> 61</span> <span class="comment"></span> </div>
<div class="line"><a name="l00062"></a><span class="lineno"> 62</span> <span class="comment"> Answer (David Schwartz):</span></div>
<div class="line"><a name="l00063"></a><span class="lineno"> 63</span> <span class="comment"></span> </div>
<div class="line"><a name="l00064"></a><span class="lineno"> 64</span> <span class="comment"> The short answer is that we kept Bitcoin's behavior.</span></div>
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span> <span class="comment"> The longer answer was that:</span></div>
<div class="line"><a name="l00066"></a><span class="lineno"> 66</span> <span class="comment"> 1) Using a single hash could leave ripple</span></div>
<div class="line"><a name="l00067"></a><span class="lineno"> 67</span> <span class="comment"> vulnerable to length extension attacks.</span></div>
<div class="line"><a name="l00068"></a><span class="lineno"> 68</span> <span class="comment"> 2) Only RIPEMD160 is generally considered safe at 160 bits.</span></div>
<div class="line"><a name="l00069"></a><span class="lineno"> 69</span> <span class="comment"></span> </div>
<div class="line"><a name="l00070"></a><span class="lineno"> 70</span> <span class="comment"> Any of those schemes would have been acceptable. However,</span></div>
<div class="line"><a name="l00071"></a><span class="lineno"> 71</span> <span class="comment"> the one chosen avoids any need to defend the scheme chosen.</span></div>
<div class="line"><a name="l00072"></a><span class="lineno"> 72</span> <span class="comment"> (Against any criticism other than unnecessary complexity.)</span></div>
<div class="line"><a name="l00073"></a><span class="lineno"> 73</span> <span class="comment"></span> </div>
<div class="line"><a name="l00074"></a><span class="lineno"> 74</span> <span class="comment"> "The historical reason was that in the very early days,</span></div>
<div class="line"><a name="l00075"></a><span class="lineno"> 75</span> <span class="comment"> we wanted to give people as few ways to argue that we were</span></div>
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span> <span class="comment"> less secure than Bitcoin. So where there was no good reason</span></div>
<div class="line"><a name="l00077"></a><span class="lineno"> 77</span> <span class="comment"> to change something, it was not changed."</span></div>
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span> <span class="comment">*/</span></div>
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span> <a class="code" href="namespaceripple.html#a00ae0d729cb3e35b6bcac9a27ebb5284">AccountID</a></div>
<div class="line"><a name="l00080"></a><span class="lineno"><a class="line" href="namespaceripple.html#a614d8681c8dff84ac2257939751987c5"> 80</a></span> <a class="code" href="namespaceripple.html#a614d8681c8dff84ac2257939751987c5">calcAccountID</a>(<a class="code" href="classripple_1_1PublicKey.html">PublicKey</a> <span class="keyword">const</span>& pk)</div>
<div class="line"><a name="l00081"></a><span class="lineno"> 81</span> {</div>
<div class="line"><a name="l00082"></a><span class="lineno"> 82</span>  static_assert(<a class="code" href="classripple_1_1base__uint.html#a4b9e8d36a37963d48be8f081d99257bf">AccountID::bytes</a> == <span class="keyword">sizeof</span>(<a class="codeRef" href="http://en.cppreference.com/w/cpp/container/array.html">ripesha_hasher::result_type</a>));</div>
<div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  </div>
<div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  <a class="code" href="structripple_1_1ripesha__hasher.html">ripesha_hasher</a> rsh;</div>
<div class="line"><a name="l00085"></a><span class="lineno"> 85</span>  rsh(pk.<a class="code" href="classripple_1_1PublicKey.html#a46e654e5021f7a037dbacd14db86fc5e">data</a>(), pk.<a class="code" href="classripple_1_1PublicKey.html#a663437215503b159ed33b1664e4213a3">size</a>());</div>
<div class="line"><a name="l00086"></a><span class="lineno"> 86</span>  <span class="keywordflow">return</span> <a class="code" href="classripple_1_1base__uint.html">AccountID</a>{<span class="keyword">static_cast<</span><a class="codeRef" href="http://en.cppreference.com/w/cpp/container/array.html">ripesha_hasher::result_type</a><span class="keyword">></span>(rsh)};</div>
<div class="line"><a name="l00087"></a><span class="lineno"> 87</span> }</div>
<div class="line"><a name="l00088"></a><span class="lineno"> 88</span>  </div>
<div class="line"><a name="l00089"></a><span class="lineno"> 89</span> <a class="code" href="namespaceripple.html#a00ae0d729cb3e35b6bcac9a27ebb5284">AccountID</a> <span class="keyword">const</span>&</div>
<div class="line"><a name="l00090"></a><span class="lineno"><a class="line" href="namespaceripple.html#a21696ba0d0fac348f88f1b9da51091b0"> 90</a></span> <a class="code" href="namespaceripple.html#a21696ba0d0fac348f88f1b9da51091b0">xrpAccount</a>()</div>
<div class="line"><a name="l00091"></a><span class="lineno"> 91</span> {</div>
<div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  <span class="keyword">static</span> <a class="code" href="classripple_1_1base__uint.html">AccountID</a> <span class="keyword">const</span> account(beast::zero);</div>
<div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  <span class="keywordflow">return</span> account;</div>
<div class="line"><a name="l00094"></a><span class="lineno"> 94</span> }</div>
<div class="line"><a name="l00095"></a><span class="lineno"> 95</span>  </div>
<div class="line"><a name="l00096"></a><span class="lineno"> 96</span> <a class="code" href="namespaceripple.html#a00ae0d729cb3e35b6bcac9a27ebb5284">AccountID</a> <span class="keyword">const</span>&</div>
<div class="line"><a name="l00097"></a><span class="lineno"><a class="line" href="namespaceripple.html#a065cda95aed9cb1d66fb81cad0867ef6"> 97</a></span> <a class="code" href="namespaceripple.html#a065cda95aed9cb1d66fb81cad0867ef6">noAccount</a>()</div>
<div class="line"><a name="l00098"></a><span class="lineno"> 98</span> {</div>
<div class="line"><a name="l00099"></a><span class="lineno"> 99</span>  <span class="keyword">static</span> <a class="code" href="classripple_1_1base__uint.html">AccountID</a> <span class="keyword">const</span> account(1);</div>
<div class="line"><a name="l00100"></a><span class="lineno"> 100</span>  <span class="keywordflow">return</span> account;</div>
<div class="line"><a name="l00101"></a><span class="lineno"> 101</span> }</div>
<div class="line"><a name="l00102"></a><span class="lineno"> 102</span>  </div>
<div class="line"><a name="l00103"></a><span class="lineno"> 103</span> <span class="keywordtype">bool</span></div>
<div class="line"><a name="l00104"></a><span class="lineno"><a class="line" href="namespaceripple.html#a300af819bde0c7c49207d10cd787e62e"> 104</a></span> <a class="code" href="namespaceripple.html#a300af819bde0c7c49207d10cd787e62e">to_issuer</a>(<a class="code" href="classripple_1_1base__uint.html">AccountID</a>& issuer, <a class="codeRef" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> <span class="keyword">const</span>& s)</div>
<div class="line"><a name="l00105"></a><span class="lineno"> 105</span> {</div>
<div class="line"><a name="l00106"></a><span class="lineno"> 106</span>  <span class="keywordflow">if</span> (issuer.<a class="code" href="classripple_1_1base__uint.html#a698d3fd0c0f0155995c87d2f48ac90d5">parseHex</a>(s))</div>
<div class="line"><a name="l00107"></a><span class="lineno"> 107</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a name="l00108"></a><span class="lineno"> 108</span>  <span class="keyword">auto</span> <span class="keyword">const</span> account = parseBase58<AccountID>(s);</div>
<div class="line"><a name="l00109"></a><span class="lineno"> 109</span>  <span class="keywordflow">if</span> (!account)</div>
<div class="line"><a name="l00110"></a><span class="lineno"> 110</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00111"></a><span class="lineno"> 111</span>  issuer = *account;</div>
<div class="line"><a name="l00112"></a><span class="lineno"> 112</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a name="l00113"></a><span class="lineno"> 113</span> }</div>
<div class="line"><a name="l00114"></a><span class="lineno"> 114</span>  </div>
<div class="line"><a name="l00115"></a><span class="lineno"> 115</span> <span class="comment">//------------------------------------------------------------------------------</span></div>
<div class="line"><a name="l00116"></a><span class="lineno"> 116</span>  </div>
<div class="line"><a name="l00117"></a><span class="lineno"> 117</span> <span class="comment">/* VFALCO NOTE</span></div>
<div class="line"><a name="l00118"></a><span class="lineno"> 118</span> <span class="comment"> An alternate implementation could use a pair of insert-only</span></div>
<div class="line"><a name="l00119"></a><span class="lineno"> 119</span> <span class="comment"> hash maps that each use a single large memory allocation</span></div>
<div class="line"><a name="l00120"></a><span class="lineno"> 120</span> <span class="comment"> to store a fixed size hash table and all of the AccountID/string</span></div>
<div class="line"><a name="l00121"></a><span class="lineno"> 121</span> <span class="comment"> pairs laid out in memory (wouldn't use std::string here just a</span></div>
<div class="line"><a name="l00122"></a><span class="lineno"> 122</span> <span class="comment"> length prefixed or zero terminated array). Possibly using</span></div>
<div class="line"><a name="l00123"></a><span class="lineno"> 123</span> <span class="comment"> boost::intrusive as the basis for the unordered container.</span></div>
<div class="line"><a name="l00124"></a><span class="lineno"> 124</span> <span class="comment"> This would cut down to one allocate/free cycle per swap of</span></div>
<div class="line"><a name="l00125"></a><span class="lineno"> 125</span> <span class="comment"> the map.</span></div>
<div class="line"><a name="l00126"></a><span class="lineno"> 126</span> <span class="comment">*/</span></div>
<div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  </div>
<div class="line"><a name="l00128"></a><span class="lineno"><a class="line" href="classripple_1_1AccountIDCache.html#a5e4bab5c5b62a9db7e5c866677500dd6"> 128</a></span> <a class="code" href="classripple_1_1AccountIDCache.html#aa85c90f69b07dabacc652080e04d7a41">AccountIDCache::AccountIDCache</a>(<a class="codeRef" href="http://en.cppreference.com/w/cpp/types/size_t.html">std::size_t</a> capacity) : capacity_(capacity)</div>
<div class="line"><a name="l00129"></a><span class="lineno"> 129</span> {</div>
<div class="line"><a name="l00130"></a><span class="lineno"> 130</span>  <a class="code" href="classripple_1_1AccountIDCache.html#a9963e4fa249bf87fd0fd5c1baefd7741">m1_</a>.reserve(<a class="code" href="classripple_1_1AccountIDCache.html#a1468b730efd9722a1a55ff81f0c59b94">capacity_</a>);</div>
<div class="line"><a name="l00131"></a><span class="lineno"> 131</span> }</div>
<div class="line"><a name="l00132"></a><span class="lineno"> 132</span>  </div>
<div class="line"><a name="l00133"></a><span class="lineno"> 133</span> <a class="codeRef" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a></div>
<div class="line"><a name="l00134"></a><span class="lineno"><a class="line" href="classripple_1_1AccountIDCache.html#a7c3b7a60b432ff4dcb87dcde20c61c02"> 134</a></span> <a class="code" href="classripple_1_1AccountIDCache.html#a7c3b7a60b432ff4dcb87dcde20c61c02">AccountIDCache::toBase58</a>(<a class="code" href="classripple_1_1base__uint.html">AccountID</a> <span class="keyword">const</span>& <span class="keywordtype">id</span>)<span class="keyword"> const</span></div>
<div class="line"><a name="l00135"></a><span class="lineno"> 135</span> <span class="keyword"></span>{</div>
<div class="line"><a name="l00136"></a><span class="lineno"> 136</span>  <a class="codeRef" href="http://en.cppreference.com/w/cpp/thread/lock_guard.html">std::lock_guard</a> lock(<a class="code" href="classripple_1_1AccountIDCache.html#a31116ba6b6e77fc075c80e746be57446">mutex_</a>);</div>
<div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  <span class="keyword">auto</span> iter = <a class="code" href="classripple_1_1AccountIDCache.html#a9963e4fa249bf87fd0fd5c1baefd7741">m1_</a>.find(<span class="keywordtype">id</span>);</div>
<div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  <span class="keywordflow">if</span> (iter != <a class="code" href="classripple_1_1AccountIDCache.html#a9963e4fa249bf87fd0fd5c1baefd7741">m1_</a>.end())</div>
<div class="line"><a name="l00139"></a><span class="lineno"> 139</span>  <span class="keywordflow">return</span> iter->second;</div>
<div class="line"><a name="l00140"></a><span class="lineno"> 140</span>  iter = <a class="code" href="classripple_1_1AccountIDCache.html#a945faf739aff5dd35d9f3c7c0bfe4a41">m0_</a>.find(<span class="keywordtype">id</span>);</div>
<div class="line"><a name="l00141"></a><span class="lineno"> 141</span>  <a class="codeRef" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> result;</div>
<div class="line"><a name="l00142"></a><span class="lineno"> 142</span>  <span class="keywordflow">if</span> (iter != <a class="code" href="classripple_1_1AccountIDCache.html#a945faf739aff5dd35d9f3c7c0bfe4a41">m0_</a>.end())</div>
<div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  {</div>
<div class="line"><a name="l00144"></a><span class="lineno"> 144</span>  result = iter->second;</div>
<div class="line"><a name="l00145"></a><span class="lineno"> 145</span>  <span class="comment">// Can use insert-only hash maps if</span></div>
<div class="line"><a name="l00146"></a><span class="lineno"> 146</span>  <span class="comment">// we didn't erase from here.</span></div>
<div class="line"><a name="l00147"></a><span class="lineno"> 147</span>  <a class="code" href="classripple_1_1AccountIDCache.html#a945faf739aff5dd35d9f3c7c0bfe4a41">m0_</a>.erase(iter);</div>
<div class="line"><a name="l00148"></a><span class="lineno"> 148</span>  }</div>
<div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  <span class="keywordflow">else</span></div>
<div class="line"><a name="l00150"></a><span class="lineno"> 150</span>  {</div>
<div class="line"><a name="l00151"></a><span class="lineno"> 151</span>  result = <a class="code" href="namespaceripple.html#a08a13b62b18272366f788632359e8793">ripple::toBase58</a>(<span class="keywordtype">id</span>);</div>
<div class="line"><a name="l00152"></a><span class="lineno"> 152</span>  }</div>
<div class="line"><a name="l00153"></a><span class="lineno"> 153</span>  <span class="keywordflow">if</span> (<a class="code" href="classripple_1_1AccountIDCache.html#a9963e4fa249bf87fd0fd5c1baefd7741">m1_</a>.size() >= <a class="code" href="classripple_1_1AccountIDCache.html#a1468b730efd9722a1a55ff81f0c59b94">capacity_</a>)</div>
<div class="line"><a name="l00154"></a><span class="lineno"> 154</span>  {</div>
<div class="line"><a name="l00155"></a><span class="lineno"> 155</span>  <a class="code" href="classripple_1_1AccountIDCache.html#a945faf739aff5dd35d9f3c7c0bfe4a41">m0_</a> = std::move(<a class="code" href="classripple_1_1AccountIDCache.html#a9963e4fa249bf87fd0fd5c1baefd7741">m1_</a>);</div>
<div class="line"><a name="l00156"></a><span class="lineno"> 156</span>  <a class="code" href="classripple_1_1AccountIDCache.html#a9963e4fa249bf87fd0fd5c1baefd7741">m1_</a>.clear();</div>
<div class="line"><a name="l00157"></a><span class="lineno"> 157</span>  <a class="code" href="classripple_1_1AccountIDCache.html#a9963e4fa249bf87fd0fd5c1baefd7741">m1_</a>.reserve(<a class="code" href="classripple_1_1AccountIDCache.html#a1468b730efd9722a1a55ff81f0c59b94">capacity_</a>);</div>
<div class="line"><a name="l00158"></a><span class="lineno"> 158</span>  }</div>
<div class="line"><a name="l00159"></a><span class="lineno"> 159</span>  <a class="code" href="classripple_1_1AccountIDCache.html#a9963e4fa249bf87fd0fd5c1baefd7741">m1_</a>.emplace(<span class="keywordtype">id</span>, result);</div>
<div class="line"><a name="l00160"></a><span class="lineno"> 160</span>  <span class="keywordflow">return</span> result;</div>
<div class="line"><a name="l00161"></a><span class="lineno"> 161</span> }</div>
<div class="line"><a name="l00162"></a><span class="lineno"> 162</span>  </div>
<div class="line"><a name="l00163"></a><span class="lineno"> 163</span> } <span class="comment">// namespace ripple</span></div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aclassripple_1_1PublicKey_html_a46e654e5021f7a037dbacd14db86fc5e"><div class="ttname"><a href="classripple_1_1PublicKey.html#a46e654e5021f7a037dbacd14db86fc5e">ripple::PublicKey::data</a></div><div class="ttdeci">std::uint8_t const * data() const noexcept</div><div class="ttdef"><b>Definition:</b> <a href="PublicKey_8h_source.html#l00081">PublicKey.h:81</a></div></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 class="ttdoc">STL class.</div></div>
<div class="ttc" id="acstring_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/header/cstring.html">cstring</a></div></div>
<div class="ttc" id="aclassripple_1_1AccountIDCache_html_a1468b730efd9722a1a55ff81f0c59b94"><div class="ttname"><a href="classripple_1_1AccountIDCache.html#a1468b730efd9722a1a55ff81f0c59b94">ripple::AccountIDCache::capacity_</a></div><div class="ttdeci">std::size_t capacity_</div><div class="ttdef"><b>Definition:</b> <a href="AccountID_8h_source.html#l00122">AccountID.h:122</a></div></div>
<div class="ttc" id="aclassripple_1_1AccountIDCache_html_aa85c90f69b07dabacc652080e04d7a41"><div class="ttname"><a href="classripple_1_1AccountIDCache.html#aa85c90f69b07dabacc652080e04d7a41">ripple::AccountIDCache::AccountIDCache</a></div><div class="ttdeci">AccountIDCache(AccountIDCache const &)=delete</div></div>
<div class="ttc" id="anamespaceripple_html_a08a13b62b18272366f788632359e8793"><div class="ttname"><a href="namespaceripple.html#a08a13b62b18272366f788632359e8793">ripple::toBase58</a></div><div class="ttdeci">std::string toBase58(AccountID const &v)</div><div class="ttdoc">Convert AccountID to base58 checked string.</div><div class="ttdef"><b>Definition:</b> <a href="AccountID_8cpp_source.html#l00029">AccountID.cpp:29</a></div></div>
<div class="ttc" id="anamespaceripple_html_a9952e5a413358e9a647b31c86c5835ff"><div class="ttname"><a href="namespaceripple.html#a9952e5a413358e9a647b31c86c5835ff">ripple::decodeBase58Token</a></div><div class="ttdeci">std::string decodeBase58Token(std::string const &s, TokenType type)</div><div class="ttdoc">Decode a token of given type encoded using Base58Check and the XRPL alphabet.</div><div class="ttdef"><b>Definition:</b> <a href="tokens_8cpp_source.html#l00223">tokens.cpp:223</a></div></div>
<div class="ttc" id="alock_guard_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/thread/lock_guard.html">std::lock_guard</a></div><div class="ttdoc">STL class.</div></div>
<div class="ttc" id="aclassripple_1_1base__uint_html_a5342507fe2fb5ac55d578e7e98863f70"><div class="ttname"><a href="classripple_1_1base__uint.html#a5342507fe2fb5ac55d578e7e98863f70">ripple::base_uint::data</a></div><div class="ttdeci">pointer data()</div><div class="ttdef"><b>Definition:</b> <a href="base__uint_8h_source.html#l00115">base_uint.h:115</a></div></div>
<div class="ttc" id="anamespaceripple_html_a1bf8df553d36589191c8057c136cce03aba430b63631349ab773285535e878405"><div class="ttname"><a href="namespaceripple.html#a1bf8df553d36589191c8057c136cce03aba430b63631349ab773285535e878405">ripple::TokenType::AccountID</a></div><div class="ttdeci">@ AccountID</div></div>
<div class="ttc" id="aclassripple_1_1base__uint_html_adbe18ef92b677603e8539b3a77c064b0"><div class="ttname"><a href="classripple_1_1base__uint.html#adbe18ef92b677603e8539b3a77c064b0">ripple::base_uint::size</a></div><div class="ttdeci">constexpr static std::size_t size()</div><div class="ttdef"><b>Definition:</b> <a href="base__uint_8h_source.html#l00498">base_uint.h:498</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< 160, detail::AccountIDTag ></a></div></div>
<div class="ttc" id="aclassripple_1_1AccountIDCache_html_a9963e4fa249bf87fd0fd5c1baefd7741"><div class="ttname"><a href="classripple_1_1AccountIDCache.html#a9963e4fa249bf87fd0fd5c1baefd7741">ripple::AccountIDCache::m1_</a></div><div class="ttdeci">hash_map< AccountID, std::string > m1_</div><div class="ttdef"><b>Definition:</b> <a href="AccountID_8h_source.html#l00124">AccountID.h:124</a></div></div>
<div class="ttc" id="aclassripple_1_1AccountIDCache_html_a31116ba6b6e77fc075c80e746be57446"><div class="ttname"><a href="classripple_1_1AccountIDCache.html#a31116ba6b6e77fc075c80e746be57446">ripple::AccountIDCache::mutex_</a></div><div class="ttdeci">std::mutex mutex_</div><div class="ttdef"><b>Definition:</b> <a href="AccountID_8h_source.html#l00121">AccountID.h:121</a></div></div>
<div class="ttc" id="aclassripple_1_1base__uint_html_a4b9e8d36a37963d48be8f081d99257bf"><div class="ttname"><a href="classripple_1_1base__uint.html#a4b9e8d36a37963d48be8f081d99257bf">ripple::base_uint< 160, detail::AccountIDTag >::bytes</a></div><div class="ttdeci">static constexpr std::size_t bytes</div><div class="ttdef"><b>Definition:</b> <a href="base__uint_8h_source.html#l00098">base_uint.h:98</a></div></div>
<div class="ttc" id="astructripple_1_1ripesha__hasher_html"><div class="ttname"><a href="structripple_1_1ripesha__hasher.html">ripple::ripesha_hasher</a></div><div class="ttdoc">Returns the RIPEMD-160 digest of the SHA256 hash of the message.</div><div class="ttdef"><b>Definition:</b> <a href="digest_8h_source.html#l00131">digest.h:131</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#l00059">PublicKey.h:59</a></div></div>
<div class="ttc" id="aclassripple_1_1PublicKey_html_a663437215503b159ed33b1664e4213a3"><div class="ttname"><a href="classripple_1_1PublicKey.html#a663437215503b159ed33b1664e4213a3">ripple::PublicKey::size</a></div><div class="ttdeci">std::size_t size() const noexcept</div><div class="ttdef"><b>Definition:</b> <a href="PublicKey_8h_source.html#l00087">PublicKey.h:87</a></div></div>
<div class="ttc" id="anamespaceripple_html_a614d8681c8dff84ac2257939751987c5"><div class="ttname"><a href="namespaceripple.html#a614d8681c8dff84ac2257939751987c5">ripple::calcAccountID</a></div><div class="ttdeci">AccountID calcAccountID(PublicKey const &pk)</div><div class="ttdef"><b>Definition:</b> <a href="AccountID_8cpp_source.html#l00080">AccountID.cpp:80</a></div></div>
<div class="ttc" id="aarray_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a></div><div class="ttdoc">STL class.</div></div>
<div class="ttc" id="anamespaceripple_html_a21696ba0d0fac348f88f1b9da51091b0"><div class="ttname"><a href="namespaceripple.html#a21696ba0d0fac348f88f1b9da51091b0">ripple::xrpAccount</a></div><div class="ttdeci">AccountID const & xrpAccount()</div><div class="ttdoc">Compute AccountID from public key.</div><div class="ttdef"><b>Definition:</b> <a href="AccountID_8cpp_source.html#l00090">AccountID.cpp:90</a></div></div>
<div class="ttc" id="aclassripple_1_1AccountIDCache_html_a945faf739aff5dd35d9f3c7c0bfe4a41"><div class="ttname"><a href="classripple_1_1AccountIDCache.html#a945faf739aff5dd35d9f3c7c0bfe4a41">ripple::AccountIDCache::m0_</a></div><div class="ttdeci">hash_map< AccountID, std::string > m0_</div><div class="ttdef"><b>Definition:</b> <a href="AccountID_8h_source.html#l00123">AccountID.h:123</a></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="RCLCensorshipDetector_8h_source.html#l00029">RCLCensorshipDetector.h:29</a></div></div>
<div class="ttc" id="anamespaceripple_html_a4c70c1f85ccff1b830f4bda1becb21b4"><div class="ttname"><a href="namespaceripple.html#a4c70c1f85ccff1b830f4bda1becb21b4">ripple::encodeBase58Token</a></div><div class="ttdeci">std::string encodeBase58Token(TokenType type, void const *token, std::size_t size)</div><div class="ttdoc">Encode data in Base58Check format using XRPL alphabet.</div><div class="ttdef"><b>Definition:</b> <a href="tokens_8cpp_source.html#l00199">tokens.cpp:199</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 class="ttc" id="aclassripple_1_1base__uint_html_a698d3fd0c0f0155995c87d2f48ac90d5"><div class="ttname"><a href="classripple_1_1base__uint.html#a698d3fd0c0f0155995c87d2f48ac90d5">ripple::base_uint::parseHex</a></div><div class="ttdeci">constexpr bool parseHex(std::string_view sv)</div><div class="ttdoc">Parse a hex string into a base_uint.</div><div class="ttdef"><b>Definition:</b> <a href="base__uint_8h_source.html#l00475">base_uint.h:475</a></div></div>
<div class="ttc" id="anamespaceripple_html_a6ed6129376e1d37ef607c2697f5b9d6a"><div class="ttname"><a href="namespaceripple.html#a6ed6129376e1d37ef607c2697f5b9d6a">ripple::parseBase58</a></div><div class="ttdeci">std::optional< AccountID > parseBase58(std::string const &s)</div><div class="ttdoc">Parse AccountID from checked, base58 string.</div><div class="ttdef"><b>Definition:</b> <a href="AccountID_8cpp_source.html#l00036">AccountID.cpp:36</a></div></div>
<div class="ttc" id="anamespaceripple_html_a065cda95aed9cb1d66fb81cad0867ef6"><div class="ttname"><a href="namespaceripple.html#a065cda95aed9cb1d66fb81cad0867ef6">ripple::noAccount</a></div><div class="ttdeci">AccountID const & noAccount()</div><div class="ttdoc">A placeholder for empty accounts.</div><div class="ttdef"><b>Definition:</b> <a href="AccountID_8cpp_source.html#l00097">AccountID.cpp:97</a></div></div>
<div class="ttc" id="anamespaceripple_html_a00ae0d729cb3e35b6bcac9a27ebb5284"><div class="ttname"><a href="namespaceripple.html#a00ae0d729cb3e35b6bcac9a27ebb5284">ripple::AccountID</a></div><div class="ttdeci">base_uint< 160, detail::AccountIDTag > AccountID</div><div class="ttdoc">A 160-bit unsigned that uniquely identifies an account.</div><div class="ttdef"><b>Definition:</b> <a href="AccountID_8h_source.html#l00047">AccountID.h:47</a></div></div>
<div class="ttc" id="aclassripple_1_1AccountIDCache_html_a7c3b7a60b432ff4dcb87dcde20c61c02"><div class="ttname"><a href="classripple_1_1AccountIDCache.html#a7c3b7a60b432ff4dcb87dcde20c61c02">ripple::AccountIDCache::toBase58</a></div><div class="ttdeci">std::string toBase58(AccountID const &) const</div><div class="ttdoc">Return ripple::toBase58 for the AccountID.</div><div class="ttdef"><b>Definition:</b> <a href="AccountID_8cpp_source.html#l00134">AccountID.cpp:134</a></div></div>
<div class="ttc" id="anamespaceripple_html_a300af819bde0c7c49207d10cd787e62e"><div class="ttname"><a href="namespaceripple.html#a300af819bde0c7c49207d10cd787e62e">ripple::to_issuer</a></div><div class="ttdeci">bool to_issuer(AccountID &, std::string const &)</div><div class="ttdoc">Convert hex or base58 string to AccountID.</div><div class="ttdef"><b>Definition:</b> <a href="AccountID_8cpp_source.html#l00104">AccountID.cpp:104</a></div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
</body>
</html>