Skip to content

Commit

Permalink
Change brace formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanofsky committed Feb 22, 2019
1 parent f6af927 commit a8da749
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
12 changes: 8 additions & 4 deletions src/wallet/rpcdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ UniValue importprivkey(const JSONRPCRequest& request)
if (!request.params[2].isNull())
fRescan = request.params[2].get_bool();

if (fRescan && pwallet->chain().getPruneMode())
if (fRescan && pwallet->chain().getPruneMode()) {
throw JSONRPCError(RPC_WALLET_ERROR, "Rescan is disabled in pruned mode");
}

if (fRescan && !reserver.reserve()) {
throw JSONRPCError(RPC_WALLET_ERROR, "Wallet is currently rescanning. Abort existing rescan or wait.");
Expand Down Expand Up @@ -313,8 +314,9 @@ UniValue importaddress(const JSONRPCRequest& request)
if (!request.params[2].isNull())
fRescan = request.params[2].get_bool();

if (fRescan && pwallet->chain().getPruneMode())
if (fRescan && pwallet->chain().getPruneMode()) {
throw JSONRPCError(RPC_WALLET_ERROR, "Rescan is disabled in pruned mode");
}

WalletRescanReserver reserver(pwallet);
if (fRescan && !reserver.reserve()) {
Expand Down Expand Up @@ -501,8 +503,9 @@ UniValue importpubkey(const JSONRPCRequest& request)
if (!request.params[2].isNull())
fRescan = request.params[2].get_bool();

if (fRescan && pwallet->chain().getPruneMode())
if (fRescan && pwallet->chain().getPruneMode()) {
throw JSONRPCError(RPC_WALLET_ERROR, "Rescan is disabled in pruned mode");
}

WalletRescanReserver reserver(pwallet);
if (fRescan && !reserver.reserve()) {
Expand Down Expand Up @@ -562,8 +565,9 @@ UniValue importwallet(const JSONRPCRequest& request)
},
}.ToString());

if (pwallet->chain().getPruneMode())
if (pwallet->chain().getPruneMode()) {
throw JSONRPCError(RPC_WALLET_ERROR, "Importing wallets is disabled in pruned mode");
}

WalletRescanReserver reserver(pwallet);
if (!reserver.reserve()) {
Expand Down
12 changes: 8 additions & 4 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,9 @@ static UniValue getreceivedbyaddress(const JSONRPCRequest& request)
CAmount nAmount = 0;
for (const std::pair<const uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
const CWalletTx& wtx = pairWtx.second;
if (wtx.IsCoinBase() || !locked_chain->checkFinalTx(*wtx.tx))
if (wtx.IsCoinBase() || !locked_chain->checkFinalTx(*wtx.tx)) {
continue;
}

for (const CTxOut& txout : wtx.tx->vout)
if (txout.scriptPubKey == scriptPubKey)
Expand Down Expand Up @@ -693,8 +694,9 @@ static UniValue getreceivedbylabel(const JSONRPCRequest& request)
CAmount nAmount = 0;
for (const std::pair<const uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
const CWalletTx& wtx = pairWtx.second;
if (wtx.IsCoinBase() || !locked_chain->checkFinalTx(*wtx.tx))
if (wtx.IsCoinBase() || !locked_chain->checkFinalTx(*wtx.tx)) {
continue;
}

for (const CTxOut& txout : wtx.tx->vout)
{
Expand Down Expand Up @@ -1078,8 +1080,9 @@ static UniValue ListReceived(interfaces::Chain::Lock& locked_chain, CWallet * co
for (const std::pair<const uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
const CWalletTx& wtx = pairWtx.second;

if (wtx.IsCoinBase() || !locked_chain.checkFinalTx(*wtx.tx))
if (wtx.IsCoinBase() || !locked_chain.checkFinalTx(*wtx.tx)) {
continue;
}

int nDepth = wtx.GetDepthInMainChain(locked_chain);
if (nDepth < nMinDepth)
Expand Down Expand Up @@ -2690,8 +2693,9 @@ static UniValue resendwallettransactions(const JSONRPCRequest& request)
}.ToString()
);

if (!pwallet->chain().p2pEnabled())
if (!pwallet->chain().p2pEnabled()) {
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
}

auto locked_chain = pwallet->chain().lock();
LOCK(pwallet->cs_wallet);
Expand Down
12 changes: 7 additions & 5 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2073,8 +2073,9 @@ bool CWalletTx::InMempool() const
bool CWalletTx::IsTrusted(interfaces::Chain::Lock& locked_chain) const
{
// Quick answer in most cases
if (!locked_chain.checkFinalTx(*tx))
if (!locked_chain.checkFinalTx(*tx)) {
return false;
}
int nDepth = GetDepthInMainChain(locked_chain);
if (nDepth >= 1)
return true;
Expand Down Expand Up @@ -2129,8 +2130,9 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(interfaces::Chain::
for (const std::pair<const unsigned int, CWalletTx*>& item : mapSorted)
{
CWalletTx& wtx = *item.second;
if (wtx.RelayWalletTransaction(locked_chain))
if (wtx.RelayWalletTransaction(locked_chain)) {
result.push_back(wtx.GetHash());
}
}
return result;
}
Expand Down Expand Up @@ -2319,8 +2321,9 @@ void CWallet::AvailableCoins(interfaces::Chain::Lock& locked_chain, std::vector<
const uint256& wtxid = entry.first;
const CWalletTx* pcoin = &entry.second;

if (!locked_chain.checkFinalTx(*pcoin->tx))
if (!locked_chain.checkFinalTx(*pcoin->tx)) {
continue;
}

if (pcoin->IsImmatureCoinBase(locked_chain))
continue;
Expand Down Expand Up @@ -4331,8 +4334,7 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
//We can't rescan beyond non-pruned blocks, stop and throw an error
//this might happen if a user uses an old wallet within a pruned node
// or if he ran -disablewallet for a longer time, then decided to re-enable
if (chain.getPruneMode())
{
if (chain.getPruneMode()) {
int block_height = *tip_height;
while (block_height > 0 && locked_chain->haveBlockOnDisk(block_height - 1) && rescan_height != block_height) {
--block_height;
Expand Down

0 comments on commit a8da749

Please sign in to comment.