Skip to content
This repository has been archived by the owner on Mar 3, 2021. It is now read-only.

Commit

Permalink
1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Remapper committed Mar 11, 2019
1 parent e9ae061 commit 3bbcdad
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

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

//! Set to true for release, false for prerelease or test build
Expand Down
99 changes: 77 additions & 22 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ CCriticalSection cs_main;

BlockMap mapBlockIndex;
map<uint256, uint256> mapProofOfStake;
map<COutPoint, int> mapStakeSpent;
set<pair<COutPoint, unsigned int> > setStakeSeen;
map<unsigned int, unsigned int> mapHashedBlocks;
CChain chainActive;
Expand Down Expand Up @@ -2130,28 +2131,12 @@ int64_t GetBlockValue(int nHeight)
nSubsidy = 11200 * COIN;
} else if (nHeight < 525601 && nHeight > 0) {
nSubsidy = 0.05 * COIN;
} else if (nHeight <= 526001 && nHeight >= 525601) {
nSubsidy = 0.05 * COIN;
} else if (nHeight <= 1051201 && nHeight >= 526001) {
nSubsidy = 0.05 * COIN;
} else if (nHeight <= 1052001 && nHeight >= 1051201) {
nSubsidy = 0.05 * COIN;
} else if (nHeight <= 1576801 && nHeight >= 1052001) {
nSubsidy = 0.05 * COIN;
} else if (nHeight <= 1578401 && nHeight >= 1576801) {
nSubsidy = 0.05 * COIN;
} else if (nHeight <= 2102401 && nHeight >= 1578401) {
nSubsidy = 0.05 * COIN;
} else if (nHeight <= 2105601 && nHeight >= 2102401) {
nSubsidy = 0.05 * COIN;
} else if (nHeight <= 2628001 && nHeight >= 2105601) {
nSubsidy = 0.05 * COIN;
} else if (nHeight <= 2634400 && nHeight >= 2628001) {
nSubsidy = 0.05 * COIN;
} else if (nHeight >= 2634401) {
} else if (nHeight <= 610000 && nHeight >= 525601) {
nSubsidy = 0.05 * COIN;
} else if (nHeight >= 610000) { // 0.025 Block reward starts block 610000
nSubsidy = 0.025 * COIN;
} else {
nSubsidy = 0.01 * COIN;
nSubsidy = 0.025 * COIN;
}
return nSubsidy;
}
Expand All @@ -2176,7 +2161,7 @@ int64_t GetMasternodePayment(int nHeight, int64_t blockValue, int nMasternodeCou

return ret;
}

bool IsInitialBlockDownload()
{
LOCK(cs_main);
Expand All @@ -2186,7 +2171,7 @@ bool IsInitialBlockDownload()
if (lockIBDState)
return false;
bool state = (chainActive.Height() < pindexBestHeader->nHeight - 24 * 6 ||
pindexBestHeader->GetBlockTime() < GetTime() - 6 * 60 * 60); // ~144 blocks behind -> 2 x fork detection time
pindexBestHeader->GetBlockTime() < GetTime() - 6 * 60 * 60) && chainActive.Height() == 610000; // ~144 blocks behind -> 2 x fork detection ; // ~144 blocks behind -> 2 x fork detection time
if (!state)
lockIBDState = true;
return state;
Expand Down Expand Up @@ -2548,6 +2533,7 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
if (coins->vout.size() < out.n + 1)
coins->vout.resize(out.n + 1);
coins->vout[out.n] = undo.txout;
mapStakeSpent.erase(out);
}
}
}
Expand Down Expand Up @@ -3021,6 +3007,27 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
if (fTxIndex)
if (!pblocktree->WriteTxIndex(vPos))
return state.Abort("Failed to write transaction index");
// add new entries
for (const CTransaction tx: block.vtx) {
if (tx.IsCoinBase())
continue;
for (const CTxIn in: tx.vin) {
LogPrint("map", "mapStakeSpent: Insert %s | %u\n", in.prevout.ToString(), pindex->nHeight);
mapStakeSpent.insert(std::make_pair(in.prevout, pindex->nHeight));
}
}

// delete old entries
for (auto it = mapStakeSpent.begin(); it != mapStakeSpent.end();) {
if (it->second < pindex->nHeight - Params().MaxReorganizationDepth()) {
LogPrint("map", "mapStakeSpent: Erase %s | %u\n", it->first.ToString(), it->second);
it = mapStakeSpent.erase(it);
}
else {
it++;
}
}


// add this block to the view's block chain
view.SetBestBlock(pindex->GetBlockHash());
Expand Down Expand Up @@ -4187,6 +4194,54 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
}

int nHeight = pindex->nHeight;

if (block.IsProofOfStake()) {
LOCK(cs_main);

CCoinsViewCache coins(pcoinsTip);

if (!coins.HaveInputs(block.vtx[1])) {
// the inputs are spent at the chain tip so we should look at the recently spent outputs

for (CTxIn in : block.vtx[1].vin) {
auto it = mapStakeSpent.find(in.prevout);
if (it == mapStakeSpent.end()) {
return false;
}
if (it->second < pindexPrev->nHeight) {
return false;
}
}
}

// if this is on a fork
if (!chainActive.Contains(pindexPrev) && pindexPrev != NULL) {
// start at the block we're adding on to
CBlockIndex *last = pindexPrev;

// while that block is not on the main chain
while (!chainActive.Contains(last) && last != NULL) {
CBlock bl;
ReadBlockFromDisk(bl, last);
// loop through every spent input from said block
for (CTransaction t : bl.vtx) {
for (CTxIn in: t.vin) {
// loop through every spent input in the staking transaction of the new block
for (CTxIn stakeIn : block.vtx[1].vin) {
// if they spend the same input
if (stakeIn.prevout == in.prevout) {
// reject the block
return false;
}
}
}
}

// go to the parent block
last = last->pprev;
}
}
}

// Write block to history file
try {
Expand Down
6 changes: 3 additions & 3 deletions src/masternode-sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ bool CMasternodeSync::IsBlockchainSynced()

CBlockIndex* pindex = chainActive.Tip();

///if (chainActive.Height() == 306) {
///return true;
//}
if (chainActive.Height() == 610000) {
return true;
}

if (pindex == NULL) return false;

Expand Down
6 changes: 3 additions & 3 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* network protocol versioning
*/

static const int PROTOCOL_VERSION = 70020;
static const int PROTOCOL_VERSION = 70022;

//! initial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209;
Expand All @@ -21,8 +21,8 @@ static const int INIT_PROTO_VERSION = 209;
static const int GETHEADERS_VERSION = 70000;

//! disconnect from peers older than this proto version
static const int MIN_PEER_PROTO_VERSION_BEFORE_ENFORCEMENT = 70002;
static const int MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT = 70020;
static const int MIN_PEER_PROTO_VERSION_BEFORE_ENFORCEMENT = 70020;
static const int MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT = 70022;

//! nTime field added to CAddress, starting with this version;
//! if possible, avoid requesting addresses nodes older than this
Expand Down

0 comments on commit 3bbcdad

Please sign in to comment.