|
8 | 8 |
|
9 | 9 | #include <clientversion.h>
|
10 | 10 | #include <config/bitcoin-config.h>
|
| 11 | +#include <fs.h> |
| 12 | +#include <hash.h> |
11 | 13 | #include <netaddress.h>
|
12 | 14 | #include <protocol.h>
|
13 | 15 | #include <random.h>
|
| 16 | +#include <streams.h> |
14 | 17 | #include <sync.h>
|
15 | 18 | #include <timedata.h>
|
16 | 19 | #include <tinyformat.h>
|
17 | 20 | #include <util/system.h>
|
18 | 21 |
|
19 |
| -#include <fs.h> |
20 |
| -#include <hash.h> |
21 | 22 | #include <ios>
|
22 |
| -#include <map> |
23 | 23 | #include <optional>
|
24 | 24 | #include <set>
|
25 | 25 | #include <stdint.h>
|
26 |
| -#include <streams.h> |
| 26 | +#include <unordered_map> |
27 | 27 | #include <vector>
|
28 | 28 |
|
29 | 29 | /**
|
@@ -257,7 +257,7 @@ class CAddrMan
|
257 | 257 |
|
258 | 258 | int nUBuckets = ADDRMAN_NEW_BUCKET_COUNT ^ (1 << 30);
|
259 | 259 | s << nUBuckets;
|
260 |
| - std::map<int, int> mapUnkIds; |
| 260 | + std::unordered_map<int, int> mapUnkIds; |
261 | 261 | int nIds = 0;
|
262 | 262 | for (const auto& entry : mapInfo) {
|
263 | 263 | mapUnkIds[entry.first] = nIds;
|
@@ -448,13 +448,13 @@ class CAddrMan
|
448 | 448 |
|
449 | 449 | // Prune new entries with refcount 0 (as a result of collisions).
|
450 | 450 | int nLostUnk = 0;
|
451 |
| - for (std::map<int, CAddrInfo>::const_iterator it = mapInfo.begin(); it != mapInfo.end(); ) { |
| 451 | + for (auto it = mapInfo.cbegin(); it != mapInfo.cend(); ) { |
452 | 452 | if (it->second.fInTried == false && it->second.nRefCount == 0) {
|
453 |
| - std::map<int, CAddrInfo>::const_iterator itCopy = it++; |
| 453 | + const auto itCopy = it++; |
454 | 454 | Delete(itCopy->first);
|
455 |
| - nLostUnk++; |
| 455 | + ++nLostUnk; |
456 | 456 | } else {
|
457 |
| - it++; |
| 457 | + ++it; |
458 | 458 | }
|
459 | 459 | }
|
460 | 460 | if (nLost + nLostUnk > 0) {
|
@@ -682,10 +682,10 @@ class CAddrMan
|
682 | 682 | int nIdCount GUARDED_BY(cs);
|
683 | 683 |
|
684 | 684 | //! table with information about all nIds
|
685 |
| - std::map<int, CAddrInfo> mapInfo GUARDED_BY(cs); |
| 685 | + std::unordered_map<int, CAddrInfo> mapInfo GUARDED_BY(cs); |
686 | 686 |
|
687 | 687 | //! find an nId based on its network address
|
688 |
| - std::map<CService, int> mapAddr GUARDED_BY(cs); |
| 688 | + std::unordered_map<CNetAddr, int, CNetAddrHash> mapAddr GUARDED_BY(cs); |
689 | 689 |
|
690 | 690 | //! randomly-ordered vector of all nIds
|
691 | 691 | //! This is mutable because it is unobservable outside the class, so any
|
|
0 commit comments