Changeset View
Changeset View
Standalone View
Standalone View
src/protocol.h
Show First 20 Lines • Show All 414 Lines • ▼ Show 20 Lines | |||||
static inline bool MayHaveUsefulAddressDB(ServiceFlags services) { | static inline bool MayHaveUsefulAddressDB(ServiceFlags services) { | ||||
return (services & NODE_NETWORK) || (services & NODE_NETWORK_LIMITED); | return (services & NODE_NETWORK) || (services & NODE_NETWORK_LIMITED); | ||||
} | } | ||||
/** | /** | ||||
* A CService with information about it as peer. | * A CService with information about it as peer. | ||||
*/ | */ | ||||
class CAddress : public CService { | class CAddress : public CService { | ||||
static constexpr uint32_t TIME_INIT{100000000}; | |||||
public: | public: | ||||
CAddress(); | CAddress() : CService{} {}; | ||||
explicit CAddress(CService ipIn, ServiceFlags nServicesIn); | explicit CAddress(CService ipIn, ServiceFlags nServicesIn) | ||||
: CService{ipIn}, nServices{nServicesIn} {}; | |||||
void Init(); | void Init(); | ||||
SERIALIZE_METHODS(CAddress, obj) { | SERIALIZE_METHODS(CAddress, obj) { | ||||
SER_READ(obj, obj.Init()); | SER_READ(obj, obj.nTime = TIME_INIT); | ||||
int nVersion = s.GetVersion(); | int nVersion = s.GetVersion(); | ||||
if (s.GetType() & SER_DISK) { | if (s.GetType() & SER_DISK) { | ||||
READWRITE(nVersion); | READWRITE(nVersion); | ||||
} | } | ||||
if ((s.GetType() & SER_DISK) || | if ((s.GetType() & SER_DISK) || | ||||
(nVersion != INIT_PROTO_VERSION && !(s.GetType() & SER_GETHASH))) { | (nVersion != INIT_PROTO_VERSION && !(s.GetType() & SER_GETHASH))) { | ||||
// The only time we serialize a CAddress object without nTime is in | // The only time we serialize a CAddress object without nTime is in | ||||
// the initial VERSION messages which contain two CAddress records. | // the initial VERSION messages which contain two CAddress records. | ||||
// At that point, the serialization version is INIT_PROTO_VERSION. | // At that point, the serialization version is INIT_PROTO_VERSION. | ||||
// After the version handshake, serialization version is >= | // After the version handshake, serialization version is >= | ||||
// MIN_PEER_PROTO_VERSION and all ADDR messages are serialized with | // MIN_PEER_PROTO_VERSION and all ADDR messages are serialized with | ||||
// nTime. | // nTime. | ||||
READWRITE(obj.nTime); | READWRITE(obj.nTime); | ||||
} | } | ||||
READWRITE(Using<CustomUintFormatter<8>>(obj.nServices)); | READWRITE(Using<CustomUintFormatter<8>>(obj.nServices)); | ||||
READWRITEAS(CService, obj); | READWRITEAS(CService, obj); | ||||
} | } | ||||
ServiceFlags nServices; | ServiceFlags nServices{NODE_NONE}; | ||||
// disk and network only | // disk and network only | ||||
unsigned int nTime; | uint32_t nTime{TIME_INIT}; | ||||
}; | }; | ||||
/** getdata message type flags */ | /** getdata message type flags */ | ||||
const uint32_t MSG_TYPE_MASK = 0xffffffff >> 3; | const uint32_t MSG_TYPE_MASK = 0xffffffff >> 3; | ||||
/** | /** | ||||
* getdata / inv message types. | * getdata / inv message types. | ||||
* These numbers are defined by the protocol. When adding a new value, be sure | * These numbers are defined by the protocol. When adding a new value, be sure | ||||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |