Skip to content

Commit

Permalink
Ending POW
Browse files Browse the repository at this point in the history
End POW on block 475k
  • Loading branch information
sp00lin9 committed Mar 4, 2018
1 parent 07a5ac6 commit 2965ad6
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 10 deletions.
2 changes: 1 addition & 1 deletion EduCoin.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
TARGET = EduCoin
VERSION = 1.0.0.0
VERSION = 1.1.0.0

greaterThan(QT_MAJOR_VERSION, 5) {
INCLUDEPATH += src src/json src/qt
Expand Down
9 changes: 6 additions & 3 deletions src/chainparams.cpp
Expand Up @@ -27,9 +27,11 @@ int64_t CChainParams::GetProofOfWorkReward(int nHeight, int64_t nFees) const

if(nHeight == 1) {
nSubsidy = 25000000 * COIN;
} else {
} else if (nHeight <= nLastPOWBlock) {
nSubsidy = 5 * COIN;
}
} else {
nSubsidy = 0 * COIN;
}

if (fDebug && GetBoolArg("-printcreation"))
LogPrintf("GetProofOfWorkReward() : create=%s nSubsidy=%d\n", FormatMoney(nSubsidy).c_str(), nSubsidy);
Expand Down Expand Up @@ -144,6 +146,7 @@ class CMainParams : public CBaseChainParams {
nDefaultPort = 17389;
nRPCPort = 17388;
nFirstPosv3Block = 1;
nLastPOWBlock = 475000;
nBIP44ID = 0x80000023;
bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20); // "standard" scrypt target limit for proof of work, results with 0,000244140625 proof-of-work difficulty
bnProofOfStakeLimit = CBigNum(~uint256(0) >> 20);
Expand Down Expand Up @@ -196,7 +199,7 @@ class CTestNetParams : public CBaseChainParams {
nDefaultPort = 22525;
nRPCPort = 22521;
nBIP44ID = 0x80000001;

nLastPOWBlock = 475000;
bnProofOfWorkLimit = CBigNum(~uint256(0) >> 16);
bnProofOfStakeLimit = CBigNum(~uint256(0) >> 20);
bnProofOfStakeLimitV2 = CBigNum(~uint256(0) >> 16);
Expand Down
3 changes: 2 additions & 1 deletion src/chainparams.h
Expand Up @@ -85,7 +85,7 @@ class CChainParams
int RPCPort() const { return nRPCPort; }

int BIP44ID() const { return nBIP44ID; }

int LastPOWBlock() const { return nLastPOWBlock; }
int64_t GetProofOfWorkReward(int nHeight, int64_t nFees) const;
int64_t GetProofOfStakeReward(const CBlockIndex* pindexPrev, int64_t nCoinAge, int64_t nFees) const;

Expand All @@ -108,6 +108,7 @@ class CChainParams
std::string strDataDir;
std::vector<CDNSSeedData> vSeeds;
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
int nLastPOWBlock;
};

/**
Expand Down
4 changes: 2 additions & 2 deletions src/clientversion.h
Expand Up @@ -7,8 +7,8 @@

// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 1
#define CLIENT_VERSION_MINOR 0
#define CLIENT_VERSION_REVISION 1
#define CLIENT_VERSION_MINOR 1
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_BUILD 0

// Converts the parameter X to a string after macro replacement on X has been performed.
Expand Down
6 changes: 6 additions & 0 deletions src/main.cpp
Expand Up @@ -1425,6 +1425,9 @@ bool CBlockThin::AcceptBlockThin()

CBlockThinIndex* pindexPrev = (*mi).second;
int nHeight = pindexPrev->nHeight+1;

if (IsProofOfWork() && nHeight > Params().LastPOWBlock())
return DoS(100, error("AcceptBlockThin() : reject proof-of-work at height %d", nHeight));

// Check proof-of-work or proof-of-stake
if (nBits != GetNextTargetRequiredThin(pindexPrev, IsProofOfStake()))
Expand Down Expand Up @@ -3543,6 +3546,9 @@ bool CBlock::AcceptBlock()
if (Params().IsProtocolV2(nHeight) && nVersion < 7)
return DoS(100, error("AcceptBlock() : reject too old nVersion = %d", nVersion));

if (IsProofOfWork() && nHeight > Params().LastPOWBlock())
return DoS(100, error("AcceptBlock() : reject proof-of-work at height %d", nHeight));

// Check coinbase timestamp
if (GetBlockTime() > FutureDrift((int64_t)vtx[0].nTime))
return DoS(50, error("AcceptBlock() : coinbase timestamp is too early"));
Expand Down
3 changes: 3 additions & 0 deletions src/rpcblockchain.cpp
Expand Up @@ -70,6 +70,9 @@ double GetHeaderDifficulty(const CBlockThinIndex* blockindex)

double GetPoWMHashPS()
{
if (pindexBest->nHeight >= Params().LastPOWBlock())
return 0;

int nPoWInterval = 72;
int64_t nTargetSpacingWorkMin = 30, nTargetSpacingWork = 30;

Expand Down
9 changes: 9 additions & 0 deletions src/rpcmining.cpp
Expand Up @@ -267,6 +267,9 @@ Value getworkex(const Array& params, bool fHelp)

if (IsInitialBlockDownload())
throw JSONRPCError(-10, "EduCoin is downloading blocks...");

if (pindexBest->nHeight >= Params().LastPOWBlock())
throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks");

typedef map<uint256, pair<CBlock*, CScript> > mapNewBlock_t;
static mapNewBlock_t mapNewBlock;
Expand Down Expand Up @@ -400,6 +403,9 @@ Value getwork(const Array& params, bool fHelp)

if (IsInitialBlockDownload())
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "EduCoin is downloading blocks...");

if (pindexBest->nHeight >= Params().LastPOWBlock())
throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks");

typedef map<uint256, pair<CBlock*, CScript> > mapNewBlock_t;
static mapNewBlock_t mapNewBlock; // FIXME: thread safety
Expand Down Expand Up @@ -541,6 +547,9 @@ Value getblocktemplate(const Array& params, bool fHelp)

if (IsInitialBlockDownload())
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "EduCoin is downloading blocks...");

if (pindexBest->nHeight >= Params().LastPOWBlock())
throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks");

static CReserveKey reservekey(pwalletMain);

Expand Down
6 changes: 3 additions & 3 deletions src/version.h
Expand Up @@ -30,13 +30,13 @@ static const int DATABASE_VERSION = 70511;
// network protocol versioning
//

static const int PROTOCOL_VERSION = 80016;
static const int PROTOCOL_VERSION = 80017;

// intial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 80015;
static const int INIT_PROTO_VERSION = 80016;

// disconnect from peers older than this proto version
static const int MIN_PEER_PROTO_VERSION = 80013;
static const int MIN_PEER_PROTO_VERSION = 80016;

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

0 comments on commit 2965ad6

Please sign in to comment.