upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/net.h b/src/net.h
index 752b1fe..0988542 100644
--- a/src/net.h
+++ b/src/net.h
@@ -12,7 +12,13 @@ class CBlockIndex;
12 12
13 13
14 14
15static 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.
19static const unsigned short MAINNET_PORT = 8433;
20static const unsigned short TESTNET_PORT = 18433;
21static const unsigned int PUBLISH_HOPS = 5;
16enum 22enum
17{ 23{
18 NODE_NETWORK = (1 << 0), 24 NODE_NETWORK = (1 << 0),
@@ -30,6 +36,9 @@ enum
30bool IsBlockFetchNearTip(); 36bool IsBlockFetchNearTip();
31 37
32bool GetMyExternalIP(unsigned int& ipRet); 38bool GetMyExternalIP(unsigned int& ipRet);
39bool IsTestNet();
40unsigned short GetDefaultPort();
41void SelectNetworkParams(bool fTestNetIn);
33CNode* ConnectNodeBtf(const string& strBtfAddr); 42CNode* ConnectNodeBtf(const string& strBtfAddr);
34CNode* ConnectNodeBtfResolved(const string& strBtfAddr, const string& strMeeting, 43CNode* 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
271static const char pchMessageStart[4] = { 0xbf, 0x20, 0x5c, 0xfd }; 280// mainnet before consensus-level testnet activation exists.
281extern char pchMessageStart[4];
272 282
273class CMessageHeader 283class CMessageHeader
274{ 284{
275public: 285public:
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