mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
rpc: avoid expensive IsMine calls in GetReceived tally
This commit is contained in:
parent
a7b65af2a4
commit
f336ff7f21
1 changed files with 5 additions and 2 deletions
|
|
@ -23,7 +23,10 @@ static CAmount GetReceived(const CWallet& wallet, const UniValue& params, bool b
|
|||
// Get the set of addresses assigned to label
|
||||
std::string label = LabelFromValue(params[0]);
|
||||
for (const auto& address : wallet.GetLabelAddresses(label)) {
|
||||
output_scripts.insert(GetScriptForDestination(address));
|
||||
auto output_script{GetScriptForDestination(address)};
|
||||
if (wallet.IsMine(output_script)) {
|
||||
output_scripts.insert(output_script);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Get the address
|
||||
|
|
@ -67,7 +70,7 @@ static CAmount GetReceived(const CWallet& wallet, const UniValue& params, bool b
|
|||
}
|
||||
|
||||
for (const CTxOut& txout : wtx.tx->vout) {
|
||||
if (wallet.IsMine(txout.scriptPubKey) && output_scripts.count(txout.scriptPubKey) > 0) {
|
||||
if (output_scripts.count(txout.scriptPubKey) > 0) {
|
||||
amount += txout.nValue;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue