diff --git a/src/httpserver.h b/src/httpserver.h --- a/src/httpserver.h +++ b/src/httpserver.h @@ -32,7 +32,7 @@ * This is separate from InitHTTPServer to give users race-condition-free time * to register their handlers between InitHTTPServer and StartHTTPServer. */ -bool StartHTTPServer(); +void StartHTTPServer(); /** Interrupt HTTP server threads */ void InterruptHTTPServer(); diff --git a/src/httpserver.cpp b/src/httpserver.cpp --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -438,7 +438,7 @@ std::future threadResult; static std::vector g_thread_http_workers; -bool StartHTTPServer() { +void StartHTTPServer() { LogPrint(BCLog::HTTP, "Starting HTTP server\n"); int rpcThreads = std::max((long)gArgs.GetArg("-rpcthreads", DEFAULT_HTTP_THREADS), 1L); @@ -450,7 +450,6 @@ for (int i = 0; i < rpcThreads; i++) { g_thread_http_workers.emplace_back(HTTPWorkQueueRun, workQueue); } - return true; } void InterruptHTTPServer() { diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -1242,18 +1242,17 @@ if (!InitHTTPServer(config)) { return false; } - if (!StartRPC()) { - return false; - } + + StartRPC(); + if (!StartHTTPRPC(config, httpRPCRequestProcessor)) { return false; } if (gArgs.GetBoolArg("-rest", DEFAULT_REST_ENABLE) && !StartREST()) { return false; } - if (!StartHTTPServer()) { - return false; - } + + StartHTTPServer(); return true; } diff --git a/src/rpc/server.h b/src/rpc/server.h --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -282,7 +282,7 @@ extern std::string HelpExampleRpc(const std::string &methodname, const std::string &args); -bool StartRPC(); +void StartRPC(); void InterruptRPC(); void StopRPC(); std::string JSONRPCExecBatch(Config &config, RPCServer &rpcServer, diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -371,11 +371,10 @@ return true; } -bool StartRPC() { +void StartRPC() { LogPrint(BCLog::RPC, "Starting RPC\n"); fRPCRunning = true; g_rpcSignals.Started(); - return true; } void InterruptRPC() { diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -97,7 +97,7 @@ /** * Disconnect from Tor control port. */ - bool Disconnect(); + void Disconnect(); /** * Send a command, register a handler for the reply. @@ -243,12 +243,11 @@ return true; } -bool TorControlConnection::Disconnect() { +void TorControlConnection::Disconnect() { if (b_conn) { bufferevent_free(b_conn); } b_conn = nullptr; - return true; } bool TorControlConnection::Command(const std::string &cmd, diff --git a/src/txdb.h b/src/txdb.h --- a/src/txdb.h +++ b/src/txdb.h @@ -100,7 +100,7 @@ bool ReadBlockFileInfo(int nFile, CBlockFileInfo &info); bool ReadLastBlockFile(int &nFile); bool WriteReindexing(bool fReindexing); - bool ReadReindexing(bool &fReindexing); + void ReadReindexing(bool &fReindexing); bool WriteFlag(const std::string &name, bool fValue); bool ReadFlag(const std::string &name, bool &fValue); bool LoadBlockIndexGuts( diff --git a/src/txdb.cpp b/src/txdb.cpp --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -169,9 +169,8 @@ return Erase(DB_REINDEX_FLAG); } -bool CBlockTreeDB::ReadReindexing(bool &fReindexing) { +void CBlockTreeDB::ReadReindexing(bool &fReindexing) { fReindexing = Exists(DB_REINDEX_FLAG); - return true; } bool CBlockTreeDB::ReadLastBlockFile(int &nFile) { diff --git a/src/txmempool.h b/src/txmempool.h --- a/src/txmempool.h +++ b/src/txmempool.h @@ -589,8 +589,8 @@ // Note that addUnchecked is ONLY called from ATMP outside of tests // and any other callers may break wallet's in-mempool tracking (due to // lack of CValidationInterface::TransactionAddedToMempool callbacks). - bool addUnchecked(const uint256 &hash, const CTxMemPoolEntry &entry); - bool addUnchecked(const uint256 &hash, const CTxMemPoolEntry &entry, + void addUnchecked(const uint256 &hash, const CTxMemPoolEntry &entry); + void addUnchecked(const uint256 &hash, const CTxMemPoolEntry &entry, setEntries &setAncestors); void removeRecursive( diff --git a/src/txmempool.cpp b/src/txmempool.cpp --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -409,7 +409,7 @@ nTransactionsUpdated += n; } -bool CTxMemPool::addUnchecked(const uint256 &hash, const CTxMemPoolEntry &entry, +void CTxMemPool::addUnchecked(const uint256 &hash, const CTxMemPoolEntry &entry, setEntries &setAncestors) { NotifyEntryAdded(entry.GetSharedTx()); // Add to memory pool without checking anything. @@ -462,8 +462,6 @@ vTxHashes.emplace_back(tx.GetHash(), newit); newit->vTxHashesIdx = vTxHashes.size() - 1; - - return true; } void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason) { @@ -1084,7 +1082,7 @@ } } -bool CTxMemPool::addUnchecked(const uint256 &hash, +void CTxMemPool::addUnchecked(const uint256 &hash, const CTxMemPoolEntry &entry) { LOCK(cs); setEntries setAncestors; diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -665,13 +665,13 @@ CBlockIndex *pindex); /** Remove invalidity status from a block and its descendants. */ -bool ResetBlockFailureFlags(CBlockIndex *pindex); +void ResetBlockFailureFlags(CBlockIndex *pindex); /** Remove parked status from a block and its descendants. */ -bool UnparkBlockAndChildren(CBlockIndex *pindex); +void UnparkBlockAndChildren(CBlockIndex *pindex); /** Remove parked status from a block. */ -bool UnparkBlock(CBlockIndex *pindex); +void UnparkBlock(CBlockIndex *pindex); /** * Retrieve the topmost finalized block. diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -166,7 +166,7 @@ CBlockIndex *pindex); bool UnwindBlock(const Config &config, CValidationState &state, CBlockIndex *pindex, bool invalidate); - bool ResetBlockFailureFlags(CBlockIndex *pindex); + void ResetBlockFailureFlags(CBlockIndex *pindex); template void UpdateFlagsForBlock(CBlockIndex *pindexBase, CBlockIndex *pindex, F f); template @@ -176,7 +176,7 @@ void UpdateFlags(CBlockIndex *pindex, F f) EXCLUSIVE_LOCKS_REQUIRED(cs_main); /** Remove parked status from a block and its descendants. */ - bool UnparkBlockImpl(CBlockIndex *pindex, bool fClearChildren); + void UnparkBlockImpl(CBlockIndex *pindex, bool fClearChildren); bool ReplayBlocks(const Consensus::Params ¶ms, CCoinsView *view); bool RewindBlockIndex(const Config &config); @@ -3219,7 +3219,7 @@ UpdateFlags(pindex, f, f); } -bool CChainState::ResetBlockFailureFlags(CBlockIndex *pindex) { +void CChainState::ResetBlockFailureFlags(CBlockIndex *pindex) { AssertLockHeld(cs_main); if (pindexBestInvalid && @@ -3239,15 +3239,13 @@ UpdateFlags(pindex, [](const BlockStatus status) { return status.withClearedFailureFlags(); }); - - return true; } -bool ResetBlockFailureFlags(CBlockIndex *pindex) { +void ResetBlockFailureFlags(CBlockIndex *pindex) { return g_chainstate.ResetBlockFailureFlags(pindex); } -bool CChainState::UnparkBlockImpl(CBlockIndex *pindex, bool fClearChildren) { +void CChainState::UnparkBlockImpl(CBlockIndex *pindex, bool fClearChildren) { AssertLockHeld(cs_main); if (pindexBestParked && @@ -3265,15 +3263,13 @@ return fClearChildren ? status.withClearedParkedFlags() : status.withParkedParent(false); }); - - return true; } -bool UnparkBlockAndChildren(CBlockIndex *pindex) { +void UnparkBlockAndChildren(CBlockIndex *pindex) { return g_chainstate.UnparkBlockImpl(pindex, true); } -bool UnparkBlock(CBlockIndex *pindex) { +void UnparkBlock(CBlockIndex *pindex) { return g_chainstate.UnparkBlockImpl(pindex, false); } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -919,9 +919,9 @@ } //! Load metadata (used by LoadWallet) - bool LoadKeyMetadata(const CKeyID &keyID, const CKeyMetadata &metadata) + void LoadKeyMetadata(const CKeyID &keyID, const CKeyMetadata &metadata) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); - bool LoadScriptMetadata(const CScriptID &script_id, + void LoadScriptMetadata(const CScriptID &script_id, const CKeyMetadata &metadata) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); @@ -950,7 +950,7 @@ //! Erases a destination data tuple in the store and on disk bool EraseDestData(const CTxDestination &dest, const std::string &key); //! Adds a destination data tuple to the store, without saving it to disk - bool LoadDestData(const CTxDestination &dest, const std::string &key, + void LoadDestData(const CTxDestination &dest, const std::string &key, const std::string &value); //! Look up a destination data tuple in the store, return true if found //! false otherwise @@ -997,7 +997,7 @@ void MarkDirty(); bool AddToWallet(const CWalletTx &wtxIn, bool fFlushOnClose = true); - bool LoadToWallet(const CWalletTx &wtxIn); + void LoadToWallet(const CWalletTx &wtxIn); void TransactionAddedToMempool(const CTransactionRef &tx) override; void BlockConnected(const std::shared_ptr &pblock, @@ -1165,7 +1165,7 @@ //! signify that a particular wallet feature is now used. this may change //! nWalletVersion and nWalletMaxVersion if those are lower - bool SetMinVersion(enum WalletFeature, WalletBatch *batch_in = nullptr, + void SetMinVersion(enum WalletFeature, WalletBatch *batch_in = nullptr, bool fExplicit = false); //! change which version we're allowed to upgrade to (note that this does @@ -1254,7 +1254,7 @@ bool BackupWallet(const std::string &strDest); /* Set the HD chain model (chain child index counters) */ - bool SetHDChain(const CHDChain &chain, bool memonly); + void SetHDChain(const CHDChain &chain, bool memonly); const CHDChain &GetHDChain() const { return hdChain; } /* Returns true if HD is enabled */ @@ -1269,7 +1269,7 @@ * caller must ensure the current wallet version is correct before calling * this function). */ - bool SetHDMasterKey(const CPubKey &key); + void SetHDMasterKey(const CPubKey &key); /** * Blocks until the wallet state is up-to-date to /at least/ the current diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -319,21 +319,19 @@ vchPubKey, vchCryptedSecret, mapKeyMetadata[vchPubKey.GetID()]); } -bool CWallet::LoadKeyMetadata(const CKeyID &keyID, const CKeyMetadata &meta) { +void CWallet::LoadKeyMetadata(const CKeyID &keyID, const CKeyMetadata &meta) { // mapKeyMetadata AssertLockHeld(cs_wallet); UpdateTimeFirstKey(meta.nCreateTime); mapKeyMetadata[keyID] = meta; - return true; } -bool CWallet::LoadScriptMetadata(const CScriptID &script_id, +void CWallet::LoadScriptMetadata(const CScriptID &script_id, const CKeyMetadata &meta) { // m_script_metadata AssertLockHeld(cs_wallet); UpdateTimeFirstKey(meta.nCreateTime); m_script_metadata[script_id] = meta; - return true; } bool CWallet::LoadCryptedKey(const CPubKey &vchPubKey, @@ -526,12 +524,12 @@ batch.WriteBestBlock(loc); } -bool CWallet::SetMinVersion(enum WalletFeature nVersion, WalletBatch *batch_in, +void CWallet::SetMinVersion(enum WalletFeature nVersion, WalletBatch *batch_in, bool fExplicit) { // nWalletVersion LOCK(cs_wallet); if (nWalletVersion >= nVersion) { - return true; + return; } // When doing an explicit upgrade, if we pass the max version permitted, @@ -553,8 +551,6 @@ if (!batch_in) { delete batch; } - - return true; } bool CWallet::SetMaxVersion(int nVersion) { @@ -785,9 +781,7 @@ // If we are using HD, replace the HD master key (seed) with a new one. if (IsHDEnabled()) { - if (!SetHDMasterKey(GenerateNewHDMasterKey())) { - return false; - } + SetHDMasterKey(GenerateNewHDMasterKey()); } NewKeyPool(); @@ -1049,7 +1043,7 @@ return true; } -bool CWallet::LoadToWallet(const CWalletTx &wtxIn) { +void CWallet::LoadToWallet(const CWalletTx &wtxIn) { const TxId &txid = wtxIn.GetId(); CWalletTx &wtx = mapWallet.emplace(txid, wtxIn).first->second; wtx.BindWallet(this); @@ -1064,8 +1058,6 @@ } } } - - return true; } /** @@ -1576,7 +1568,7 @@ return pubkey; } -bool CWallet::SetHDMasterKey(const CPubKey &pubkey) { +void CWallet::SetHDMasterKey(const CPubKey &pubkey) { LOCK(cs_wallet); // Store the keyid (hash160) together with the child index counter in the @@ -1587,11 +1579,9 @@ : CHDChain::VERSION_HD_BASE; newHdChain.masterKeyID = pubkey.GetID(); SetHDChain(newHdChain, false); - - return true; } -bool CWallet::SetHDChain(const CHDChain &chain, bool memonly) { +void CWallet::SetHDChain(const CHDChain &chain, bool memonly) { LOCK(cs_wallet); if (!memonly && !WalletBatch(*database).WriteHDChain(chain)) { throw std::runtime_error(std::string(__func__) + @@ -1599,7 +1589,6 @@ } hdChain = chain; - return true; } bool CWallet::IsHDEnabled() const { @@ -4203,10 +4192,9 @@ return WalletBatch(*database).EraseDestData(dest, key); } -bool CWallet::LoadDestData(const CTxDestination &dest, const std::string &key, +void CWallet::LoadDestData(const CTxDestination &dest, const std::string &key, const std::string &value) { mapAddressBook[dest].destdata.insert(std::make_pair(key, value)); - return true; } bool CWallet::GetDestData(const CTxDestination &dest, const std::string &key, @@ -4396,10 +4384,7 @@ // Generate a new master key. CPubKey masterPubKey = walletInstance->GenerateNewHDMasterKey(); - if (!walletInstance->SetHDMasterKey(masterPubKey)) { - throw std::runtime_error(std::string(__func__) + - ": Storing master key failed"); - } + walletInstance->SetHDMasterKey(masterPubKey); // Top up the keypool if (!walletInstance->TopUpKeyPool()) { diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -494,19 +494,13 @@ ssKey >> strAddress; ssKey >> strKey; ssValue >> strValue; - if (!pwallet->LoadDestData( - DecodeDestination(strAddress, pwallet->chainParams), strKey, - strValue)) { - strErr = "Error reading wallet database: LoadDestData failed"; - return false; - } + pwallet->LoadDestData( + DecodeDestination(strAddress, pwallet->chainParams), strKey, + strValue); } else if (strType == "hdchain") { CHDChain chain; ssValue >> chain; - if (!pwallet->SetHDChain(chain, true)) { - strErr = "Error reading wallet database: SetHDChain failed"; - return false; - } + pwallet->SetHDChain(chain, true); } else if (strType != "bestblock" && strType != "bestblock_nomerkle") { wss.m_unknown_records++; }