aboutsummaryrefslogtreecommitdiff
path: root/src/addrman.h
Commit message (Collapse)AuthorAgeFilesLines
* Increment MIT Licence copyright header year on files modified in 2016isle29832016-12-311-1/+1
| | | | | | Edited via: $ contrib/devtools/copyright_header.py update .
* Remove double brackets in addrmanMatt Corallo2016-11-261-18/+12
|
* Fix AddrMan lockingMatt Corallo2016-11-261-13/+10
|
* Get rid of nType and nVersionPieter Wuille2016-11-071-3/+3
| | | | | | | | | | | Remove the nType and nVersion as parameters to all serialization methods and functions. There is only one place where it's read and has an impact (in CAddress), and even there it does not impact any of the recursively invoked serializers. Instead, the few places that need nType or nVersion are changed to read it directly from the stream object, through GetType() and GetVersion() methods which are added to all stream classes.
* Make GetSerializeSize a wrapper on top of CSizeComputerPieter Wuille2016-11-071-5/+0
| | | | | | | | | | | Given that in default GetSerializeSize implementations created by ADD_SERIALIZE_METHODS we're already using CSizeComputer(), get rid of the specialized GetSerializeSize methods everywhere, and just use CSizeComputer. This removes a lot of code which isn't actually used anywhere. For CCompactSize and CVarInt this actually removes a more efficient size computing algorithm, which is brought back in a later commit.
* Kill insecure_random and associated global stateWladimir J. van der Laan2016-10-171-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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`.
* net: narrow include scope after moving to netaddressCory Fields2016-07-311-1/+1
| | | | | Net functionality is no longer needed for CAddress/CAddrman/etc. now that CNetAddr/CService/CSubNet are dumb storage classes.
* Introduce enum ServiceFlags for service flagsPieter Wuille2016-06-131-2/+2
|
* Keep addrman's nService bits consistent with outbound observationsPieter Wuille2016-06-131-0/+11
|
* Do not increment nAttempts by more than one for every Good connection.Gregory Maxwell2016-05-261-0/+8
| | | | | 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-3/+3
| | | | | | | | | | | | | | | | | | | | | 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).
* CAddrMan::Deserialize handle corrupt serializations better.Patrick Strateman2016-04-241-0/+8
|
* Merge #7212: Adds unittests for CAddrMan and CAddrinfo, removes source of ↵Wladimir J. van der Laan2016-01-281-8/+5
|\ | | | | | | | | | | non-determinism. 40c87b6 Increase test coverage for addrman and addrinfo (Ethan Heilman)
| * Increase test coverage for addrman and addrinfoEthan Heilman2016-01-271-8/+5
| | | | | | | | | | | | | | 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-4/+12
| | | | | Adds several unittests for addrman to verify it works as expected. Makes small modifications to addrman to allow deterministic and targeted tests.
* typofixes (found by misspell_fixer)Veres Lajos2015-08-101-1/+1
|
* make CAddrMan::size() return the correct type of size_tPhilip Kaufmann2015-06-151-1/+1
|
* Comment edits and cleanupBitcoinPRReadingGroup2015-05-141-3/+3
| | | | Original PR here: https://github.com/bitcoin/bitcoin/pull/6044
* addrman: update commentsPavel Vasin2015-05-141-2/+0
| | | | nUnkBias was removed in https://github.com/bitcoin/bitcoin/pull/5941
* Non-grammatical language improvementsLuke Dashjr2015-05-021-1/+1
|
* Bugfix: Grammar fixesCorinne Dashjr2015-05-011-3/+3
|
* nLastTry is only used for addrman entriesPieter Wuille2015-04-191-6/+7
| | | | No need to define it for every CAddress, as it's memory only anyway.
* Scale up addrmanPieter Wuille2015-03-231-10/+10
| | | | | | | This change was suggested as Countermeasure 6 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.
* Always use a 50% chance to choose between tried and new entriesPieter Wuille2015-03-231-3/+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.
* Make addrman's bucket placement deterministic.Pieter Wuille2015-03-231-60/+107
| | | | | | | | | | | | | | | 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/+15
|
* Fix all header definesPavel Janík2014-11-031-3/+3
|
* Update comments in addrman to be doxygen compatibleMichael Ford2014-10-241-115/+124
| | | | Also correct the file license
* Remove some unnecessary c_strs() in logging and the GUIPhilip Kaufmann2014-09-091-1/+1
| | | | | Includes `core: remove unneeded c_str() / Qt: replace c_str() with Qt code` by P. Kaufmann.
* Rename IMPLEMENT_SERIALIZE to ADD_SERIALIZE_METHODSPieter Wuille2014-09-021-2/+2
|
* Merge pull request #4737Pieter Wuille2014-09-011-4/+6
|\ | | | | | | | | | | | | 31e9a83 Use CSizeComputer to avoid counting sizes in SerializationOp (Pieter Wuille) 84881f8 rework overhauled serialization methods to non-static (Kamil Domanski) 5d96b4a remove fields of ser_streamplaceholder (Kamil Domanski) 3d796f8 overhaul serialization code (Kamil Domanski)
| * Use CSizeComputer to avoid counting sizes in SerializationOpPieter Wuille2014-08-311-5/+2
| |
| * rework overhauled serialization methods to non-staticKamil Domanski2014-08-311-7/+7
| | | | | | | | | | | | | | Thanks to Pieter Wuille for most of the work on this commit. I did not fixup the overhaul commit, because a rebase conflicted with "remove fields of ser_streamplaceholder". I prefer not to risk making a mistake while resolving it.
| * overhaul serialization codeKamil Domanski2014-08-311-6/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The implementation of each class' serialization/deserialization is no longer passed within a macro. The implementation now lies within a template of form: template <typename T, typename Stream, typename Operation> inline static size_t SerializationOp(T thisPtr, Stream& s, Operation ser_action, int nType, int nVersion) { size_t nSerSize = 0; /* CODE */ return nSerSize; } In cases when codepath should depend on whether or not we are just deserializing (old fGetSize, fWrite, fRead flags) an additional clause can be used: bool fRead = boost::is_same<Operation, CSerActionUnserialize>(); The IMPLEMENT_SERIALIZE macro will now be a freestanding clause added within class' body (similiar to Qt's Q_OBJECT) to implement GetSerializeSize, Serialize and Unserialize. These are now wrappers around the "SerializationOp" template.
* | add missing header end commentsPhilip Kaufmann2014-08-281-2/+2
|/ | | | | | - ensures a consistent usage in header files - also add a blank line after the copyright header where missing - also remove orphan new-lines at the end of some files
* Break up CAddrMan's IMPLEMENT_SERIALIZEPieter Wuille2014-07-161-129/+131
|
* move rand functions from util to new random.h/.cppPhilip Kaufmann2014-07-091-0/+1
|
* add GetRandBytes() as wrapper for RAND_bytes()Philip Kaufmann2014-07-091-3/+1
| | | | | | - add a small wrapper in util around RAND_bytes() and replace with GetRandBytes() in the code to log errors from calling RAND_bytes() - remove OpenSSL header rand.h where no longer needed
* Move network-time related functions to timedata.cpp/hWladimir J. van der Laan2014-06-251-0/+1
| | | | | The network time-offset-mangement functions from util.cpp are moved to timedata.(cpp|h). This breaks the dependency of util on netbase.
* Remove redundant c_strR E Broadley2014-05-221-2/+2
|
* Cleanup code using forward declarations.Brandon Dahler2013-11-101-16/+17
| | | | | | | | | 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.
* re-work -debug switch handlingPhilip Kaufmann2013-10-301-2/+2
| | | | | | | | | | | | - re-work -debug help message text - make -debug log every debugging information again (even all categories) - remove unneeded fDebug checks in front of LogPrint()/qDebug(), as that check is done in LogPrintf() when category is != NULL (true for all LogPrint() calls - remove fDebug ONLY in code which is NOT performance-critical - harmonize addrman category name - deprecate -debugnet usage, should be used via -debug=net and remove the corresponding global
* Replace printf with LogPrintf / LogPrintGavin Andresen2013-09-181-3/+3
|
* Trim trailing whitespace for src/*.{h,cpp}Jeff Garzik2012-09-181-1/+1
|
* Bugfix: Correct English grammar regarding "'s"Luke Dashjr2012-08-011-4/+4
|
* Bugfix: Fix a variety of misspellingsLuke Dashjr2012-08-011-1/+1
|
* Fix a few typosfanquake2012-06-291-2/+2
|
* 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.
* Split synchronization mechanisms from util.{h,cpp}Pieter Wuille2012-05-111-0/+1
|