aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2016-06-21 13:08:29 -0700
committerMarcoFalke <falke.marco@gmail.com>2016-11-20 15:07:39 +0100
commit36e3b951039b98508badaafa0bbec166c22900d3 (patch)
treea22ea0303a2537336ad98dbeb407b32311f3c601 /src
parent286e548d87266f3b394d75182f04fb701b2263e8 (diff)
downloadbitcoin-36e3b951039b98508badaafa0bbec166c22900d3.tar.xz
Dont remove a "preferred" cmpctblock peer if they provide a block
Github-Pull: #8637 Rebased-From: 02a337defdd854efc78ecba6d1fb19cb1c075f16
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 96734b839f..3436caaf10 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -495,9 +495,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 = (nLocalServices & NODE_WITNESS) ? 2 : 1;
if (lNodesAnnouncingHeaderAndIDs.size() >= 3) {
@@ -5727,6 +5731,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))