aboutsummaryrefslogtreecommitdiff
path: root/src/addrman.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright headers to 2018DrahtBot2018-07-271-1/+1
|
* scripted-diff: Remove trailing whitespacesJoão Barbosa2018-07-241-1/+1
| | | | | | | | -BEGIN VERIFY SCRIPT- sed --in-place'' --regexp-extended 's/[[:space:]]+$//g' $(git grep -I --files-with-matches --extended-regexp '[[:space:]]+$' -- src test ':!*.svg' ':!src/crypto/sha256_sse4*' ':!src/leveldb' ':!src/qt/locale' ':!src/secp256k1' ':!src/univalue') -END VERIFY SCRIPT-
* net: Correct addrman loggingWladimir J. van der Laan2018-03-061-2/+2
| | | | | | These were introduced in #9037. Found by @theuni.
* Add test-before-evict discipline to addrmanEthan Heilman2018-03-061-4/+95
| | | | | | | | | | | | | Changes addrman to use the test-before-evict discipline in which an address is to be evicted from the tried table is first tested and if it is still online it is not evicted. Adds tests to provide test coverage for this change. This change was suggested as Countermeasure 3 in Eclipse Attacks on Bitcoin’s Peer-to-Peer Network, Ethan Heilman, Alison Kendler, Aviv Zohar, Sharon Goldberg. ePrint Archive Report 2015/263. March 2015.
* Merge #11577: Fix warnings (-Wsign-compare) when building with DEBUG_ADDRMANWladimir J. van der Laan2018-01-291-4/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 6eddd43 Fix warnings when building with DEBUG_ADDRMAN (practicalswift) Pull request description: Fix warnings when building with `DEBUG_ADDRMAN`. Warnings prior to this commit: ``` addrman.cpp:390:24: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare] if (vRandom.size() != nTried + nNew) ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~ addrman.cpp:411:52: warning: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare] if (info.nRandomPos < 0 || info.nRandomPos >= vRandom.size() || vRandom[info.nRandomPos] != n) ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~ addrman.cpp:419:25: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare] if (setTried.size() != nTried) ~~~~~~~~~~~~~~~ ^ ~~~~~~ addrman.cpp:421:23: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare] if (mapNew.size() != nNew) ~~~~~~~~~~~~~ ^ ~~~~ 4 warnings generated. ``` Tree-SHA512: 0316faecfe95066d2c9a0b6b3960086e43824f21a67086a895ea45fbce1327f8d6df5945fe923c2dbe4efce430bc1384d515d317c3930d97d24965e507cf734d
| * Fix warnings when building with DEBUG_ADDRMANpracticalswift2017-10-301-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Warnings prior to this commit: ``` addrman.cpp:390:24: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare] if (vRandom.size() != nTried + nNew) ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~ addrman.cpp:411:52: warning: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare] if (info.nRandomPos < 0 || info.nRandomPos >= vRandom.size() || vRandom[info.nRandomPos] != n) ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~ addrman.cpp:419:25: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare] if (setTried.size() != nTried) ~~~~~~~~~~~~~~~ ^ ~~~~~~ addrman.cpp:421:23: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare] if (mapNew.size() != nNew) ~~~~~~~~~~~~~ ^ ~~~~ 4 warnings generated. ```
* | Increment MIT Licence copyright header year on files modified in 2017Akira Takizawa2018-01-031-1/+1
| |
* | Merge #10493: Use range-based for loops (C++11) when looping over map elementsMarcoFalke2017-11-301-3/+3
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 680bc2cbb Use range-based for loops (C++11) when looping over map elements (practicalswift) Pull request description: Before this commit: ```c++ for (std::map<T1, T2>::iterator x = y.begin(); x != y.end(); ++x) { T1 z = (*x).first; … } ``` After this commit: ```c++ for (auto& x : y) { T1 z = x.first; … } ``` Tree-SHA512: 954b136b7f5e6df09f39248a6b530fd9baa9ab59d7c2c7eb369fd4afbb591b7a52c92ee25f87f1745f47b41d6828b7abfd395b43daf84a55b4e6a3d45015e3a0
| * | Use range-based for loops (C++11) when looping over map elementspracticalswift2017-10-091-3/+3
| |/ | | | | | | | | | | | | | | | | | | | | | | Before this commit: for (std::map<T1, T2>::iterator x = y.begin(); x != y.end(); ++x) { } After this commit: for (auto& x : y) { }
* / scripted-diff: Replace #include "" with #include <> (ryanofsky)MeshCollider2017-11-161-4/+4
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -BEGIN VERIFY SCRIPT- for f in \ src/*.cpp \ src/*.h \ src/bench/*.cpp \ src/bench/*.h \ src/compat/*.cpp \ src/compat/*.h \ src/consensus/*.cpp \ src/consensus/*.h \ src/crypto/*.cpp \ src/crypto/*.h \ src/crypto/ctaes/*.h \ src/policy/*.cpp \ src/policy/*.h \ src/primitives/*.cpp \ src/primitives/*.h \ src/qt/*.cpp \ src/qt/*.h \ src/qt/test/*.cpp \ src/qt/test/*.h \ src/rpc/*.cpp \ src/rpc/*.h \ src/script/*.cpp \ src/script/*.h \ src/support/*.cpp \ src/support/*.h \ src/support/allocators/*.h \ src/test/*.cpp \ src/test/*.h \ src/wallet/*.cpp \ src/wallet/*.h \ src/wallet/test/*.cpp \ src/wallet/test/*.h \ src/zmq/*.cpp \ src/zmq/*.h do base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f done -END VERIFY SCRIPT-
* scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal ↵practicalswift2017-08-071-2/+2
| | | | | | | | | | | | | instead of the macro NULL -BEGIN VERIFY SCRIPT- sed -i 's/\<NULL\>/nullptr/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/qt/*/*.cpp src/qt/*/*.h src/wallet/*/*.cpp src/wallet/*/*.h src/support/allocators/*.h sed -i 's/Prefer nullptr, otherwise SAFECOOKIE./Prefer NULL, otherwise SAFECOOKIE./g' src/torcontrol.cpp sed -i 's/tor: Using nullptr authentication/tor: Using NULL authentication/g' src/torcontrol.cpp sed -i 's/METHODS=nullptr/METHODS=NULL/g' src/test/torcontrol_tests.cpp src/torcontrol.cpp sed -i 's/nullptr certificates/NULL certificates/g' src/qt/paymentserver.cpp sed -i 's/"nullptr"/"NULL"/g' src/torcontrol.cpp src/test/torcontrol_tests.cpp -END VERIFY SCRIPT-
* Merge #9792: FastRandomContext improvements and switch to ChaCha20Wladimir J. van der Laan2017-04-241-4/+4
|\ | | | | | | | | | | | | | | | | | | 4fd2d2f Add a FastRandomContext::randrange and use it (Pieter Wuille) 1632922 Switch FastRandomContext to ChaCha20 (Pieter Wuille) e04326f Add ChaCha20 (Pieter Wuille) 663fbae FastRandom benchmark (Pieter Wuille) c21cbe6 Introduce FastRandomContext::randbool() (Pieter Wuille) Tree-SHA512: 7fff61e3f6d6dc6ac846ca643d877b377db609646dd401a0e8f50b052c6b9bcd2f5fc34de6bbf28f04afd1724f6279ee163ead5f37d724fb782a00239f35db1d
| * Switch FastRandomContext to ChaCha20Pieter Wuille2017-03-291-4/+4
| |
* | Change LogAcceptCategory to use uint32_t rather than sets of strings.Gregory Maxwell2017-04-011-1/+1
|/ | | | | | | | | | | | | | | | | This changes the logging categories to boolean flags instead of strings. This simplifies the acceptance testing by avoiding accessing a scoped static thread local pointer to a thread local set of strings. It eliminates the only use of boost::thread_specific_ptr outside of lockorder debugging. This change allows log entries to be directed to multiple categories and makes it easy to change the logging flags at runtime (e.g. via an RPC, though that isn't done by this commit.) It also eliminates the fDebug global. Configuration of unknown logging categories now produces a warning.
* Use z = std::max(x - y, 0); instead of z = x - y; if (z < 0) z = 0;practicalswift2017-02-071-5/+1
|
* Merge #9532: Remove unused variablesWladimir J. van der Laan2017-02-071-3/+0
|\ | | | | | | | | 90fd29b Remove unused int64_t nSinceLastSeen (practicalswift) ac4a095 Remove unused Python variables (practicalswift)
| * Remove unused int64_t nSinceLastSeenpracticalswift2017-01-131-3/+0
| |
* | [trivial] Fix typos in commentspracticalswift2017-01-271-1/+1
|/
* Increment MIT Licence copyright header year on files modified in 2016isle29832016-12-311-1/+1
| | | | | | Edited via: $ contrib/devtools/copyright_header.py update .
* Kill insecure_random and associated global stateWladimir J. van der Laan2016-10-171-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are only a few uses of `insecure_random` outside the tests. This PR replaces uses of insecure_random (and its accompanying global state) in the core code with an FastRandomContext that is automatically seeded on creation. This is meant to be used for inner loops. The FastRandomContext can be in the outer scope, or the class itself, then rand32() is used inside the loop. Useful e.g. for pushing addresses in CNode or the fee rounding, or randomization for coin selection. As a context is created per purpose, thus it gets rid of cross-thread unprotected shared usage of a single set of globals, this should also get rid of the potential race conditions. - I'd say TxMempool::check is not called enough to warrant using a special fast random context, this is switched to GetRand() (open for discussion...) - The use of `insecure_rand` in ConnectThroughProxy has been replaced by an atomic integer counter. The only goal here is to have a different credentials pair for each connection to go on a different Tor circuit, it does not need to be random nor unpredictable. - To avoid having a FastRandomContext on every CNode, the context is passed into PushAddress as appropriate. There remains an insecure_random for test usage in `test_random.h`.
* Do not set an addr time penalty when a peer advertises itself.Gregory Maxwell2016-09-031-0/+5
| | | | Claims a peer makes about itself are inherently more credible.
* Introduce enum ServiceFlags for service flagsPieter Wuille2016-06-131-2/+2
|
* Keep addrman's nService bits consistent with outbound observationsPieter Wuille2016-06-131-0/+18
|
* Do not increment nAttempts by more than one for every Good connection.Gregory Maxwell2016-05-261-1/+7
| | | | | This slows the increase of the nAttempts in addrman while partitioned, even if the node hasn't yet noticed the partitioning.
* Avoid counting failed connect attempts when probably offline.Gregory Maxwell2016-05-261-2/+2
| | | | | | | | | | | | | | | | | | | | | If a node is offline failed outbound connection attempts will crank up the addrman counter and effectively blow away our state. This change reduces the problem by only counting attempts made while the node believes it has outbound connections to at least two netgroups. Connect and addnode connections are also not counted, as there is no reason to unequally penalize them for their more frequent connections -- though there should be no real effect from this unless their addnode configureation is later removed. Wasteful repeated connection attempts while only a few connections are up are avoided via nLastTry. This is still somewhat incomplete protection because our outbound peers could be down but not timed out or might all be on 'local' networks (although the requirement for multiple netgroups helps).
* Merge #7212: Adds unittests for CAddrMan and CAddrinfo, removes source of ↵Wladimir J. van der Laan2016-01-281-10/+14
|\ | | | | | | | | | | non-determinism. 40c87b6 Increase test coverage for addrman and addrinfo (Ethan Heilman)
| * Increase test coverage for addrman and addrinfoEthan Heilman2016-01-271-10/+14
| | | | | | | | | | | | | | Adds several unittests for CAddrMan and CAddrInfo. Increases the accuracy of addrman tests. Removes non-determinism in tests by overriding the random number generator. Extracts testing code from addrman class to test class.
* | Add missing copyright headersMarcoFalke2016-01-051-0/+1
|/
* Creates unittests for addrman, makes addrman testable.EthanHeilman2015-09-241-2/+6
| | | | | Adds several unittests for addrman to verify it works as expected. Makes small modifications to addrman to allow deterministic and targeted tests.
* Improve addrman Select() performance when buckets are nearly emptyPieter Wuille2015-08-261-4/+8
|
* remove using namespace std from addrman.cppPhilip Kaufmann2015-06-151-5/+3
|
* Merge pull request #6028Wladimir J. van der Laan2015-04-241-2/+2
|\ | | | | | | 1d5b47a nLastTry is only used for addrman entries (Pieter Wuille)
| * nLastTry is only used for addrman entriesPieter Wuille2015-04-191-2/+2
| | | | | | | | No need to define it for every CAddress, as it's memory only anyway.
* | Cap nAttempts penalty at 8 and switch to pow instead of a division loop.Gregory Maxwell2015-04-191-3/+2
|/ | | | | | | | On hosts that had spent some time with a failed internet connection their nAttempts penalty was going through the roof (e.g. thousands for all peers) and as a result the connect search was pegging the CPU and failing to get more than a 4 connections after days of running (because it was taking so long per try).
* Always use a 50% chance to choose between tried and new entriesPieter Wuille2015-03-231-4/+3
| | | | | | | This change was suggested as Countermeasure 2 in Eclipse Attacks on Bitcoin’s Peer-to-Peer Network, Ethan Heilman, Alison Kendler, Aviv Zohar, Sharon Goldberg. ePrint Archive Report 2015/263. March 2015.
* Do not bias outgoing connections towards fresh addressesPieter Wuille2015-03-231-2/+0
| | | | | | | This change was suggested as Countermeasure 2 in Eclipse Attacks on Bitcoin’s Peer-to-Peer Network, Ethan Heilman, Alison Kendler, Aviv Zohar, Sharon Goldberg. ePrint Archive Report 2015/263. March 2015.
* Simplify hashing codePieter Wuille2015-03-231-21/+5
|
* Make addrman's bucket placement deterministic.Pieter Wuille2015-03-231-146/+124
| | | | | | | | | | | | | | | Give each address a single fixed location in the new and tried tables, which become simple fixed-size arrays instead of sets and vectors. This prevents attackers from having an advantages by inserting an address multiple times. This change was suggested as Countermeasure 1 in Eclipse Attacks on Bitcoin’s Peer-to-Peer Network, Ethan Heilman, Alison Kendler, Aviv Zohar, Sharon Goldberg. ePrint Archive Report 2015/263. March 2015. It is also more efficient.
* Switch addrman key from vector to uint256Pieter Wuille2015-03-231-6/+8
|
* Reduce fingerprinting through timestamps in 'addr' messages.Pieter Wuille2015-03-171-1/+2
| | | | Suggested by Jonas Nick.
* Replace GetLow64 with GetCheapHashWladimir J. van der Laan2015-01-051-4/+4
|
* Merge pull request #5119Pieter Wuille2014-10-271-0/+1
|\ | | | | | | fa73619 boost: split stream classes out of serialize.h (Cory Fields)
| * boost: split stream classes out of serialize.hCory Fields2014-10-221-0/+1
| | | | | | | | serialization now has no dependencies.
* | Update comments in addrman to be doxygen compatibleMichael Ford2014-10-241-4/+4
|/ | | | Also correct the file license
* Apply clang-format on some infrequently-updated filesPieter Wuille2014-09-191-115/+110
|
* Improve readability of CAddrInfo::IsTerribleTeran McKinney2014-09-051-3/+3
| | | | | | | - Replaced 86400 with 24*60*60 - Remove references to specific timespans in comments Github-Pull: #4724
* addrman: Do not propagate obviously poor addresses onto the networkJeff Garzik2014-08-181-4/+10
|
* Remove redundant .c_str()sWladimir J. van der Laan2014-01-231-1/+1
| | | | | | | After the tinyformat switch sprintf() family functions support passing actual std::string objects. Remove unnecessary c_str calls (236 of them) in logging and formatting.
* Changed Get64(.) to GetLow64()Thomas Holenstein2013-12-251-4/+4
| | | | | | | The function Get64(.) has a bug in case the width is not divisible by 64. Since it is only ever used as Get64(0) this simply changes it to this special case. Additionally, an assert is added, and a cast to prevent a compiler error.
* Cleanup code using forward declarations.Brandon Dahler2013-11-101-17/+19
| | | | | | | | | Use misc methods of avoiding unnecesary header includes. Replace int typedefs with int##_t from stdint.h. Replace PRI64[xdu] with PRI[xdu]64 from inttypes.h. Normalize QT_VERSION ifs where possible. Resolve some indirect dependencies as direct ones. Remove extern declarations from .cpp files.