mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-09 10:43:19 -05:00
Refactor HaveKeys to early return on false result
This commit is contained in:
parent
9d9c4185fa
commit
5bdbbdc096
1 changed files with 5 additions and 8 deletions
|
@ -13,16 +13,13 @@
|
||||||
|
|
||||||
typedef std::vector<unsigned char> valtype;
|
typedef std::vector<unsigned char> valtype;
|
||||||
|
|
||||||
unsigned int HaveKeys(const std::vector<valtype>& pubkeys, const CKeyStore& keystore)
|
static bool HaveKeys(const std::vector<valtype>& pubkeys, const CKeyStore& keystore)
|
||||||
{
|
{
|
||||||
unsigned int nResult = 0;
|
for (const valtype& pubkey : pubkeys) {
|
||||||
for (const valtype& pubkey : pubkeys)
|
|
||||||
{
|
|
||||||
CKeyID keyID = CPubKey(pubkey).GetID();
|
CKeyID keyID = CPubKey(pubkey).GetID();
|
||||||
if (keystore.HaveKey(keyID))
|
if (!keystore.HaveKey(keyID)) return false;
|
||||||
++nResult;
|
|
||||||
}
|
}
|
||||||
return nResult;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey, SigVersion sigversion)
|
isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey, SigVersion sigversion)
|
||||||
|
@ -140,7 +137,7 @@ isminetype IsMine(const CKeyStore &keystore, const CScript& scriptPubKey, bool&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (HaveKeys(keys, keystore) == keys.size())
|
if (HaveKeys(keys, keystore))
|
||||||
return ISMINE_SPENDABLE;
|
return ISMINE_SPENDABLE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue