Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
SkaZun committed Feb 7, 2019
1 parent d799097 commit 3b3d599
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 66 deletions.
1 change: 1 addition & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class CMainParams : public CChainParams
nMinerThreads = 0;
nTargetSpacing = 2 * 60; // 2 minute
nTargetSpacingSlowLaunch = 2 * 60; // before block 100
nPoSTargetSpacing = 60; // 1 minute
nMaturity = 40;
nMasternodeCountDrift = 3;
nMaxMoneyOut = 13994245 * COIN;
Expand Down
2 changes: 2 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class CChainParams
bool RequireStandard() const { return fRequireStandard; }
int64_t TargetSpacing() const { return nTargetSpacing; }
int64_t TargetSpacingSlowLaunch() const { return nTargetSpacingSlowLaunch; }
int64_t PoSTargetSpacing() const { return nPoSTargetSpacing; }
/** Instamine Prevention, Zero reward to block **/
// int ANTI_INSTAMINE_TIME() const { return nAntiInstamineTime; }
int COINBASE_MATURITY() const { return nMaturity; }
Expand Down Expand Up @@ -132,6 +133,7 @@ class CChainParams
int nToCheckBlockUpgradeMajority;
int64_t nTargetSpacing;
int64_t nTargetSpacingSlowLaunch;
int64_t nPoSTargetSpacing;
// int nAntiInstamineTime;
int nLastPOWBlock;
int nStartMasternodePaymentsBlock;
Expand Down
3 changes: 1 addition & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5450,8 +5450,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,

int ActiveProtocol()
{
if (IsSporkActive(SPORK_8_NEW_PROTOCOL_ENFORCEMENT))
return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT;
// if (IsSporkActive(SPORK_8_NEW_PROTOCOL_ENFORCEMENT)) return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT;

return MIN_PEER_PROTO_VERSION_BEFORE_ENFORCEMENT;
}
Expand Down
18 changes: 4 additions & 14 deletions src/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,7 @@ int64_t CMasternode::GetLastPaid()
const CBlockIndex* BlockReading = pindexPrev;

int nMnCount = 0;
if (IsSporkActive(SPORK_8_NEW_PROTOCOL_ENFORCEMENT))
nMnCount = int(mnodeman.CountEnabled(Level()) * 1.25); // new
else
nMnCount = int(mnodeman.CountEnabled(Level()) / 1.25);
nMnCount = int(mnodeman.CountEnabled(Level()) * 1.25); // new

int n = 0;
for (unsigned int i = 1; BlockReading && BlockReading->nHeight > 0; i++) {
Expand All @@ -290,17 +287,10 @@ int64_t CMasternode::GetLastPaid()

if (masternodePayments.mapMasternodeBlocks.count(BlockReading->nHeight)) {
/*
Search for this payee, with at least 2 votes. This will aid in consensus allowing the network
to converge on the same payees quickly, then keep the same schedule.
Search for this payee, with at least 6 votes.
*/
if (IsSporkActive(SPORK_8_NEW_PROTOCOL_ENFORCEMENT)) { //new
if (masternodePayments.mapMasternodeBlocks[BlockReading->nHeight].HasPayeeWithVotes(mnpayee, 6)) {
return BlockReading->nTime - nOffset;
}
} else {
if (masternodePayments.mapMasternodeBlocks[BlockReading->nHeight].HasPayeeWithVotes(mnpayee, 2)) {
return BlockReading->nTime - nOffset;
}
if (masternodePayments.mapMasternodeBlocks[BlockReading->nHeight].HasPayeeWithVotes(mnpayee, 6)) {
return BlockReading->nTime - nOffset;
}
}

Expand Down
35 changes: 10 additions & 25 deletions src/masternodeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,32 +677,17 @@ CMasternode* CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight
uint256 nHigh = 0;
CMasternode* pBestMasternode = nullptr;

if (IsSporkActive(SPORK_8_NEW_PROTOCOL_ENFORCEMENT)) {
for(const auto& s : vecMasternodeLastPaid) {
CMasternode* pmn = Find(s.second);
if (!pmn)
continue;
uint256 n = pmn->CalculateScore(1, nBlockHeight - 100);
if (n > nHigh) {
nHigh = n;
pBestMasternode = pmn;
}
// LogPrintf("New Level: %d, ID: %d, LastPay: %d, Address: %s, Score: %s\n", mnlevel, nCountTenth, s.first, CBitcoinAddress(pmn->pubKeyCollateralAddress.GetID()).ToString(), n.ToString());
if(--nCountTenth <= 0) break;
}
} else {
for(const auto& s : vecMasternodeLastPaid) {
CMasternode* pmn = Find(s.second);
if (!pmn)
continue;
uint256 n = pmn->CalculateScore(1, nBlockHeight - 100);
if (n > nHigh) {
nHigh = n;
pBestMasternode = pmn;
}
// LogPrintf("Level: %d, ID: %d, LastPay: %d, Address: %s, Score: %s\n", mnlevel, nCountTenth, s.first, CBitcoinAddress(pmn->pubKeyCollateralAddress.GetID()).ToString(), n.ToString());
if(--nCountTenth > 0) break;
for(const auto& s : vecMasternodeLastPaid) {
CMasternode* pmn = Find(s.second);
if (!pmn)
continue;
uint256 n = pmn->CalculateScore(1, nBlockHeight - 100);
if (n > nHigh) {
nHigh = n;
pBestMasternode = pmn;
}
// LogPrintf("New Level: %d, ID: %d, LastPay: %d, Address: %s, Score: %s\n", mnlevel, nCountTenth, s.first, CBitcoinAddress(pmn->pubKeyCollateralAddress.GetID()).ToString(), n.ToString());
if(--nCountTenth <= 0) break;
}
// if (pBestMasternode)
// LogPrintf("Level: %d Winner: %s\n", mnlevel, CBitcoinAddress(pBestMasternode->pubKeyCollateralAddress.GetID()).ToString());
Expand Down
16 changes: 8 additions & 8 deletions src/pow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast)

if (pindexLast->nHeight >= Params().LAST_POW_BLOCK()) {
uint256 bnTargetLimit = (~uint256(0) >> 24);
int64_t nTargetSpacing = 60;
int64_t nTargetTimespan = 60 * 40;
int64_t nTargetSpacing = Params().PoSTargetSpacing(); // 60;
int64_t nTargetTimespan = Params().PoSTargetSpacing() /*60*/ * 40;

int64_t nActualSpacing = 0;
if (pindexLast->nHeight != 0)
Expand All @@ -49,14 +49,14 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast)
// ppcoin: target change every block
// ppcoin: retarget with exponential moving toward target spacing
uint256 bnNew;

if(pindexLast->nHeight >= Params().LAST_POW_BLOCK() && pindexLast->nHeight <= Params().LAST_POW_BLOCK() + 2) {
//LogPrintf("DarkGravityWave: drop difficulty in PoS start\n");
uint256 bnTargetZero = (~uint256(0) >> 4);
bnNew = bnTargetZero;
//LogPrintf("DarkGravityWave: drop difficulty in PoS start\n");
uint256 bnTargetZero = (~uint256(0) >> 4);
bnNew = bnTargetZero;
} else
bnNew.SetCompact(pindexLast->nBits);
bnNew.SetCompact(pindexLast->nBits);

int64_t nInterval = nTargetTimespan / nTargetSpacing;
bnNew *= ((nInterval - 1) * nTargetSpacing + nActualSpacing + nActualSpacing);
bnNew /= ((nInterval + 1) * nTargetSpacing);
Expand Down
13 changes: 8 additions & 5 deletions src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ double roi1, roi2, roi3, roi4;

void OverviewPage::updateMasternodeInfo()
{
int CurrentBlock = clientModel->getNumBlocks();

if (masternodeSync.IsBlockchainSynced() && masternodeSync.IsSynced())
{

Expand Down Expand Up @@ -366,13 +368,14 @@ void OverviewPage::updateMasternodeInfo()

// TODO: need a read actual 24h blockcount from chain
int BlockCount24h = block24hCount > 0 ? block24hCount : 1440;

// update ROI
double BlockReward = GetBlockValue(chainActive.Height());
double BlockReward = GetBlockValue(CurrentBlock);
(mn1==0) ? roi1 = 0 : roi1 = (0.2*BlockReward*BlockCount24h)/mn1/COIN;
(mn2==0) ? roi2 = 0 : roi2 = (0.3*BlockReward*BlockCount24h)/mn2/COIN;
(mn3==0) ? roi3 = 0 : roi3 = (0.3*BlockReward*BlockCount24h)/mn3/COIN;
(mn4==0) ? roi4 = 0 : roi4 = (0.02*BlockReward*BlockCount24h)/mn4/COIN;
if (chainActive.Height() >= 0) {
if (CurrentBlock >= 0) {
/*
ui->roi_1->setText(mn1==0 ? "-" : QString::number(((((0.4*BlockReward*1440)/mn1)*365)/3000)/1000000,'f',0).append("%"));
ui->roi_2->setText(mn2==0 ? "-" : QString::number(((((0.2*BlockReward*1440)/mn2)*365)/10000)/1000000,'f',0).append("%"));
Expand All @@ -399,7 +402,7 @@ void OverviewPage::updateMasternodeInfo()
}

// update collateral info
if (chainActive.Height() >= 0) {
if (CurrentBlock >= 0) {
ui->label_lcolat->setText("5000 ESBC");
ui->label_mcolat->setText("25000 ESBC");
ui->label_fcolat->setText("50000 ESBC");
Expand All @@ -412,9 +415,9 @@ void OverviewPage::updatBlockChainInfo()
{
if (masternodeSync.IsBlockchainSynced())
{
int CurrentBlock = (int)chainActive.Height();
int CurrentBlock = clientModel->getNumBlocks();
int64_t netHashRate = chainActive.GetNetworkHashPS(24, CurrentBlock-1);
double BlockReward = GetBlockValue(chainActive.Height());
double BlockReward = GetBlockValue(CurrentBlock);
double BlockRewardesbcoin = static_cast<double>(BlockReward/COIN);
double CurrentDiff = GetDifficulty();

Expand Down
2 changes: 1 addition & 1 deletion src/qt/peertablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ PeerTableModel::PeerTableModel(ClientModel* parent) : QAbstractTableModel(parent
// set up timer for auto refresh
timer = new QTimer();
connect(timer, SIGNAL(timeout()), SLOT(refresh()));
timer->setInterval(MODEL_UPDATE_DELAY);
timer->setInterval(MODEL_UPDATE_DELAY*4);

// load initial data
refresh();
Expand Down
8 changes: 5 additions & 3 deletions src/qt/transactionrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ void TransactionRecord::updateStatus(const CWalletTx& wtx)
if (mi != mapBlockIndex.end())
pindex = (*mi).second;

int CurrentBlock = (int)chainActive.Height();

// Sort order, unrecorded transactions sort to the top
status.sortKey = strprintf("%010d-%01d-%010u-%03d",
(pindex ? pindex->nHeight : std::numeric_limits<int>::max()),
Expand All @@ -241,13 +243,13 @@ void TransactionRecord::updateStatus(const CWalletTx& wtx)
idx);
status.countsForBalance = wtx.IsTrusted() && !(wtx.GetBlocksToMaturity() > 0);
status.depth = wtx.GetDepthInMainChain();
status.cur_num_blocks = chainActive.Height();
status.cur_num_blocks = CurrentBlock;
status.cur_num_ix_locks = nCompleteTXLocks;

if (!IsFinalTx(wtx, chainActive.Height() + 1)) {
if (!IsFinalTx(wtx, CurrentBlock + 1)) {
if (wtx.nLockTime < LOCKTIME_THRESHOLD) {
status.status = TransactionStatus::OpenUntilBlock;
status.open_for = wtx.nLockTime - chainActive.Height();
status.open_for = wtx.nLockTime - CurrentBlock;
} else {
status.status = TransactionStatus::OpenUntilDate;
status.open_for = wtx.nLockTime;
Expand Down
14 changes: 7 additions & 7 deletions src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,17 @@ void WalletModel::pollBalanceChanged()
// periodical polls if the core is holding the locks for a longer time -
// for example, during a wallet rescan.
TRY_LOCK(cs_main, lockMain);
if (!lockMain)
return;
TRY_LOCK(wallet->cs_wallet, lockWallet);
if (!lockWallet)
return;
if (!lockMain) return;

int CurrentBlock = (int)chainActive.Height();

if (fForceCheckBalanceChanged || chainActive.Height() != cachedNumBlocks || nObfuscationRounds != cachedObfuscationRounds || cachedTxLocks != nCompleteTXLocks) {
if (fForceCheckBalanceChanged || CurrentBlock != cachedNumBlocks || nObfuscationRounds != cachedObfuscationRounds || cachedTxLocks != nCompleteTXLocks) {
fForceCheckBalanceChanged = false;

TRY_LOCK(wallet->cs_wallet, lockWallet);
if (!lockWallet) return;
// Balance and number of transactions might have changed
cachedNumBlocks = chainActive.Height();
cachedNumBlocks = CurrentBlock;
cachedObfuscationRounds = nObfuscationRounds;

// checkBalanceChanged();
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static const int PROTOCOL_VERSION = 70222;
static const int INIT_PROTO_VERSION = 209;

//! disconnect from peers older than this proto version
static const int MIN_PEER_PROTO_VERSION_BEFORE_ENFORCEMENT = 70220;
static const int MIN_PEER_PROTO_VERSION_BEFORE_ENFORCEMENT = 70222;
static const int MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT = 70222;

//! nTime field added to CAddress, starting with this version;
Expand Down

0 comments on commit 3b3d599

Please sign in to comment.