Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/protocol.h
Show All 33 Lines | |||||
class CMessageHeader { | class CMessageHeader { | ||||
public: | public: | ||||
CMessageHeader(); | CMessageHeader(); | ||||
CMessageHeader(const char *pszCommand, unsigned int nMessageSizeIn); | CMessageHeader(const char *pszCommand, unsigned int nMessageSizeIn); | ||||
std::string GetCommand() const; | std::string GetCommand() const; | ||||
bool IsValid() const; | bool IsValid() const; | ||||
IMPLEMENT_SERIALIZE(READWRITE(FLATDATA(pchMessageStart)); | ADD_SERIALIZE_METHODS; | ||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
READWRITE(FLATDATA(pchMessageStart)); | |||||
READWRITE(FLATDATA(pchCommand)); | READWRITE(FLATDATA(pchCommand)); | ||||
READWRITE(nMessageSize); | READWRITE(nMessageSize); | ||||
if (nVersion >= 209) READWRITE(nChecksum);) | if (s.GetVersion() >= 209) { | ||||
READWRITE(nChecksum); | |||||
} | |||||
} | |||||
// TODO: make private (improves encapsulation) | // TODO: make private (improves encapsulation) | ||||
public: | public: | ||||
enum { COMMAND_SIZE = 12 }; | enum { COMMAND_SIZE = 12 }; | ||||
char pchMessageStart[sizeof(::pchMessageStart)]; | char pchMessageStart[sizeof(::pchMessageStart)]; | ||||
char pchCommand[COMMAND_SIZE]; | char pchCommand[COMMAND_SIZE]; | ||||
unsigned int nMessageSize; | unsigned int nMessageSize; | ||||
unsigned int nChecksum; | unsigned int nChecksum; | ||||
Show All 9 Lines | |||||
class CAddress : public CService { | class CAddress : public CService { | ||||
public: | public: | ||||
CAddress(); | CAddress(); | ||||
CAddress(CService ipIn, | CAddress(CService ipIn, | ||||
uint64_t nServicesIn = NODE_NETWORK | NODE_BITCOIN_CASH); | uint64_t nServicesIn = NODE_NETWORK | NODE_BITCOIN_CASH); | ||||
void Init(); | void Init(); | ||||
IMPLEMENT_SERIALIZE(CAddress *pthis = const_cast<CAddress *>(this); | ADD_SERIALIZE_METHODS; | ||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
int nVersion = s.GetVersion(); | |||||
CAddress *pthis = const_cast<CAddress *>(this); | |||||
CService *pip = (CService *)pthis; | CService *pip = (CService *)pthis; | ||||
if (fRead) pthis->Init(); | if (ser_action.ForRead()) { | ||||
if (nType & SER_DISK) READWRITE(nVersion); | pthis->Init(); | ||||
if ((nType & SER_DISK) || | } | ||||
(nVersion >= 31402 && !(nType & SER_GETHASH))) | if (s.GetType() & SER_DISK) { | ||||
READWRITE(nVersion); | |||||
} | |||||
if ((s.GetType() & SER_DISK) || | |||||
(nVersion >= 31402 && !(s.GetType() & SER_GETHASH))) { | |||||
READWRITE(nTime); | READWRITE(nTime); | ||||
READWRITE(nServices); READWRITE(*pip);) | } | ||||
READWRITE(nServices); | |||||
READWRITE(*pip); | |||||
} | |||||
void print() const; | void print() const; | ||||
// TODO: make private (improves encapsulation) | // TODO: make private (improves encapsulation) | ||||
public: | public: | ||||
uint64_t nServices; | uint64_t nServices; | ||||
// disk and network only | // disk and network only | ||||
unsigned int nTime; | unsigned int nTime; | ||||
}; | }; | ||||
class CInv { | class CInv { | ||||
public: | public: | ||||
CInv(); | CInv(); | ||||
CInv(int typeIn, const uint256 &hashIn); | CInv(int typeIn, const uint256 &hashIn); | ||||
CInv(const std::string &strType, const uint256 &hashIn); | CInv(const std::string &strType, const uint256 &hashIn); | ||||
IMPLEMENT_SERIALIZE(READWRITE(type); READWRITE(hash);) | ADD_SERIALIZE_METHODS; | ||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
READWRITE(type); | |||||
READWRITE(hash); | |||||
} | |||||
friend bool operator<(const CInv &a, const CInv &b); | friend bool operator<(const CInv &a, const CInv &b); | ||||
bool IsKnownType() const; | bool IsKnownType() const; | ||||
const char *GetCommand() const; | const char *GetCommand() const; | ||||
std::string ToString() const; | std::string ToString() const; | ||||
void print() const; | void print() const; | ||||
// TODO: make private (improves encapsulation) | // TODO: make private (improves encapsulation) | ||||
public: | public: | ||||
int type; | int type; | ||||
uint256 hash; | uint256 hash; | ||||
}; | }; | ||||
#endif // __INCLUDED_PROTOCOL_H__ | #endif // __INCLUDED_PROTOCOL_H__ |