LCOV - code coverage report
Current view: top level - src/llmq - quorums_commitment.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 21 21 100.0 %
Date: 2025-02-23 09:33:43 Functions: 10 10 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2018-2019 The Dash Core developers
       2             : // Copyright (c) 2021 The PIVX Core developers
       3             : // Distributed under the MIT/X11 software license, see the accompanying
       4             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       5             : 
       6             : #ifndef PIVX_LLMQ_QUORUMS_COMMITMENT_H
       7             : #define PIVX_LLMQ_QUORUMS_COMMITMENT_H
       8             : 
       9             : #include "bls/bls_wrapper.h"
      10             : #include "consensus/params.h"
      11             : 
      12             : #include <univalue.h>
      13             : 
      14             : class CBlockIndex;
      15             : class CValidationState;
      16             : class CTransaction;
      17             : 
      18             : namespace llmq
      19             : {
      20             : 
      21             : // This message is an aggregation of all received premature commitments and only valid if
      22             : // enough (>=threshold) premature commitments were aggregated
      23             : // This is mined on-chain as part of LLMQCOMM payload.
      24       16176 : class CFinalCommitment
      25             : {
      26             : public:
      27             :     static const uint16_t CURRENT_VERSION = 1;
      28             : 
      29             :     uint16_t nVersion{CURRENT_VERSION};
      30             :     uint8_t llmqType{Consensus::LLMQ_NONE};
      31             :     uint256 quorumHash;
      32             :     std::vector<bool> signers;
      33             :     std::vector<bool> validMembers;
      34             : 
      35             :     CBLSPublicKey quorumPublicKey;
      36             :     uint256 quorumVvecHash;
      37             : 
      38             :     CBLSSignature quorumSig; // recovered threshold sig of blockHash+validMembers+pubKeyHash+vvecHash
      39             :     CBLSSignature membersSig; // aggregated member sig of blockHash+validMembers+pubKeyHash+vvecHash
      40             : 
      41             : public:
      42       77214 :     CFinalCommitment() = default;
      43             :     CFinalCommitment(const Consensus::LLMQParams& params, const uint256& _quorumHash);
      44             : 
      45        8347 :     int CountSigners() const { return (int)std::count(signers.begin(), signers.end(), true); }
      46        7640 :     int CountValidMembers() const { return (int)std::count(validMembers.begin(), validMembers.end(), true); }
      47             : 
      48             :     bool IsNull() const;
      49             :     void ToJson(UniValue& obj) const;
      50             : 
      51             :     bool Verify(const std::vector<CBLSPublicKey>& allkeys, const Consensus::LLMQParams& params) const;
      52             :     bool VerifySizes(const Consensus::LLMQParams& params) const;
      53             : 
      54       15613 :     SERIALIZE_METHODS(CFinalCommitment, obj)
      55             :     {
      56       11836 :         READWRITE(obj.nVersion);
      57       11836 :         READWRITE(obj.llmqType);
      58       11836 :         READWRITE(obj.quorumHash);
      59       11836 :         READWRITE(DYNBITSET(obj.signers));
      60       11836 :         READWRITE(DYNBITSET(obj.validMembers));
      61       11836 :         READWRITE(obj.quorumPublicKey);
      62       11836 :         READWRITE(obj.quorumVvecHash);
      63       11836 :         READWRITE(obj.quorumSig);
      64       11836 :         READWRITE(obj.membersSig);
      65       11836 :     }
      66             : };
      67             : 
      68       35663 : class LLMQCommPL
      69             : {
      70             : public:
      71             :     static const uint16_t CURRENT_VERSION = 1;
      72             : 
      73             : public:
      74             :     uint16_t nVersion{CURRENT_VERSION};
      75             :     uint32_t nHeight{(uint32_t)-1};
      76             :     CFinalCommitment commitment;
      77             : 
      78             : public:
      79       13724 :     SERIALIZE_METHODS(LLMQCommPL, obj)
      80             :     {
      81       10874 :         READWRITE(obj.nVersion);
      82       10874 :         READWRITE(obj.nHeight);
      83       10874 :         READWRITE(obj.commitment);
      84       10874 :     }
      85             : 
      86             :     void ToJson(UniValue& obj) const;
      87             : };
      88             : 
      89             : } // namespace llmq
      90             : 
      91             : #endif // PIVX_LLMQ_QUORUMS_COMMITMENT_H

Generated by: LCOV version 1.14