Skip to content

Commit d78a8dc

Browse files
Return void instead of bool for functions that cannot fail
* CBlockTreeDB::ReadReindexing(...) * CChainState::ResetBlockFailureFlags(...) * CTxMemPool::addUnchecked(...) * CWallet::LoadDestData(...) * CWallet::LoadKeyMetadata(...) * CWallet::LoadScriptMetadata(...) * CWallet::LoadToWallet(...) * CWallet::SetHDChain(...) * CWallet::SetHDSeed(...) * RemoveLocal(...) * SetMinVersion(...) * StartHTTPServer(...) * StartRPC(...) * TorControlConnection::Disconnect(...)
1 parent f58674a commit d78a8dc

17 files changed

+41
-74
lines changed

src/httpserver.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ std::thread threadHTTP;
423423
std::future<bool> threadResult;
424424
static std::vector<std::thread> g_thread_http_workers;
425425

426-
bool StartHTTPServer()
426+
void StartHTTPServer()
427427
{
428428
LogPrint(BCLog::HTTP, "Starting HTTP server\n");
429429
int rpcThreads = std::max((long)gArgs.GetArg("-rpcthreads", DEFAULT_HTTP_THREADS), 1L);
@@ -435,7 +435,6 @@ bool StartHTTPServer()
435435
for (int i = 0; i < rpcThreads; i++) {
436436
g_thread_http_workers.emplace_back(HTTPWorkQueueRun, workQueue);
437437
}
438-
return true;
439438
}
440439

441440
void InterruptHTTPServer()

src/httpserver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ bool InitHTTPServer();
2626
* This is separate from InitHTTPServer to give users race-condition-free time
2727
* to register their handlers between InitHTTPServer and StartHTTPServer.
2828
*/
29-
bool StartHTTPServer();
29+
void StartHTTPServer();
3030
/** Interrupt HTTP server threads */
3131
void InterruptHTTPServer();
3232
/** Stop HTTP server */

src/init.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -731,14 +731,12 @@ static bool AppInitServers()
731731
RPCServer::OnStopped(&OnRPCStopped);
732732
if (!InitHTTPServer())
733733
return false;
734-
if (!StartRPC())
735-
return false;
734+
StartRPC();
736735
if (!StartHTTPRPC())
737736
return false;
738737
if (gArgs.GetBoolArg("-rest", DEFAULT_REST_ENABLE) && !StartREST())
739738
return false;
740-
if (!StartHTTPServer())
741-
return false;
739+
StartHTTPServer();
742740
return true;
743741
}
744742

src/net.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,11 @@ bool AddLocal(const CNetAddr &addr, int nScore)
235235
return AddLocal(CService(addr, GetListenPort()), nScore);
236236
}
237237

238-
bool RemoveLocal(const CService& addr)
238+
void RemoveLocal(const CService& addr)
239239
{
240240
LOCK(cs_mapLocalHost);
241241
LogPrintf("RemoveLocal(%s)\n", addr.ToString());
242242
mapLocalHost.erase(addr);
243-
return true;
244243
}
245244

246245
/** Make a particular network entirely off-limits (no automatic connects to it) */

src/net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ bool IsLimited(enum Network net);
505505
bool IsLimited(const CNetAddr& addr);
506506
bool AddLocal(const CService& addr, int nScore = LOCAL_NONE);
507507
bool AddLocal(const CNetAddr& addr, int nScore = LOCAL_NONE);
508-
bool RemoveLocal(const CService& addr);
508+
void RemoveLocal(const CService& addr);
509509
bool SeenLocal(const CService& addr);
510510
bool IsLocal(const CService& addr);
511511
bool GetLocal(CService &addr, const CNetAddr *paddrPeer = nullptr);

src/rpc/server.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,11 @@ bool CRPCTable::appendCommand(const std::string& name, const CRPCCommand* pcmd)
301301
return true;
302302
}
303303

304-
bool StartRPC()
304+
void StartRPC()
305305
{
306306
LogPrint(BCLog::RPC, "Starting RPC\n");
307307
fRPCRunning = true;
308308
g_rpcSignals.Started();
309-
return true;
310309
}
311310

312311
void InterruptRPC()

src/rpc/server.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ extern CAmount AmountFromValue(const UniValue& value);
198198
extern std::string HelpExampleCli(const std::string& methodname, const std::string& args);
199199
extern std::string HelpExampleRpc(const std::string& methodname, const std::string& args);
200200

201-
bool StartRPC();
201+
void StartRPC();
202202
void InterruptRPC();
203203
void StopRPC();
204204
std::string JSONRPCExecBatch(const JSONRPCRequest& jreq, const UniValue& vReq);

src/torcontrol.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class TorControlConnection
9191
/**
9292
* Disconnect from Tor control port.
9393
*/
94-
bool Disconnect();
94+
void Disconnect();
9595

9696
/** Send a command, register a handler for the reply.
9797
* A trailing CRLF is automatically added.
@@ -223,12 +223,11 @@ bool TorControlConnection::Connect(const std::string &target, const ConnectionCB
223223
return true;
224224
}
225225

226-
bool TorControlConnection::Disconnect()
226+
void TorControlConnection::Disconnect()
227227
{
228228
if (b_conn)
229229
bufferevent_free(b_conn);
230230
b_conn = nullptr;
231-
return true;
232231
}
233232

234233
bool TorControlConnection::Command(const std::string &cmd, const ReplyHandlerCB& reply_handler)

src/txdb.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,8 @@ bool CBlockTreeDB::WriteReindexing(bool fReindexing) {
160160
return Erase(DB_REINDEX_FLAG);
161161
}
162162

163-
bool CBlockTreeDB::ReadReindexing(bool &fReindexing) {
163+
void CBlockTreeDB::ReadReindexing(bool &fReindexing) {
164164
fReindexing = Exists(DB_REINDEX_FLAG);
165-
return true;
166165
}
167166

168167
bool CBlockTreeDB::ReadLastBlockFile(int &nFile) {

src/txdb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class CBlockTreeDB : public CDBWrapper
9292
bool ReadBlockFileInfo(int nFile, CBlockFileInfo &info);
9393
bool ReadLastBlockFile(int &nFile);
9494
bool WriteReindexing(bool fReindexing);
95-
bool ReadReindexing(bool &fReindexing);
95+
void ReadReindexing(bool &fReindexing);
9696
bool WriteFlag(const std::string &name, bool fValue);
9797
bool ReadFlag(const std::string &name, bool &fValue);
9898
bool LoadBlockIndexGuts(const Consensus::Params& consensusParams, std::function<CBlockIndex*(const uint256&)> insertBlockIndex);

0 commit comments

Comments
 (0)