Skip to content

Commit

Permalink
fixing pow-pos gap
Browse files Browse the repository at this point in the history
  • Loading branch information
multipos committed Sep 30, 2017
1 parent 95a89cc commit 6c72cc4
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 24 deletions.
6 changes: 3 additions & 3 deletions contrib/macdeploy/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleGetInfoString</key>
<string>PoS-N 1.0.0.2</string>
<string>PoS-N 1.1.0.1</string>
<key>CFBundleExecutable</key>
<string>PoSN-Qt</string>
<key>CFBundleIdentifier</key>
<string>us.posncoin.posncoin-qt</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0.2</string>
<string>1.1.0.1</string>
<key>CFBundleSignature</key>
<string>P0SN</string>
<key>CFBundleVersion</key>
<string>1.0.0.2</string>
<string>1.1.0.1</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion posn.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ win32 {

TEMPLATE = app
TARGET = "PoSN-Qt"
VERSION = 1.0.0.2
VERSION = 1.1.0.1
INCLUDEPATH += src src/json src/qt src/tor
INCLUDEPATH += src/tor/adapter src/tor/common src/tor/ext
INCLUDEPATH += src/tor/ext/curve25519_donna src/tor/ext/ed25519/donna
Expand Down
4 changes: 2 additions & 2 deletions src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

// 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_MINOR 1
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_BUILD 2
#define CLIENT_VERSION_BUILD 1

// Converts the parameter X to a string after macro replacement on X has been performed.
// Don't merge these into one macro!
Expand Down
21 changes: 17 additions & 4 deletions src/globalparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
///
//////////////////////////////////////////////////////////////////////

// Monday, October 2, 2017 4:00:00 AM GMT
static const int64_t POS_START_TIME = 1506916800;


//////////////////////////////////////////////////////////////////////
///
Expand Down Expand Up @@ -60,8 +63,10 @@ static const int LAST_FAIR_LAUNCH_BLOCK_TESTNET = 30; // 6 min
#if PROOF_MODEL == PURE_POS
// must have a last PoW block if it is to be pure PoS
// optional overlap between PoW and PoS
int LAST_POW_BLOCK = 101100; // 300 + 14 * 5 * 24 * 60 = 14 day
int FIRST_POS_BLOCK = 101101; // LAST_POW_BLOCK + 1
int LAST_POW_BLOCK_ORIG = 101100; // 300 + 14 * 5 * 24 * 60 = 14 day
int FIRST_POS_BLOCK_ORIG = 101101; // LAST_POW_BLOCK_ORIG + 1
int LAST_POW_BLOCK = 94478; // ALL MINING DEPLETED
int FIRST_POS_BLOCK = 94479; // LAST_POW_BLOCK + 1
static const int LAST_POW_BLOCK_TESTNET = 101100;
static const int FIRST_POS_BLOCK_TESTNET = 81;
#elif PROOF_MODEL == MIXED_POW_POS
Expand Down Expand Up @@ -696,13 +701,21 @@ int64_t GetMaxPoWSubsidy(int nColor, const int64_t nReward)
return nReward;
}

int GetLastPoWBlock()
int GetLastPoWBlock(int64_t nTime)
{
if (nTime < POS_START_TIME)
{
return fTestNet ? LAST_POW_BLOCK_TESTNET : LAST_POW_BLOCK_ORIG;
}
return fTestNet ? LAST_POW_BLOCK_TESTNET : LAST_POW_BLOCK;
}

int GetFirstPoSBlock()
int GetFirstPoSBlock(int64_t nTime)
{
if (nTime < POS_START_TIME)
{
return fTestNet ? FIRST_POS_BLOCK_TESTNET : FIRST_POS_BLOCK_ORIG;
}
return fTestNet ? FIRST_POS_BLOCK_TESTNET : FIRST_POS_BLOCK;
}

4 changes: 2 additions & 2 deletions src/globalparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ void FillNets(const std::map<int, int64_t> &mapDebit,
int64_t GetTargetSpacing(int nHeight, bool fProofOfStake);
int GetLastFairLaunchBlock();
#if PROOF_MODEL == PURE_POS
int GetLastPoWBlock();
int GetFirstPoSBlock();
int GetLastPoWBlock(int64_t nTime);
int GetFirstPoSBlock(int64_t nTime);
#endif

int64_t GetMaxPoWMint(int nColor);
Expand Down
5 changes: 4 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,10 @@ bool AppInit2()
#endif

// ensure that there is not a gap where no blocks can be signed
assert ((GetFirstPoSBlock() - 1) <= GetLastPoWBlock());
int64_t inittime = GetAdjustedTime();
int nLastPoWBlock = GetLastPoWBlock(inittime);
int nFirstPoSBlock = GetFirstPoSBlock(inittime);
assert ((nFirstPoSBlock - 1) <= nLastPoWBlock);

// basic multicurrency checks and setup
{
Expand Down
7 changes: 4 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ struct AMOUNT GetPoWSubsidy(const CBlockIndex *pindexPrev, int nColor)
static const int64_t STANDARD_REWARD = 9375 * BASE_COIN; // 9375

static const int nLastFairLaunchBlock = GetLastFairLaunchBlock();
static const int nLastPoWBlock = GetLastPoWBlock();
int nLastPoWBlock = GetLastPoWBlock(GetAdjustedTime());

struct AMOUNT stSubsidy;
stSubsidy.nValue = 0;
Expand Down Expand Up @@ -3335,8 +3335,9 @@ bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig) c

bool CBlock::AcceptBlock()
{
static const int nLastPoWBlock = GetLastPoWBlock();
static const int nFirstPoSBlock = GetFirstPoSBlock();
int accepttime = GetAdjustedTime();
int nLastPoWBlock = GetLastPoWBlock(accepttime);
int nFirstPoSBlock = GetFirstPoSBlock(accepttime);

AssertLockHeld(cs_main);
// Check for duplicate
Expand Down
3 changes: 1 addition & 2 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,8 +811,7 @@ void StakeMiner(CWallet *pwallet)
RenameThread("posncoin-miner");

#if PROOF_MODEL == PURE_POS
//
static const int nFirstPoSBlock = GetFirstPoSBlock();
int nFirstPoSBlock = GetFirstPoSBlock(GetAdjustedTime());
int nTargetSpacing = GetTargetSpacing(pindexBest->nHeight +1, true);
unsigned int nMilliWaitForPoS = nTargetSpacing * 1000 / 2;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/rpcblockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ double GetDifficulty(const CBlockIndex* blockindex)
double GetPoWMHashPS()
{
#if PROOF_MODEL == PURE_POS
static const int nLastPoWBlock = GetLastPoWBlock();
int nLastPoWBlock = GetLastPoWBlock(GetAdjustedTime());
if (pindexBest->nHeight >= nLastPoWBlock)
return 0;
#endif
Expand Down
8 changes: 4 additions & 4 deletions src/rpcmining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Value getsubsidy(const Array& params, bool fHelp)
int nSubsidyColor = PSN_COLOR_P02;

#if PROOF_MODEL == PURE_POS
static const int nLastPoWBlock = GetLastPoWBlock();
int nLastPoWBlock = GetLastPoWBlock(GetAdjustedTime());
#endif

if (params.size() == 0) {
Expand Down Expand Up @@ -263,7 +263,7 @@ Value getworkex(const Array& params, bool fHelp)
throw JSONRPCError(-10, "posncoin is downloading blocks...");

#if PROOF_MODEL == PURE_POS
static const int nLastPoWBlock = GetLastPoWBlock();
int nLastPoWBlock = GetLastPoWBlock(GetAdjustedTime());
if (pindexBest->nHeight >= nLastPoWBlock)
throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks");
#endif
Expand Down Expand Up @@ -400,7 +400,7 @@ Value getwork(const Array& params, bool fHelp)
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "posncoin is downloading blocks...");

#if PROOF_MODEL == PURE_POS
static const int nLastPoWBlock = GetLastPoWBlock();
int nLastPoWBlock = GetLastPoWBlock(GetAdjustedTime());
if (pindexBest->nHeight >= nLastPoWBlock)
throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks");
#endif
Expand Down Expand Up @@ -549,7 +549,7 @@ Value getblocktemplate(const Array& params, bool fHelp)
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "posncoin is downloading blocks...");

#if PROOF_MODEL == PURE_POS
static const int nLastPoWBlock = GetLastPoWBlock();
int nLastPoWBlock = GetLastPoWBlock(GetAdjustedTime());
if (pindexBest->nHeight >= nLastPoWBlock)
throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks");
#endif
Expand Down
3 changes: 2 additions & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ static const int DATABASE_VERSION = 70508;

// 61017: original release version (v1.0.0.1)
// fix staking loop (v1.0.0.2)
static const int PROTOCOL_VERSION = 61017;
// 61018: fix pow-pos gap (v1.1.0.1)
static const int PROTOCOL_VERSION = 61018;

// earlier versions not supported as of Feb 2012, and are disconnected
static const int MIN_PROTO_VERSION = 209;
Expand Down

0 comments on commit 6c72cc4

Please sign in to comment.