dash/src/masternode-sync.h
Evan Duffield 95ba71570b Merge #864: govobj sync
487674f Governance object/vote syncing fixes
- disable fCached values
- use two maps for storing votes, by hash and parent-hash/type
- disable part of flatdb.dump (still overwriting)
- fixed govobj/votes relay and sync

15821fe various fixes
- Added const where possible
- Uncommented sync block
- Protocol min 70201
- Fixed bug which flags invalid votes incorrectly
- Formatting

aa8fdd7 fix curly braces

d8e39b1 Fix GetTypeHash bug
- Should not collide based on the outcome

732a8a3 fixed mismatched index for vote map
2016-06-08 08:57:16 +02:00

83 lines
2.3 KiB
C++

// Copyright (c) 2014-2016 The Dash Core developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef MASTERNODE_SYNC_H
#define MASTERNODE_SYNC_H
#define MASTERNODE_SYNC_INITIAL 0
#define MASTERNODE_SYNC_SPORKS 1
#define MASTERNODE_SYNC_LIST 2
#define MASTERNODE_SYNC_MNW 3
#define MASTERNODE_SYNC_GOVERNANCE 4
#define MASTERNODE_SYNC_GOVOBJ 10
#define MASTERNODE_SYNC_GOVERNANCE_FIN 11
#define MASTERNODE_SYNC_FAILED 998
#define MASTERNODE_SYNC_FINISHED 999
#define MASTERNODE_SYNC_TIMEOUT 30 // our blocks are 2.5 minutes so 30 seconds should be fine
class CMasternodeSync;
extern CMasternodeSync masternodeSync;
//
// CMasternodeSync : Sync masternode assets in stages
//
class CMasternodeSync
{
public:
std::map<uint256, int> mapSeenSyncMNB;
std::map<uint256, int> mapSeenSyncMNW;
std::map<uint256, int> mapSeenSyncBudget;
int64_t lastMasternodeList;
int64_t lastMasternodeWinner;
int64_t lastBudgetItem;
int64_t lastFailure;
int nCountFailures;
// sum of all counts
int sumMasternodeList;
int sumMasternodeWinner;
int sumBudgetItemProp;
int sumBudgetItemFin;
// peers that reported counts
int countMasternodeList;
int countMasternodeWinner;
int countBudgetItemProp;
int countBudgetItemFin;
// Count peers we've requested the list from
int RequestedMasternodeAssets;
int RequestedMasternodeAttempt;
// Time when current masternode asset sync started
int64_t nAssetSyncStarted;
// Keep track of current block index
const CBlockIndex *pCurrentBlockIndex;
CMasternodeSync();
void AddedMasternodeList(uint256 hash);
void AddedMasternodeWinner(uint256 hash);
void AddedBudgetItem(uint256 hash);
void GetNextAsset();
std::string GetAssetName();
std::string GetSyncStatus();
void ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
bool IsBudgetFinEmpty();
bool IsBudgetPropEmpty();
void Reset();
void Process();
bool IsSynced();
bool IsBlockchainSynced();
void ClearFulfilledRequest();
void UpdatedBlockTip(const CBlockIndex *pindex);
};
#endif