diff options
| author | João Barbosa <[email protected]> | 2018-01-29 23:41:06 +0000 |
|---|---|---|
| committer | João Barbosa <[email protected]> | 2018-01-29 23:45:25 +0000 |
| commit | 5bdbbdc0967626a763c836a55dc7d018c15c10f2 (patch) | |
| tree | 7ec547fbc7ab699a7bdf95483e7530308e558d04 /src/script/ismine.cpp | |
| parent | Merge #12293: [rpc] Mention that HD is enabled if hdmasterkeyid is present (diff) | |
| download | discoin-5bdbbdc0967626a763c836a55dc7d018c15c10f2.tar.xz discoin-5bdbbdc0967626a763c836a55dc7d018c15c10f2.zip | |
Refactor HaveKeys to early return on false result
Diffstat (limited to 'src/script/ismine.cpp')
| -rw-r--r-- | src/script/ismine.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/script/ismine.cpp b/src/script/ismine.cpp index d0dd27255..35d794b98 100644 --- a/src/script/ismine.cpp +++ b/src/script/ismine.cpp @@ -13,16 +13,13 @@ 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(); - if (keystore.HaveKey(keyID)) - ++nResult; + if (!keystore.HaveKey(keyID)) return false; } - return nResult; + return true; } 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; break; } |