aboutsummaryrefslogtreecommitdiff
path: root/src/addrman.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Replace printf with LogPrintf / LogPrintGavin Andresen2013-09-181-4/+1
|
* Split off hash.h from util.hPieter Wuille2012-12-181-0/+1
|
* Trim trailing whitespace for src/*.{h,cpp}Jeff Garzik2012-09-181-2/+2
|
* fix a comment in addrman.cppPhilip Kaufmann2012-08-181-1/+1
|
* Update License in File HeadersFordy2012-05-181-1/+1
| | | | | | 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.
* Clean up warningsPieter Wuille2012-05-091-3/+2
| | | | | | * Use -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameters * Remove xCXXFLAGS usage in makefile.unix * Fix several recent and older sign-compare warnings
* Fix addrman crashesPieter Wuille2012-05-051-2/+5
| | | | | | | | | 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
* Add extra asserts to addrmanPieter Wuille2012-05-051-0/+19
|
* Further reduce header dependenciesPieter Wuille2012-04-171-4/+4
| | | | | | | 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.
* Fix loop index var types, fixing many minor sign comparison warningsJeff Garzik2012-04-151-2/+2
| | | | | foo.size() typically returns an unsigned integral type; make loop variables match those types' signedness.
* fix warnings: '&&' within '||' [-Wlogical-op-parentheses]Wladimir J. van der Laan2012-04-151-1/+1
|
* CAddrMan: stochastic address managerPieter Wuille2012-02-241-0/+506
Design goals: * Only keep a limited number of addresses around, so that addr.dat does not grow without bound. * Keep the address tables in-memory, and occasionally write the table to addr.dat. * Make sure no (localized) attacker can fill the entire table with his nodes/addresses. See comments in addrman.h for more detailed information.