File tree Expand file tree Collapse file tree 3 files changed +14
-9
lines changed Expand file tree Collapse file tree 3 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -218,11 +218,7 @@ void AddrManImpl::Serialize(Stream& s_) const
218
218
}
219
219
// Store asmap checksum after bucket entries so that it
220
220
// can be ignored by older clients for backward compatibility.
221
- uint256 asmap_checksum;
222
- if (m_netgroupman.GetAsmap ().size () != 0 ) {
223
- asmap_checksum = SerializeHash (m_netgroupman.GetAsmap ());
224
- }
225
- s << asmap_checksum;
221
+ s << m_netgroupman.GetAsmapChecksum ();
226
222
}
227
223
228
224
template <typename Stream>
@@ -335,10 +331,7 @@ void AddrManImpl::Unserialize(Stream& s_)
335
331
// If the bucket count and asmap checksum haven't changed, then attempt
336
332
// to restore the entries to the buckets/positions they were in before
337
333
// serialization.
338
- uint256 supplied_asmap_checksum;
339
- if (m_netgroupman.GetAsmap ().size () != 0 ) {
340
- supplied_asmap_checksum = SerializeHash (m_netgroupman.GetAsmap ());
341
- }
334
+ uint256 supplied_asmap_checksum{m_netgroupman.GetAsmapChecksum ()};
342
335
uint256 serialized_asmap_checksum;
343
336
if (format >= Format::V2_ASMAP) {
344
337
s >> serialized_asmap_checksum;
Original file line number Diff line number Diff line change 4
4
5
5
#include < netgroup.h>
6
6
7
+ #include < hash.h>
7
8
#include < util/asmap.h>
8
9
10
+ uint256 NetGroupManager::GetAsmapChecksum () const
11
+ {
12
+ if (!m_asmap.size ()) return {};
13
+
14
+ return SerializeHash (m_asmap);
15
+ }
16
+
9
17
std::vector<unsigned char > NetGroupManager::GetGroup (const CNetAddr& address) const
10
18
{
11
19
std::vector<unsigned char > vchRet;
Original file line number Diff line number Diff line change 6
6
#define BITCOIN_NETGROUP_H
7
7
8
8
#include < netaddress.h>
9
+ #include < uint256.h>
9
10
10
11
#include < vector>
11
12
@@ -22,6 +23,9 @@ class NetGroupManager {
22
23
* exists, since the data is const. */
23
24
const std::vector<bool >& GetAsmap () const { return m_asmap; }
24
25
26
+ /* * Get a checksum identifying the asmap being used. */
27
+ uint256 GetAsmapChecksum () const ;
28
+
25
29
/* *
26
30
* Get the canonical identifier of the network group for address.
27
31
*
You can’t perform that action at this time.
0 commit comments