aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoão Barbosa <[email protected]>2018-05-03 11:32:57 +0100
committerJoão Barbosa <[email protected]>2018-05-03 11:32:57 +0100
commita59dac35abf64d5af4d499bc3397b3369eb76eda (patch)
treed9c1ece569e94926c998f69b0a1346f098728fb7 /src
parentrpc: Reduce cs_main lock in listunspent (diff)
downloaddiscoin-a59dac35abf64d5af4d499bc3397b3369eb76eda.tar.xz
discoin-a59dac35abf64d5af4d499bc3397b3369eb76eda.zip
refactor: Avoid extra lookups of mapAddressBook in listunspent RPC
Diffstat (limited to 'src')
-rw-r--r--src/wallet/rpcwallet.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index 5785cf909..ea294fee3 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -3171,10 +3171,11 @@ UniValue listunspent(const JSONRPCRequest& request)
if (fValidAddress) {
entry.pushKV("address", EncodeDestination(address));
- if (pwallet->mapAddressBook.count(address)) {
- entry.pushKV("label", pwallet->mapAddressBook[address].name);
+ auto i = pwallet->mapAddressBook.find(address);
+ if (i != pwallet->mapAddressBook.end()) {
+ entry.pushKV("label", i->second.name);
if (IsDeprecatedRPCEnabled("accounts")) {
- entry.pushKV("account", pwallet->mapAddressBook[address].name);
+ entry.pushKV("account", i->second.name);
}
}