Skip to content

Commit 4dd2e52

Browse files
committed
Merge #18946: rpcwallet: Replace boost::optional<T>::emplace with simple assignment of T{}
fa1f840 rpcwallet: Replace pwallet-> with wallet. (MarcoFalke) fa182a8 rpcwallet: Replace boost::optional<T>::emplace with simple assignment of T{} (MarcoFalke) Pull request description: Closes #18943 ACKs for top commit: laanwj: ACK fa1f840 ryanofsky: Code review ACK fa1f840 and thanks for using a standalone commit for the fix promag: Code review ACK fa1f840. hebasto: ACK fa1f840, tested on Linux Mint 19.3. Tree-SHA512: 0838485d1f93f737ce5bf12740669dcafeebb78dbc3fa15dbcc511edce64bf024f60f0497a04149a1e799d893d57b0c9ffe442020c1b9cfc3c69db731f50e712
2 parents b9c504c + fa1f840 commit 4dd2e52

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,10 +1482,9 @@ UniValue listtransactions(const JSONRPCRequest& request)
14821482

14831483
static UniValue listsinceblock(const JSONRPCRequest& request)
14841484
{
1485-
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
1486-
const CWallet* const pwallet = wallet.get();
1485+
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
14871486

1488-
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
1487+
if (!EnsureWalletIsAvailable(pwallet.get(), request.fHelp)) {
14891488
return NullUniValue;
14901489
}
14911490

@@ -1542,11 +1541,12 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
15421541
},
15431542
}.Check(request);
15441543

1544+
const CWallet& wallet = *pwallet;
15451545
// Make sure the results are valid at least up to the most recent block
15461546
// the user could have gotten from another RPC command prior to now
1547-
pwallet->BlockUntilSyncedToCurrentChain();
1547+
wallet.BlockUntilSyncedToCurrentChain();
15481548

1549-
LOCK(pwallet->cs_wallet);
1549+
LOCK(wallet.cs_wallet);
15501550

15511551
// The way the 'height' is initialized is just a workaround for the gcc bug #47679 since version 4.6.0.
15521552
Optional<int> height = MakeOptional(false, int()); // Height of the specified block or the common ancestor, if the block provided was in a deactivated chain.
@@ -1557,9 +1557,9 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
15571557
uint256 blockId;
15581558
if (!request.params[0].isNull() && !request.params[0].get_str().empty()) {
15591559
blockId = ParseHashV(request.params[0], "blockhash");
1560-
height.emplace();
1561-
altheight.emplace();
1562-
if (!pwallet->chain().findCommonAncestor(blockId, pwallet->GetLastBlockHash(), /* ancestor out */ FoundBlock().height(*height), /* blockId out */ FoundBlock().height(*altheight))) {
1560+
height = int{};
1561+
altheight = int{};
1562+
if (!wallet.chain().findCommonAncestor(blockId, wallet.GetLastBlockHash(), /* ancestor out */ FoundBlock().height(*height), /* blockId out */ FoundBlock().height(*altheight))) {
15631563
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
15641564
}
15651565
}
@@ -1572,21 +1572,21 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
15721572
}
15731573
}
15741574

1575-
if (ParseIncludeWatchonly(request.params[2], *pwallet)) {
1575+
if (ParseIncludeWatchonly(request.params[2], wallet)) {
15761576
filter |= ISMINE_WATCH_ONLY;
15771577
}
15781578

15791579
bool include_removed = (request.params[3].isNull() || request.params[3].get_bool());
15801580

1581-
int depth = height ? pwallet->GetLastBlockHeight() + 1 - *height : -1;
1581+
int depth = height ? wallet.GetLastBlockHeight() + 1 - *height : -1;
15821582

15831583
UniValue transactions(UniValue::VARR);
15841584

1585-
for (const std::pair<const uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
1585+
for (const std::pair<const uint256, CWalletTx>& pairWtx : wallet.mapWallet) {
15861586
const CWalletTx& tx = pairWtx.second;
15871587

15881588
if (depth == -1 || abs(tx.GetDepthInMainChain()) < depth) {
1589-
ListTransactions(pwallet, tx, 0, true, transactions, filter, nullptr /* filter_label */);
1589+
ListTransactions(&wallet, tx, 0, true, transactions, filter, nullptr /* filter_label */);
15901590
}
15911591
}
15921592

@@ -1595,23 +1595,23 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
15951595
UniValue removed(UniValue::VARR);
15961596
while (include_removed && altheight && *altheight > *height) {
15971597
CBlock block;
1598-
if (!pwallet->chain().findBlock(blockId, FoundBlock().data(block)) || block.IsNull()) {
1598+
if (!wallet.chain().findBlock(blockId, FoundBlock().data(block)) || block.IsNull()) {
15991599
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
16001600
}
16011601
for (const CTransactionRef& tx : block.vtx) {
1602-
auto it = pwallet->mapWallet.find(tx->GetHash());
1603-
if (it != pwallet->mapWallet.end()) {
1602+
auto it = wallet.mapWallet.find(tx->GetHash());
1603+
if (it != wallet.mapWallet.end()) {
16041604
// We want all transactions regardless of confirmation count to appear here,
16051605
// even negative confirmation ones, hence the big negative.
1606-
ListTransactions(pwallet, it->second, -100000000, true, removed, filter, nullptr /* filter_label */);
1606+
ListTransactions(&wallet, it->second, -100000000, true, removed, filter, nullptr /* filter_label */);
16071607
}
16081608
}
16091609
blockId = block.hashPrevBlock;
16101610
--*altheight;
16111611
}
16121612

16131613
uint256 lastblock;
1614-
CHECK_NONFATAL(pwallet->chain().findAncestorByHeight(pwallet->GetLastBlockHash(), pwallet->GetLastBlockHeight() + 1 - target_confirms, FoundBlock().hash(lastblock)));
1614+
CHECK_NONFATAL(wallet.chain().findAncestorByHeight(wallet.GetLastBlockHash(), wallet.GetLastBlockHeight() + 1 - target_confirms, FoundBlock().hash(lastblock)));
16151615

16161616
UniValue ret(UniValue::VOBJ);
16171617
ret.pushKV("transactions", transactions);

0 commit comments

Comments
 (0)