Skip to content

Commit

Permalink
Fixed CInv::IsKnownType()
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeShark committed Jan 11, 2016
1 parent 0f9efb0 commit c602f23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ bool operator<(const CInv& a, const CInv& b)

bool CInv::IsKnownType() const
{
return (type >= 1 && type < (int)ARRAYLEN(ppszTypeName));
int masked = type & MSG_TYPE_MASK;
return (masked >= 1 && masked <= MSG_TYPE_MAX);
}

const char* CInv::GetCommand() const
Expand Down
8 changes: 6 additions & 2 deletions src/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,17 @@ class CInv
uint256 hash;
};

const uint32_t MSG_WITNESS_FLAG = 1 << 30;
const uint32_t MSG_TYPE_MASK = 0xffffffff >> 2;
enum {
MSG_TX = 1,
MSG_BLOCK,
// The following can only occur in getdata. Invs always use TX or BLOCK.
MSG_FILTERED_BLOCK,
MSG_WITNESS_BLOCK = MSG_BLOCK | 0x40000000,
MSG_WITNESS_TX = MSG_TX | 0x40000000,
MSG_WITNESS_BLOCK = MSG_BLOCK | MSG_WITNESS_FLAG,
MSG_WITNESS_TX = MSG_TX | MSG_WITNESS_FLAG,
};

const int MSG_TYPE_MAX = MSG_FILTERED_BLOCK;

#endif // BITCOIN_PROTOCOL_H

0 comments on commit c602f23

Please sign in to comment.