aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bench/block_assemble.cpp12
-rw-r--r--src/bench/prevector.cpp28
-rw-r--r--src/httpserver.cpp9
-rw-r--r--src/httpserver.h2
-rw-r--r--src/init.cpp8
-rw-r--r--src/miner.cpp4
-rw-r--r--src/net.cpp3
-rw-r--r--src/net.h2
-rw-r--r--src/rpc/server.cpp3
-rw-r--r--src/rpc/server.h2
-rw-r--r--src/script/interpreter.cpp6
-rw-r--r--src/torcontrol.cpp5
-rw-r--r--src/txdb.cpp3
-rw-r--r--src/txdb.h2
-rw-r--r--src/txmempool.cpp6
-rw-r--r--src/txmempool.h4
-rw-r--r--src/validation.cpp8
-rw-r--r--src/validation.h2
-rw-r--r--src/wallet/wallet.cpp42
-rw-r--r--src/wallet/wallet.h14
-rw-r--r--src/wallet/walletdb.cpp12
21 files changed, 88 insertions, 89 deletions
diff --git a/src/bench/block_assemble.cpp b/src/bench/block_assemble.cpp
index 36fa175a76..9b53c6b023 100644
--- a/src/bench/block_assemble.cpp
+++ b/src/bench/block_assemble.cpp
@@ -97,10 +97,14 @@ static void AssembleBlock(benchmark::State& state)
if (NUM_BLOCKS - b >= COINBASE_MATURITY)
txs.at(b) = MakeTransactionRef(tx);
}
- for (const auto& txr : txs) {
- CValidationState state;
- bool ret{::AcceptToMemoryPool(::mempool, state, txr, nullptr /* pfMissingInputs */, nullptr /* plTxnReplaced */, false /* bypass_limits */, /* nAbsurdFee */ 0)};
- assert(ret);
+ {
+ LOCK(::cs_main); // Required for ::AcceptToMemoryPool.
+
+ for (const auto& txr : txs) {
+ CValidationState state;
+ bool ret{::AcceptToMemoryPool(::mempool, state, txr, nullptr /* pfMissingInputs */, nullptr /* plTxnReplaced */, false /* bypass_limits */, /* nAbsurdFee */ 0)};
+ assert(ret);
+ }
}
while (state.KeepRunning()) {
diff --git a/src/bench/prevector.cpp b/src/bench/prevector.cpp
index 09c7020848..7986d0da79 100644
--- a/src/bench/prevector.cpp
+++ b/src/bench/prevector.cpp
@@ -4,12 +4,17 @@
#include <compat.h>
#include <prevector.h>
+#include <serialize.h>
+#include <streams.h>
#include <bench/bench.h>
struct nontrivial_t {
int x;
nontrivial_t() :x(-1) {}
+ ADD_SERIALIZE_METHODS
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action) {READWRITE(x);}
};
static_assert(!IS_TRIVIALLY_CONSTRUCTIBLE<nontrivial_t>::value,
"expected nontrivial_t to not be trivially constructible");
@@ -62,6 +67,28 @@ static void PrevectorResize(benchmark::State& state)
}
}
+template <typename T>
+static void PrevectorDeserialize(benchmark::State& state)
+{
+ CDataStream s0(SER_NETWORK, 0);
+ prevector<28, T> t0;
+ t0.resize(28);
+ for (auto x = 0; x < 900; ++x) {
+ s0 << t0;
+ }
+ t0.resize(100);
+ for (auto x = 0; x < 101; ++x) {
+ s0 << t0;
+ }
+ while (state.KeepRunning()) {
+ prevector<28, T> t1;
+ for (auto x = 0; x < 1000; ++x) {
+ s0 >> t1;
+ }
+ s0.Init(SER_NETWORK, 0);
+ }
+}
+
#define PREVECTOR_TEST(name, nontrivops, trivops) \
static void Prevector ## name ## Nontrivial(benchmark::State& state) { \
Prevector ## name<nontrivial_t>(state); \
@@ -75,3 +102,4 @@ static void PrevectorResize(benchmark::State& state)
PREVECTOR_TEST(Clear, 28300, 88600)
PREVECTOR_TEST(Destructor, 28800, 88900)
PREVECTOR_TEST(Resize, 28900, 90300)
+PREVECTOR_TEST(Deserialize, 6800, 52000)
diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index bd08b04c0f..9daf3d1968 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -279,7 +279,7 @@ static void http_reject_request_cb(struct evhttp_request* req, void*)
}
/** Event dispatcher thread */
-static bool ThreadHTTP(struct event_base* base, struct evhttp* http)
+static bool ThreadHTTP(struct event_base* base)
{
RenameThread("bitcoin-http");
LogPrint(BCLog::HTTP, "Entering http event loop\n");
@@ -423,19 +423,18 @@ std::thread threadHTTP;
std::future<bool> threadResult;
static std::vector<std::thread> 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);
LogPrintf("HTTP: starting %d worker threads\n", rpcThreads);
- std::packaged_task<bool(event_base*, evhttp*)> task(ThreadHTTP);
+ std::packaged_task<bool(event_base*)> task(ThreadHTTP);
threadResult = task.get_future();
- threadHTTP = std::thread(std::move(task), eventBase, eventHTTP);
+ threadHTTP = std::thread(std::move(task), eventBase);
for (int i = 0; i < rpcThreads; i++) {
g_thread_http_workers.emplace_back(HTTPWorkQueueRun, workQueue);
}
- return true;
}
void InterruptHTTPServer()
diff --git a/src/httpserver.h b/src/httpserver.h
index 8132c887b5..8a3adaf91f 100644
--- a/src/httpserver.h
+++ b/src/httpserver.h
@@ -26,7 +26,7 @@ bool InitHTTPServer();
* 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();
/** Stop HTTP server */
diff --git a/src/init.cpp b/src/init.cpp
index c7ea40817d..18402ef5d7 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -731,14 +731,12 @@ static bool AppInitServers()
RPCServer::OnStopped(&OnRPCStopped);
if (!InitHTTPServer())
return false;
- if (!StartRPC())
- return false;
+ StartRPC();
if (!StartHTTPRPC())
return false;
if (gArgs.GetBoolArg("-rest", DEFAULT_REST_ENABLE) && !StartREST())
return false;
- if (!StartHTTPServer())
- return false;
+ StartHTTPServer();
return true;
}
@@ -927,7 +925,7 @@ bool AppInitParameterInteraction()
// also see: InitParameterInteraction()
if (!fs::is_directory(GetBlocksDir(false))) {
- return InitError(strprintf(_("Specified blocks directory \"%s\" does not exist.\n"), gArgs.GetArg("-blocksdir", "").c_str()));
+ return InitError(strprintf(_("Specified blocks directory \"%s\" does not exist."), gArgs.GetArg("-blocksdir", "").c_str()));
}
// if using block pruning, then disallow txindex
diff --git a/src/miner.cpp b/src/miner.cpp
index 738ccad1b9..c32dc26f86 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -64,7 +64,7 @@ BlockAssembler::BlockAssembler(const CChainParams& params, const Options& option
nBlockMaxWeight = std::max<size_t>(4000, std::min<size_t>(MAX_BLOCK_WEIGHT - 4000, options.nBlockMaxWeight));
}
-static BlockAssembler::Options DefaultOptions(const CChainParams& params)
+static BlockAssembler::Options DefaultOptions()
{
// Block resource limits
// If -blockmaxweight is not given, limit to DEFAULT_BLOCK_MAX_WEIGHT
@@ -80,7 +80,7 @@ static BlockAssembler::Options DefaultOptions(const CChainParams& params)
return options;
}
-BlockAssembler::BlockAssembler(const CChainParams& params) : BlockAssembler(params, DefaultOptions(params)) {}
+BlockAssembler::BlockAssembler(const CChainParams& params) : BlockAssembler(params, DefaultOptions()) {}
void BlockAssembler::resetBlock()
{
diff --git a/src/net.cpp b/src/net.cpp
index 67a73fa9fc..0ebfefa757 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -235,12 +235,11 @@ bool AddLocal(const CNetAddr &addr, int nScore)
return AddLocal(CService(addr, GetListenPort()), nScore);
}
-bool RemoveLocal(const CService& addr)
+void RemoveLocal(const CService& addr)
{
LOCK(cs_mapLocalHost);
LogPrintf("RemoveLocal(%s)\n", addr.ToString());
mapLocalHost.erase(addr);
- return true;
}
/** Make a particular network entirely off-limits (no automatic connects to it) */
diff --git a/src/net.h b/src/net.h
index 607b2fc53c..36c2a4b8f5 100644
--- a/src/net.h
+++ b/src/net.h
@@ -505,7 +505,7 @@ bool IsLimited(enum Network net);
bool IsLimited(const CNetAddr& addr);
bool AddLocal(const CService& addr, int nScore = LOCAL_NONE);
bool AddLocal(const CNetAddr& addr, int nScore = LOCAL_NONE);
-bool RemoveLocal(const CService& addr);
+void RemoveLocal(const CService& addr);
bool SeenLocal(const CService& addr);
bool IsLocal(const CService& addr);
bool GetLocal(CService &addr, const CNetAddr *paddrPeer = nullptr);
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp
index b420e9d8b3..e46bf2f765 100644
--- a/src/rpc/server.cpp
+++ b/src/rpc/server.cpp
@@ -301,12 +301,11 @@ bool CRPCTable::appendCommand(const std::string& name, const CRPCCommand* pcmd)
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/rpc/server.h b/src/rpc/server.h
index 373914885c..a9dbfbd21f 100644
--- a/src/rpc/server.h
+++ b/src/rpc/server.h
@@ -198,7 +198,7 @@ extern CAmount AmountFromValue(const UniValue& value);
extern std::string HelpExampleCli(const std::string& methodname, const std::string& args);
extern std::string HelpExampleRpc(const std::string& methodname, const std::string& args);
-bool StartRPC();
+void StartRPC();
void InterruptRPC();
void StopRPC();
std::string JSONRPCExecBatch(const JSONRPCRequest& jreq, const UniValue& vReq);
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index 1936d44cd5..be2138d502 100644
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -1588,7 +1588,7 @@ bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const C
return set_success(serror);
}
-size_t static WitnessSigOps(int witversion, const std::vector<unsigned char>& witprogram, const CScriptWitness& witness, int flags)
+size_t static WitnessSigOps(int witversion, const std::vector<unsigned char>& witprogram, const CScriptWitness& witness)
{
if (witversion == 0) {
if (witprogram.size() == WITNESS_V0_KEYHASH_SIZE)
@@ -1616,7 +1616,7 @@ size_t CountWitnessSigOps(const CScript& scriptSig, const CScript& scriptPubKey,
int witnessversion;
std::vector<unsigned char> witnessprogram;
if (scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) {
- return WitnessSigOps(witnessversion, witnessprogram, witness ? *witness : witnessEmpty, flags);
+ return WitnessSigOps(witnessversion, witnessprogram, witness ? *witness : witnessEmpty);
}
if (scriptPubKey.IsPayToScriptHash() && scriptSig.IsPushOnly()) {
@@ -1628,7 +1628,7 @@ size_t CountWitnessSigOps(const CScript& scriptSig, const CScript& scriptPubKey,
}
CScript subscript(data.begin(), data.end());
if (subscript.IsWitnessProgram(witnessversion, witnessprogram)) {
- return WitnessSigOps(witnessversion, witnessprogram, witness ? *witness : witnessEmpty, flags);
+ return WitnessSigOps(witnessversion, witnessprogram, witness ? *witness : witnessEmpty);
}
}
diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp
index 1f42ab8fa8..fbc193c2cf 100644
--- a/src/torcontrol.cpp
+++ b/src/torcontrol.cpp
@@ -91,7 +91,7 @@ public:
/**
* Disconnect from Tor control port.
*/
- bool Disconnect();
+ void Disconnect();
/** Send a command, register a handler for the reply.
* A trailing CRLF is automatically added.
@@ -223,12 +223,11 @@ bool TorControlConnection::Connect(const std::string &target, const ConnectionCB
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, const ReplyHandlerCB& reply_handler)
diff --git a/src/txdb.cpp b/src/txdb.cpp
index 1fc7919442..cbea550739 100644
--- a/src/txdb.cpp
+++ b/src/txdb.cpp
@@ -160,9 +160,8 @@ bool CBlockTreeDB::WriteReindexing(bool fReindexing) {
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/txdb.h b/src/txdb.h
index 100adb428d..84011097ce 100644
--- a/src/txdb.h
+++ b/src/txdb.h
@@ -92,7 +92,7 @@ public:
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(const Consensus::Params& consensusParams, std::function<CBlockIndex*(const uint256&)> insertBlockIndex);
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 2108e6ba2d..9d705e3d23 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -357,7 +357,7 @@ void CTxMemPool::AddTransactionsUpdated(unsigned int n)
nTransactionsUpdated += n;
}
-bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, setEntries &setAncestors, bool validFeeEstimate)
+void CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, setEntries &setAncestors, bool validFeeEstimate)
{
NotifyEntryAdded(entry.GetSharedTx());
// Add to memory pool without checking anything.
@@ -412,8 +412,6 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry,
vTxHashes.emplace_back(tx.GetWitnessHash(), newit);
newit->vTxHashesIdx = vTxHashes.size() - 1;
-
- return true;
}
void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason)
@@ -933,7 +931,7 @@ int CTxMemPool::Expire(int64_t time) {
return stage.size();
}
-bool CTxMemPool::addUnchecked(const uint256&hash, const CTxMemPoolEntry &entry, bool validFeeEstimate)
+void CTxMemPool::addUnchecked(const uint256&hash, const CTxMemPoolEntry &entry, bool validFeeEstimate)
{
LOCK(cs);
setEntries setAncestors;
diff --git a/src/txmempool.h b/src/txmempool.h
index f3b8a68a9d..bb676cf05d 100644
--- a/src/txmempool.h
+++ b/src/txmempool.h
@@ -539,8 +539,8 @@ public:
// 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 validFeeEstimate = true);
- bool addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, setEntries &setAncestors, bool validFeeEstimate = true);
+ void addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, bool validFeeEstimate = true);
+ void addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, setEntries &setAncestors, bool validFeeEstimate = true);
void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason = MemPoolRemovalReason::UNKNOWN);
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags);
diff --git a/src/validation.cpp b/src/validation.cpp
index f1b63b5b44..702a8d7e05 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -178,7 +178,7 @@ public:
// Manual block validity manipulation:
bool PreciousBlock(CValidationState& state, const CChainParams& params, CBlockIndex* pindex) LOCKS_EXCLUDED(cs_main);
bool InvalidateBlock(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
- bool ResetBlockFailureFlags(CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
+ void ResetBlockFailureFlags(CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
bool ReplayBlocks(const CChainParams& params, CCoinsView* view);
bool RewindBlockIndex(const CChainParams& params);
@@ -2882,7 +2882,7 @@ bool InvalidateBlock(CValidationState& state, const CChainParams& chainparams, C
return g_chainstate.InvalidateBlock(state, chainparams, pindex);
}
-bool CChainState::ResetBlockFailureFlags(CBlockIndex *pindex) {
+void CChainState::ResetBlockFailureFlags(CBlockIndex *pindex) {
AssertLockHeld(cs_main);
int nHeight = pindex->nHeight;
@@ -2914,9 +2914,9 @@ bool CChainState::ResetBlockFailureFlags(CBlockIndex *pindex) {
}
pindex = pindex->pprev;
}
- return true;
}
-bool ResetBlockFailureFlags(CBlockIndex *pindex) {
+
+void ResetBlockFailureFlags(CBlockIndex *pindex) {
return g_chainstate.ResetBlockFailureFlags(pindex);
}
diff --git a/src/validation.h b/src/validation.h
index 1aff10f025..ce46a5a782 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -449,7 +449,7 @@ bool PreciousBlock(CValidationState& state, const CChainParams& params, CBlockIn
bool InvalidateBlock(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
/** Remove invalidity status from a block and its descendants. */
-bool ResetBlockFailureFlags(CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
+void ResetBlockFailureFlags(CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
/** The currently-connected chain of blocks (protected by cs_main). */
extern CChain& chainActive;
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 3ec6aefaec..4918100b30 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -304,20 +304,18 @@ bool CWallet::AddCryptedKey(const CPubKey &vchPubKey,
}
}
-bool CWallet::LoadKeyMetadata(const CKeyID& keyID, const CKeyMetadata &meta)
+void CWallet::LoadKeyMetadata(const CKeyID& keyID, const CKeyMetadata &meta)
{
AssertLockHeld(cs_wallet); // mapKeyMetadata
UpdateTimeFirstKey(meta.nCreateTime);
mapKeyMetadata[keyID] = meta;
- return true;
}
-bool CWallet::LoadScriptMetadata(const CScriptID& script_id, const CKeyMetadata &meta)
+void CWallet::LoadScriptMetadata(const CScriptID& script_id, const CKeyMetadata &meta)
{
AssertLockHeld(cs_wallet); // m_script_metadata
UpdateTimeFirstKey(meta.nCreateTime);
m_script_metadata[script_id] = meta;
- return true;
}
bool CWallet::LoadCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret)
@@ -470,11 +468,11 @@ void CWallet::ChainStateFlushed(const CBlockLocator& loc)
batch.WriteBestBlock(loc);
}
-bool CWallet::SetMinVersion(enum WalletFeature nVersion, WalletBatch* batch_in, bool fExplicit)
+void CWallet::SetMinVersion(enum WalletFeature nVersion, WalletBatch* batch_in, bool fExplicit)
{
LOCK(cs_wallet); // nWalletVersion
if (nWalletVersion >= nVersion)
- return true;
+ return;
// when doing an explicit upgrade, if we pass the max version permitted, upgrade all the way
if (fExplicit && nVersion > nWalletMaxVersion)
@@ -492,8 +490,6 @@ bool CWallet::SetMinVersion(enum WalletFeature nVersion, WalletBatch* batch_in,
if (!batch_in)
delete batch;
}
-
- return true;
}
bool CWallet::SetMaxVersion(int nVersion)
@@ -703,9 +699,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
// if we are using HD, replace the HD seed with a new one
if (IsHDEnabled()) {
- if (!SetHDSeed(GenerateNewSeed())) {
- return false;
- }
+ SetHDSeed(GenerateNewSeed());
}
NewKeyPool();
@@ -1006,7 +1000,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose)
return true;
}
-bool CWallet::LoadToWallet(const CWalletTx& wtxIn)
+void CWallet::LoadToWallet(const CWalletTx& wtxIn)
{
uint256 hash = wtxIn.GetHash();
const auto& ins = mapWallet.emplace(hash, wtxIn);
@@ -1025,8 +1019,6 @@ bool CWallet::LoadToWallet(const CWalletTx& wtxIn)
}
}
}
-
- return true;
}
bool CWallet::AddToWalletIfInvolvingMe(const CTransactionRef& ptx, const CBlockIndex* pIndex, int posInBlock, bool fUpdate)
@@ -1478,7 +1470,7 @@ CPubKey CWallet::DeriveNewSeed(const CKey& key)
return seed;
}
-bool CWallet::SetHDSeed(const CPubKey& seed)
+void CWallet::SetHDSeed(const CPubKey& seed)
{
LOCK(cs_wallet);
// store the keyid (hash160) together with
@@ -1488,18 +1480,15 @@ bool CWallet::SetHDSeed(const CPubKey& seed)
newHdChain.nVersion = CanSupportFeature(FEATURE_HD_SPLIT) ? CHDChain::VERSION_HD_CHAIN_SPLIT : CHDChain::VERSION_HD_BASE;
newHdChain.seed_id = seed.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__) + ": writing chain failed");
hdChain = chain;
- return true;
}
bool CWallet::IsHDEnabled() const
@@ -3899,10 +3888,9 @@ bool CWallet::EraseDestData(const CTxDestination &dest, const std::string &key)
return WalletBatch(*database).EraseDestData(EncodeDestination(dest), key);
}
-bool CWallet::LoadDestData(const CTxDestination &dest, const std::string &key, const std::string &value)
+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, std::string *value) const
@@ -4091,9 +4079,7 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(const std::string& name,
// generate a new master key
CPubKey masterPubKey = walletInstance->GenerateNewSeed();
- if (!walletInstance->SetHDSeed(masterPubKey)) {
- throw std::runtime_error(std::string(__func__) + ": Storing master key failed");
- }
+ walletInstance->SetHDSeed(masterPubKey);
hd_upgrade = true;
}
// Upgrade to HD chain split if necessary
@@ -4109,7 +4095,7 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(const std::string& name,
// Regenerate the keypool if upgraded to HD
if (hd_upgrade) {
if (!walletInstance->TopUpKeyPool()) {
- InitError(_("Unable to generate keys") += "\n");
+ InitError(_("Unable to generate keys"));
return nullptr;
}
}
@@ -4130,14 +4116,12 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(const std::string& name,
} else {
// generate a new seed
CPubKey seed = walletInstance->GenerateNewSeed();
- if (!walletInstance->SetHDSeed(seed)) {
- throw std::runtime_error(std::string(__func__) + ": Storing HD seed failed");
- }
+ walletInstance->SetHDSeed(seed);
}
// Top up the keypool
if (!walletInstance->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) && !walletInstance->TopUpKeyPool()) {
- InitError(_("Unable to generate initial keys") += "\n");
+ InitError(_("Unable to generate initial keys"));
return nullptr;
}
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 2ada233514..9f9501cf72 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -885,8 +885,8 @@ public:
//! Adds a key to the store, without saving it to disk (used by LoadWallet)
bool LoadKey(const CKey& key, const CPubKey &pubkey) { return CCryptoKeyStore::AddKeyPubKey(key, pubkey); }
//! Load metadata (used by LoadWallet)
- bool LoadKeyMetadata(const CKeyID& keyID, const CKeyMetadata &metadata) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
- bool LoadScriptMetadata(const CScriptID& script_id, const CKeyMetadata &metadata) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
+ void LoadKeyMetadata(const CKeyID& keyID, const CKeyMetadata &metadata) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
+ void LoadScriptMetadata(const CScriptID& script_id, const CKeyMetadata &metadata) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { AssertLockHeld(cs_wallet); nWalletVersion = nVersion; nWalletMaxVersion = std::max(nWalletMaxVersion, nVersion); return true; }
void UpdateTimeFirstKey(int64_t nCreateTime) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
@@ -903,7 +903,7 @@ public:
//! 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, const std::string &value);
+ 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
bool GetDestData(const CTxDestination &dest, const std::string &key, std::string *value) const;
//! Get all destination values matching a prefix.
@@ -936,7 +936,7 @@ public:
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<const CBlock>& pblock, const CBlockIndex *pindex, const std::vector<CTransactionRef>& vtxConflicted) override;
void BlockDisconnected(const std::shared_ptr<const CBlock>& pblock) override;
@@ -1075,7 +1075,7 @@ public:
}
//! 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, bool fExplicit = false);
+ void SetMinVersion(enum WalletFeature, WalletBatch* batch_in = nullptr, bool fExplicit = false);
//! change which version we're allowed to upgrade to (note that this does not immediately imply upgrading to that format)
bool SetMaxVersion(int nVersion);
@@ -1146,7 +1146,7 @@ public:
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 */
@@ -1162,7 +1162,7 @@ public:
Sets the seed's version based on the current wallet version (so the
caller must ensure the current wallet version is correct before calling
this function). */
- bool SetHDSeed(const CPubKey& key);
+ void SetHDSeed(const CPubKey& key);
/**
* Blocks until the wallet state is up-to-date to /at least/ the current
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp
index 67fcaa725b..43e4747317 100644
--- a/src/wallet/walletdb.cpp
+++ b/src/wallet/walletdb.cpp
@@ -495,21 +495,13 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
ssKey >> strAddress;
ssKey >> strKey;
ssValue >> strValue;
- if (!pwallet->LoadDestData(DecodeDestination(strAddress), strKey, strValue))
- {
- strErr = "Error reading wallet database: LoadDestData failed";
- return false;
- }
+ pwallet->LoadDestData(DecodeDestination(strAddress), 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 == "flags") {
uint64_t flags;
ssValue >> flags;