diff options
author | John Newbery <john@johnnewbery.com> | 2019-04-03 17:55:24 -0400 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2019-10-18 09:26:32 -0400 |
commit | d1734f9a3b138ab046f38ee44a09bc3847bf938a (patch) | |
tree | 172eb76ab4c70e926fe292d8e535cae48ee879fc /src/wallet/wallet.cpp | |
parent | b6f486a02b463ffeaf82ec11fc6f74f439c037ae (diff) |
[wallet] Remove return value from CommitTransaction()
CommitTransaction returns a bool to indicate success, but since commit
b3a74100b8 it only returns true, even if the transaction was not
successfully broadcast. This commit changes CommitTransaction() to return
void.
All dead code in `if (!CommitTransaction())` branches has been removed.
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r-- | src/wallet/wallet.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a9ea56b6ab..9c5de45c28 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3286,7 +3286,7 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std return true; } -bool CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector<std::pair<std::string, std::string>> orderForm, CValidationState& state) +void CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector<std::pair<std::string, std::string>> orderForm, CValidationState& state) { auto locked_chain = chain().lock(); LOCK(cs_wallet); @@ -3314,15 +3314,16 @@ bool CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::ve // fInMempool flag is cached properly CWalletTx& wtx = mapWallet.at(wtxNew.GetHash()); - if (fBroadcastTransactions) { - std::string err_string; - if (!wtx.SubmitMemoryPoolAndRelay(err_string, true, *locked_chain)) { - WalletLogPrintf("CommitTransaction(): Transaction cannot be broadcast immediately, %s\n", err_string); - // TODO: if we expect the failure to be long term or permanent, instead delete wtx from the wallet and return failure. - } + if (!fBroadcastTransactions) { + // Don't submit tx to the mempool + return; } - return true; + std::string err_string; + if (!wtx.SubmitMemoryPoolAndRelay(err_string, true, *locked_chain)) { + WalletLogPrintf("CommitTransaction(): Transaction cannot be broadcast immediately, %s\n", err_string); + // TODO: if we expect the failure to be long term or permanent, instead delete wtx from the wallet and return failure. + } } DBErrors CWallet::LoadWallet(bool& fFirstRunRet) |