LCOV - code coverage report
Current view: top level - src/tiertwo - tiertwo_sync_state.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 26 26 100.0 %
Date: 2025-02-23 09:33:43 Functions: 5 5 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2021 The PIVX Core developers
       2             : // Distributed under the MIT software license, see the accompanying
       3             : // file COPYING or https://www.opensource.org/licenses/mit-license.php.
       4             : 
       5             : #include "tiertwo/tiertwo_sync_state.h"
       6             : #include "uint256.h"
       7             : #include "utiltime.h"
       8             : 
       9             : TierTwoSyncState g_tiertwo_sync_state;
      10             : 
      11       10492 : static void UpdateLastTime(const uint256& hash, int64_t& last, std::map<uint256, int>& mapSeen)
      12             : {
      13       10492 :     auto it = mapSeen.find(hash);
      14       10492 :     if (it != mapSeen.end()) {
      15        8207 :         if (it->second < MASTERNODE_SYNC_THRESHOLD) {
      16        1151 :             last = GetTime();
      17        1151 :             it->second++;
      18             :         }
      19             :     } else {
      20        2285 :         last = GetTime();
      21        2285 :         mapSeen.emplace(hash, 1);
      22             :     }
      23       10492 : }
      24             : 
      25         246 : void TierTwoSyncState::AddedMasternodeList(const uint256& hash)
      26             : {
      27         246 :     UpdateLastTime(hash, lastMasternodeList, mapSeenSyncMNB);
      28         246 : }
      29             : 
      30        3675 : void TierTwoSyncState::AddedMasternodeWinner(const uint256& hash)
      31             : {
      32        3675 :     UpdateLastTime(hash, lastMasternodeWinner, mapSeenSyncMNW);
      33        3675 : }
      34             : 
      35        6571 : void TierTwoSyncState::AddedBudgetItem(const uint256& hash)
      36             : {
      37        6571 :     UpdateLastTime(hash, lastBudgetItem, mapSeenSyncBudget);
      38        6571 : }
      39             : 
      40         538 : void TierTwoSyncState::ResetData()
      41             : {
      42         538 :     lastMasternodeList = 0;
      43         538 :     lastMasternodeWinner = 0;
      44         538 :     lastBudgetItem = 0;
      45         538 :     mapSeenSyncMNB.clear();
      46         538 :     mapSeenSyncMNW.clear();
      47         538 :     mapSeenSyncBudget.clear();
      48         538 : }

Generated by: LCOV version 1.14