|
|
|
@ -327,6 +327,8 @@ struct CNodeState {
|
|
|
|
|
bool fProvidesHeaderAndIDs;
|
|
|
|
|
//! Whether this peer can give us witnesses
|
|
|
|
|
bool fHaveWitness;
|
|
|
|
|
//! Whether this peer can give us MWEB data
|
|
|
|
|
bool fHaveMWEB;
|
|
|
|
|
//! Whether this peer wants witnesses in cmpctblocks/blocktxns
|
|
|
|
|
bool fWantsCmpctWitness;
|
|
|
|
|
/**
|
|
|
|
@ -407,6 +409,7 @@ struct CNodeState {
|
|
|
|
|
fPreferHeaderAndIDs = false;
|
|
|
|
|
fProvidesHeaderAndIDs = false;
|
|
|
|
|
fHaveWitness = false;
|
|
|
|
|
fHaveMWEB = false;
|
|
|
|
|
fWantsCmpctWitness = false;
|
|
|
|
|
fSupportsDesiredCmpctVersion = false;
|
|
|
|
|
m_chain_sync = { 0, nullptr, false, false };
|
|
|
|
@ -736,6 +739,10 @@ static void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vec
|
|
|
|
|
// We wouldn't download this block or its descendants from this peer.
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!State(nodeid)->fHaveMWEB && IsMWEBEnabled(pindex->pprev, consensusParams)) {
|
|
|
|
|
// MWEB: Can't download this block from this peer.
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (pindex->nStatus & BLOCK_HAVE_DATA || ::ChainActive().Contains(pindex)) {
|
|
|
|
|
if (pindex->HaveTxsDownloaded())
|
|
|
|
|
state->pindexLastCommonBlock = pindex;
|
|
|
|
@ -1698,7 +1705,7 @@ void static ProcessGetData(CNode& pfrom, Peer& peer, const CChainParams& chainpa
|
|
|
|
|
CTransactionRef tx = FindTxForGetData(mempool, pfrom, ToGenTxid(inv), mempool_req, now);
|
|
|
|
|
if (tx) {
|
|
|
|
|
// WTX and WITNESS_TX imply we serialize with witness
|
|
|
|
|
int nSendFlags = (inv.IsMsgTx() ? SERIALIZE_TRANSACTION_NO_WITNESS : 0);
|
|
|
|
|
int nSendFlags = (inv.IsMsgTx() ? SERIALIZE_TRANSACTION_NO_WITNESS | SERIALIZE_NO_MWEB : (pfrom.SupportsMWEB() ? 0 : SERIALIZE_NO_MWEB));
|
|
|
|
|
connman.PushMessage(&pfrom, msgMaker.Make(nSendFlags, NetMsgType::TX, *tx));
|
|
|
|
|
mempool.RemoveUnbroadcastTx(tx->GetHash());
|
|
|
|
|
// As we're going to send tx, make sure its unconfirmed parents are made requestable.
|
|
|
|
@ -1887,7 +1894,8 @@ void PeerManager::ProcessHeadersMessage(CNode& pfrom, const std::vector<CBlockHe
|
|
|
|
|
while (pindexWalk && !::ChainActive().Contains(pindexWalk) && vToFetch.size() <= MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
|
|
|
|
|
if (!(pindexWalk->nStatus & BLOCK_HAVE_DATA) &&
|
|
|
|
|
!mapBlocksInFlight.count(pindexWalk->GetBlockHash()) &&
|
|
|
|
|
(!IsWitnessEnabled(pindexWalk->pprev, m_chainparams.GetConsensus()) || State(pfrom.GetId())->fHaveWitness)) {
|
|
|
|
|
(!IsWitnessEnabled(pindexWalk->pprev, m_chainparams.GetConsensus()) || State(pfrom.GetId())->fHaveWitness) &&
|
|
|
|
|
(!IsMWEBEnabled(pindexWalk->pprev, m_chainparams.GetConsensus()) || State(pfrom.GetId())->fHaveMWEB)) {
|
|
|
|
|
// We don't have this block, and it's not yet in flight.
|
|
|
|
|
vToFetch.push_back(pindexWalk);
|
|
|
|
|
}
|
|
|
|
@ -2401,6 +2409,10 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
|
|
|
|
|
{
|
|
|
|
|
LOCK(cs_main);
|
|
|
|
|
State(pfrom.GetId())->fHaveWitness = true;
|
|
|
|
|
|
|
|
|
|
if (nServices & NODE_MWEB) {
|
|
|
|
|
State(pfrom.GetId())->fHaveMWEB = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Potentially mark this peer as a preferred download peer.
|
|
|
|
|