2016-12-20 14:26:45 +01:00
|
|
|
// Copyright (c) 2014-2017 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.
|
|
|
|
|
|
|
|
#include "dsnotificationinterface.h"
|
2017-01-29 09:22:14 +01:00
|
|
|
#include "instantx.h"
|
2016-04-15 04:54:11 +02:00
|
|
|
#include "governance.h"
|
2016-10-20 23:11:30 +02:00
|
|
|
#include "masternodeman.h"
|
2016-03-02 22:20:04 +01:00
|
|
|
#include "masternode-payments.h"
|
|
|
|
#include "masternode-sync.h"
|
2017-07-10 16:42:09 +02:00
|
|
|
#include "privatesend-client.h"
|
2017-09-17 18:00:44 +02:00
|
|
|
#include "txmempool.h"
|
2016-03-02 22:20:04 +01:00
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
|
|
|
masternodeSync.UpdatedBlockTip(pindexNew, fInitialDownload, connman);
|
|
|
|
|
2017-09-15 20:08:03 +02:00
|
|
|
// DIP0001 updates
|
|
|
|
|
2017-09-17 18:00:44 +02:00
|
|
|
bool fDIP0001ActiveAtTipTmp = fDIP0001ActiveAtTip;
|
2017-09-15 20:08:03 +02:00
|
|
|
// Update global flags
|
|
|
|
fDIP0001LockedInAtTip = (VersionBitsState(pindexNew, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0001, versionbitscache) == THRESHOLD_LOCKED_IN);
|
|
|
|
fDIP0001ActiveAtTip = (VersionBitsState(pindexNew, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0001, versionbitscache) == THRESHOLD_ACTIVE);
|
2017-09-17 18:00:44 +02:00
|
|
|
|
2017-09-22 03:53:43 +02:00
|
|
|
// Update min fees only if activation changed and we are using default fees
|
2017-09-17 18:00:44 +02:00
|
|
|
if (fDIP0001ActiveAtTipTmp != fDIP0001ActiveAtTip) {
|
|
|
|
if (!mapArgs.count("-minrelaytxfee")) {
|
|
|
|
::minRelayTxFee = CFeeRate(fDIP0001ActiveAtTip ? DEFAULT_DIP0001_MIN_RELAY_TX_FEE : DEFAULT_LEGACY_MIN_RELAY_TX_FEE);
|
|
|
|
mempool.UpdateMinFee(::minRelayTxFee);
|
|
|
|
}
|
|
|
|
if (!mapArgs.count("-mintxfee")) {
|
|
|
|
CWallet::minTxFee = CFeeRate(fDIP0001ActiveAtTip ? DEFAULT_DIP0001_TRANSACTION_MINFEE : DEFAULT_LEGACY_TRANSACTION_MINFEE);
|
|
|
|
}
|
2017-09-22 03:53:43 +02:00
|
|
|
if (!mapArgs.count("-fallbackfee")) {
|
|
|
|
CWallet::fallbackFee = CFeeRate(fDIP0001ActiveAtTip ? DEFAULT_DIP0001_FALLBACK_FEE : DEFAULT_LEGACY_FALLBACK_FEE);
|
|
|
|
}
|
2017-09-17 18:00:44 +02:00
|
|
|
}
|
2017-09-22 03:54:14 +02:00
|
|
|
|
|
|
|
if (fInitialDownload || !masternodeSync.IsBlockchainSynced())
|
|
|
|
return;
|
|
|
|
|
|
|
|
mnodeman.UpdatedBlockTip(pindexNew);
|
|
|
|
privateSendClient.UpdatedBlockTip(pindexNew);
|
|
|
|
instantsend.UpdatedBlockTip(pindexNew);
|
|
|
|
mnpayments.UpdatedBlockTip(pindexNew, connman);
|
|
|
|
governance.UpdatedBlockTip(pindexNew, connman);
|
2016-03-02 22:20:04 +01:00
|
|
|
}
|
2017-01-29 09:22:14 +01:00
|
|
|
|
|
|
|
void CDSNotificationInterface::SyncTransaction(const CTransaction &tx, const CBlock *pblock)
|
|
|
|
{
|
|
|
|
instantsend.SyncTransaction(tx, pblock);
|
2017-07-10 16:42:09 +02:00
|
|
|
CPrivateSend::SyncTransaction(tx, pblock);
|
2017-09-15 20:08:03 +02:00
|
|
|
}
|