aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2018-02-08 13:30:34 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2018-02-08 13:31:22 +0100
commita1ffddb90d1bb00a6c6c03a109e549a06c544126 (patch)
treef68934ee1c32d207078e6e242b38c3645b7bbef2 /src/script
parentc9ca4f6024e01fdca509ae07887e6fe2157c6384 (diff)
parent5bdbbdc0967626a763c836a55dc7d018c15c10f2 (diff)
Merge #12298: Refactor HaveKeys to early return on false result
5bdbbdc Refactor HaveKeys to early return on false result (João Barbosa) Pull request description: This consists in a trivial change where the return type of `HaveKeys()` is now `bool` meaning that it returns whether all keys are in the keystore, and early returns when one isn't. Tree-SHA512: 03e35ea8486404b84884b49f6905c9f4fc161a3eeef080b06482d77985d5242a2bdd57a34b8d16abe19ee8c6cfa3e6fbcb935c73197d53f4cd468a2c7c0b889b
Diffstat (limited to 'src/script')
-rw-r--r--src/script/ismine.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/script/ismine.cpp b/src/script/ismine.cpp
index d0dd272550..35d794b983 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;
}