diff options
author | Jon Atack <jon@atack.com> | 2020-11-16 18:55:32 +0100 |
---|---|---|
committer | Jon Atack <jon@atack.com> | 2020-11-18 16:11:47 +0100 |
commit | c46c18b788cb0862aafbb116fd37936cbed6a431 (patch) | |
tree | 8852d6d1334d1aa181bfc2f26ff388527f754800 /src/wallet | |
parent | c463f70fb05ed45cfcc609324078a0ccb08c7f06 (diff) |
wallet: refactor GetClosestWalletFeature()
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/walletutil.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/wallet/walletutil.cpp b/src/wallet/walletutil.cpp index 702293e6c7..88a52cdf63 100644 --- a/src/wallet/walletutil.cpp +++ b/src/wallet/walletutil.cpp @@ -87,13 +87,9 @@ bool IsFeatureSupported(int wallet_version, int feature_version) WalletFeature GetClosestWalletFeature(int version) { - if (version >= FEATURE_LATEST) return FEATURE_LATEST; - if (version >= FEATURE_PRE_SPLIT_KEYPOOL) return FEATURE_PRE_SPLIT_KEYPOOL; - if (version >= FEATURE_NO_DEFAULT_KEY) return FEATURE_NO_DEFAULT_KEY; - if (version >= FEATURE_HD_SPLIT) return FEATURE_HD_SPLIT; - if (version >= FEATURE_HD) return FEATURE_HD; - if (version >= FEATURE_COMPRPUBKEY) return FEATURE_COMPRPUBKEY; - if (version >= FEATURE_WALLETCRYPT) return FEATURE_WALLETCRYPT; - if (version >= FEATURE_BASE) return FEATURE_BASE; + const std::array<WalletFeature, 8> wallet_features{{FEATURE_LATEST, FEATURE_PRE_SPLIT_KEYPOOL, FEATURE_NO_DEFAULT_KEY, FEATURE_HD_SPLIT, FEATURE_HD, FEATURE_COMPRPUBKEY, FEATURE_WALLETCRYPT, FEATURE_BASE}}; + for (const WalletFeature& wf : wallet_features) { + if (version >= wf) return wf; + } return static_cast<WalletFeature>(0); } |