2019-01-29 15:53:14 +01:00
|
|
|
// Copyright (c) 2014-2019 The Dash Core developers
|
2016-03-02 22:20:04 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2017-12-01 19:53:34 +01:00
|
|
|
#include "chainparams.h"
|
2016-03-02 22:20:04 +01:00
|
|
|
#include "dsnotificationinterface.h"
|
2019-05-21 15:26:15 +02:00
|
|
|
#include "instantsend.h"
|
|
|
|
#include "governance/governance.h"
|
|
|
|
#include "masternode/masternode-payments.h"
|
|
|
|
#include "masternode/masternode-sync.h"
|
|
|
|
#include "privatesend/privatesend.h"
|
2017-12-01 19:53:34 +01:00
|
|
|
#ifdef ENABLE_WALLET
|
2019-05-21 15:26:15 +02:00
|
|
|
#include "privatesend/privatesend-client.h"
|
2017-12-01 19:53:34 +01:00
|
|
|
#endif // ENABLE_WALLET
|
2019-01-03 21:08:34 +01:00
|
|
|
#include "validation.h"
|
2016-03-02 22:20:04 +01:00
|
|
|
|
2018-02-14 14:43:03 +01:00
|
|
|
#include "evo/deterministicmns.h"
|
2019-03-22 11:52:37 +01:00
|
|
|
#include "evo/mnauth.h"
|
2018-02-14 14:43:03 +01:00
|
|
|
|
2019-01-22 14:20:32 +01:00
|
|
|
#include "llmq/quorums.h"
|
|
|
|
#include "llmq/quorums_chainlocks.h"
|
2018-09-21 16:01:04 +02:00
|
|
|
#include "llmq/quorums_instantsend.h"
|
2019-01-22 14:20:32 +01:00
|
|
|
#include "llmq/quorums_dkgsessionmgr.h"
|
|
|
|
|
2017-08-29 01:51:33 +02:00
|
|
|
void CDSNotificationInterface::InitializeCurrentBlockTip()
|
2016-03-02 22:20:04 +01:00
|
|
|
{
|
2017-08-29 01:51:33 +02:00
|
|
|
LOCK(cs_main);
|
|
|
|
UpdatedBlockTip(chainActive.Tip(), NULL, IsInitialBlockDownload());
|
2016-03-02 22:20:04 +01:00
|
|
|
}
|
|
|
|
|
2017-09-03 15:30:08 +02:00
|
|
|
void CDSNotificationInterface::AcceptedBlockHeader(const CBlockIndex *pindexNew)
|
|
|
|
{
|
2019-01-22 14:20:32 +01:00
|
|
|
llmq::chainLocksHandler->AcceptedBlockHeader(pindexNew);
|
2017-09-03 15:30:08 +02:00
|
|
|
masternodeSync.AcceptedBlockHeader(pindexNew);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDSNotificationInterface::NotifyHeaderTip(const CBlockIndex *pindexNew, bool fInitialDownload)
|
|
|
|
{
|
2017-09-19 16:51:38 +02:00
|
|
|
masternodeSync.NotifyHeaderTip(pindexNew, fInitialDownload, connman);
|
2017-09-03 15:30:08 +02:00
|
|
|
}
|
|
|
|
|
2017-08-04 19:43:48 +02:00
|
|
|
void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
|
2016-03-02 22:20:04 +01:00
|
|
|
{
|
2017-09-20 22:30:56 +02:00
|
|
|
if (pindexNew == pindexFork) // blocks were disconnected without any new ones
|
|
|
|
return;
|
|
|
|
|
2018-02-14 14:43:03 +01:00
|
|
|
deterministicMNManager->UpdatedBlockTip(pindexNew);
|
|
|
|
|
2017-09-20 22:30:56 +02:00
|
|
|
masternodeSync.UpdatedBlockTip(pindexNew, fInitialDownload, connman);
|
|
|
|
|
2017-12-07 10:43:23 +01:00
|
|
|
// Update global DIP0001 activation status
|
2018-03-08 13:18:24 +01:00
|
|
|
fDIP0001ActiveAtTip = pindexNew->nHeight >= Params().GetConsensus().DIP0001Height;
|
2018-10-26 18:42:52 +02:00
|
|
|
// update instantsend autolock activation flag (we reuse the DIP3 deployment)
|
2019-04-25 17:39:04 +02:00
|
|
|
instantsend.isAutoLockBip9Active = pindexNew->nHeight + 1 >= Params().GetConsensus().DIP0003Height;
|
2017-09-22 03:54:14 +02:00
|
|
|
|
2017-10-09 20:25:24 +02:00
|
|
|
if (fInitialDownload)
|
2017-09-22 03:54:14 +02:00
|
|
|
return;
|
|
|
|
|
2018-03-29 17:08:00 +02:00
|
|
|
if (fLiteMode)
|
|
|
|
return;
|
|
|
|
|
2019-04-05 05:55:30 +02:00
|
|
|
llmq::quorumInstantSendManager->UpdatedBlockTip(pindexNew);
|
2019-04-30 14:48:21 +02:00
|
|
|
llmq::chainLocksHandler->UpdatedBlockTip(pindexNew);
|
2019-01-22 14:20:32 +01:00
|
|
|
|
2017-12-07 10:42:47 +01:00
|
|
|
CPrivateSend::UpdatedBlockTip(pindexNew);
|
2017-12-01 19:53:34 +01:00
|
|
|
#ifdef ENABLE_WALLET
|
2017-09-22 03:54:14 +02:00
|
|
|
privateSendClient.UpdatedBlockTip(pindexNew);
|
2017-12-01 19:53:34 +01:00
|
|
|
#endif // ENABLE_WALLET
|
2017-09-22 03:54:14 +02:00
|
|
|
instantsend.UpdatedBlockTip(pindexNew);
|
|
|
|
governance.UpdatedBlockTip(pindexNew, connman);
|
2019-04-30 14:48:21 +02:00
|
|
|
llmq::quorumManager->UpdatedBlockTip(pindexNew, fInitialDownload);
|
|
|
|
llmq::quorumDKGSessionManager->UpdatedBlockTip(pindexNew, fInitialDownload);
|
2016-03-02 22:20:04 +01:00
|
|
|
}
|
2017-01-29 09:22:14 +01:00
|
|
|
|
2018-01-08 18:41:06 +01:00
|
|
|
void CDSNotificationInterface::SyncTransaction(const CTransaction &tx, const CBlockIndex *pindex, int posInBlock)
|
2017-01-29 09:22:14 +01:00
|
|
|
{
|
2018-09-21 16:01:04 +02:00
|
|
|
llmq::quorumInstantSendManager->SyncTransaction(tx, pindex, posInBlock);
|
2019-02-28 15:04:27 +01:00
|
|
|
llmq::chainLocksHandler->SyncTransaction(tx, pindex, posInBlock);
|
2018-01-08 18:41:06 +01:00
|
|
|
instantsend.SyncTransaction(tx, pindex, posInBlock);
|
|
|
|
CPrivateSend::SyncTransaction(tx, pindex, posInBlock);
|
2017-09-15 20:08:03 +02:00
|
|
|
}
|
2019-01-03 10:17:43 +01:00
|
|
|
|
2019-04-09 13:26:33 +02:00
|
|
|
void CDSNotificationInterface::NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff)
|
2019-01-03 10:17:43 +01:00
|
|
|
{
|
2019-04-09 13:26:33 +02:00
|
|
|
CMNAuth::NotifyMasternodeListChanged(undo, oldMNList, diff);
|
2019-01-03 10:17:43 +01:00
|
|
|
governance.CheckMasternodeOrphanObjects(connman);
|
|
|
|
governance.CheckMasternodeOrphanVotes(connman);
|
|
|
|
governance.UpdateCachesAndClean();
|
|
|
|
}
|
2018-09-21 16:01:04 +02:00
|
|
|
|
2019-05-23 11:13:58 +02:00
|
|
|
void CDSNotificationInterface::NotifyChainLock(const CBlockIndex* pindex, const llmq::CChainLockSig& clsig)
|
2018-09-21 16:01:04 +02:00
|
|
|
{
|
|
|
|
llmq::quorumInstantSendManager->NotifyChainLock(pindex);
|
|
|
|
}
|