aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-03-17 16:23:00 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2015-03-17 16:38:06 +0100
commit93a8c46807a8b9c98e536ccd21ecdb11b9b3cf52 (patch)
tree0898a06bb3ca73ded1b6eb7e9d7afd8454795186 /src/main.cpp
parent5bd3a92da2ddfc831520685b4492569b4a5ed543 (diff)
parent9c2737901b5203f267d21d728019d64b46f1d9f3 (diff)
Merge pull request #5860
9c27379 Reduce fingerprinting through timestamps in 'addr' messages. (Pieter Wuille)
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 9b4bb43128..94cf213490 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -238,6 +238,10 @@ struct CBlockReject {
* and we're no longer holding the node's locks.
*/
struct CNodeState {
+ //! The peer's address
+ CService address;
+ //! Whether we have a fully established connection.
+ bool fCurrentlyConnected;
//! Accumulated misbehaviour score for this peer.
int nMisbehavior;
//! Whether this peer should be disconnected and banned (unless whitelisted).
@@ -262,6 +266,7 @@ struct CNodeState {
bool fPreferredDownload;
CNodeState() {
+ fCurrentlyConnected = false;
nMisbehavior = 0;
fShouldBan = false;
pindexBestKnownBlock = NULL;
@@ -305,6 +310,7 @@ void InitializeNode(NodeId nodeid, const CNode *pnode) {
LOCK(cs_main);
CNodeState &state = mapNodeState.insert(std::make_pair(nodeid, CNodeState())).first->second;
state.name = pnode->addrName;
+ state.address = pnode->addr;
}
void FinalizeNode(NodeId nodeid) {
@@ -314,6 +320,10 @@ void FinalizeNode(NodeId nodeid) {
if (state->fSyncStarted)
nSyncStarted--;
+ if (state->nMisbehavior == 0 && state->fCurrentlyConnected) {
+ AddressCurrentlyConnected(state->address);
+ }
+
BOOST_FOREACH(const QueuedBlock& entry, state->vBlocksInFlight)
mapBlocksInFlight.erase(entry.hash);
EraseOrphansFor(nodeid);
@@ -3627,6 +3637,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
else if (strCommand == "verack")
{
pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION));
+
+ // Mark this node as currently connected, so we update its timestamp later.
+ if (pfrom->fNetworkNode) {
+ LOCK(cs_main);
+ State(pfrom->GetId())->fCurrentlyConnected = true;
+ }
}
@@ -4271,11 +4287,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
}
- // Update the last seen time for this node's address
- if (pfrom->fNetworkNode)
- if (strCommand == "version" || strCommand == "addr" || strCommand == "inv" || strCommand == "getdata" || strCommand == "ping")
- AddressCurrentlyConnected(pfrom->addr);
-
return true;
}