aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
AgeCommit message (Collapse)Author
2017-05-09Merge #9279: Consensus: Move CFeeRate out of libconsensusWladimir J. van der Laan
381a46e Consensus: Policy: MOVEONLY: Move CFeeRate out of the consensus module (Jorge Timón) 330bb5a Consensus: Minimal way to move dust out of consensus (Jorge Timón) Tree-SHA512: 19a2ea8169afd5a9d3f940d8974e34cfaead153e3ff3068ac82fccdb8694d19d9b45938904ec9e8cd095bd5ca3a0080364da29372f6aaf56b11a6c2ccd6c7a4d
2017-05-04net: make CNode's id privateCory Fields
2017-05-03Consensus: Policy: MOVEONLY: Move CFeeRate out of the consensus moduleJorge Timón
...from amount.o to policy/feerate.o Policy, because it moves policy code to the policy directory (common module)
2017-04-26Merge #9930: Trivial: Correct indentation and bracingWladimir J. van der Laan
31a14d4 Correct indentation and remove unnecessary braces (Matthias Grundmann) Tree-SHA512: c0e827ec4474133c7674254dfd13f59608820cd639debc7759bddae71d73451645fcfe14384f343d08f74d69ac3922bafc12a514f3b790ae2bf9271aa67d5f36
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-20Merge #10181: Include cleanupWladimir J. van der Laan
1c897fc Missing includes (Jorge Timón) a1fd450 Trivial: Remove unneeded includes from .h: (Jorge Timón) Tree-SHA512: ada3e62cc2435e58172a88b380be371b717a05725956c15e5493b6e19fe2903e5e6e43fd22dc24699333a0e8a0c7b42eb1ae61b41cb4ba82495be18e2d4ef3c6
2017-04-13Merge #10176: net: gracefully handle NodeId wrappingWladimir J. van der Laan
c851be4 net: define NodeId as an int64_t (Cory Fields) Tree-SHA512: 2ccc931cfcdc555313b9434d8de2f6cea759b31891212ca62f962208f60157d4fc593010e3ca61265d1a20d6f78c6ca79103600b85df77983d5509d192875b96
2017-04-13Trivial: Remove unneeded includes from .h:Jorge Timón
- validation.h doesn't need to include chain.h anymore - Remove unneeded includes from net.h
2017-04-12net: define NodeId as an int64_tCory Fields
This should make occurances of NodeId wrapping essentially impossible for real-world usage.
2017-04-03Replace includes of boost/filesystem.h with fs.hWladimir J. van der Laan
This is step one in abstracting the use of boost::filesystem.
2017-04-02Correct indentation and remove unnecessary bracesMatthias Grundmann
2017-03-29Add a FastRandomContext::randrange and use itPieter Wuille
2017-03-17Remove unused codepracticalswift
2017-02-10Move CNode::addrLocal access behind locked accessorsMatt Corallo
2017-02-10Move CNode::addrName accesses behind locked accessorsMatt Corallo
2017-02-10Move [clean|str]SubVer writes/copyStats into a lockMatt Corallo
2017-02-10Make nServices atomicMatt Corallo
2017-02-10Make nStartingHeight atomicMatt Corallo
2017-02-10Make nTimeConnected const in CNodeMatt Corallo
2017-02-10net: fix a few races. Credit @TheBlueMattCory Fields
These are (afaik) all long-standing races or concurrent accesses. Going forward, we can clean these up so that they're not all individual atomic accesses. - Reintroduce cs_vRecv to guard receive-specific vars - Lock vRecv/vSend for CNodeStats - Make some vars atomic. - Only set the connection time in CNode's constructor so that it doesn't change
2017-02-06net: add a lock around hSocketCory Fields
2017-02-06Merge #9659: Net: Turn some methods and params/variables constWladimir J. van der Laan
0729102 Net: pass interruptMsgProc as const where possible (Jorge Timón) fc7f2ff Net: Make CNetMsgMaker more const (Jorge Timón) d45955f Net: CConnman: Make some methods const (Jorge Timón)
2017-02-02net: log an error rather than asserting if send version is misusedCory Fields
Also cleaned up the comments and moved from the header to the .cpp so that logging headers aren't needed from net.h
2017-02-02net: don't run callbacks on nodes that haven't completed the version handshakeCory Fields
Since ForEach* are can be used to send messages to all nodes, the caller may end up sending a message before the version handshake is complete. To limit this, filter out these nodes. While we're at it, may as well filter out disconnected nodes as well. Delete unused methods rather than updating them.
2017-02-02net: deserialize the entire version message locallyCory Fields
This avoids having some vars set if the version negotiation fails. Also copy it all into CNode at the same site. nVersion and fSuccessfullyConnected are set last, as they are the gates for the other vars. Make them atomic for that reason.
2017-01-31Net: CConnman: Make some methods constJorge Timón
2017-01-24Delete some unused (and broken) functions in CConnmanMatt Corallo
2017-01-19Merge #9535: Split CNode::cs_vSend: message processing and message sendingWladimir J. van der Laan
376b3c2 Make the cs_sendProcessing a LOCK instead of a TRY_LOCK (Matt Corallo) d7c58ad Split CNode::cs_vSend: message processing and message sending (Matt Corallo)
2017-01-14Make WakeMessageHandler publicMatt Corallo
2017-01-13Split CNode::cs_vSend: message processing and message sendingMatt Corallo
cs_vSend is used for two purposes - to lock the datastructures used to queue messages to place on the wire and to only call SendMessages once at a time per-node. I believe SendMessages used to access some of the vSendMsg stuff, but it doesn't anymore, so these locks do not need to be on the same mutex, and also make deadlocking much more likely.
2017-01-13Merge #9441: Net: Massive speedup. Net locks overhaulPieter Wuille
e60360e net: remove cs_vRecvMsg (Cory Fields) 991955e net: add a flag to indicate when a node's send buffer is full (Cory Fields) c6e8a9b net: add a flag to indicate when a node's process queue is full (Cory Fields) 4d712e3 net: add a new message queue for the message processor (Cory Fields) c5a8b1b net: rework the way that the messagehandler sleeps (Cory Fields) c72cc88 net: remove useless comments (Cory Fields) ef7b5ec net: Add a simple function for waking the message handler (Cory Fields) f5c36d1 net: record bytes written before notifying the message processor (Cory Fields) 60befa3 net: handle message accounting in ReceiveMsgBytes (Cory Fields) 56212e2 net: set message deserialization version when it's actually time to deserialize (Cory Fields) 0e973d9 net: remove redundant max sendbuffer size check (Cory Fields) 6042587 net: wait until the node is destroyed to delete its recv buffer (Cory Fields) f6315e0 net: only disconnect if fDisconnect has been set (Cory Fields) 5b4a8ac net: make GetReceiveFloodSize public (Cory Fields) e5bcd9c net: make vRecvMsg a list so that we can use splice() (Cory Fields) 53ad9a1 net: fix typo causing the wrong receive buffer size (Cory Fields)
2017-01-12net: remove cs_vRecvMsgCory Fields
vRecvMsg is now only touched by the socket handler thread. The accounting vars (nRecvBytes/nLastRecv/mapRecvBytesPerMsgCmd) are also only used by the socket handler thread, with the exception of queries from rpc/gui. These accesses are not threadsafe, but they never were. This needs to be addressed separately. Also, update comment describing data flow
2017-01-12net: add a flag to indicate when a node's send buffer is fullCory Fields
Similar to the recv flag, but this one indicates whether or not the net's send buffer is full. The socket handler checks the send queue when a new message is added and pauses if necessary, and possibly unpauses after each message is drained from its buffer.
2017-01-12net: add a flag to indicate when a node's process queue is fullCory Fields
Messages are dumped very quickly from the socket handler to the processor, so it's the depth of the processing queue that's interesting. The socket handler checks the process queue's size during the brief message hand-off and pauses if necessary, and the processor possibly unpauses each time a message is popped off of its queue.
2017-01-12net: add a new message queue for the message processorCory Fields
This separates the storage of messages from the net and queued messages for processing, allowing the locks to be split.
2017-01-12net: rework the way that the messagehandler sleepsCory Fields
In order to sleep accurately, the message handler needs to know if _any_ node has more processing that it should do before the entire thread sleeps. Rather than returning a value that represents whether ProcessMessages encountered a message that should trigger a disconnnect, interpret the return value as whether or not that node has more work to do. Also, use a global fProcessWake value that can be set by other threads, which takes precedence (for one cycle) over the messagehandler's decision. Note that the previous behavior was to only process one message per loop (except in the case of a bad checksum or invalid header). That was changed in PR #3180. The only change here in that regard is that the current node now falls to the back of the processing queue for the bad checksum/invalid header cases.
2017-01-12net: Add a simple function for waking the message handlerCory Fields
This may be used publicly in the future
2017-01-05Break addnode out from the outbound connection limits.Gregory Maxwell
Previously addnodes were in competition with outbound connections for access to the eight outbound slots. One result of this is that frequently a node with several addnode configured peers would end up connected to none of them, because while the addnode loop was in its two minute sleep the automatic connection logic would fill any free slots with random peers. This is particularly unwelcome to users trying to maintain links to specific nodes for fast block relay or purposes. Another result is that a group of nine or more nodes which are have addnode configured towards each other can become partitioned from the public network. This commit introduces a new limit of eight connections just for addnode peers which is not subject to any of the other connection limitations (including maxconnections). The choice of eight is sufficient so that under no condition would a user find themselves connected to fewer addnoded peers than previously. It is also low enough that users who are confused about the significance of more connections and have gotten too copy-and-paste happy will not consume more than twice the slot usage of a typical user. Any additional load on the network resulting from this will likely be offset by a reduction in users applying even more wasteful workaround for the prior behavior. The retry delays are reduced to avoid nodes sitting around without their added peers up, but are still sufficient to prevent overly aggressive repeated connections. The reduced delays also make the system much more responsive to the addnode RPC. Ban-disconnects are also exempted for peers added via addnode since the outbound addnode logic ignores bans. Previously it would ban an addnode then immediately reconnect to it. A minor change was also made to CSemaphoreGrant so that it is possible to re-acquire via an object whos grant was moved.
2017-01-04net: set message deserialization version when it's actually time to deserializeCory Fields
We'll soon no longer have access to vRecvMsg, and this is more intuitive anyway.
2017-01-04net: make GetReceiveFloodSize publicCory Fields
This will be needed so that the message processor can cork incoming messages
2017-01-04net: make vRecvMsg a list so that we can use splice()Cory Fields
2017-01-04Merge #9289: net: drop boost::thread_groupWladimir J. van der Laan
67ee4ec net: misc header cleanups (Cory Fields) 8b3159e net: make proxy receives interruptible (Cory Fields) 5cb0fce net: remove thread_interrupted catch (Cory Fields) d3d7056 net: make net processing interruptible (Cory Fields) 0985052 net: make net interruptible (Cory Fields) 799df91 net: add CThreadInterrupt and InterruptibleSleep (Cory Fields) 7325b15 net: a few small cleanups before replacing boost threads (Cory Fields)
2017-01-03net: make net processing interruptibleCory Fields
2017-01-03net: make net interruptibleCory Fields
Also now that net threads are interruptible, switch them to use std threads/binds/mutexes/condvars.
2016-12-31Increment MIT Licence copyright header year on files modified in 2016isle2983
Edited via: $ contrib/devtools/copyright_header.py update .
2016-11-30Merge #9226: Remove fNetworkNode and pnodeLocalHost.Pieter Wuille
bdb922b Remove pnodeLocalHost. (Gregory Maxwell) 083f203 Remove fNetworkNode. (Gregory Maxwell)
2016-11-29Merge #9225: Fix some benign racesWladimir J. van der Laan
dfed983 Fix unlocked access to vNodes.size() (Matt Corallo) 3033522 Remove double brackets in addrman (Matt Corallo) dbfaade Fix AddrMan locking (Matt Corallo) 047ea10 Make fImporting an std::atomic (Matt Corallo) 42071ca Make fDisconnect an std::atomic (Matt Corallo)
2016-11-27Remove fNetworkNode.Gregory Maxwell
Matt pointed out to me that this appeared to be doing nothing (except involving itself in data races).
2016-11-25Make fDisconnect an std::atomicMatt Corallo
2016-11-25net: push only raw data into CConnmanCory Fields
This fixes one of the last major layer violations in the networking stack. The network side is no longer in charge of message serialization, so it is now decoupled from Bitcoin structures. Only the header is serialized and attached to the payload.