diff options
author | Andrew Chow <achow101-github@achow101.com> | 2019-07-25 11:58:14 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2021-12-10 08:29:47 -0500 |
commit | c5c63b8e4f3fbdb6b5a423a39d6e318fecab991f (patch) | |
tree | 45768b268c8bbf9529ebb5f4ff6197c5b6e1bd87 /src/script | |
parent | d3dbb16168145ccbcc7ef0a8e150695711b661b7 (diff) | |
download | bitcoin-c5c63b8e4f3fbdb6b5a423a39d6e318fecab991f.tar.xz |
Implement operator< for KeyOriginInfo and CExtPubKey
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/keyorigin.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/script/keyorigin.h b/src/script/keyorigin.h index 210395d177..c779872be2 100644 --- a/src/script/keyorigin.h +++ b/src/script/keyorigin.h @@ -18,6 +18,25 @@ struct KeyOriginInfo return std::equal(std::begin(a.fingerprint), std::end(a.fingerprint), std::begin(b.fingerprint)) && a.path == b.path; } + friend bool operator<(const KeyOriginInfo& a, const KeyOriginInfo& b) + { + // Compare the fingerprints lexicographically + int fpr_cmp = memcmp(a.fingerprint, b.fingerprint, 4); + if (fpr_cmp < 0) { + return true; + } else if (fpr_cmp > 0) { + return false; + } + // Compare the sizes of the paths, shorter is "less than" + if (a.path.size() < b.path.size()) { + return true; + } else if (a.path.size() > b.path.size()) { + return false; + } + // Paths same length, compare them lexicographically + return a.path < b.path; + } + SERIALIZE_METHODS(KeyOriginInfo, obj) { READWRITE(obj.fingerprint, obj.path); } void clear() |