Skip to content

Commit

Permalink
Merge branch 'SAPP-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 Jun 12, 2023
2 parents 405dae5 + 5a1dc14 commit e32de16
Show file tree
Hide file tree
Showing 76 changed files with 1,803 additions and 354 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, 1)
define(_CLIENT_VERSION_MINOR, 5)
define(_CLIENT_VERSION_REVISION, 1)
define(_CLIENT_VERSION_REVISION, 2)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_RC, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
Expand Down
8 changes: 0 additions & 8 deletions doc/man/pivx-qt.1
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ Specify pid file (default: pivx.pid)
.IP
Rebuild block chain index from current blk000??.dat files on startup
.HP
\fB\-reindexmoneysupply\fR
.IP
Reindex the PIV money supply statistics on startup
.HP
\fB\-resync\fR
.IP
Delete blockchain folders and resync from scratch on startup
Expand All @@ -113,10 +109,6 @@ Create new files with system default permissions, instead of umask 077
.IP
Maintain a full transaction index, used by the getrawtransaction rpc
call (default: 1)
.HP
\fB\-forcestart\fR
.IP
Attempt to force blockchain corruption recovery on startup
.PP
Connection options:
.HP
Expand Down
6 changes: 3 additions & 3 deletions src/activemasternode.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
class CActiveMasternode
{
private:
/// Ping Masternode
bool SendMasternodePing(std::string& errorMessage);

int status;
std::string notCapableReason;

Expand Down Expand Up @@ -58,6 +55,9 @@ class CActiveMasternode

/// Enable cold wallet mode (run a Masternode with no funds)
bool EnableHotColdMasterNode(CTxIn& vin, CService& addr);

/// Ping Masternode
bool SendMasternodePing(std::string& errorMessage);
};

#endif //ACTIVEMASTERNODE_H
6 changes: 1 addition & 5 deletions src/chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,10 @@ CScript* CBlockIndex::GetPaidPayee()
CBlock block;
if (nHeight <= chainActive.Height() && ReadBlockFromDisk(block, this)) {
auto amount = CMasternode::GetMasternodePayment(nHeight);
auto mnpayee = block.GetPaidPayee(nHeight, amount);
auto mnpayee = block.GetPaidPayee(amount);

if(!mnpayee.empty()) {
paidPayee = new CScript(mnpayee);
auto pmn = mnodeman.Find(mnpayee);
if(pmn) {
pmn->lastPaid = GetBlockTime();
}
}
}
}
Expand Down
19 changes: 15 additions & 4 deletions src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ class CBlockIndex
std::vector<unsigned char> vStakeModifier{};
unsigned int nFlags{0};

//! (memory only) MoneySupply for this block.
//! Will be nullopt if there was no calculations made into it.
Optional<CAmount> nMoneySupply{nullopt};

//! block header
int nVersion{0};
uint256 hashMerkleRoot{};
Expand Down Expand Up @@ -277,7 +281,9 @@ class CBlockIndex
/** Used to marshal pointers into hashes for db storage. */

// New serialization introduced on PIVX
static const int DBI_SER_VERSION_NO_MS = 1004000; // removes nMoneySupply
static const int DBI_SER_VERSION_NO_MS = 1004000; // removes nMoneySupply from persisted block index
// New serialization introduced on DSW
static const int DBI_SER_VERSION_MS = 1050200; // reintroduces the nMoneySupply to the persisted block index

class CDiskBlockIndex : public CBlockIndex
{
Expand Down Expand Up @@ -323,14 +329,19 @@ class CDiskBlockIndex : public CBlockIndex
READWRITE(nTime);
READWRITE(nBits);
READWRITE(nNonce);
if(this->nVersion > 3 && this->nVersion < 7)

if(this->nVersion > 3 && this->nVersion < 7) {
READWRITE(nAccumulatorCheckpoint);
}

if (this->nVersion >= 7 && nSerVersion >= DBI_SER_VERSION_MS) {
READWRITE(nMoneySupply);
}

} else if (ser_action.ForRead()) {
// Serialization with CLIENT_VERSION <= DBI_SER_VERSION_NO_MS
int64_t nMint = 0;
uint256 hashNext{};
int64_t nMoneySupply = 0;
READWRITE(nMint);
READWRITE(nMoneySupply);
READWRITE(nFlags);
Expand Down Expand Up @@ -402,7 +413,7 @@ class CChain
}

/** Returns the index entry for the tip of this chain, or NULL if none. */
CBlockIndex* Tip(bool fProofOfStake = false) const
CBlockIndex* Tip() const
{
LOCK(cs);

Expand Down
205 changes: 100 additions & 105 deletions src/chainparams.cpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ enum UpgradeIndex : uint32_t {
UPGRADE_STAKE_MIN_DEPTH_V2,
UPGRADE_CHECK_WORK_V2,
UPGRADE_MASTERNODE_RANK_V2,
UPGRADE_DYNAMIC_COLLATERAL,
// NOTE: Also add new upgrades to NetworkUpgradeInfo in upgrades.cpp
UPGRADE_TESTDUMMY,
MAX_NETWORK_UPGRADES,
Expand Down
4 changes: 4 additions & 0 deletions src/consensus/upgrades.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ const struct NUInfo NetworkUpgradeInfo[Consensus::MAX_NETWORK_UPGRADES] = {
/*.strName =*/ "masternode_rank_v2",
/*.strInfo =*/ "new masternode ranking system",
},
{
/*.strName =*/ "dynamic_collateral_v2",
/*.strInfo =*/ "new dynamic collateral system",
},
{
/*.strName =*/ "Test_dummy",
/*.strInfo =*/ "Test dummy info",
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/sph_haval.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ void sph_haval160_4_close(void *cc, void *dst);
* @param n the number of extra bits (0 to 7)
* @param dst the output buffer
*/
void sph_haval160_3_addbits_and_close(void *cc,
void sph_haval160_4_addbits_and_close(void *cc,
unsigned ub, unsigned n, void *dst);

/**
Expand Down
80 changes: 49 additions & 31 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,6 @@ int nWalletBackups = 10;
#endif
volatile bool fFeeEstimatesInitialized = false;
volatile bool fRestartRequested = false; // true: restart false: shutdown
static const bool DEFAULT_PROXYRANDOMIZE = true;
static const bool DEFAULT_REST_ENABLE = false;
static const bool DEFAULT_DISABLE_SAFEMODE = false;
static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false;
static const bool DEFAULT_MASTERNODE = false;
static const bool DEFAULT_MNCONFLOCK = true;

std::unique_ptr<CConnman> g_connman;

Expand Down Expand Up @@ -403,14 +397,13 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-pid=<file>", strprintf(_("Specify pid file (default: %s)"), PIVX_PID_FILENAME));
#endif
strUsage += HelpMessageOpt("-reindex", _("Rebuild block chain index from current blk000??.dat files") + " " + _("on startup"));
strUsage += HelpMessageOpt("-reindexmoneysupply", strprintf(_("Reindex the %s and z%s money supply statistics"), CURRENCY_UNIT, CURRENCY_UNIT) + " " + _("on startup"));
strUsage += HelpMessageOpt("-resync", _("Delete blockchain folders and resync from scratch") + " " + _("on startup"));
strUsage += HelpMessageOpt("-rewindblockindex[=<n or hash>]", _("When used without a value, rewinds blockchain to last checkpoint. When passing a number, rolls back the chain by the given number of blocks. When passing a block hash (as a hex string), rewind up to (not including) the block with the matching hash."));
#if !defined(WIN32)
strUsage += HelpMessageOpt("-sysperms", _("Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)"));
#endif
strUsage += HelpMessageOpt("-txindex", strprintf(_("Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)"), DEFAULT_TXINDEX));
strUsage += HelpMessageOpt("-forcestart", _("Attempt to force blockchain corruption recovery") + " " + _("on startup"));


strUsage += HelpMessageGroup(_("Connection options:"));
strUsage += HelpMessageOpt("-addnode=<ip>", _("Add a node to connect to and attempt to keep the connection open"));
strUsage += HelpMessageOpt("-banscore=<n>", strprintf(_("Threshold for disconnecting misbehaving peers (default: %u)"), DEFAULT_BANSCORE_THRESHOLD));
Expand Down Expand Up @@ -1425,6 +1418,8 @@ bool AppInit2()
LogPrintf("* Using %.1fMiB for chain state database\n", nCoinDBCache * (1.0 / 1024 / 1024));
LogPrintf("* Using %.1fMiB for in-memory UTXO set\n", nCoinCacheUsage * (1.0 / 1024 / 1024));

const CChainParams& chainparams = Params();

bool fLoaded = false;
while (!fLoaded && !ShutdownRequested()) {
bool fReset = fReindex;
Expand Down Expand Up @@ -1494,37 +1489,60 @@ bool AppInit2()
break;
}

{
LOCK(cs_main);
nMoneySupply = 0;

std::unique_ptr<CCoinsViewCursor> pcursor(pcoinsTip->Cursor());

while (pcursor->Valid()) {
boost::this_thread::interruption_point();
COutPoint key;
Coin coin;
if (pcursor->GetKey(key) && pcursor->GetValue(coin)) {
// ----------- burn address scanning -----------
CTxDestination source;
if (ExtractDestination(coin.out.scriptPubKey, source)) {
const std::string addr = EncodeDestination(source);
if (consensus.mBurnAddresses.find(addr) != consensus.mBurnAddresses.end() &&
consensus.mBurnAddresses.at(addr) < chainActive.Height())
{
pcursor->Next();
continue;
if (chainActive.Tip() != nullptr) {
if (!chainActive.Tip()->nMoneySupply) {
LOCK(cs_main);
nMoneySupply = 0;

std::unique_ptr<CCoinsViewCursor> pcursor(pcoinsTip->Cursor());

while (pcursor->Valid()) {
boost::this_thread::interruption_point();
COutPoint key;
Coin coin;
if (pcursor->GetKey(key) && pcursor->GetValue(coin)) {
// ----------- burn address scanning -----------
CTxDestination source;
if (ExtractDestination(coin.out.scriptPubKey, source)) {
const std::string addr = EncodeDestination(source);
if (consensus.mBurnAddresses.find(addr) != consensus.mBurnAddresses.end() &&
consensus.mBurnAddresses.at(addr) < chainActive.Height()) {
pcursor->Next();
continue;
}
}
nMoneySupply += coin.out.nValue;
}
nMoneySupply += coin.out.nValue;
pcursor->Next();
}
pcursor->Next();

chainActive.Tip()->nMoneySupply = nMoneySupply;
} else {
nMoneySupply = chainActive.Tip()->nMoneySupply.get();
}
}

if (!fReindex) {
uiInterface.InitMessage(_("Verifying blocks..."));

// If the active chain has blocks and -rewindblockindex option is enabled.
if (chainActive.Tip() != NULL && !SoftSetBoolArg("-rewindblockindex", false)) {

// Figure out whether we got a parameter with -rewindblockindex, what type it is,
// and how many blocks to rewind.
std::string targetBlockHashStr = GetArg("-rewindblockindex", "");

uiInterface.InitMessage(_("Rewinding blocks..."));

if (!RewindBlockIndex(targetBlockHashStr)) {
strLoadError = _("Unable to rewind the blockchain. You will need to redownload the blockchain");
break;
}

// Clear the banned adresses to aid the recovery of a possible fork
g_connman->ClearBanned();
}

// Flag sent to validation code to let it know it can skip certain checks
fVerifyingBlocks = true;

Expand Down
7 changes: 7 additions & 0 deletions src/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@

#include <string>

const bool DEFAULT_PROXYRANDOMIZE = true;
const bool DEFAULT_REST_ENABLE = false;
const bool DEFAULT_DISABLE_SAFEMODE = false;
const bool DEFAULT_STOPAFTERBLOCKIMPORT = false;
const bool DEFAULT_MASTERNODE = false;
const bool DEFAULT_MNCONFLOCK = true;

class CScheduler;
class CWallet;

Expand Down
Loading

0 comments on commit e32de16

Please sign in to comment.