aboutsummaryrefslogtreecommitdiff
path: root/src/addrman.cpp
AgeCommit message (Collapse)Author
2017-11-16scripted-diff: Replace #include "" with #include <> (ryanofsky)MeshCollider
-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-
2017-08-07scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal ↵practicalswift
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-
2017-04-24Merge #9792: FastRandomContext improvements and switch to ChaCha20Wladimir J. van der Laan
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
2017-04-01Change LogAcceptCategory to use uint32_t rather than sets of strings.Gregory Maxwell
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.
2017-03-29Switch FastRandomContext to ChaCha20Pieter Wuille
2017-02-07Use z = std::max(x - y, 0); instead of z = x - y; if (z < 0) z = 0;practicalswift
2017-02-07Merge #9532: Remove unused variablesWladimir J. van der Laan
90fd29b Remove unused int64_t nSinceLastSeen (practicalswift) ac4a095 Remove unused Python variables (practicalswift)
2017-01-27[trivial] Fix typos in commentspracticalswift
2017-01-13Remove unused int64_t nSinceLastSeenpracticalswift
2016-12-31Increment MIT Licence copyright header year on files modified in 2016isle2983
Edited via: $ contrib/devtools/copyright_header.py update .
2016-10-17Kill insecure_random and associated global stateWladimir J. van der Laan
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`.
2016-09-03Do not set an addr time penalty when a peer advertises itself.Gregory Maxwell
Claims a peer makes about itself are inherently more credible.
2016-06-13Introduce enum ServiceFlags for service flagsPieter Wuille
2016-06-13Keep addrman's nService bits consistent with outbound observationsPieter Wuille
2016-05-26Do not increment nAttempts by more than one for every Good connection.Gregory Maxwell
This slows the increase of the nAttempts in addrman while partitioned, even if the node hasn't yet noticed the partitioning.
2016-05-26Avoid counting failed connect attempts when probably offline.Gregory Maxwell
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).
2016-01-28Merge #7212: Adds unittests for CAddrMan and CAddrinfo, removes source of ↵Wladimir J. van der Laan
non-determinism. 40c87b6 Increase test coverage for addrman and addrinfo (Ethan Heilman)
2016-01-27Increase test coverage for addrman and addrinfoEthan Heilman
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.
2016-01-05Add missing copyright headersMarcoFalke
2015-09-24Creates unittests for addrman, makes addrman testable.EthanHeilman
Adds several unittests for addrman to verify it works as expected. Makes small modifications to addrman to allow deterministic and targeted tests.
2015-08-26Improve addrman Select() performance when buckets are nearly emptyPieter Wuille
2015-06-15remove using namespace std from addrman.cppPhilip Kaufmann
2015-04-24Merge pull request #6028Wladimir J. van der Laan
1d5b47a nLastTry is only used for addrman entries (Pieter Wuille)
2015-04-19Cap nAttempts penalty at 8 and switch to pow instead of a division loop.Gregory Maxwell
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).
2015-04-19nLastTry is only used for addrman entriesPieter Wuille
No need to define it for every CAddress, as it's memory only anyway.
2015-03-23Always use a 50% chance to choose between tried and new entriesPieter Wuille
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.
2015-03-23Do not bias outgoing connections towards fresh addressesPieter Wuille
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.
2015-03-23Simplify hashing codePieter Wuille
2015-03-23Make addrman's bucket placement deterministic.Pieter Wuille
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.
2015-03-23Switch addrman key from vector to uint256Pieter Wuille
2015-03-17Reduce fingerprinting through timestamps in 'addr' messages.Pieter Wuille
Suggested by Jonas Nick.
2015-01-05Replace GetLow64 with GetCheapHashWladimir J. van der Laan
2014-10-27Merge pull request #5119Pieter Wuille
fa73619 boost: split stream classes out of serialize.h (Cory Fields)
2014-10-24Update comments in addrman to be doxygen compatibleMichael Ford
Also correct the file license
2014-10-22boost: split stream classes out of serialize.hCory Fields
serialization now has no dependencies.
2014-09-19Apply clang-format on some infrequently-updated filesPieter Wuille
2014-09-05Improve readability of CAddrInfo::IsTerribleTeran McKinney
- Replaced 86400 with 24*60*60 - Remove references to specific timespans in comments Github-Pull: #4724
2014-08-18addrman: Do not propagate obviously poor addresses onto the networkJeff Garzik
2014-01-23Remove redundant .c_str()sWladimir J. van der Laan
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.
2013-12-25Changed Get64(.) to GetLow64()Thomas Holenstein
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.
2013-11-10Cleanup code using forward declarations.Brandon Dahler
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.
2013-09-18Replace printf with LogPrintf / LogPrintGavin Andresen
2012-12-18Split off hash.h from util.hPieter Wuille
2012-09-18Trim trailing whitespace for src/*.{h,cpp}Jeff Garzik
2012-08-18fix a comment in addrman.cppPhilip Kaufmann
2012-05-18Update License in File HeadersFordy
I originally created a pull to replace the "COPYING" in crypter.cpp and crypter.h, but it turned out that COPYING was actually the correct file.
2012-05-09Clean up warningsPieter Wuille
* Use -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameters * Remove xCXXFLAGS usage in makefile.unix * Fix several recent and older sign-compare warnings
2012-05-05Fix addrman crashesPieter Wuille
A function returned the element to remove from a bucket, instead of its position in that bucket. This function was only called when a tried bucket overflowed, which only happens after many outgoing connections have been made. Closes: #1065, #1156
2012-05-05Add extra asserts to addrmanPieter Wuille
2012-04-17Further reduce header dependenciesPieter Wuille
This commit removes the dependency of serialize.h on PROTOCOL_VERSION, and makes this parameter required instead of implicit. This is much saner, as it makes the places where changing a version number can have an influence obvious.