diff options
| author | Cory Fields <[email protected]> | 2017-01-20 20:34:57 -0500 |
|---|---|---|
| committer | Cory Fields <[email protected]> | 2017-02-02 16:14:16 -0500 |
| commit | 12752af0cc99745d6273ef072645d999c26a9ef7 (patch) | |
| tree | a7e0a2f8beec66f4486fef0ced9450a16b616731 /src/net.cpp | |
| parent | net: deserialize the entire version message locally (diff) | |
| download | discoin-12752af0cc99745d6273ef072645d999c26a9ef7.tar.xz discoin-12752af0cc99745d6273ef072645d999c26a9ef7.zip | |
net: don't run callbacks on nodes that haven't completed the version handshake
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.
Diffstat (limited to 'src/net.cpp')
| -rw-r--r-- | src/net.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/net.cpp b/src/net.cpp index df88b12c7..19358dd5b 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2630,6 +2630,11 @@ void CNode::AskFor(const CInv& inv) mapAskFor.insert(std::make_pair(nRequestTime, inv)); } +bool CConnman::NodeFullyConnected(const CNode* pnode) +{ + return pnode && pnode->fSuccessfullyConnected && !pnode->fDisconnect; +} + void CConnman::PushMessage(CNode* pnode, CSerializedNetMsg&& msg) { size_t nMessageSize = msg.data.size(); @@ -2680,7 +2685,7 @@ bool CConnman::ForNode(NodeId id, std::function<bool(CNode* pnode)> func) break; } } - return found != nullptr && func(found); + return found != nullptr && NodeFullyConnected(found) && func(found); } int64_t PoissonNextSend(int64_t nNow, int average_interval_seconds) { |