1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2012 The Bitcoin developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
7 # error This header can only be compiled as C++.
10 #ifndef __INCLUDED_PROTOCOL_H__
11 #define __INCLUDED_PROTOCOL_H__
13 #include "serialize.h"
18 #define PPCOIN_PORT 9901
20 #define TESTNET_PORT 9903
24 static inline unsigned short GetDefaultPort(const bool testnet = fTestNet)
26 return testnet ? TESTNET_PORT : PPCOIN_PORT;
30 extern unsigned char pchMessageStart[4];
42 CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn);
44 std::string GetCommand() const;
49 READWRITE(FLATDATA(pchMessageStart));
50 READWRITE(FLATDATA(pchCommand));
51 READWRITE(nMessageSize);
55 // TODO: make private (improves encapsulation)
57 enum { COMMAND_SIZE=12 };
58 char pchMessageStart[sizeof(::pchMessageStart)];
59 char pchCommand[COMMAND_SIZE];
60 unsigned int nMessageSize;
61 unsigned int nChecksum;
64 /** nServices flags */
67 NODE_NETWORK = (1 << 0),
70 /** A CService with information about it as peer */
71 class CAddress : public CService
75 explicit CAddress(CService ipIn, uint64 nServicesIn=NODE_NETWORK);
81 CAddress* pthis = const_cast<CAddress*>(this);
82 CService* pip = (CService*)pthis;
87 if ((nType & SER_DISK) ||
88 (nVersion >= CADDR_TIME_VERSION && !(nType & SER_GETHASH)))
96 // TODO: make private (improves encapsulation)
100 // disk and network only
107 /** inv message data */
112 CInv(int typeIn, const uint256& hashIn);
113 CInv(const std::string& strType, const uint256& hashIn);
121 friend bool operator<(const CInv& a, const CInv& b);
123 bool IsKnownType() const;
124 const char* GetCommand() const;
125 std::string ToString() const;
128 // TODO: make private (improves encapsulation)
134 #endif // __INCLUDED_PROTOCOL_H__