Changeset View
Changeset View
Standalone View
Standalone View
src/protocol.h
Show First 20 Lines • Show All 353 Lines • ▼ Show 20 Lines | enum GetDataMsg { | ||||
MSG_FILTERED_BLOCK = 3, | MSG_FILTERED_BLOCK = 3, | ||||
//!< Defined in BIP152 | //!< Defined in BIP152 | ||||
MSG_CMPCT_BLOCK = 4, | MSG_CMPCT_BLOCK = 4, | ||||
}; | }; | ||||
/** inv message data */ | /** inv message data */ | ||||
class CInv { | class CInv { | ||||
public: | public: | ||||
CInv(); | // TODO: make private (improves encapsulation) | ||||
CInv(int typeIn, const uint256 &hashIn); | uint32_t type; | ||||
uint256 hash; | |||||
public: | |||||
CInv() : type(0), hash() {} | |||||
CInv(uint32_t typeIn, const uint256 &hashIn) : type(typeIn), hash(hashIn) {} | |||||
ADD_SERIALIZE_METHODS; | ADD_SERIALIZE_METHODS; | ||||
template <typename Stream, typename Operation> | template <typename Stream, typename Operation> | ||||
inline void SerializationOp(Stream &s, Operation ser_action) { | inline void SerializationOp(Stream &s, Operation ser_action) { | ||||
READWRITE(type); | READWRITE(type); | ||||
READWRITE(hash); | READWRITE(hash); | ||||
} | } | ||||
friend bool operator<(const CInv &a, const CInv &b); | friend bool operator<(const CInv &a, const CInv &b) { | ||||
return a.type < b.type || (a.type == b.type && a.hash < b.hash); | |||||
} | |||||
std::string GetCommand() const; | std::string GetCommand() const; | ||||
std::string ToString() const; | std::string ToString() const; | ||||
uint32_t GetKind() const { return type & MSG_TYPE_MASK; } | uint32_t GetKind() const { return type & MSG_TYPE_MASK; } | ||||
bool IsTx() const { | bool IsTx() const { | ||||
auto k = GetKind(); | auto k = GetKind(); | ||||
return k == MSG_TX; | return k == MSG_TX; | ||||
} | } | ||||
bool IsSomeBlock() const { | bool IsSomeBlock() const { | ||||
auto k = GetKind(); | auto k = GetKind(); | ||||
return k == MSG_BLOCK || k == MSG_FILTERED_BLOCK || | return k == MSG_BLOCK || k == MSG_FILTERED_BLOCK || | ||||
k == MSG_CMPCT_BLOCK; | k == MSG_CMPCT_BLOCK; | ||||
} | } | ||||
// TODO: make private (improves encapsulation) | |||||
public: | |||||
int type; | |||||
uint256 hash; | |||||
}; | }; | ||||
#endif // BITCOIN_PROTOCOL_H | #endif // BITCOIN_PROTOCOL_H |