net: Pass best block known height into CConnman
commitf60b9059e4958245bda82e9656c52a31d5268ad9
authorCory Fields <cory-nospam-@coryfields.com>
Tue, 24 May 2016 20:42:17 +0000 (24 16:42 -0400)
committerCory Fields <cory-nospam-@coryfields.com>
Thu, 8 Sep 2016 16:24:06 +0000 (8 12:24 -0400)
treeebe2791c74d053d270d9057a5237dc85b9c5fb2e
parentfdf69ff21aef8ed8071a757979f4239537f7afba
net: Pass best block known height into CConnman

CConnman then passes the current best height into CNode at creation time.

This way CConnman/CNode have no dependency on main for height, and the signals
only move in one direction.

This also helps to prevent identity leakage a tiny bit. Before this change, an
attacker could theoretically make 2 connections on different interfaces. They
would connect fully on one, and only establish the initial connection on the
other. Once they receive a new block, they would relay it to your first
connection, and immediately commence the version handshake on the second. Since
the new block height is reflected immediately, they could attempt to learn
whether the two connections were correlated.

This is, of course, incredibly unlikely to work due to the small timings
involved and receipt from other senders. But it doesn't hurt to lock-in
nBestHeight at the time of connection, rather than letting the remote choose
the time.
src/init.cpp
src/main.cpp
src/net.cpp
src/net.h
src/test/DoS_tests.cpp
src/test/net_tests.cpp