Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tip lock handling in tier two. #1656

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ BITCOIN_CORE_H = \
primitives/block.h \
primitives/transaction.h \
core_io.h \
dsnotificationinterface.h \
crypter.h \
pairresult.h \
addressbook.h \
Expand Down Expand Up @@ -272,6 +273,7 @@ libbitcoin_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libbitcoin_wallet_a_SOURCES = \
activemasternode.cpp \
bip38.cpp \
dsnotificationinterface.cpp \
denomination_functions.cpp \
addressbook.cpp \
crypter.cpp \
Expand Down
23 changes: 23 additions & 0 deletions src/dsnotificationinterface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2015 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 "masternode-budget.h"
#include "masternode-payments.h"
#include "masternode-sync.h"

CDSNotificationInterface::CDSNotificationInterface()
{
}

CDSNotificationInterface::~CDSNotificationInterface()
{
}

void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindex)
{
masternodePayments.UpdatedBlockTip(pindex);
budget.UpdatedBlockTip(pindex);
masternodeSync.UpdatedBlockTip(pindex);
}
24 changes: 24 additions & 0 deletions src/dsnotificationinterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) 2015 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef BITCOIN_DSNOTIFICATIONINTERFACE_H
#define BITCOIN_DSNOTIFICATIONINTERFACE_H

#include "validationinterface.h"

class CDSNotificationInterface : public CValidationInterface
{
public:
// virtual CDSNotificationInterface();
CDSNotificationInterface();
virtual ~CDSNotificationInterface();

protected:
// CValidationInterface
void UpdatedBlockTip(const CBlockIndex *pindex);

private:
};

#endif // BITCOIN_DSNOTIFICATIONINTERFACE_H
20 changes: 20 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
#include "validationinterface.h"
#include "zpivchain.h"

#include "dsnotificationinterface.h"

#ifdef ENABLE_WALLET
#include "wallet/db.h"
#include "wallet/wallet.h"
Expand Down Expand Up @@ -85,6 +87,8 @@ volatile bool fRestartRequested = false; // true: restart false: shutdown
static CZMQNotificationInterface* pzmqNotificationInterface = NULL;
#endif

static CDSNotificationInterface* pdsNotificationInterface = nullptr;

#ifdef WIN32
// Win32 LevelDB doesn't use filedescriptors, and the ones used for
// accessing block files, don't count towards to fd_set size limit
Expand Down Expand Up @@ -266,6 +270,12 @@ void PrepareShutdown()
// Disconnect all slots
UnregisterAllValidationInterfaces();

if (pdsNotificationInterface) {
UnregisterValidationInterface(pdsNotificationInterface);
delete pdsNotificationInterface;
pdsNotificationInterface = nullptr;
}

#ifndef WIN32
try {
boost::filesystem::remove(GetPidFile());
Expand Down Expand Up @@ -1412,6 +1422,10 @@ bool AppInit2()
}
#endif

// Register tier two interface
pdsNotificationInterface = new CDSNotificationInterface();
RegisterValidationInterface(pdsNotificationInterface);

// ********************************************************* Step 7: load block chain

fReindex = GetBoolArg("-reindex", false);
Expand Down Expand Up @@ -1979,6 +1993,12 @@ bool AppInit2()
LogPrintf("nSwiftTXDepth %d\n", nSwiftTXDepth);
LogPrintf("Budget Mode %s\n", strBudgetMode.c_str());

// force UpdatedBlockTip to initialize pCurrentBlockIndex for DS, MN payments and budgets
{
LOCK(cs_main);
GetMainSignals().UpdatedBlockTip(chainActive.Tip());
}

threadGroup.create_thread(boost::bind(&ThreadCheckMasternodes));

if (ShutdownRequested()) {
Expand Down
2 changes: 2 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4281,12 +4281,14 @@ bool ProcessNewBlock(CValidationState& state, CNode* pfrom, CBlock* pblock, CDis
if (!ActivateBestChain(state, pblock, checked))
return error("%s : ActivateBestChain failed", __func__);

/*
if (!fLiteMode) {
if (masternodeSync.RequestedMasternodeAssets > MASTERNODE_SYNC_LIST) {
masternodePayments.ProcessBlock(GetHeight() + 10);
budget.NewBlock();
}
}
*/

if (pwalletMain) {
/* disable multisend
Expand Down
Loading