Michael's answer was very helpful for me, but I think it is also helpful to take a look at the source code and implementation of inv
messages while the question is tagged bitcoin-core-development
.
This is the source code for inv
messages. Link:
/** inv message data */
class CInv
{
public:
CInv();
CInv(uint32_t typeIn, const uint256& hashIn);
SERIALIZE_METHODS(CInv, obj) { READWRITE(obj.type, obj.hash); }
friend bool operator<(const CInv& a, const CInv& b);
std::string GetCommand() const;
std::string ToString() const;
// Single-message helper methods
bool IsMsgTx() const { return type == MSG_TX; }
bool IsMsgBlk() const { return type == MSG_BLOCK; }
bool IsMsgWtx() const { return type == MSG_WTX; }
bool IsMsgFilteredBlk() const { return type == MSG_FILTERED_BLOCK; }
bool IsMsgCmpctBlk() const { return type == MSG_CMPCT_BLOCK; }
bool IsMsgWitnessBlk() const { return type == MSG_WITNESS_BLOCK; }
// Combined-message helper methods
bool IsGenTxMsg() const
{
return type == MSG_TX || type == MSG_WTX || type == MSG_WITNESS_TX;
}
bool IsGenBlkMsg() const
{
return type == MSG_BLOCK || type == MSG_FILTERED_BLOCK || type == MSG_CMPCT_BLOCK || type == MSG_WITNESS_BLOCK;
}
uint32_t type;
uint256 hash;
};