LCOV - code coverage report
Current view: top level - src/script - keyorigin.h (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 16 22 72.7 %
Date: 2022-04-21 14:51:19 Functions: 5 5 100.0 %
Legend: Modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed

Not modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed
Branches: 6 12 50.0 %

           Branch data     Line data    Source code
#       1                 :            : // Copyright (c) 2019-2020 The Bitcoin Core developers
#       2                 :            : // Distributed under the MIT software license, see the accompanying
#       3                 :            : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#       4                 :            : 
#       5                 :            : #ifndef BITCOIN_SCRIPT_KEYORIGIN_H
#       6                 :            : #define BITCOIN_SCRIPT_KEYORIGIN_H
#       7                 :            : 
#       8                 :            : #include <serialize.h>
#       9                 :            : #include <vector>
#      10                 :            : 
#      11                 :            : struct KeyOriginInfo
#      12                 :            : {
#      13                 :            :     unsigned char fingerprint[4]; //!< First 32 bits of the Hash160 of the public key at the root of the path
#      14                 :            :     std::vector<uint32_t> path;
#      15                 :            : 
#      16                 :            :     friend bool operator==(const KeyOriginInfo& a, const KeyOriginInfo& b)
#      17                 :       5196 :     {
#      18 [ +  - ][ +  - ]:       5196 :         return std::equal(std::begin(a.fingerprint), std::end(a.fingerprint), std::begin(b.fingerprint)) && a.path == b.path;
#      19                 :       5196 :     }
#      20                 :            : 
#      21                 :            :     friend bool operator<(const KeyOriginInfo& a, const KeyOriginInfo& b)
#      22                 :          8 :     {
#      23                 :            :         // Compare the fingerprints lexicographically
#      24                 :          8 :         int fpr_cmp = memcmp(a.fingerprint, b.fingerprint, 4);
#      25         [ -  + ]:          8 :         if (fpr_cmp < 0) {
#      26                 :          0 :             return true;
#      27         [ -  + ]:          8 :         } else if (fpr_cmp > 0) {
#      28                 :          0 :             return false;
#      29                 :          0 :         }
#      30                 :            :         // Compare the sizes of the paths, shorter is "less than"
#      31         [ -  + ]:          8 :         if (a.path.size() < b.path.size()) {
#      32                 :          0 :             return true;
#      33         [ -  + ]:          8 :         } else if (a.path.size() > b.path.size()) {
#      34                 :          0 :             return false;
#      35                 :          0 :         }
#      36                 :            :         // Paths same length, compare them lexicographically
#      37                 :          8 :         return a.path < b.path;
#      38                 :          8 :     }
#      39                 :            : 
#      40                 :      33903 :     SERIALIZE_METHODS(KeyOriginInfo, obj) { READWRITE(obj.fingerprint, obj.path); }
#      41                 :            : 
#      42                 :            :     void clear()
#      43                 :     683536 :     {
#      44                 :     683536 :         memset(fingerprint, 0, 4);
#      45                 :     683536 :         path.clear();
#      46                 :     683536 :     }
#      47                 :            : };
#      48                 :            : 
#      49                 :            : #endif // BITCOIN_SCRIPT_KEYORIGIN_H

Generated by: LCOV version 0-eol-96201-ge66f56f4af6a