dash/src/dsnotificationinterface.cpp

73 lines
2.8 KiB
C++
Raw Normal View History

2016-12-20 14:26:45 +01:00
// Copyright (c) 2014-2017 The Dash Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "dsnotificationinterface.h"
#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"
#include "masternode-payments.h"
#include "masternode-sync.h"
#include "privatesend-client.h"
#include "txmempool.h"
void CDSNotificationInterface::InitializeCurrentBlockTip()
{
LOCK(cs_main);
UpdatedBlockTip(chainActive.Tip(), NULL, IsInitialBlockDownload());
}
void CDSNotificationInterface::AcceptedBlockHeader(const CBlockIndex *pindexNew)
{
masternodeSync.AcceptedBlockHeader(pindexNew);
}
void CDSNotificationInterface::NotifyHeaderTip(const CBlockIndex *pindexNew, bool fInitialDownload)
{
Eliminate remaining uses of g_connman in Dash-specific code. (#1635) This monstrous change eliminates all remaining uses of g_connman global variable in Dash-specific code. Unlike previous changes eliminating g_connman use that were isolated to particular modules, this one covers multiple modules simultaneously because they are so interdependent that change in one module was quickly spreading to others. This is mostly invariant change that was done by * changing all functions using g_connman to use connman argument, * changing all functions calling these functions to use connman argument, * repeating previous step until there's nothing to change. After multiple iterations, this process converged to final result, producing code that is mostly equivalent to original one, but passing CConnman instance through arguments instead of global variable. The only exception to equivalence of resulting code is that I had to create overload of CMasternodeMan::CheckAndRemove() method without arguments that does nothing just for use in CFlatDB<CMasternodeMan>::Dump() and CFlatDB<CMasternodeMan>::Load() methods. Normal CMasternodeMan::CheckAndRemove() overload now has argument of CConnman& type and is used everywhere else. The normal overload has this code in the beginning: if(!masternodeSync.IsMasternodeListSynced()) return; Masternode list is not synced yet when we load "mncache.dat" file, and we save "mncache.dat" file on shutdown, so I presume that it's OK to use overload that does nothing in both cases. Signed-off-by: Oleg Girko <ol@infoserver.lv>
2017-09-19 16:51:38 +02:00
masternodeSync.NotifyHeaderTip(pindexNew, fInitialDownload, connman);
}
void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
{
2017-09-20 22:30:56 +02:00
if (pindexNew == pindexFork) // blocks were disconnected without any new ones
return;
masternodeSync.UpdatedBlockTip(pindexNew, fInitialDownload, connman);
// DIP0001 updates
bool fDIP0001ActiveAtTipTmp = fDIP0001ActiveAtTip;
// Update global flags
fDIP0001ActiveAtTip = (VersionBitsState(pindexNew, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0001, versionbitscache) == THRESHOLD_ACTIVE);
fDIP0001WasLockedIn = fDIP0001ActiveAtTip || (VersionBitsState(pindexNew, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0001, versionbitscache) == THRESHOLD_LOCKED_IN);
2017-09-22 03:53:43 +02:00
// Update min fees only if activation changed and we are using default fees
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);
}
}
if (fInitialDownload)
return;
mnodeman.UpdatedBlockTip(pindexNew);
privateSendClient.UpdatedBlockTip(pindexNew);
instantsend.UpdatedBlockTip(pindexNew);
mnpayments.UpdatedBlockTip(pindexNew, connman);
governance.UpdatedBlockTip(pindexNew, connman);
}
void CDSNotificationInterface::SyncTransaction(const CTransaction &tx, const CBlock *pblock)
{
instantsend.SyncTransaction(tx, pblock);
CPrivateSend::SyncTransaction(tx, pblock);
}