upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorBitflash <admin@bitflash.network>2026-08-20 16:50:04 -0300
committerBitflash <admin@bitflash.network>2026-08-20 16:50:04 -0300
commit721a7e46fadba3251564e2308b7b7eefcb2e9d36 (patch)
treeda4ce79046b258edc1ebc7e0343c696205f26fb2 /src/net.cpp
parent0714027dc6fc7266841eeb088a0c52b6db64a62f (diff)
parent28a2656d22a193fcd92d225964da5a01e8183623 (diff)
Merge pull request 'net: add isolated testnet parameters' (#67) from testnet-prep into main
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 4603d2d..ecfd565 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -50,10 +50,14 @@ static int BtfPoll(BtfPollFd* pfd, unsigned int nfd, int nTimeoutMs)
50// 50//
51// Global state variables 51// Global state variables
52// 52//
53static const char pchMainnetMessageStart[4] = { 0xbf, 0x20, 0x5c, 0xfd };
54static const char pchTestnetMessageStart[4] = { (char)0xce, (char)0xe2, (char)0xc0, (char)0xff };
55static bool fTestNet = false;
56char pchMessageStart[4] = { 0xbf, 0x20, 0x5c, 0xfd };
53bool fClient = false; 57bool fClient = false;
54uint64 nLocalServices = (fClient ? 0 : NODE_NETWORK); 58uint64 nLocalServices = (fClient ? 0 : NODE_NETWORK);
55CAddress addrLocalHost(0, DEFAULT_PORT, nLocalServices); 59CAddress addrLocalHost(0, GetDefaultPort(), nLocalServices);
56unsigned short nListenPort = DEFAULT_PORT; // local P2P port (tunable via /port) 60unsigned short nListenPort = GetDefaultPort(); // local P2P port (tunable via /port)
57CNode nodeLocalHost(INVALID_SOCKET, CAddress("127.0.0.1", nLocalServices)); 61CNode nodeLocalHost(INVALID_SOCKET, CAddress("127.0.0.1", nLocalServices));
58CNode* pnodeLocalHost = &nodeLocalHost; 62CNode* pnodeLocalHost = &nodeLocalHost;
59bool fShutdown = false; 63bool fShutdown = false;
@@ -90,6 +94,29 @@ static int64 nBtfHandshakeSilent = 0;
90static string strBtfLastDialFail; 94static string strBtfLastDialFail;
91static string strBtfLastHandshakeTimeout; 95static string strBtfLastHandshakeTimeout;
92 96
97bool IsTestNet()
98{
99 return fTestNet;
100}
101
102unsigned short GetDefaultPort()
103{
104 return htons(fTestNet ? TESTNET_PORT : MAINNET_PORT);
105}
106
107void SelectNetworkParams(bool fTestNetIn)
108{
109 if (fTestNet == fTestNetIn)
110 return;
111
112 fTestNet = fTestNetIn;
113 memcpy(pchMessageStart,
114 fTestNet ? pchTestnetMessageStart : pchMainnetMessageStart,
115 sizeof(pchMessageStart));
116 nListenPort = GetDefaultPort();
117 addrLocalHost.port = nListenPort;
118}
119
93void BtfChurnNoteResolveAttempt() 120void BtfChurnNoteResolveAttempt()
94{ 121{
95 CRITICAL_BLOCK(cs_btfChurn) 122 CRITICAL_BLOCK(cs_btfChurn)
@@ -288,6 +315,7 @@ string GetDiagnosticsText()
288 int nMedian = GetPeerMedianHeight(); 315 int nMedian = GetPeerMedianHeight();
289 316
290 str += "Bitflash node diagnostics\n"; 317 str += "Bitflash node diagnostics\n";
318 str += strprintf(" network %s\n", IsTestNet() ? "testnet" : "mainnet");
291 str += strprintf(" uptime %s\n", 319 str += strprintf(" uptime %s\n",
292 FormatAge(nNodeStartTime ? nNow - nNodeStartTime : -1).c_str()); 320 FormatAge(nNodeStartTime ? nNow - nNodeStartTime : -1).c_str());
293 if (nMedian < 0) 321 if (nMedian < 0)