#include "netbase.h"
#include <string>
#include <limits>
+#include <vector>
#include "uint256.h"
+extern uint32_t nNetworkID;
extern bool fTestNet;
-static inline unsigned short GetDefaultPort(const bool testnet = fTestNet)
+inline uint16_t GetDefaultPort()
{
- return testnet ? 17777 : 7777;
+ return static_cast<uint16_t>(fTestNet ? 17777 : 7777);
}
-
-extern unsigned char pchMessageStart[4];
-
/** Message header.
- * (4) message start.
+ * (4) network identifier.
* (12) command.
* (4) size.
* (4) checksum.
IMPLEMENT_SERIALIZE
(
- READWRITE(FLATDATA(pchMessageStart));
+ READWRITE(nNetworkID);
READWRITE(FLATDATA(pchCommand));
READWRITE(nMessageSize);
READWRITE(nChecksum);
// TODO: make private (improves encapsulation)
public:
enum {
- MESSAGE_START_SIZE=sizeof(::pchMessageStart),
+ MESSAGE_START_SIZE=4,
COMMAND_SIZE=12,
- MESSAGE_SIZE_SIZE=sizeof(int),
- CHECKSUM_SIZE=sizeof(int),
+ MESSAGE_SIZE_SIZE=4,
+ CHECKSUM_SIZE=4,
MESSAGE_SIZE_OFFSET=MESSAGE_START_SIZE+COMMAND_SIZE,
CHECKSUM_OFFSET=MESSAGE_SIZE_OFFSET+MESSAGE_SIZE_SIZE
};
- char pchMessageStart[MESSAGE_START_SIZE];
+ uint32_t nNetworkID;
char pchCommand[COMMAND_SIZE];
- unsigned int nMessageSize;
- unsigned int nChecksum;
+ uint32_t nMessageSize;
+ uint32_t nChecksum;
};
/** nServices flags */
READWRITE(*pip);
)
- void print() const;
-
// TODO: make private (improves encapsulation)
public:
uint64_t nServices;
bool IsKnownType() const;
const char* GetCommand() const;
std::string ToString() const;
- void print() const;
// TODO: make private (improves encapsulation)
public: