New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segregated witness rebased #8149

Merged
merged 27 commits into from Jun 24, 2016
Commits
File filter...
Filter file types
Jump to file or symbol
Failed to load files and symbols.
+6 −2
Diff settings

Always

Just for now

Do not use compact blocks when segwit is enabled

  • Loading branch information...
sipa committed Jun 22, 2016
commit af87a67eff8ce7bf2c7fb29f760da9fc610f162f
Copy path View file
@@ -473,6 +473,10 @@ void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) {
}

void MaybeSetPeerAsAnnouncingHeaderAndIDs(const CNodeState* nodestate, CNode* pfrom) {
if (nLocalServices & NODE_WITNESS) {

This comment has been minimized.

@rebroad

rebroad Aug 25, 2016

Contributor

How does SegWit impact on the usefulness of Compact Blocks?

This comment has been minimized.

@sipa

sipa via email Aug 25, 2016

Member
// Don't ever request compact blocks when segwit is enabled.
return;
}
if (nodestate->fProvidesHeaderAndIDs) {
BOOST_FOREACH(const NodeId nodeid, lNodesAnnouncingHeaderAndIDs)
if (nodeid == pfrom->GetId())
@@ -5286,7 +5290,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER &&
(!IsWitnessEnabled(chainActive.Tip(), chainparams.GetConsensus()) || State(pfrom->GetId())->fHaveWitness)) {

This comment has been minimized.

@rebroad

rebroad Aug 26, 2016

Contributor

Maybe I'm misreading the code, but once SegWit activates then where is the code that downloads blocks upon receiving a block inv? Block invs are no longer responded to?

This comment has been minimized.

@sipa

sipa Aug 26, 2016

Member

Read the part of the line after ||.

This comment has been minimized.

@rebroad

rebroad Aug 26, 2016

Contributor

Sorry, it's taking me a while to get my head around this - I keep making the assumption that most nodes won't be running SegWit for some reason!!

inv.type |= nFetchFlags;
if (nodestate->fProvidesHeaderAndIDs)
if (nodestate->fProvidesHeaderAndIDs && !(nLocalServices & NODE_WITNESS))
vToFetch.push_back(CInv(MSG_CMPCT_BLOCK, inv.hash));
else
vToFetch.push_back(inv);
@@ -5905,7 +5909,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
pindexLast->GetBlockHash().ToString(), pindexLast->nHeight);
}
if (vGetData.size() > 0) {
if (nodestate->fProvidesHeaderAndIDs && vGetData.size() == 1 && mapBlocksInFlight.size() == 1 && pindexLast->pprev->IsValid(BLOCK_VALID_CHAIN)) {
if (nodestate->fProvidesHeaderAndIDs && vGetData.size() == 1 && mapBlocksInFlight.size() == 1 && pindexLast->pprev->IsValid(BLOCK_VALID_CHAIN) && !(nLocalServices & NODE_WITNESS)) {
// 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);
ProTip! Use n and p to navigate between commits in a pull request.