Skip to content

Commit

Permalink
Merge branch 'DASHD-develop' of https://github.com/decenomy/DSW
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro-at-decenomy committed Jan 25, 2025
2 parents 0596da9 + 40c698b commit 658e8d9
Show file tree
Hide file tree
Showing 40 changed files with 943 additions and 2,060 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 2)
define(_CLIENT_VERSION_MINOR, 1)
define(_CLIENT_VERSION_REVISION, 5)
define(_CLIENT_VERSION_REVISION, 6)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_RC, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
Expand Down
2 changes: 0 additions & 2 deletions contrib/docker/Dockerfile.dsw-windows-x64-builder
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ RUN for host in $HOSTS; \
done \
done

RUN ln -s ${WRAP_DIR}/x86_64-w64-mingw32-windres ${WRAP_DIR}/windres

# Clone the repository
RUN git clone https://github.com/decenomy/DSW.git

Expand Down
1 change: 1 addition & 0 deletions depends/packages/gmp.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ $(package)_sha256_hash=5275bb04f4863a13516b2f39392ac5e272f5e1bb8057b18aec1c9b79d
define $(package)_set_vars
$(package)_config_opts=--disable-shared
$(package)_config_opts_mingw32=--enable-mingw
$(package)_config_opts_mingw32+=CC_FOR_BUILD=gcc
$(package)_config_opts_linux=--with-pic
endef

Expand Down
1 change: 1 addition & 0 deletions depends/packages/openssl.mk
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ $(package)_config_opts_alpha_linux=linux-generic64
$(package)_config_opts_m68k_linux=linux-generic32
$(package)_config_opts_x86_64_darwin=darwin64-x86_64-cc
$(package)_config_opts_x86_64_mingw32=mingw64
$(package)_config_opts_x86_64_mingw32+=RC=x86_64-w64-mingw32-windres
$(package)_config_opts_i686_mingw32=mingw
endef

Expand Down
35 changes: 3 additions & 32 deletions src/activemasternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,38 +48,9 @@ void CActiveMasternode::ManageStatus()
if (status != ACTIVE_MASTERNODE_STARTED) {
// Set defaults
status = ACTIVE_MASTERNODE_NOT_CAPABLE;
notCapableReason = "";

if (pwalletMain->IsLocked()) {
notCapableReason = "Wallet is locked.";
LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason);
return;
}

if (pwalletMain->GetAvailableBalance() == 0) {
notCapableReason = "Hot node, waiting for remote activation.";
LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason);
return;
}

if (!GetLocal(service)) {
notCapableReason = "Can't detect external address.";
LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason);
return;
}

// The service needs the correct default port to work properly
if (!CMasternodeBroadcast::CheckDefaultPort(service, errorMessage, "CActiveMasternode::ManageStatus()"))
return;

LogPrintf("CActiveMasternode::ManageStatus() - Checking inbound connection to '%s'\n", service.ToString());

CAddress addr(service, NODE_NETWORK);
if (!g_connman->OpenNetworkConnection(addr, true, nullptr)) {
notCapableReason = "Could not connect to " + service.ToString();
LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason);
return;
}

notCapableReason = "Waiting for start message from controller.";
return;
}

//send to all peers
Expand Down
19 changes: 7 additions & 12 deletions src/chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,21 +246,16 @@ uint256 CBlockIndex::GetStakeModifierV2() const

bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex);

CScript* CBlockIndex::GetPaidPayee()
CScript CBlockIndex::GetPaidPayee() const
{
if(paidPayee == nullptr || paidPayee->empty()) {
CBlock block;
if (nHeight <= chainActive.Height() && ReadBlockFromDisk(block, this)) {
auto amount = CMasternode::GetMasternodePayment(nHeight);
auto mnpayee = block.GetPaidPayee(amount);

if(!mnpayee.empty()) {
paidPayee = new CScript(mnpayee);
}
}
CBlock block;
if (nHeight <= chainActive.Height() && ReadBlockFromDisk(block, this)) {
auto amount = CMasternode::GetMasternodePayment(nHeight);
auto paidPayee = block.GetPaidPayee(amount);
return paidPayee;
}

return paidPayee;
return CScript();
}

//! Check whether this block index entry is valid up to the passed validity level.
Expand Down
5 changes: 1 addition & 4 deletions src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,6 @@ class CBlockIndex
//! (memory only) Sequential id assigned to distinguish order in which blocks are received.
uint32_t nSequenceId{0};

//! (memory only) paid masternode.
CScript* paidPayee{nullptr};

CBlockIndex() {}
CBlockIndex(const CBlock& block);

Expand Down Expand Up @@ -263,7 +260,7 @@ class CBlockIndex
void SetNewStakeModifier(const uint256& prevoutId); // generates and sets new v2 modifier
uint64_t GetStakeModifierV1() const;
uint256 GetStakeModifierV2() const;
CScript* GetPaidPayee();
CScript GetPaidPayee() const;

//! Check whether this block index entry is valid up to the passed validity level.
bool IsValid(enum BlockStatus nUpTo = BLOCK_VALID_TRANSACTIONS) const;
Expand Down
4 changes: 1 addition & 3 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class CMainParams : public CChainParams
consensus.nTargetSpacingV2 = 1 * 60;
consensus.nTimeSlotLength = 15;
consensus.nRewardAdjustmentInterval = 7 * DAY_IN_SECONDS / consensus.nTargetSpacing;
consensus.nRewardAdjustmentIntervalV2 = 7 * DAY_IN_SECONDS / consensus.nTargetSpacingV2;

// spork keys
consensus.strSporkPubKey = "02d8e66d000dbe1c014cf7d0a1fe89fec297d78603cb5d0b1a17ec0e6809e9271d";
Expand All @@ -164,7 +165,6 @@ class CMainParams : public CChainParams
consensus.vUpgrades[Consensus::UPGRADE_P2PKH_BLOCK_SIGNATURES].nActivationHeight = 338100;
consensus.vUpgrades[Consensus::UPGRADE_NEW_TARGET_SPACING].nActivationHeight = 292001;
consensus.vUpgrades[Consensus::UPGRADE_STAKE_MIN_DEPTH_V2].nActivationHeight = 525001;
consensus.vUpgrades[Consensus::UPGRADE_MASTERNODE_RANK_V2].nActivationHeight = 523001;
consensus.vUpgrades[Consensus::UPGRADE_COINBASE_MATURITY_V2].nActivationHeight = 525001;
consensus.vUpgrades[Consensus::UPGRADE_DYNAMIC_REWARDS].nActivationHeight = 2250001;
consensus.vUpgrades[Consensus::UPGRADE_DYNAMIC_COLLATERALS].nActivationHeight = Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
Expand All @@ -178,7 +178,6 @@ class CMainParams : public CChainParams
consensus.vUpgrades[Consensus::UPGRADE_P2PKH_BLOCK_SIGNATURES].hashActivationBlock = uint256S("c06e7c7d19a30a298ea59f69533d66f68b4f535a9d6ba957f6d738f6ec965281");
consensus.vUpgrades[Consensus::UPGRADE_NEW_TARGET_SPACING].hashActivationBlock = uint256S("f39105a85aec716241fc717add26b08cc2785748aa4c7cf3c0daec5d578565f6");
consensus.vUpgrades[Consensus::UPGRADE_STAKE_MIN_DEPTH_V2].hashActivationBlock = uint256S("8686d0f1739d6dfc6eafcefb4c9ad1b56fc256a852d5087593631ccb0866b8f4");
consensus.vUpgrades[Consensus::UPGRADE_MASTERNODE_RANK_V2].hashActivationBlock = uint256S("982267b09fbedbfad523c97f2c73a483dd070b11c00042a1fdb5586e3ab8848d");
consensus.vUpgrades[Consensus::UPGRADE_COINBASE_MATURITY_V2].hashActivationBlock = uint256S("8686d0f1739d6dfc6eafcefb4c9ad1b56fc256a852d5087593631ccb0866b8f4");
consensus.vUpgrades[Consensus::UPGRADE_DYNAMIC_REWARDS].hashActivationBlock = uint256S("0x0");
consensus.vUpgrades[Consensus::UPGRADE_DYNAMIC_COLLATERALS].hashActivationBlock = uint256S("0x0");
Expand Down Expand Up @@ -275,7 +274,6 @@ class CTestNetParams : public CMainParams
consensus.vUpgrades[Consensus::UPGRADE_TIME_PROTOCOL_V2].nActivationHeight = 1641;
consensus.vUpgrades[Consensus::UPGRADE_P2PKH_BLOCK_SIGNATURES].nActivationHeight = 1741;
consensus.vUpgrades[Consensus::UPGRADE_STAKE_MIN_DEPTH_V2].nActivationHeight = 1841;
consensus.vUpgrades[Consensus::UPGRADE_MASTERNODE_RANK_V2].nActivationHeight = 1941;
consensus.vUpgrades[Consensus::UPGRADE_DYNAMIC_REWARDS].nActivationHeight = Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
consensus.vUpgrades[Consensus::UPGRADE_DYNAMIC_COLLATERALS].nActivationHeight = Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
consensus.vUpgrades[Consensus::UPGRADE_POS_V3].nActivationHeight = Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
Expand Down
2 changes: 1 addition & 1 deletion src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ enum UpgradeIndex : uint32_t {
UPGRADE_P2PKH_BLOCK_SIGNATURES,
UPGRADE_NEW_TARGET_SPACING,
UPGRADE_STAKE_MIN_DEPTH_V2,
UPGRADE_MASTERNODE_RANK_V2,
UPGRADE_COINBASE_MATURITY_V2,
UPGRADE_DYNAMIC_REWARDS,
UPGRADE_DYNAMIC_COLLATERALS,
Expand Down Expand Up @@ -110,6 +109,7 @@ struct Params {
int nTimeSlotLength;

int nRewardAdjustmentInterval;
int nRewardAdjustmentIntervalV2;

// burn addresses
std::map<std::string, int> mBurnAddresses = {};
Expand Down
6 changes: 1 addition & 5 deletions src/consensus/upgrades.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
const struct NUInfo NetworkUpgradeInfo[Consensus::MAX_NETWORK_UPGRADES] = {
{
/*.strName =*/ "Base",
/*.strInfo =*/ "DashDiamond network",
/*.strInfo =*/ "Base network",
},
{
/*.strName =*/ "PoS",
Expand Down Expand Up @@ -52,10 +52,6 @@ const struct NUInfo NetworkUpgradeInfo[Consensus::MAX_NETWORK_UPGRADES] = {
/*.strName =*/ "Stake_min_depth_v2",
/*.strInfo =*/ "Increases the stake min depth",
},
{
/*.strName =*/ "masternode_rank_v2",
/*.strInfo =*/ "new masternode ranking system",
},
{
/*.strName =*/ "coinbase_maturity_v2",
/*.strInfo =*/ "new coinbase maturity back to the regular 100 confirmations",
Expand Down
37 changes: 9 additions & 28 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ void PrepareShutdown()
g_connman.reset();

DumpMasternodes();
DumpMasternodePayments();
UnregisterNodeSignals(GetNodeSignals());

// After everything has been shut down, but before things get flushed, stop the
Expand All @@ -242,6 +241,7 @@ void PrepareShutdown()
LOCK(cs_main);

CRewards::Shutdown();
mnodeman.Shutdown();

if (pcoinsTip != NULL) {
FlushStateToDisk();
Expand Down Expand Up @@ -503,7 +503,7 @@ std::string HelpMessage(HelpMessageMode mode)
}
strUsage += HelpMessageOpt("-shrinkdebugfile", _("Shrink debug.log file on client startup (default: 1 when no -debug)"));
strUsage += HelpMessageOpt("-testnet", _("Use the test network"));
strUsage += HelpMessageOpt("-litemode=<n>", strprintf(_("Disable all DASHD specific functionality (Masternodes) (0-1, default: %u)"), 0));
strUsage += HelpMessageOpt("-litemode=<n>", strprintf(_("Disable all additional functionalities (Masternodes) (0-1, default: %u)"), 0));

strUsage += HelpMessageGroup(_("Masternode options:"));
strUsage += HelpMessageOpt("-masternode=<n>", strprintf(_("Enable the client to act as a masternode (0-1, default: %u)"), DEFAULT_MASTERNODE));
Expand Down Expand Up @@ -681,7 +681,7 @@ void ThreadImport(std::vector<fs::path> vImportFiles)
}

/** Sanity checks
* Ensure that DashDiamond is running in a usable environment with all
* Ensure that the wallet is running in a usable environment with all
* necessary library support.
*/
bool InitSanityCheck(void)
Expand Down Expand Up @@ -915,7 +915,7 @@ void InitLogging()
LogPrintf("DashDiamond version %s (%s)\n", version_string, CLIENT_DATE);
}

/** Initialize dashdiamond.
/** Initialize wallet.
* @pre Parameters should be parsed and config file should be read.
*/
bool AppInit2()
Expand Down Expand Up @@ -1076,19 +1076,19 @@ bool AppInit2()

// Sanity check
if (!InitSanityCheck())
return UIError(_("Initialization sanity check failed. DashDiamond is shutting down."));
return UIError(_("Initialization sanity check failed. Wallet is shutting down."));

std::string strDataDir = GetDataDir().string();

// Make sure only a single DashDiamond process is using the data directory.
// Make sure only a single wallet process is using the data directory.
fs::path pathLockFile = GetDataDir() / ".lock";
FILE* file = fsbridge::fopen(pathLockFile, "a"); // empty lock file; created if it doesn't exist.
if (file) fclose(file);
static boost::interprocess::file_lock lock(pathLockFile.string().c_str());

// Wait maximum 10 seconds if an old wallet is still running. Avoids lockup during restart
if (!lock.timed_lock(boost::get_system_time() + boost::posix_time::seconds(10)))
return UIError(strprintf(_("Cannot obtain a lock on data directory %s. DashDiamond is probably already running."), strDataDir));
return UIError(strprintf(_("Cannot obtain a lock on data directory %s. Wallet is probably already running."), strDataDir));

#ifndef WIN32
CreatePidFile(GetPidFile(), getpid());
Expand Down Expand Up @@ -1263,10 +1263,6 @@ bool AppInit2()
} // (!fDisableWallet)
#endif // ENABLE_WALLET

// Initialize dynamic rewards
if(!CRewards::Init(fReindex))
return false;

// ********************************************************* Step 6: network initialization

assert(!g_connman);
Expand Down Expand Up @@ -1463,7 +1459,7 @@ bool AppInit2()
delete pblocktree;
delete pSporkDB;

//DashDiamond specific: spork DB's
//specific: spork DB's
pSporkDB = new CSporkDB(0, false, false);
pblocktree = new CBlockTreeDB(nBlockTreeDBCache, false, fReindex);
pcoinsdbview = new CCoinsViewDB(nCoinDBCache, false, fReindex);
Expand All @@ -1484,7 +1480,7 @@ bool AppInit2()
// End loop if shutdown was requested
if (ShutdownRequested()) break;

// DashDiamond: load previous sessions sporks if we have them.
// load previous sessions sporks if we have them.
uiInterface.InitMessage(_("Loading sporks..."));
sporkManager.LoadSporksFromDB();

Expand Down Expand Up @@ -1676,21 +1672,6 @@ bool AppInit2()
LogPrintf("file format is unknown or invalid, please fix it manually\n");
}

uiInterface.InitMessage(_("Loading masternode payment cache..."));

CMasternodePaymentDB mnpayments;
CMasternodePaymentDB::ReadResult readResult3 = mnpayments.Read(masternodePayments);

if (readResult3 == CMasternodePaymentDB::FileError)
LogPrintf("Missing masternode payment cache - mnpayments.dat, will try to recreate\n");
else if (readResult3 != CMasternodePaymentDB::Ok) {
LogPrintf("Error reading mnpayments.dat: ");
if (readResult3 == CMasternodePaymentDB::IncorrectFormat)
LogPrintf("magic is ok but data has invalid format, will try to recreate\n");
else
LogPrintf("file format is unknown or invalid, please fix it manually\n");
}

fMasterNode = GetBoolArg("-masternode", DEFAULT_MASTERNODE);

if ((fMasterNode || masternodeConfig.getCount() > -1) && fTxIndex == false) {
Expand Down
Loading

0 comments on commit 658e8d9

Please sign in to comment.