diff options
Diffstat (limited to 'src/net.h')
| -rw-r--r-- | src/net.h | 25 |
1 files changed, 18 insertions, 7 deletions
| @@ -12,7 +12,13 @@ class CBlockIndex; | |||
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | static const unsigned short DEFAULT_PORT = htons(8433); | 15 | // Held in host byte order, unlike the DEFAULT_PORT constant these replace, |
| 16 | // which was htons(8433). Nothing is lost: net.cpp's GetDefaultPort() applies | ||
| 17 | // htons() itself and is what every caller now uses, so the value that reaches | ||
| 18 | // a sockaddr is byte-for-byte what it was. Mainnet stays on 8433. | ||
| 19 | static const unsigned short MAINNET_PORT = 8433; | ||
| 20 | static const unsigned short TESTNET_PORT = 18433; | ||
| 21 | static const unsigned int PUBLISH_HOPS = 5; | ||
| 16 | enum | 22 | enum |
| 17 | { | 23 | { |
| 18 | NODE_NETWORK = (1 << 0), | 24 | NODE_NETWORK = (1 << 0), |
| @@ -30,6 +36,9 @@ enum | |||
| 30 | bool IsBlockFetchNearTip(); | 36 | bool IsBlockFetchNearTip(); |
| 31 | 37 | ||
| 32 | bool GetMyExternalIP(unsigned int& ipRet); | 38 | bool GetMyExternalIP(unsigned int& ipRet); |
| 39 | bool IsTestNet(); | ||
| 40 | unsigned short GetDefaultPort(); | ||
| 41 | void SelectNetworkParams(bool fTestNetIn); | ||
| 33 | CNode* ConnectNodeBtf(const string& strBtfAddr); | 42 | CNode* ConnectNodeBtf(const string& strBtfAddr); |
| 34 | CNode* ConnectNodeBtfResolved(const string& strBtfAddr, const string& strMeeting, | 43 | CNode* ConnectNodeBtfResolved(const string& strBtfAddr, const string& strMeeting, |
| 35 | const string& strOnion, const unsigned char enc_pub[32], | 44 | const string& strOnion, const unsigned char enc_pub[32], |
| @@ -266,15 +275,17 @@ void CheckForShutdown(int n); | |||
| 266 | // The message start string is designed to be unlikely to occur in normal data. | 275 | // The message start string is designed to be unlikely to occur in normal data. |
| 267 | // The characters are rarely used upper ascii, not valid as UTF-8, and produce | 276 | // The characters are rarely used upper ascii, not valid as UTF-8, and produce |
| 268 | // a large 4-byte int at any alignment. | 277 | // a large 4-byte int at any alignment. |
| 269 | // Magic bytes unique to the Bitflash network (0xbf = "BF"). Second byte bumped | 278 | // Magic bytes unique to the selected Bitflash network. Mainnet uses 0xbf = |
| 270 | // to 0x20 for the 2026 stable relaunch so the old test chain can't interfere. | 279 | // "BF"; testnet swaps the whole sequence so a test node cannot handshake with |
| 271 | static const char pchMessageStart[4] = { 0xbf, 0x20, 0x5c, 0xfd }; | 280 | // mainnet before consensus-level testnet activation exists. |
| 281 | extern char pchMessageStart[4]; | ||
| 272 | 282 | ||
| 273 | class CMessageHeader | 283 | class CMessageHeader |
| 274 | { | 284 | { |
| 275 | public: | 285 | public: |
| 276 | enum { COMMAND_SIZE=12 }; | 286 | enum { COMMAND_SIZE=12 }; |
| 277 | char pchMessageStart[sizeof(::pchMessageStart)]; | 287 | enum { MESSAGE_START_SIZE=4 }; |
| 288 | char pchMessageStart[MESSAGE_START_SIZE]; | ||
| 278 | char pchCommand[COMMAND_SIZE]; | 289 | char pchCommand[COMMAND_SIZE]; |
| 279 | unsigned int nMessageSize; | 290 | unsigned int nMessageSize; |
| 280 | 291 | ||
| @@ -365,7 +376,7 @@ public: | |||
| 365 | nServices = 0; | 376 | nServices = 0; |
| 366 | memcpy(pchReserved, pchIPv4, sizeof(pchReserved)); | 377 | memcpy(pchReserved, pchIPv4, sizeof(pchReserved)); |
| 367 | ip = 0; | 378 | ip = 0; |
| 368 | port = DEFAULT_PORT; | 379 | port = GetDefaultPort(); |
| 369 | nTime = GetAdjustedTime(); | 380 | nTime = GetAdjustedTime(); |
| 370 | nLastFailed = 0; | 381 | nLastFailed = 0; |
| 371 | } | 382 | } |
| @@ -395,7 +406,7 @@ public: | |||
| 395 | nServices = nServicesIn; | 406 | nServices = nServicesIn; |
| 396 | memcpy(pchReserved, pchIPv4, sizeof(pchReserved)); | 407 | memcpy(pchReserved, pchIPv4, sizeof(pchReserved)); |
| 397 | ip = 0; | 408 | ip = 0; |
| 398 | port = DEFAULT_PORT; | 409 | port = GetDefaultPort(); |
| 399 | nTime = GetAdjustedTime(); | 410 | nTime = GetAdjustedTime(); |
| 400 | nLastFailed = 0; | 411 | nLastFailed = 0; |
| 401 | 412 | ||