Skip to content

Commit 50ea909

Browse files
committed
Merge remote-tracking branch 'xyephy/improve-startup-logging'
2 parents d3b1748 + d5e5c08 commit 50ea909

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/sv2-tp.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <logging.h>
1717
#include <sv2/template_provider.h>
1818
#include <tinyformat.h>
19+
#include <util/chaintype.h>
1920
#include <util/translation.h>
2021

2122
#ifndef WIN32
@@ -131,6 +132,9 @@ MAIN_FUNCTION
131132
return EXIT_FAILURE;
132133
}
133134

135+
const ChainType chain_type = args.GetChainType();
136+
LogPrintf("Starting sv2-tp on %s network\n", ChainTypeToString(chain_type));
137+
134138
ECC_Context ecc_context{};
135139
std::string sha256_algo = SHA256AutoDetect();
136140
LogInfo("Using the '%s' SHA256 implementation\n", sha256_algo);
@@ -171,20 +175,23 @@ MAIN_FUNCTION
171175
assert(mine_init);
172176
std::unique_ptr<interfaces::Init> node_init;
173177
std::string address{args.GetArg("-ipcconnect", "unix")};
178+
179+
LogPrintf("Attempting IPC connection to bitcoin-node at %s\n", address);
180+
LogPrintf("Ensure Bitcoin Core is running with '-ipcbind=unix' and the correct network (%s)\n",
181+
ChainTypeToString(chain_type));
182+
174183
while (true) {
175184
try {
176185
node_init = mine_init->ipc()->connectAddress(address);
186+
LogPrintf("Connected to bitcoin-node via IPC at: %s\n", address);
177187
break; // Success: break out of the loop
178188
} catch (const std::exception& exception) {
179189
LogPrintf("IPC connection failed: %s\n", exception.what());
180-
LogPrintf("bitcoin-node might not be running or listening on a UNIX socket.\n");
181-
LogPrintf("Retrying in 10 seconds...\n");
182-
190+
LogPrintf("Retrying in 10 seconds... (Ensure Bitcoin Core is running with '-ipcbind=unix')\n");
183191
std::this_thread::sleep_for(std::chrono::seconds(10));
184192
}
185193
}
186194
assert(node_init);
187-
tfm::format(std::cout, "Connected to bitcoin-node\n");
188195
std::unique_ptr<interfaces::Mining> mining{node_init->makeMining()};
189196
assert(mining);
190197

@@ -195,6 +202,9 @@ MAIN_FUNCTION
195202
return EXIT_FAILURE;
196203
}
197204

205+
LogPrintf("sv2-tp listening for Stratum v2 connections on %s:%d\n",
206+
options.host, options.port);
207+
198208
#ifndef WIN32
199209
registerSignalHandler(SIGTERM, HandleSIGTERM);
200210
registerSignalHandler(SIGINT, HandleSIGTERM);

src/sv2/template_provider.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <logging.h>
88
#include <sv2/noise.h>
99
#include <consensus/validation.h> // NO_WITNESS_COMMITMENT
10+
#include <util/chaintype.h>
1011
#include <util/readwritefile.h>
1112
#include <util/strencodings.h>
1213
#include <util/thread.h>
@@ -167,12 +168,19 @@ void Sv2TemplateProvider::ThreadSv2Handler()
167168
}
168169

169170
// Wait to come out of IBD, except on signet, where we might be the only miner.
171+
size_t log_ibd{0};
170172
while (!m_flag_interrupt_sv2 && gArgs.GetChainType() != ChainType::SIGNET) {
171173
// TODO: Wait until there's no headers-only branch with more work than our chaintip.
172174
// The current check can still cause us to broadcast a few dozen useless templates
173175
// at startup.
174176
if (!m_mining.isInitialBlockDownload()) break;
175-
LogPrintLevel(BCLog::SV2, BCLog::Level::Trace, "Waiting to come out of IBD\n");
177+
if (log_ibd == 0) {
178+
LogPrintf("Waiting for IBD to complete on %s network before serving templates (this may take a while)\n",
179+
ChainTypeToString(gArgs.GetChainType()));
180+
} else if (log_ibd % 10 == 0) {
181+
LogPrintf(".\n");
182+
}
183+
log_ibd++;
176184
std::this_thread::sleep_for(1000ms);
177185
}
178186

0 commit comments

Comments
 (0)