Merge upstream FSM into duke
This commit is contained in:
33
src/init.cpp
33
src/init.cpp
@@ -75,7 +75,9 @@
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/interprocess/sync/file_lock.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <chrono>
|
||||
#include <openssl/crypto.h>
|
||||
#include <thread>
|
||||
|
||||
#include <libsnark/common/profiling.hpp>
|
||||
|
||||
@@ -95,6 +97,7 @@ using namespace std;
|
||||
extern void ThreadSendAlert();
|
||||
extern bool komodo_dailysnapshot(int32_t height);
|
||||
extern int32_t KOMODO_LOADINGBLOCKS;
|
||||
extern void komodo_init(int32_t height);
|
||||
|
||||
ZCJoinSplit* pzcashParams = NULL;
|
||||
|
||||
@@ -727,6 +730,22 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
|
||||
}
|
||||
}
|
||||
|
||||
void ThreadNotifyRecentlyAdded()
|
||||
{
|
||||
while (true) {
|
||||
// Run the notifier on an integer second in the steady clock.
|
||||
auto now = std::chrono::steady_clock::now().time_since_epoch();
|
||||
auto nextFire = std::chrono::duration_cast<std::chrono::seconds>(
|
||||
now + std::chrono::seconds(1));
|
||||
std::this_thread::sleep_until(
|
||||
std::chrono::time_point<std::chrono::steady_clock>(nextFire));
|
||||
|
||||
boost::this_thread::interruption_point();
|
||||
|
||||
mempool.NotifyRecentlyAdded();
|
||||
}
|
||||
}
|
||||
|
||||
/** Sanity checks
|
||||
* Ensure that Bitcoin is running in a usable environment with all
|
||||
* necessary library support.
|
||||
@@ -1088,7 +1107,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
RegisterAllCoreRPCCommands(tableRPC);
|
||||
#ifdef ENABLE_WALLET
|
||||
bool fDisableWallet = GetBoolArg("-disablewallet", false);
|
||||
if ( KOMODO_NSPV > 0 )
|
||||
if ( KOMODO_NSPV_SUPERLITE )
|
||||
{
|
||||
fDisableWallet = true;
|
||||
nLocalServices = 0;
|
||||
@@ -1169,7 +1188,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
// Option to startup with mocktime set (used for regression testing):
|
||||
SetMockTime(GetArg("-mocktime", 0)); // SetMockTime(0) is a no-op
|
||||
|
||||
if ( KOMODO_NSPV <= 0 )
|
||||
if ( KOMODO_NSPV_FULLNODE )
|
||||
{
|
||||
if (GetBoolArg("-peerbloomfilters", true))
|
||||
nLocalServices |= NODE_BLOOM;
|
||||
@@ -1333,7 +1352,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
libsnark::inhibit_profiling_info = true;
|
||||
libsnark::inhibit_profiling_counters = true;
|
||||
|
||||
if ( KOMODO_NSPV <= 0 )
|
||||
if ( KOMODO_NSPV_FULLNODE )
|
||||
{
|
||||
// Initialize Zcash circuit parameters
|
||||
ZC_LoadParams(chainparams);
|
||||
@@ -1514,7 +1533,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( KOMODO_NSPV > 0 )
|
||||
if ( KOMODO_NSPV_SUPERLITE )
|
||||
{
|
||||
std::vector<boost::filesystem::path> vImportFiles;
|
||||
threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles));
|
||||
@@ -1655,7 +1674,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
// (we're likely using a testnet datadir, or the other way around).
|
||||
if (!mapBlockIndex.empty() && mapBlockIndex.count(chainparams.GetConsensus().hashGenesisBlock) == 0)
|
||||
return InitError(_("Incorrect or no genesis block found. Wrong datadir for network?"));
|
||||
|
||||
komodo_init(1);
|
||||
// Initialize the block index (no-op if non-empty database was already loaded)
|
||||
if (!InitBlockIndex()) {
|
||||
strLoadError = _("Error initializing block database");
|
||||
@@ -1990,6 +2009,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
LogPrintf("mapAddressBook.size() = %u\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0);
|
||||
#endif
|
||||
|
||||
// Start the thread that notifies listeners of transactions that have been
|
||||
// recently added to the mempool.
|
||||
threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "txnotify", &ThreadNotifyRecentlyAdded));
|
||||
|
||||
if (GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION))
|
||||
StartTorControl(threadGroup, scheduler);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user