Skip to content

Commit

Permalink
Collateral Change - UI Re-design
Browse files Browse the repository at this point in the history
  • Loading branch information
Dixicoin-DXC committed Oct 30, 2018
1 parent 4fdd250 commit 0b656bc
Show file tree
Hide file tree
Showing 31 changed files with 104 additions and 67 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 4)
define(_CLIENT_VERSION_MINOR, 3)
define(_CLIENT_VERSION_MINOR, 4)
define(_CLIENT_VERSION_REVISION, 0)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
Expand Down
2 changes: 1 addition & 1 deletion src/activemasternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ vector<COutput> CActiveMasternode::SelectCoinsMasternode()

// Filter
BOOST_FOREACH (const COutput& out, vCoins) {
if (out.tx->vout[out.i].nValue == 1000 * COIN) { //exactly
if (out.tx->vout[out.i].nValue == GetMstrNodCollateral(chainActive.Height()) * COIN) { //exactly
filteredCoins.push_back(out);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

//! These need to be macros, as clientversion.cpp's and dixicoin*-res.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 4
#define CLIENT_VERSION_MINOR 3
#define CLIENT_VERSION_MINOR 4
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_BUILD 0

Expand Down
28 changes: 18 additions & 10 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2148,8 +2148,9 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
REJECT_INVALID, "bad-blk-sigops");
}

nFees += view.GetValueIn(tx) - tx.GetValueOut();
nValueIn += view.GetValueIn(tx);
if (!tx.IsCoinStake())
nFees += view.GetValueIn(tx) - tx.GetValueOut();
nValueIn += view.GetValueIn(tx);

std::vector<CScriptCheck> vChecks;
if (!CheckInputs(tx, state, view, fScriptChecks, flags, false, nScriptCheckThreads ? &vChecks : NULL))
Expand All @@ -2169,8 +2170,9 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
}

// ppcoin: track money supply and mint amount info
pindex->nMint = nValueOut - nValueIn + nFees;
pindex->nMoneySupply = (pindex->pprev ? pindex->pprev->nMoneySupply : 0) + nValueOut - nValueIn;
CAmount nMoneySupplyPrev = pindex->pprev ? pindex->pprev->nMoneySupply : 0;
pindex->nMoneySupply = nMoneySupplyPrev + nValueOut - nValueIn;
pindex->nMint = pindex->nMoneySupply - nMoneySupplyPrev + nFees;

if (!pblocktree->WriteBlockIndex(CDiskBlockIndex(pindex)))
return error("Connect() : WriteBlockIndex for pindex failed");
Expand All @@ -2179,12 +2181,18 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
nTimeConnect += nTime1 - nTimeStart;
LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs - 1), nTimeConnect * 0.000001);

if (!IsInitialBlockDownload() && !IsBlockValueValid(block, GetBlockValue(pindex->pprev->nHeight))) {
return state.DoS(100,
error("ConnectBlock() : reward pays too much (actual=%d vs limit=%d)",
block.vtx[0].GetValueOut(), GetBlockValue(pindex->pprev->nHeight)),
REJECT_INVALID, "bad-cb-amount");
}
CAmount nExpectedMint = GetBlockValue(pindex->pprev->nHeight);
if (block.IsProofOfWork())
nExpectedMint += nFees;

if (pindex->pprev->nHeight > 342500) {
if (!IsBlockValueValid(block, nExpectedMint, pindex->nMint)) {
return state.DoS(100,
error("ConnectBlock() : reward pays too much (actual=%s vs limit=%s)",
FormatMoney(pindex->nMint), FormatMoney(nExpectedMint)),
REJECT_INVALID, "bad-cb-amount");
}
}

if (!control.Wait())
return state.DoS(100, false);
Expand Down
12 changes: 12 additions & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ class CValidationState;
struct CBlockTemplate;
struct CNodeStateStats;

inline int64_t GetMstrNodCollateral(int nHeight)
{
if(nHeight < 345000)
{
return 1000;
}
else
{
return 5000;
}
}

/** Default for -blockmaxsize and -blockminsize, which control the range of sizes the mining code will create **/
static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 750000;
static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0;
Expand Down
14 changes: 9 additions & 5 deletions src/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void DumpMasternodePayments()
LogPrintf("Budget dump finished %dms\n", GetTimeMillis() - nStart);
}

bool IsBlockValueValid(const CBlock& block, int64_t nExpectedValue)
bool IsBlockValueValid(const CBlock& block, CAmount nExpectedValue, CAmount nMinted)
{
CBlockIndex* pindexPrev = chainActive.Tip();
if (pindexPrev == NULL) return true;
Expand All @@ -189,28 +189,32 @@ bool IsBlockValueValid(const CBlock& block, int64_t nExpectedValue)
}

if (nHeight == 0) {
LogPrintf("IsBlockValueValid() : WARNING: Couldn't find previous block");
LogPrint("masternode","IsBlockValueValid() : WARNING: Couldn't find previous block\n");
}

if (!masternodeSync.IsSynced()) { //there is no budget data to use to check anything
//super blocks will always be on these blocks, max 100 per budgeting
if (nHeight % GetBudgetPaymentCycleBlocks() < 100) {
return true;
} else {
if (block.vtx[0].GetValueOut() > nExpectedValue) return false;
if (nMinted > nExpectedValue) {
return false;
}
}
} else { // we're synced and have data so check the budget schedule

//are these blocks even enabled
if (!IsSporkActive(SPORK_13_ENABLE_SUPERBLOCKS)) {
return block.vtx[0].GetValueOut() <= nExpectedValue;
return nMinted <= nExpectedValue;
}

if (budget.IsBudgetPaymentBlock(nHeight)) {
//the value of the block is evaluated in CheckBlock
return true;
} else {
if (block.vtx[0].GetValueOut() > nExpectedValue) return false;
if (nMinted > nExpectedValue) {
return false;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/masternode-payments.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern CMasternodePayments masternodePayments;
void ProcessMessageMasternodePayments(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
bool IsBlockPayeeValid(const CBlock& block, int nBlockHeight);
std::string GetRequiredPaymentsString(int nBlockHeight);
bool IsBlockValueValid(const CBlock& block, int64_t nExpectedValue);
bool IsBlockValueValid(const CBlock& block, CAmount nExpectedValue, CAmount nMinted);
void FillBlockPayee(CMutableTransaction& txNew, int64_t nFees, bool fProofOfStake);

void DumpMasternodePayments();
Expand Down
4 changes: 2 additions & 2 deletions src/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void CMasternode::Check(bool forceCheck)
if (!unitTest) {
CValidationState state;
CMutableTransaction tx = CMutableTransaction();
CTxOut vout = CTxOut(999.99 * COIN, obfuScationPool.collateralPubKey);
CTxOut vout = CTxOut((GetMstrNodCollateral(chainActive.Height())-0.01) * COIN, obfuScationPool.collateralPubKey);
tx.vin.push_back(vin);
tx.vout.push_back(vout);

Expand Down Expand Up @@ -573,7 +573,7 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int& nDoS)

CValidationState state;
CMutableTransaction tx = CMutableTransaction();
CTxOut vout = CTxOut(999.99 * COIN, obfuScationPool.collateralPubKey);
CTxOut vout = CTxOut((GetMstrNodCollateral(chainActive.Height())-0.01) * COIN, obfuScationPool.collateralPubKey);
tx.vin.push_back(vin);
tx.vout.push_back(vout);

Expand Down
2 changes: 1 addition & 1 deletion src/masternodeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData

CValidationState state;
CMutableTransaction tx = CMutableTransaction();
CTxOut vout = CTxOut(999.99 * COIN, obfuScationPool.collateralPubKey);
CTxOut vout = CTxOut((GetMstrNodCollateral(chainActive.Height())-0.01) * COIN, obfuScationPool.collateralPubKey);
tx.vin.push_back(vin);
tx.vout.push_back(vout);

Expand Down
2 changes: 1 addition & 1 deletion src/obfuscation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2110,7 +2110,7 @@ bool CObfuScationSigner::IsVinAssociatedWithPubkey(CTxIn& vin, CPubKey& pubkey)
uint256 hash;
if (GetTransaction(vin.prevout.hash, txVin, hash, true)) {
BOOST_FOREACH (CTxOut out, txVin.vout) {
if (out.nValue == 1000 * COIN) {
if (out.nValue == GetMstrNodCollateral(chainActive.Height()) * COIN) {
if (out.scriptPubKey == payee2) return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/qt/forms/masternodelist.ui
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,4 @@
</widget>
<resources/>
<connections/>
</ui>
</ui>
12 changes: 6 additions & 6 deletions src/qt/guiconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ static const bool DEFAULT_SPLASHSCREEN = true;
#define STYLE_INVALID "background:#FF8080"

/* Transaction list -- unconfirmed transaction */
#define COLOR_UNCONFIRMED QColor(128, 128, 128)
#define COLOR_UNCONFIRMED QColor(255, 255, 255)
/* Transaction list -- negative amount */
#define COLOR_NEGATIVE QColor(255, 0, 0)
#define COLOR_NEGATIVE QColor(255, 255, 255)
/* Transaction list -- bare address (without label) */
#define COLOR_BAREADDRESS QColor(140, 140, 140)
#define COLOR_BAREADDRESS QColor(255, 255, 255)
/* Transaction list -- TX status decoration - open until date */
#define COLOR_TX_STATUS_OPENUNTILDATE QColor(64, 64, 255)
#define COLOR_TX_STATUS_OPENUNTILDATE QColor(255, 255, 255)
/* Transaction list -- TX status decoration - offline */
#define COLOR_TX_STATUS_OFFLINE QColor(192, 192, 192)
#define COLOR_TX_STATUS_OFFLINE QColor(255, 255, 255)
/* Transaction list -- TX status decoration - default color */
#define COLOR_BLACK QColor(51, 51, 51)
#define COLOR_BLACK QColor(255, 255, 255)

/* Tooltips longer than this (in characters) are converted into rich text,
so that they can be word-wrapped.
Expand Down
Loading

0 comments on commit 0b656bc

Please sign in to comment.