mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-28 04:52:36 +02:00
Merge 10350 via filtered_witblock-28
This commit is contained in:
commit
eb6c081439
@ -2522,7 +2522,7 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
|
|||||||
}
|
}
|
||||||
// disconnect node in case we have reached the outbound limit for serving historical blocks
|
// disconnect node in case we have reached the outbound limit for serving historical blocks
|
||||||
if (m_connman.OutboundTargetReached(true) &&
|
if (m_connman.OutboundTargetReached(true) &&
|
||||||
(((m_chainman.m_best_header != nullptr) && (m_chainman.m_best_header->GetBlockTime() - pindex->GetBlockTime() > HISTORICAL_BLOCK_AGE)) || inv.IsMsgFilteredBlk()) &&
|
(((m_chainman.m_best_header != nullptr) && (m_chainman.m_best_header->GetBlockTime() - pindex->GetBlockTime() > HISTORICAL_BLOCK_AGE)) || inv.IsMsgFilteredBlk() || inv.IsMsgFilteredWitnessBlk()) &&
|
||||||
!pfrom.HasPermission(NetPermissionFlags::Download) // nodes with the download permission may exceed target
|
!pfrom.HasPermission(NetPermissionFlags::Download) // nodes with the download permission may exceed target
|
||||||
) {
|
) {
|
||||||
LogPrint(BCLog::NET, "historical block serving limit reached, disconnect peer=%d\n", pfrom.GetId());
|
LogPrint(BCLog::NET, "historical block serving limit reached, disconnect peer=%d\n", pfrom.GetId());
|
||||||
@ -2585,7 +2585,7 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
|
|||||||
MakeAndPushMessage(pfrom, NetMsgType::BLOCK, TX_NO_WITNESS(*pblock));
|
MakeAndPushMessage(pfrom, NetMsgType::BLOCK, TX_NO_WITNESS(*pblock));
|
||||||
} else if (inv.IsMsgWitnessBlk()) {
|
} else if (inv.IsMsgWitnessBlk()) {
|
||||||
MakeAndPushMessage(pfrom, NetMsgType::BLOCK, TX_WITH_WITNESS(*pblock));
|
MakeAndPushMessage(pfrom, NetMsgType::BLOCK, TX_WITH_WITNESS(*pblock));
|
||||||
} else if (inv.IsMsgFilteredBlk()) {
|
} else if (inv.IsMsgFilteredBlk() || inv.IsMsgFilteredWitnessBlk()) {
|
||||||
bool sendMerkleBlock = false;
|
bool sendMerkleBlock = false;
|
||||||
CMerkleBlock merkleBlock;
|
CMerkleBlock merkleBlock;
|
||||||
if (auto tx_relay = peer.GetTxRelay(); tx_relay != nullptr) {
|
if (auto tx_relay = peer.GetTxRelay(); tx_relay != nullptr) {
|
||||||
@ -2603,9 +2603,10 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
|
|||||||
// they must either disconnect and retry or request the full block.
|
// they must either disconnect and retry or request the full block.
|
||||||
// Thus, the protocol spec specified allows for us to provide duplicate txn here,
|
// Thus, the protocol spec specified allows for us to provide duplicate txn here,
|
||||||
// however we MUST always provide at least what the remote peer needs
|
// however we MUST always provide at least what the remote peer needs
|
||||||
|
const auto maybe_with_witness = (inv.IsMsgFilteredWitnessBlk() ? TX_WITH_WITNESS : TX_NO_WITNESS);
|
||||||
typedef std::pair<unsigned int, uint256> PairType;
|
typedef std::pair<unsigned int, uint256> PairType;
|
||||||
for (PairType& pair : merkleBlock.vMatchedTxn)
|
for (PairType& pair : merkleBlock.vMatchedTxn)
|
||||||
MakeAndPushMessage(pfrom, NetMsgType::TX, TX_NO_WITNESS(*pblock->vtx[pair.first]));
|
MakeAndPushMessage(pfrom, NetMsgType::TX, maybe_with_witness(*pblock->vtx[pair.first]));
|
||||||
}
|
}
|
||||||
// else
|
// else
|
||||||
// no response
|
// no response
|
||||||
|
@ -484,9 +484,7 @@ enum GetDataMsg : uint32_t {
|
|||||||
MSG_CMPCT_BLOCK = 4, //!< Defined in BIP152
|
MSG_CMPCT_BLOCK = 4, //!< Defined in BIP152
|
||||||
MSG_WITNESS_BLOCK = MSG_BLOCK | MSG_WITNESS_FLAG, //!< Defined in BIP144
|
MSG_WITNESS_BLOCK = MSG_BLOCK | MSG_WITNESS_FLAG, //!< Defined in BIP144
|
||||||
MSG_WITNESS_TX = MSG_TX | MSG_WITNESS_FLAG, //!< Defined in BIP144
|
MSG_WITNESS_TX = MSG_TX | MSG_WITNESS_FLAG, //!< Defined in BIP144
|
||||||
// MSG_FILTERED_WITNESS_BLOCK is defined in BIP144 as reserved for future
|
MSG_FILTERED_WITNESS_BLOCK = MSG_FILTERED_BLOCK | MSG_WITNESS_FLAG, //!< Defined in BIP144
|
||||||
// use and remains unused.
|
|
||||||
// MSG_FILTERED_WITNESS_BLOCK = MSG_FILTERED_BLOCK | MSG_WITNESS_FLAG,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** inv message data */
|
/** inv message data */
|
||||||
@ -510,6 +508,7 @@ public:
|
|||||||
bool IsMsgFilteredBlk() const { return type == MSG_FILTERED_BLOCK; }
|
bool IsMsgFilteredBlk() const { return type == MSG_FILTERED_BLOCK; }
|
||||||
bool IsMsgCmpctBlk() const { return type == MSG_CMPCT_BLOCK; }
|
bool IsMsgCmpctBlk() const { return type == MSG_CMPCT_BLOCK; }
|
||||||
bool IsMsgWitnessBlk() const { return type == MSG_WITNESS_BLOCK; }
|
bool IsMsgWitnessBlk() const { return type == MSG_WITNESS_BLOCK; }
|
||||||
|
bool IsMsgFilteredWitnessBlk() const { return type == MSG_FILTERED_WITNESS_BLOCK; }
|
||||||
|
|
||||||
// Combined-message helper methods
|
// Combined-message helper methods
|
||||||
bool IsGenTxMsg() const
|
bool IsGenTxMsg() const
|
||||||
@ -518,7 +517,7 @@ public:
|
|||||||
}
|
}
|
||||||
bool IsGenBlkMsg() const
|
bool IsGenBlkMsg() const
|
||||||
{
|
{
|
||||||
return type == MSG_BLOCK || type == MSG_FILTERED_BLOCK || type == MSG_CMPCT_BLOCK || type == MSG_WITNESS_BLOCK;
|
return type == MSG_BLOCK || type == MSG_FILTERED_BLOCK || type == MSG_CMPCT_BLOCK || type == MSG_WITNESS_BLOCK || type == MSG_FILTERED_WITNESS_BLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t type;
|
uint32_t type;
|
||||||
|
Loading…
Reference in New Issue
Block a user