diff options
author | Matt Corallo <git@bluematt.me> | 2016-06-21 13:08:29 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2016-10-17 16:44:57 +0200 |
commit | 02a337defdd854efc78ecba6d1fb19cb1c075f16 (patch) | |
tree | 15e2aa39b57368a77e4f6e9fff235ff0f2484e2d /src/main.cpp | |
parent | c90111314435ab67808a89cac1a664cb19eafd61 (diff) | |
download | bitcoin-02a337defdd854efc78ecba6d1fb19cb1c075f16.tar.xz |
Dont remove a "preferred" cmpctblock peer if they provide a block
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp index ad4c3fce68..e27fb1fae6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -485,9 +485,13 @@ void MaybeSetPeerAsAnnouncingHeaderAndIDs(const CNodeState* nodestate, CNode* pf return; } if (nodestate->fProvidesHeaderAndIDs) { - BOOST_FOREACH(const NodeId nodeid, lNodesAnnouncingHeaderAndIDs) - if (nodeid == pfrom->GetId()) + for (std::list<NodeId>::iterator it = lNodesAnnouncingHeaderAndIDs.begin(); it != lNodesAnnouncingHeaderAndIDs.end(); it++) { + if (*it == pfrom->GetId()) { + lNodesAnnouncingHeaderAndIDs.erase(it); + lNodesAnnouncingHeaderAndIDs.push_back(pfrom->GetId()); return; + } + } bool fAnnounceUsingCMPCTBLOCK = false; uint64_t nCMPCTBLOCKVersion = (pfrom->GetLocalServices() & NODE_WITNESS) ? 2 : 1; if (lNodesAnnouncingHeaderAndIDs.size() >= 3) { @@ -5731,6 +5735,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, return true; } + if (!fAlreadyInFlight && mapBlocksInFlight.size() == 1 && pindex->pprev->IsValid(BLOCK_VALID_CHAIN)) { + // We seem to be rather well-synced, so it appears pfrom was the first to provide us + // with this block! Let's get them to announce using compact blocks in the future. + MaybeSetPeerAsAnnouncingHeaderAndIDs(nodestate, pfrom, connman); + } + BlockTransactionsRequest req; for (size_t i = 0; i < cmpctblock.BlockTxCount(); i++) { if (!partialBlock.IsTxAvailable(i)) |