describe
currently block relay is throught inv/headers, getdata cycle
Describe the solution you'd like
send newValidPoWBlock through cmpctblock message
Additional context
refer to logic in ABC's code:
void PeerLogicValidation::NewPoWValidBlock(
const CBlockIndex *pindex, const std::shared_ptr<const CBlock> &pblock) {
connman->ForEachNode([this, &pcmpctblock, pindex, &msgMaker,
&hashBlock](CNode *pnode) {
// If the peer has, or we announced to them the previous block already,
// but we don't think they have this one, go ahead and announce it.
if (state.fPreferHeaderAndIDs && !PeerHasHeader(&state, pindex) &&
PeerHasHeader(&state, pindex->pprev)) {
LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n",
"PeerLogicValidation::NewPoWValidBlock",
hashBlock.ToString(), pnode->GetId());
connman->PushMessage(
pnode, msgMaker.Make(NetMsgType::CMPCTBLOCK, *pcmpctblock));
state.pindexBestHeaderSent = pindex;
}
});
}
else if (strCommand == NetMsgType::GETHEADERS) {
...
// pindex can be nullptr either if we sent chainActive.Tip() OR
// if our peer has chainActive.Tip() (and thus we are sending an empty
// headers message). In both cases it's safe to update
// pindexBestHeaderSent to be our tip.
//
// It is important that we simply reset the BestHeaderSent value here,
// and not max(BestHeaderSent, newHeaderSent). We might have announced
// the currently-being-connected tip using a compact block, which
// resulted in the peer sending a headers request, which we respond to
// without the new block. By resetting the BestHeaderSent, we ensure we
// will re-announce the new block via headers (or compact blocks again)
// in the SendMessages logic.
nodestate->pindexBestHeaderSent = pindex ? pindex : chainActive.Tip();
connman->PushMessage(pfrom,
msgMaker.Make(NetMsgType::HEADERS, vHeaders));
}
describe currently block relay is throught inv/headers, getdata cycle
Describe the solution you'd like send newValidPoWBlock through
cmpctblock
messageAdditional context
refer to logic in ABC's code: