Skip to content

Commit

Permalink
net: Use C++11 member initialization in protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco authored and furszy committed Aug 10, 2021
1 parent 082baa3 commit 3660487
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
18 changes: 0 additions & 18 deletions src/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,24 +153,6 @@ bool CMessageHeader::IsValid(const MessageStartChars& pchMessageStartIn) const
return true;
}


CAddress::CAddress() : CService()
{
Init();
}

CAddress::CAddress(CService ipIn, ServiceFlags nServicesIn) : CService(ipIn)
{
Init();
nServices = nServicesIn;
}

void CAddress::Init()
{
nServices = NODE_NONE;
nTime = 100000000;
}

CInv::CInv()
{
type = 0;
Expand Down
17 changes: 7 additions & 10 deletions src/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,15 @@ enum ServiceFlags : uint64_t {
/** A CService with information about it as peer */
class CAddress : public CService
{
public:
CAddress();
explicit CAddress(CService ipIn, ServiceFlags nServicesIn);
static constexpr uint32_t TIME_INIT{100000000};

void Init();
public:
CAddress() : CService{} {};
explicit CAddress(CService ipIn, ServiceFlags nServicesIn) : CService{ipIn}, nServices{nServicesIn} {};

SERIALIZE_METHODS(CAddress, obj)
{
SER_READ(obj, obj.Init());
SER_READ(obj, obj.nTime = TIME_INIT);
int nVersion = s.GetVersion();
if (s.GetType() & SER_DISK) {
READWRITE(nVersion);
Expand All @@ -318,12 +318,9 @@ class CAddress : public CService
READWRITEAS(CService, obj);
}

// TODO: make private (improves encapsulation)
public:
ServiceFlags nServices;

ServiceFlags nServices{NODE_NONE};
// disk and network only
unsigned int nTime;
uint32_t nTime{TIME_INIT};
};

/** getdata message types */
Expand Down

0 comments on commit 3660487

Please sign in to comment.