LastTip() and tweak deprecation heights
This commit is contained in:
@@ -11,6 +11,7 @@ using namespace std;
|
||||
* CChain implementation
|
||||
*/
|
||||
void CChain::SetTip(CBlockIndex *pindex) {
|
||||
lastTip = pindex;
|
||||
if (pindex == NULL) {
|
||||
vChain.clear();
|
||||
return;
|
||||
|
||||
@@ -416,6 +416,7 @@ public:
|
||||
class CChain {
|
||||
private:
|
||||
std::vector<CBlockIndex*> vChain;
|
||||
CBlockIndex *lastTip;
|
||||
|
||||
public:
|
||||
/** Returns the index entry for the genesis block of this chain, or NULL if none. */
|
||||
@@ -427,6 +428,11 @@ public:
|
||||
CBlockIndex *Tip() const {
|
||||
return vChain.size() > 0 ? vChain[vChain.size() - 1] : NULL;
|
||||
}
|
||||
|
||||
/** Returns the last tip of the chain, or NULL if none. */
|
||||
CBlockIndex *LastTip() const {
|
||||
return vChain.size() > 0 ? lastTip : NULL;
|
||||
}
|
||||
|
||||
/** Returns the index entry at a particular height in this chain, or NULL if no such height exists. */
|
||||
CBlockIndex *operator[](int nHeight) const {
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
|
||||
// Deprecation policy:
|
||||
// * Shut down WEEKS_UNTIL_DEPRECATION weeks' worth of blocks after the estimated release block height.
|
||||
// * A warning is shown during the WEEKS_UNTIL_DEPRECATION worth of blocks prior to shut down.
|
||||
//static const int APPROX_RELEASE_HEIGHT = 800000;
|
||||
//static const int WEEKS_UNTIL_DEPRECATION = 52;
|
||||
static const int DEPRECATION_HEIGHT = 1400000; //APPROX_RELEASE_HEIGHT + (WEEKS_UNTIL_DEPRECATION * 7 * 24 * 60);
|
||||
// * A warning is shown during the DEPRECATION_WARN_LIMIT worth of blocks prior to shut down.
|
||||
static const int WEEKS_UNTIL_DEPRECATION = 52;
|
||||
static const int DEPRECATION_HEIGHT = 1400000;
|
||||
static const int APPROX_RELEASE_HEIGHT = DEPRECATION_HEIGHT - (WEEKS_UNTIL_DEPRECATION * 7 * 24 * 60);
|
||||
|
||||
// Number of blocks before deprecation to warn users
|
||||
static const int WEEKS_UNTIL_DEPRECATION = 60 * 24 * 60; // 2 months
|
||||
static const int DEPRECATION_WARN_LIMIT = 60 * 24 * 60; // 2 months
|
||||
|
||||
/**
|
||||
* Checks whether the node is deprecated based on the current block height, and
|
||||
|
||||
@@ -823,7 +823,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
komodo_event_rewind(sp,symbol,pindex->nHeight);
|
||||
komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0,zero,0);
|
||||
}
|
||||
komodo_currentheight_set(chainActive.Tip()->nHeight);
|
||||
komodo_currentheight_set(chainActive.LastTip()->nHeight);
|
||||
if ( pindex != 0 )
|
||||
{
|
||||
height = pindex->nHeight;
|
||||
@@ -907,7 +907,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
#else
|
||||
memcpy(scriptbuf,(uint8_t *)&block.vtx[i].vout[j].scriptPubKey[0],len);
|
||||
#endif
|
||||
notaryid = komodo_voutupdate(&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.Tip()->GetBlockTime());
|
||||
notaryid = komodo_voutupdate(&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime());
|
||||
if ( 0 && i > 0 )
|
||||
{
|
||||
for (k=0; k<len; k++)
|
||||
|
||||
@@ -751,8 +751,8 @@ int32_t komodo_blockload(CBlock& block,CBlockIndex *pindex)
|
||||
|
||||
uint32_t komodo_chainactive_timestamp()
|
||||
{
|
||||
if ( chainActive.Tip() != 0 )
|
||||
return((uint32_t)chainActive.Tip()->GetBlockTime());
|
||||
if ( chainActive.LastTip() != 0 )
|
||||
return((uint32_t)chainActive.LastTip()->GetBlockTime());
|
||||
else return(0);
|
||||
}
|
||||
|
||||
@@ -760,11 +760,11 @@ CBlockIndex *komodo_chainactive(int32_t height)
|
||||
{
|
||||
if ( chainActive.Tip() != 0 )
|
||||
{
|
||||
if ( height <= chainActive.Tip()->nHeight )
|
||||
if ( height <= chainActive.LastTip()->nHeight )
|
||||
return(chainActive[height]);
|
||||
// else fprintf(stderr,"komodo_chainactive height %d > active.%d\n",height,chainActive.Tip()->nHeight);
|
||||
// else fprintf(stderr,"komodo_chainactive height %d > active.%d\n",height,chainActive.LastTip()->nHeight);
|
||||
}
|
||||
//fprintf(stderr,"komodo_chainactive null chainActive.Tip() height %d\n",height);
|
||||
//fprintf(stderr,"komodo_chainactive null chainActive.LastTip() height %d\n",height);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -994,7 +994,7 @@ int32_t komodo_MoM(int32_t *notarized_heightp,uint256 *MoMp,uint256 *kmdtxidp,in
|
||||
int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 hash)
|
||||
{
|
||||
int32_t notarized_height,MoMdepth; uint256 MoM,notarized_hash,notarized_desttxid; CBlockIndex *notary,*pindex;
|
||||
if ( (pindex= chainActive.Tip()) == 0 )
|
||||
if ( (pindex= chainActive.LastTip()) == 0 )
|
||||
return(-1);
|
||||
notarized_height = komodo_notarizeddata(pindex->nHeight,¬arized_hash,¬arized_desttxid);
|
||||
*notarized_heightp = notarized_height;
|
||||
@@ -1036,7 +1036,7 @@ uint32_t komodo_interest_args(uint32_t *txheighttimep,int32_t *txheightp,uint32_
|
||||
*valuep = tx.vout[n].nValue;
|
||||
*txheightp = pindex->nHeight;
|
||||
*txheighttimep = pindex->nTime;
|
||||
if ( *tiptimep == 0 && (tipindex= chainActive.Tip()) != 0 )
|
||||
if ( *tiptimep == 0 && (tipindex= chainActive.LastTip()) != 0 )
|
||||
*tiptimep = (uint32_t)tipindex->nTime;
|
||||
locktime = tx.nLockTime;
|
||||
//fprintf(stderr,"tx locktime.%u %.8f height.%d | tiptime.%u\n",locktime,(double)*valuep/COIN,*txheightp,*tiptimep);
|
||||
@@ -1069,7 +1069,7 @@ int32_t komodo_isrealtime(int32_t *kmdheightp)
|
||||
if ( (sp= komodo_stateptrget((char *)"KMD")) != 0 )
|
||||
*kmdheightp = sp->CURRENT_HEIGHT;
|
||||
else *kmdheightp = 0;
|
||||
if ( (pindex= chainActive.Tip()) != 0 && pindex->nHeight >= (int32_t)komodo_longestchain() )
|
||||
if ( (pindex= chainActive.LastTip()) != 0 && pindex->nHeight >= (int32_t)komodo_longestchain() )
|
||||
return(1);
|
||||
else return(0);
|
||||
}
|
||||
|
||||
@@ -1490,7 +1490,7 @@ void komodo_passport_iteration()
|
||||
komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"realtime");
|
||||
if ( (fp= fopen(fname,"wb")) != 0 )
|
||||
{
|
||||
buf[0] = (uint32_t)chainActive.Tip()->nHeight;
|
||||
buf[0] = (uint32_t)chainActive.LastTip()->nHeight;
|
||||
buf[1] = (uint32_t)komodo_longestchain();
|
||||
if ( buf[0] != 0 && buf[0] == buf[1] )
|
||||
{
|
||||
|
||||
@@ -648,7 +648,7 @@ void jumblr_iteration()
|
||||
free(retstr);
|
||||
}
|
||||
}
|
||||
height = (int32_t)chainActive.Tip()->nHeight;
|
||||
height = (int32_t)chainActive.LastTip()->nHeight;
|
||||
if ( time(NULL) < lasttime+40 )
|
||||
return;
|
||||
lasttime = (uint32_t)time(NULL);
|
||||
|
||||
@@ -637,13 +637,13 @@ uint64_t komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint
|
||||
uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume)
|
||||
{
|
||||
int32_t i,nonz=0; int64_t diff; uint64_t price,seed,sum = 0;
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.Tip() != 0 && height > chainActive.Tip()->nHeight )
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.LastTip() != 0 && height > chainActive.LastTip()->nHeight )
|
||||
{
|
||||
if ( height < 100000000 )
|
||||
{
|
||||
static uint32_t counter;
|
||||
if ( counter++ < 3 )
|
||||
printf("komodo_paxprice height.%d vs tip.%d\n",height,chainActive.Tip()->nHeight);
|
||||
printf("komodo_paxprice height.%d vs tip.%d\n",height,chainActive.LastTip()->nHeight);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
44
src/main.cpp
44
src/main.cpp
@@ -1269,7 +1269,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
||||
}
|
||||
|
||||
auto verifier = libzcash::ProofVerifier::Strict();
|
||||
if ( komodo_validate_interest(tx,chainActive.Tip()->nHeight+1,chainActive.Tip()->GetMedianTimePast() + 777,0) < 0 )
|
||||
if ( komodo_validate_interest(tx,chainActive.LastTip()->nHeight+1,chainActive.LastTip()->GetMedianTimePast() + 777,0) < 0 )
|
||||
{
|
||||
//fprintf(stderr,"AcceptToMemoryPool komodo_validate_interest failure\n");
|
||||
return error("AcceptToMemoryPool: komodo_validate_interest failed");
|
||||
@@ -1399,7 +1399,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
||||
// Bring the best block into scope
|
||||
view.GetBestBlock();
|
||||
|
||||
nValueIn = view.GetValueIn(chainActive.Tip()->nHeight,&interest,tx,chainActive.Tip()->nTime);
|
||||
nValueIn = view.GetValueIn(chainActive.LastTip()->nHeight,&interest,tx,chainActive.LastTip()->nTime);
|
||||
if ( 0 && interest != 0 )
|
||||
fprintf(stderr,"add interest %.8f\n",(double)interest/COIN);
|
||||
// we have all inputs cached now, so switch back to dummy, so we don't need to keep lock on mempool
|
||||
@@ -1891,7 +1891,7 @@ void CheckForkWarningConditions()
|
||||
if (pindexBestForkTip && chainActive.Height() - pindexBestForkTip->nHeight >= 288)
|
||||
pindexBestForkTip = NULL;
|
||||
|
||||
if (pindexBestForkTip || (pindexBestInvalid && pindexBestInvalid->nChainWork > chainActive.Tip()->nChainWork + (GetBlockProof(*chainActive.Tip()) * 6)))
|
||||
if (pindexBestForkTip || (pindexBestInvalid && pindexBestInvalid->nChainWork > chainActive.LastTip()->nChainWork + (GetBlockProof(*chainActive.LastTip()) * 6)))
|
||||
{
|
||||
if (!fLargeWorkForkFound && pindexBestForkBase)
|
||||
{
|
||||
@@ -1926,7 +1926,7 @@ void CheckForkWarningConditionsOnNewFork(CBlockIndex* pindexNewForkTip)
|
||||
AssertLockHeld(cs_main);
|
||||
// If we are on a fork that is sufficiently large, set a warning flag
|
||||
CBlockIndex* pfork = pindexNewForkTip;
|
||||
CBlockIndex* plonger = chainActive.Tip();
|
||||
CBlockIndex* plonger = chainActive.LastTip();
|
||||
while (pfork && pfork != plonger)
|
||||
{
|
||||
while (plonger && plonger->nHeight > pfork->nHeight)
|
||||
@@ -1983,7 +1983,7 @@ void static InvalidChainFound(CBlockIndex* pindexNew)
|
||||
pindexNew->GetBlockHash().ToString(), pindexNew->nHeight,
|
||||
log(pindexNew->nChainWork.getdouble())/log(2.0), DateTimeStrFormat("%Y-%m-%d %H:%M:%S",
|
||||
pindexNew->GetBlockTime()));
|
||||
CBlockIndex *tip = chainActive.Tip();
|
||||
CBlockIndex *tip = chainActive.LastTip();
|
||||
assert (tip);
|
||||
LogPrintf("%s: current best=%s height=%d log2_work=%.8g date=%s\n", __func__,
|
||||
tip->GetBlockHash().ToString(), chainActive.Height(), log(tip->nChainWork.getdouble())/log(2.0),
|
||||
@@ -2111,14 +2111,14 @@ namespace Consensus {
|
||||
// Check for negative or overflow input values
|
||||
nValueIn += coins->vout[prevout.n].nValue;
|
||||
#ifdef KOMODO_ENABLE_INTEREST
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && nSpendHeight > 60000 )//chainActive.Tip() != 0 && chainActive.Tip()->nHeight >= 60000 )
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && nSpendHeight > 60000 )//chainActive.LastTip() != 0 && chainActive.LastTip()->nHeight >= 60000 )
|
||||
{
|
||||
if ( coins->vout[prevout.n].nValue >= 10*COIN )
|
||||
{
|
||||
int64_t interest; int32_t txheight; uint32_t locktime;
|
||||
if ( (interest= komodo_accrued_interest(&txheight,&locktime,prevout.hash,prevout.n,0,coins->vout[prevout.n].nValue,(int32_t)nSpendHeight-1)) != 0 )
|
||||
{
|
||||
//fprintf(stderr,"checkResult %.8f += val %.8f interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueIn/COIN,(double)coins->vout[prevout.n].nValue/COIN,(double)interest/COIN,txheight,locktime,chainActive.Tip()->nTime);
|
||||
//fprintf(stderr,"checkResult %.8f += val %.8f interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueIn/COIN,(double)coins->vout[prevout.n].nValue/COIN,(double)interest/COIN,txheight,locktime,chainActive.LastTip()->nTime);
|
||||
nValueIn += interest;
|
||||
}
|
||||
}
|
||||
@@ -2868,7 +2868,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||
|
||||
if (!tx.IsCoinBase())
|
||||
{
|
||||
nFees += view.GetValueIn(chainActive.Tip()->nHeight,&interest,tx,chainActive.Tip()->nTime) - tx.GetValueOut();
|
||||
nFees += view.GetValueIn(chainActive.LastTip()->nHeight,&interest,tx,chainActive.LastTip()->nTime) - tx.GetValueOut();
|
||||
sum += interest;
|
||||
|
||||
std::vector<CScriptCheck> vChecks;
|
||||
@@ -3197,16 +3197,16 @@ void static UpdateTip(CBlockIndex *pindexNew) {
|
||||
KOMODO_NEWBLOCKS++;
|
||||
double progress;
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 ) {
|
||||
progress = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.Tip());
|
||||
progress = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.LastTip());
|
||||
} else {
|
||||
int32_t longestchain = komodo_longestchain();
|
||||
progress = (longestchain > 0 ) ? (double) chainActive.Height() / longestchain : 1.0;
|
||||
}
|
||||
|
||||
LogPrintf("%s: new best=%s height=%d log2_work=%.8g tx=%lu date=%s progress=%f cache=%.1fMiB(%utx)\n", __func__,
|
||||
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(),
|
||||
log(chainActive.Tip()->nChainWork.getdouble())/log(2.0), (unsigned long)chainActive.Tip()->nChainTx,
|
||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()), progress,
|
||||
chainActive.LastTip()->GetBlockHash().ToString(), chainActive.Height(),
|
||||
log(chainActive.Tip()->nChainWork.getdouble())/log(2.0), (unsigned long)chainActive.LastTip()->nChainTx,
|
||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.LastTip()->GetBlockTime()), progress,
|
||||
pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize());
|
||||
|
||||
cvBlockChange.notify_all();
|
||||
@@ -3455,7 +3455,7 @@ static void PruneBlockIndexCandidates() {
|
||||
// Note that we can't delete the current block itself, as we may need to return to it later in case a
|
||||
// reorganization to a better block fails.
|
||||
std::set<CBlockIndex*, CBlockIndexWorkComparator>::iterator it = setBlockIndexCandidates.begin();
|
||||
while (it != setBlockIndexCandidates.end() && setBlockIndexCandidates.value_comp()(*it, chainActive.Tip())) {
|
||||
while (it != setBlockIndexCandidates.end() && setBlockIndexCandidates.value_comp()(*it, chainActive.LastTip())) {
|
||||
setBlockIndexCandidates.erase(it++);
|
||||
}
|
||||
// Either the current tip or a successor of it we're working towards is left in setBlockIndexCandidates.
|
||||
@@ -3507,8 +3507,8 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
|
||||
if ( KOMODO_REWIND != 0 )
|
||||
{
|
||||
CBlockIndex *tipindex;
|
||||
fprintf(stderr,">>>>>>>>>>> rewind start ht.%d -> KOMODO_REWIND.%d\n",chainActive.Tip()->nHeight,KOMODO_REWIND);
|
||||
while ( KOMODO_REWIND > 0 && (tipindex= chainActive.Tip()) != 0 && tipindex->nHeight > KOMODO_REWIND )
|
||||
fprintf(stderr,">>>>>>>>>>> rewind start ht.%d -> KOMODO_REWIND.%d\n",chainActive.LastTip()->nHeight,KOMODO_REWIND);
|
||||
while ( KOMODO_REWIND > 0 && (tipindex= chainActive.LastTip()) != 0 && tipindex->nHeight > KOMODO_REWIND )
|
||||
{
|
||||
fBlocksDisconnected = true;
|
||||
fprintf(stderr,"%d ",(int32_t)tipindex->nHeight);
|
||||
@@ -3922,9 +3922,9 @@ bool CheckBlockHeader(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,
|
||||
for (i=31; i>=0; i--)
|
||||
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
|
||||
fprintf(stderr," <- CheckBlockHeader\n");
|
||||
if ( chainActive.Tip() != 0 )
|
||||
if ( chainActive.LastTip() != 0 )
|
||||
{
|
||||
hash = chainActive.Tip()->GetBlockHash();
|
||||
hash = chainActive.LastTip()->GetBlockHash();
|
||||
for (i=31; i>=0; i--)
|
||||
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
|
||||
fprintf(stderr," <- chainTip\n");
|
||||
@@ -4103,7 +4103,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
|
||||
// Don't accept any forks from the main chain prior to last checkpoint
|
||||
CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(chainParams.Checkpoints());
|
||||
int32_t notarized_height;
|
||||
if ( nHeight == 1 && chainActive.Tip() != 0 && chainActive.Tip()->nHeight > 1 )
|
||||
if ( nHeight == 1 && chainActive.LastTip() != 0 && chainActive.LastTip()->nHeight > 1 )
|
||||
{
|
||||
CBlockIndex *heightblock = chainActive[nHeight];
|
||||
if ( heightblock != 0 && heightblock->GetBlockHash() == hash )
|
||||
@@ -4440,8 +4440,8 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo
|
||||
auto verifier = libzcash::ProofVerifier::Disabled();
|
||||
hash = pblock->GetHash();
|
||||
|
||||
if ( chainActive.Tip() != 0 )
|
||||
komodo_currentheight_set(chainActive.Tip()->nHeight);
|
||||
if ( chainActive.LastTip() != 0 )
|
||||
komodo_currentheight_set(chainActive.LastTip()->nHeight);
|
||||
checked = CheckBlock(&futureblock,height!=0?height:komodo_block2height(pblock),0,*pblock, state, verifier,0);
|
||||
{
|
||||
LOCK(cs_main);
|
||||
@@ -4871,8 +4871,8 @@ bool static LoadBlockIndexDB()
|
||||
}
|
||||
|
||||
LogPrintf("%s: hashBestChain=%s height=%d date=%s progress=%f\n", __func__,
|
||||
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(),
|
||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
|
||||
chainActive.LastTip()->GetBlockHash().ToString(), chainActive.Height(),
|
||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.LastTip()->GetBlockTime()),
|
||||
progress);
|
||||
|
||||
EnforceNodeDeprecation(chainActive.Height(), true);
|
||||
|
||||
@@ -211,7 +211,7 @@ int printStats(bool mining)
|
||||
{
|
||||
LOCK2(cs_main, cs_vNodes);
|
||||
height = chainActive.Height();
|
||||
tipmediantime = chainActive.Tip()->GetMedianTimePast();
|
||||
tipmediantime = chainActive.LastTip()->GetMedianTimePast();
|
||||
connections = vNodes.size();
|
||||
netsolps = GetNetworkHashPS(120, -1);
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount)
|
||||
|
||||
{
|
||||
LOCK2(cs_main, mempool.cs);
|
||||
CBlockIndex* pindexPrev = chainActive.Tip();
|
||||
CBlockIndex* pindexPrev = chainActive.LastTip();
|
||||
const int nHeight = pindexPrev->nHeight + 1;
|
||||
uint32_t consensusBranchId = CurrentEpochBranchId(nHeight, chainparams.GetConsensus());
|
||||
pblock->nTime = GetAdjustedTime();
|
||||
@@ -334,7 +334,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount)
|
||||
//fprintf(stderr,"dont have inputs\n");
|
||||
continue;
|
||||
}
|
||||
CAmount nTxFees = view.GetValueIn(chainActive.Tip()->nHeight,&interest,tx,chainActive.Tip()->nTime)-tx.GetValueOut();
|
||||
CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->nHeight,&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut();
|
||||
|
||||
nTxSigOps += GetP2SHSigOpCount(tx, view);
|
||||
if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1)
|
||||
@@ -400,14 +400,14 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount)
|
||||
if ( (siglen= komodo_staked(txStaked,pblock->nBits,&blocktime,&txtime,&utxotxid,&utxovout,&utxovalue,utxosig)) > 0 )
|
||||
{
|
||||
CAmount txfees = 0;
|
||||
//if ( (int32_t)chainActive.Tip()->nHeight+1 > 100 && GetAdjustedTime() < blocktime-157 )
|
||||
//if ( (int32_t)chainActive.LastTip()->nHeight+1 > 100 && GetAdjustedTime() < blocktime-157 )
|
||||
// return(0);
|
||||
pblock->vtx.push_back(txStaked);
|
||||
pblocktemplate->vTxFees.push_back(txfees);
|
||||
pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStaked));
|
||||
nFees += txfees;
|
||||
pblock->nTime = blocktime;
|
||||
//printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.Tip()->nHeight+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13)));
|
||||
//printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.LastTip()->nHeight+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13)));
|
||||
} else return(0); //fprintf(stderr,"no utxos eligible for staking\n");
|
||||
}
|
||||
|
||||
@@ -640,19 +640,19 @@ static bool ProcessBlockFound(CBlock* pblock)
|
||||
#endif // ENABLE_WALLET
|
||||
{
|
||||
LogPrintf("%s\n", pblock->ToString());
|
||||
LogPrintf("generated %s height.%d\n", FormatMoney(pblock->vtx[0].vout[0].nValue),chainActive.Tip()->nHeight+1);
|
||||
LogPrintf("generated %s height.%d\n", FormatMoney(pblock->vtx[0].vout[0].nValue),chainActive.LastTip()->nHeight+1);
|
||||
|
||||
// Found a solution
|
||||
{
|
||||
LOCK(cs_main);
|
||||
if (pblock->hashPrevBlock != chainActive.Tip()->GetBlockHash())
|
||||
if (pblock->hashPrevBlock != chainActive.LastTip()->GetBlockHash())
|
||||
{
|
||||
uint256 hash; int32_t i;
|
||||
hash = pblock->hashPrevBlock;
|
||||
for (i=31; i>=0; i--)
|
||||
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
|
||||
fprintf(stderr," <- prev (stale)\n");
|
||||
hash = chainActive.Tip()->GetBlockHash();
|
||||
hash = chainActive.LastTip()->GetBlockHash();
|
||||
for (i=31; i>=0; i--)
|
||||
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
|
||||
fprintf(stderr," <- chainTip (stale)\n");
|
||||
@@ -680,7 +680,7 @@ static bool ProcessBlockFound(CBlock* pblock)
|
||||
|
||||
// Process this block the same as if we had received it from another node
|
||||
CValidationState state;
|
||||
if (!ProcessNewBlock(1,chainActive.Tip()->nHeight+1,state, NULL, pblock, true, NULL))
|
||||
if (!ProcessNewBlock(1,chainActive.LastTip()->nHeight+1,state, NULL, pblock, true, NULL))
|
||||
return error("KomodoMiner: ProcessNewBlock, block not accepted");
|
||||
|
||||
TrackMinedBlock(pblock->GetHash());
|
||||
@@ -718,13 +718,13 @@ void static BitcoinMiner()
|
||||
unsigned int n = chainparams.EquihashN();
|
||||
unsigned int k = chainparams.EquihashK();
|
||||
uint8_t *script; uint64_t total,checktoshis; int32_t i,j,gpucount=KOMODO_MAXGPUCOUNT,notaryid = -1;
|
||||
while ( (ASSETCHAIN_INIT == 0 || KOMODO_INITDONE == 0) ) //chainActive.Tip()->nHeight != 235300 &&
|
||||
while ( (ASSETCHAIN_INIT == 0 || KOMODO_INITDONE == 0) ) //chainActive.LastTip()->nHeight != 235300 &&
|
||||
{
|
||||
sleep(1);
|
||||
if ( komodo_baseid(ASSETCHAINS_SYMBOL) < 0 )
|
||||
break;
|
||||
}
|
||||
komodo_chosennotary(¬aryid,chainActive.Tip()->nHeight,NOTARY_PUBKEY33,(uint32_t)chainActive.Tip()->GetBlockTime());
|
||||
komodo_chosennotary(¬aryid,chainActive.LastTip()->nHeight,NOTARY_PUBKEY33,(uint32_t)chainActive.LastTip()->GetBlockTime());
|
||||
if ( notaryid != My_notaryid )
|
||||
My_notaryid = notaryid;
|
||||
std::string solver;
|
||||
@@ -750,9 +750,9 @@ void static BitcoinMiner()
|
||||
fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str());
|
||||
while (true)
|
||||
{
|
||||
if (chainparams.MiningRequiresPeers()) //chainActive.Tip()->nHeight != 235300 &&
|
||||
if (chainparams.MiningRequiresPeers()) //chainActive.LastTip()->nHeight != 235300 &&
|
||||
{
|
||||
//if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 )
|
||||
//if ( ASSETCHAINS_SEED != 0 && chainActive.LastTip()->nHeight < 100 )
|
||||
// break;
|
||||
// Busy-wait for the network to come online so we don't waste time mining
|
||||
// on an obsolete chain. In regtest mode we expect to fly solo.
|
||||
@@ -776,7 +776,7 @@ void static BitcoinMiner()
|
||||
// Create new block
|
||||
//
|
||||
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
|
||||
CBlockIndex* pindexPrev = chainActive.Tip();
|
||||
CBlockIndex* pindexPrev = chainActive.LastTip();
|
||||
if ( Mining_height != pindexPrev->nHeight+1 )
|
||||
{
|
||||
Mining_height = pindexPrev->nHeight+1;
|
||||
@@ -962,7 +962,7 @@ void static BitcoinMiner()
|
||||
while ( GetAdjustedTime() < B.nTime-2 )
|
||||
{
|
||||
sleep(1);
|
||||
if ( chainActive.Tip()->nHeight >= Mining_height )
|
||||
if ( chainActive.LastTip()->nHeight >= Mining_height )
|
||||
{
|
||||
fprintf(stderr,"new block arrived\n");
|
||||
return(false);
|
||||
@@ -983,7 +983,7 @@ void static BitcoinMiner()
|
||||
while ( B.nTime-57 > GetAdjustedTime() )
|
||||
{
|
||||
sleep(1);
|
||||
if ( chainActive.Tip()->nHeight >= Mining_height )
|
||||
if ( chainActive.LastTip()->nHeight >= Mining_height )
|
||||
return(false);
|
||||
}
|
||||
uint256 tmp = B.GetHash();
|
||||
@@ -992,7 +992,7 @@ void static BitcoinMiner()
|
||||
fprintf(stderr," mined %s block %d!\n",ASSETCHAINS_SYMBOL,Mining_height);
|
||||
}
|
||||
CValidationState state;
|
||||
if ( !TestBlockValidity(state,B, chainActive.Tip(), true, false))
|
||||
if ( !TestBlockValidity(state,B, chainActive.LastTip(), true, false))
|
||||
{
|
||||
h = UintToArith256(B.GetHash());
|
||||
for (z=31; z>=0; z--)
|
||||
@@ -1112,7 +1112,7 @@ void static BitcoinMiner()
|
||||
fprintf(stderr,"timeout, break\n");
|
||||
break;
|
||||
}
|
||||
if ( pindexPrev != chainActive.Tip() )
|
||||
if ( pindexPrev != chainActive.LastTip() )
|
||||
{
|
||||
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
fprintf(stderr,"Tip advanced, break\n");
|
||||
|
||||
@@ -530,7 +530,7 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart)
|
||||
// serialize data
|
||||
// use exact same output as mentioned in Bip64
|
||||
CDataStream ssGetUTXOResponse(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ssGetUTXOResponse << chainActive.Height() << chainActive.Tip()->GetBlockHash() << bitmap << outs;
|
||||
ssGetUTXOResponse << chainActive.Height() << chainActive.LastTip()->GetBlockHash() << bitmap << outs;
|
||||
string ssGetUTXOResponseString = ssGetUTXOResponse.str();
|
||||
|
||||
req->WriteHeader("Content-Type", "application/octet-stream");
|
||||
@@ -540,7 +540,7 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart)
|
||||
|
||||
case RF_HEX: {
|
||||
CDataStream ssGetUTXOResponse(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ssGetUTXOResponse << chainActive.Height() << chainActive.Tip()->GetBlockHash() << bitmap << outs;
|
||||
ssGetUTXOResponse << chainActive.Height() << chainActive.LastTip()->GetBlockHash() << bitmap << outs;
|
||||
string strHex = HexStr(ssGetUTXOResponse.begin(), ssGetUTXOResponse.end()) + "\n";
|
||||
|
||||
req->WriteHeader("Content-Type", "text/plain");
|
||||
@@ -554,7 +554,7 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart)
|
||||
// pack in some essentials
|
||||
// use more or less the same output as mentioned in Bip64
|
||||
objGetUTXOResponse.push_back(Pair("chainHeight", chainActive.Height()));
|
||||
objGetUTXOResponse.push_back(Pair("chaintipHash", chainActive.Tip()->GetBlockHash().GetHex()));
|
||||
objGetUTXOResponse.push_back(Pair("chaintipHash", chainActive.LastTip()->GetBlockHash().GetHex()));
|
||||
objGetUTXOResponse.push_back(Pair("bitmap", bitmapStringRepresentation));
|
||||
|
||||
UniValue utxos(UniValue::VARR);
|
||||
|
||||
@@ -38,10 +38,10 @@ double GetDifficultyINTERNAL(const CBlockIndex* blockindex, bool networkDifficul
|
||||
// minimum difficulty = 1.0.
|
||||
if (blockindex == NULL)
|
||||
{
|
||||
if (chainActive.Tip() == NULL)
|
||||
if (chainActive.LastTip() == NULL)
|
||||
return 1.0;
|
||||
else
|
||||
blockindex = chainActive.Tip();
|
||||
blockindex = chainActive.LastTip();
|
||||
}
|
||||
|
||||
uint32_t bits;
|
||||
@@ -326,7 +326,7 @@ UniValue getbestblockhash(const UniValue& params, bool fHelp)
|
||||
);
|
||||
|
||||
LOCK(cs_main);
|
||||
return chainActive.Tip()->GetBlockHash().GetHex();
|
||||
return chainActive.LastTip()->GetBlockHash().GetHex();
|
||||
}
|
||||
|
||||
UniValue getdifficulty(const UniValue& params, bool fHelp)
|
||||
@@ -803,13 +803,13 @@ UniValue kvsearch(const UniValue& params, bool fHelp)
|
||||
if ( (keylen= (int32_t)strlen(params[0].get_str().c_str())) > 0 )
|
||||
{
|
||||
ret.push_back(Pair("coin",(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)));
|
||||
ret.push_back(Pair("currentheight", (int64_t)chainActive.Tip()->nHeight));
|
||||
ret.push_back(Pair("currentheight", (int64_t)chainActive.LastTip()->nHeight));
|
||||
ret.push_back(Pair("key",params[0].get_str()));
|
||||
ret.push_back(Pair("keylen",keylen));
|
||||
if ( keylen < sizeof(key) )
|
||||
{
|
||||
memcpy(key,params[0].get_str().c_str(),keylen);
|
||||
if ( (valuesize= komodo_kvsearch(&refpubkey,chainActive.Tip()->nHeight,&flags,&height,value,key,keylen)) >= 0 )
|
||||
if ( (valuesize= komodo_kvsearch(&refpubkey,chainActive.LastTip()->nHeight,&flags,&height,value,key,keylen)) >= 0 )
|
||||
{
|
||||
std::string val; char *valuestr;
|
||||
val.resize(valuesize);
|
||||
@@ -837,7 +837,7 @@ UniValue minerids(const UniValue& params, bool fHelp)
|
||||
LOCK(cs_main);
|
||||
int32_t height = atoi(params[0].get_str().c_str());
|
||||
if ( height <= 0 )
|
||||
height = chainActive.Tip()->nHeight;
|
||||
height = chainActive.LastTip()->nHeight;
|
||||
else
|
||||
{
|
||||
CBlockIndex *pblockindex = chainActive[height];
|
||||
@@ -899,8 +899,8 @@ UniValue notaries(const UniValue& params, bool fHelp)
|
||||
else timestamp = (uint32_t)time(NULL);
|
||||
if ( height < 0 )
|
||||
{
|
||||
height = chainActive.Tip()->nHeight;
|
||||
timestamp = chainActive.Tip()->GetBlockTime();
|
||||
height = chainActive.LastTip()->nHeight;
|
||||
timestamp = chainActive.LastTip()->GetBlockTime();
|
||||
}
|
||||
else if ( params.size() < 2 )
|
||||
{
|
||||
@@ -988,7 +988,7 @@ UniValue paxprice(const UniValue& params, bool fHelp)
|
||||
std::string rel = params[1].get_str();
|
||||
int32_t height;
|
||||
if ( params.size() == 2 )
|
||||
height = chainActive.Tip()->nHeight;
|
||||
height = chainActive.LastTip()->nHeight;
|
||||
else height = atoi(params[2].get_str().c_str());
|
||||
//if ( params.size() == 3 || (basevolume= COIN * atof(params[3].get_str().c_str())) == 0 )
|
||||
basevolume = 100000;
|
||||
@@ -1280,10 +1280,10 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
|
||||
obj.push_back(Pair("chain", Params().NetworkIDString()));
|
||||
obj.push_back(Pair("blocks", (int)chainActive.Height()));
|
||||
obj.push_back(Pair("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1));
|
||||
obj.push_back(Pair("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex()));
|
||||
obj.push_back(Pair("bestblockhash", chainActive.LastTip()->GetBlockHash().GetHex()));
|
||||
obj.push_back(Pair("difficulty", (double)GetNetworkDifficulty()));
|
||||
obj.push_back(Pair("verificationprogress", Checkpoints::GuessVerificationProgress(Params().Checkpoints(), chainActive.Tip())));
|
||||
obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex()));
|
||||
obj.push_back(Pair("verificationprogress", Checkpoints::GuessVerificationProgress(Params().Checkpoints(), chainActive.LastTip())));
|
||||
obj.push_back(Pair("chainwork", chainActive.LastTip()->nChainWork.GetHex()));
|
||||
obj.push_back(Pair("pruned", fPruneMode));
|
||||
|
||||
ZCIncrementalMerkleTree tree;
|
||||
@@ -1294,7 +1294,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
|
||||
obj.push_back(Pair("commitments", tree.size()));
|
||||
#endif
|
||||
|
||||
CBlockIndex* tip = chainActive.Tip();
|
||||
CBlockIndex* tip = chainActive.LastTip();
|
||||
UniValue valuePools(UniValue::VARR);
|
||||
valuePools.push_back(ValuePoolDesc("sprout", tip->nChainSproutValue, boost::none));
|
||||
obj.push_back(Pair("valuePools", valuePools));
|
||||
@@ -1319,7 +1319,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
|
||||
|
||||
if (fPruneMode)
|
||||
{
|
||||
CBlockIndex *block = chainActive.Tip();
|
||||
CBlockIndex *block = chainActive.LastTip();
|
||||
while (block && block->pprev && (block->pprev->nStatus & BLOCK_HAVE_DATA))
|
||||
block = block->pprev;
|
||||
|
||||
@@ -1394,7 +1394,7 @@ UniValue getchaintips(const UniValue& params, bool fHelp)
|
||||
}
|
||||
|
||||
// Always report the currently active tip.
|
||||
setTips.insert(chainActive.Tip());
|
||||
setTips.insert(chainActive.LastTip());
|
||||
|
||||
/* Construct the output array. */
|
||||
UniValue res(UniValue::VARR); const CBlockIndex *forked;
|
||||
|
||||
@@ -39,7 +39,7 @@ using namespace std;
|
||||
* If 'height' is nonnegative, compute the estimate at the time when a given block was found.
|
||||
*/
|
||||
int64_t GetNetworkHashPS(int lookup, int height) {
|
||||
CBlockIndex *pb = chainActive.Tip();
|
||||
CBlockIndex *pb = chainActive.LastTip();
|
||||
|
||||
if (height >= 0 && height < chainActive.Height())
|
||||
pb = chainActive[height];
|
||||
@@ -224,7 +224,7 @@ UniValue generate(const UniValue& params, bool fHelp)
|
||||
CBlock *pblock = &pblocktemplate->block;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
IncrementExtraNonce(pblock, chainActive.Tip(), nExtraNonce);
|
||||
IncrementExtraNonce(pblock, chainActive.LastTip(), nExtraNonce);
|
||||
}
|
||||
|
||||
// Hash state
|
||||
@@ -268,7 +268,7 @@ UniValue generate(const UniValue& params, bool fHelp)
|
||||
}
|
||||
endloop:
|
||||
CValidationState state;
|
||||
if (!ProcessNewBlock(1,chainActive.Tip()->nHeight+1,state, NULL, pblock, true, NULL))
|
||||
if (!ProcessNewBlock(1,chainActive.LastTip()->nHeight+1,state, NULL, pblock, true, NULL))
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "ProcessNewBlock, block not accepted");
|
||||
++nHeight;
|
||||
blockHashes.push_back(pblock->GetHash().GetHex());
|
||||
@@ -550,7 +550,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
return "duplicate-inconclusive";
|
||||
}
|
||||
|
||||
CBlockIndex* const pindexPrev = chainActive.Tip();
|
||||
CBlockIndex* const pindexPrev = chainActive.LastTip();
|
||||
// TestBlockValidity only supports blocks built on the current Tip
|
||||
if (block.hashPrevBlock != pindexPrev->GetBlockHash())
|
||||
return "inconclusive-not-best-prevblk";
|
||||
@@ -589,7 +589,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
else
|
||||
{
|
||||
// NOTE: Spec does not specify behaviour for non-string longpollid, but this makes testing easier
|
||||
hashWatchedChain = chainActive.Tip()->GetBlockHash();
|
||||
hashWatchedChain = chainActive.LastTip()->GetBlockHash();
|
||||
nTransactionsUpdatedLastLP = nTransactionsUpdatedLast;
|
||||
}
|
||||
|
||||
@@ -599,7 +599,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
checktxtime = boost::get_system_time() + boost::posix_time::minutes(1);
|
||||
|
||||
boost::unique_lock<boost::mutex> lock(csBestBlock);
|
||||
while (chainActive.Tip()->GetBlockHash() == hashWatchedChain && IsRPCRunning())
|
||||
while (chainActive.LastTip()->GetBlockHash() == hashWatchedChain && IsRPCRunning())
|
||||
{
|
||||
if (!cvBlockChange.timed_wait(lock, checktxtime))
|
||||
{
|
||||
@@ -621,7 +621,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
static CBlockIndex* pindexPrev;
|
||||
static int64_t nStart;
|
||||
static CBlockTemplate* pblocktemplate;
|
||||
if (pindexPrev != chainActive.Tip() ||
|
||||
if (pindexPrev != chainActive.LastTip() ||
|
||||
(mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 5))
|
||||
{
|
||||
// Clear pindexPrev so future calls make a new block, despite any failures from here on
|
||||
@@ -629,7 +629,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
|
||||
// Store the pindexBest used before CreateNewBlockWithKey, to avoid races
|
||||
nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
|
||||
CBlockIndex* pindexPrevNew = chainActive.Tip();
|
||||
CBlockIndex* pindexPrevNew = chainActive.LastTip();
|
||||
nStart = GetTime();
|
||||
|
||||
// Create new block
|
||||
@@ -640,7 +640,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
}
|
||||
#ifdef ENABLE_WALLET
|
||||
CReserveKey reservekey(pwalletMain);
|
||||
pblocktemplate = CreateNewBlockWithKey(reservekey,chainActive.Tip()->nHeight+1,KOMODO_MAXGPUCOUNT);
|
||||
pblocktemplate = CreateNewBlockWithKey(reservekey,chainActive.LastTip()->nHeight+1,KOMODO_MAXGPUCOUNT);
|
||||
#else
|
||||
pblocktemplate = CreateNewBlockWithKey();
|
||||
#endif
|
||||
@@ -693,7 +693,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
// Correct this if GetBlockTemplate changes the order
|
||||
// entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue));
|
||||
//}
|
||||
CAmount nReward = GetBlockSubsidy(chainActive.Tip()->nHeight+1, Params().GetConsensus());
|
||||
CAmount nReward = GetBlockSubsidy(chainActive.LastTip()->nHeight+1, Params().GetConsensus());
|
||||
entry.push_back(Pair("coinbasevalue", nReward));
|
||||
entry.push_back(Pair("required", true));
|
||||
txCoinbase = entry;
|
||||
@@ -726,7 +726,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
result.push_back(Pair("coinbaseaux", aux));
|
||||
result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue));
|
||||
}
|
||||
result.push_back(Pair("longpollid", chainActive.Tip()->GetBlockHash().GetHex() + i64tostr(nTransactionsUpdatedLast)));
|
||||
result.push_back(Pair("longpollid", chainActive.LastTip()->GetBlockHash().GetHex() + i64tostr(nTransactionsUpdatedLast)));
|
||||
result.push_back(Pair("target", hashTarget.GetHex()));
|
||||
result.push_back(Pair("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1));
|
||||
result.push_back(Pair("mutable", aMutable));
|
||||
@@ -809,7 +809,7 @@ UniValue submitblock(const UniValue& params, bool fHelp)
|
||||
CValidationState state;
|
||||
submitblock_StateCatcher sc(block.GetHash());
|
||||
RegisterValidationInterface(&sc);
|
||||
bool fAccepted = ProcessNewBlock(1,chainActive.Tip()->nHeight+1,state, NULL, &block, true, NULL);
|
||||
bool fAccepted = ProcessNewBlock(1,chainActive.LastTip()->nHeight+1,state, NULL, &block, true, NULL);
|
||||
UnregisterValidationInterface(&sc);
|
||||
if (fBlockPresent)
|
||||
{
|
||||
|
||||
@@ -133,8 +133,8 @@ UniValue getinfo(const UniValue& params, bool fHelp)
|
||||
//fprintf(stderr,"after longestchain %u\n",(uint32_t)time(NULL));
|
||||
obj.push_back(Pair("longestchain", longestchain));
|
||||
obj.push_back(Pair("timeoffset", GetTimeOffset()));
|
||||
if ( chainActive.Tip() != 0 )
|
||||
obj.push_back(Pair("tiptime", (int)chainActive.Tip()->nTime));
|
||||
if ( chainActive.LastTip() != 0 )
|
||||
obj.push_back(Pair("tiptime", (int)chainActive.LastTip()->nTime));
|
||||
obj.push_back(Pair("connections", (int)vNodes.size()));
|
||||
obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string())));
|
||||
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
|
||||
@@ -152,7 +152,7 @@ UniValue getinfo(const UniValue& params, bool fHelp)
|
||||
obj.push_back(Pair("errors", GetWarnings("statusbar")));
|
||||
{
|
||||
char pubkeystr[65]; int32_t notaryid;
|
||||
if ( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.Tip()->nHeight,komodo_chainactive_timestamp())) >= 0 )
|
||||
if ( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 )
|
||||
{
|
||||
obj.push_back(Pair("notaryid", notaryid));
|
||||
obj.push_back(Pair("pubkey", pubkeystr));
|
||||
@@ -826,7 +826,7 @@ UniValue getaddressutxos(const UniValue& params, bool fHelp)
|
||||
result.push_back(Pair("utxos", utxos));
|
||||
|
||||
LOCK(cs_main);
|
||||
result.push_back(Pair("hash", chainActive.Tip()->GetBlockHash().GetHex()));
|
||||
result.push_back(Pair("hash", chainActive.LastTip()->GetBlockHash().GetHex()));
|
||||
result.push_back(Pair("height", (int)chainActive.Height()));
|
||||
return result;
|
||||
} else {
|
||||
|
||||
@@ -179,7 +179,7 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue&
|
||||
const CTxOut& txout = tx.vout[i];
|
||||
UniValue out(UniValue::VOBJ);
|
||||
out.push_back(Pair("value", ValueFromAmount(txout.nValue)));
|
||||
if ( pindex != 0 && tx.nLockTime >= 500000000 && (tipindex= chainActive.Tip()) != 0 )
|
||||
if ( pindex != 0 && tx.nLockTime >= 500000000 && (tipindex= chainActive.LastTip()) != 0 )
|
||||
{
|
||||
int64_t interest; int32_t txheight; uint32_t locktime;
|
||||
interest = komodo_accrued_interest(&txheight,&locktime,tx.GetHash(),i,0,txout.nValue,(int32_t)tipindex->nHeight);
|
||||
|
||||
@@ -437,7 +437,7 @@ void CTxMemPool::removeExpired(unsigned int nBlockHeight)
|
||||
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++)
|
||||
{
|
||||
const CTransaction& tx = it->GetTx();
|
||||
tipindex = chainActive.Tip();
|
||||
tipindex = chainActive.LastTip();
|
||||
if (IsExpiredTx(tx, nBlockHeight) || (ASSETCHAINS_SYMBOL[0] == 0 && tipindex != 0 && komodo_validate_interest(tx,tipindex->nHeight+1,tipindex->GetMedianTimePast() + 777,0)) < 0)
|
||||
{
|
||||
transactionsToRemove.push_back(tx);
|
||||
|
||||
@@ -278,7 +278,7 @@ UniValue importwallet_impl(const UniValue& params, bool fHelp, bool fImportZKeys
|
||||
if (!file.is_open())
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
|
||||
|
||||
int64_t nTimeBegin = chainActive.Tip()->GetBlockTime();
|
||||
int64_t nTimeBegin = chainActive.LastTip()->GetBlockTime();
|
||||
|
||||
bool fGood = true;
|
||||
|
||||
@@ -364,7 +364,7 @@ UniValue importwallet_impl(const UniValue& params, bool fHelp, bool fImportZKeys
|
||||
file.close();
|
||||
pwalletMain->ShowProgress("", 100); // hide progress dialog in GUI
|
||||
|
||||
CBlockIndex *pindex = chainActive.Tip();
|
||||
CBlockIndex *pindex = chainActive.LastTip();
|
||||
while (pindex && pindex->pprev && pindex->GetBlockTime() > nTimeBegin - 7200)
|
||||
pindex = pindex->pprev;
|
||||
|
||||
@@ -509,8 +509,8 @@ UniValue dumpwallet_impl(const UniValue& params, bool fHelp, bool fDumpZKeys)
|
||||
// produce output
|
||||
file << strprintf("# Wallet dump created by Komodo %s (%s)\n", CLIENT_BUILD, CLIENT_DATE);
|
||||
file << strprintf("# * Created on %s\n", EncodeDumpTime(GetTime()));
|
||||
file << strprintf("# * Best block at time of backup was %i (%s),\n", chainActive.Height(), chainActive.Tip()->GetBlockHash().ToString());
|
||||
file << strprintf("# mined on %s\n", EncodeDumpTime(chainActive.Tip()->GetBlockTime()));
|
||||
file << strprintf("# * Best block at time of backup was %i (%s),\n", chainActive.Height(), chainActive.LastTip()->GetBlockHash().ToString());
|
||||
file << strprintf("# mined on %s\n", EncodeDumpTime(chainActive.LastTip()->GetBlockTime()));
|
||||
file << "\n";
|
||||
for (std::vector<std::pair<int64_t, CKeyID> >::const_iterator it = vKeyBirth.begin(); it != vKeyBirth.end(); it++) {
|
||||
const CKeyID &keyid = it->second;
|
||||
|
||||
@@ -574,7 +574,7 @@ UniValue kvupdate(const UniValue& params, bool fHelp)
|
||||
valuesize = (int32_t)strlen(params[1].get_str().c_str());
|
||||
}
|
||||
memcpy(keyvalue,key,keylen);
|
||||
if ( (refvaluesize= komodo_kvsearch(&refpubkey,chainActive.Tip()->nHeight,&tmpflags,&height,&keyvalue[keylen],key,keylen)) >= 0 )
|
||||
if ( (refvaluesize= komodo_kvsearch(&refpubkey,chainActive.LastTip()->nHeight,&tmpflags,&height,&keyvalue[keylen],key,keylen)) >= 0 )
|
||||
{
|
||||
if ( (tmpflags & KOMODO_KVPROTECTED) != 0 )
|
||||
{
|
||||
@@ -599,7 +599,7 @@ UniValue kvupdate(const UniValue& params, bool fHelp)
|
||||
// printf("%02x",((uint8_t *)&sig)[i]);
|
||||
//printf(" sig for keylen.%d + valuesize.%d\n",keylen,refvaluesize);
|
||||
ret.push_back(Pair("coin",(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)));
|
||||
height = chainActive.Tip()->nHeight;
|
||||
height = chainActive.LastTip()->nHeight;
|
||||
if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 )
|
||||
ret.push_back(Pair("owner",refpubkey.GetHex()));
|
||||
ret.push_back(Pair("height", (int64_t)height));
|
||||
@@ -671,7 +671,7 @@ UniValue paxdeposit(const UniValue& params, bool fHelp)
|
||||
int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN;
|
||||
std::string base = params[2].get_str();
|
||||
std::string dest;
|
||||
height = chainActive.Tip()->nHeight;
|
||||
height = chainActive.LastTip()->nHeight;
|
||||
if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis )
|
||||
{
|
||||
fprintf(stderr,"available %llu vs fiatoshis %llu\n",(long long)available,(long long)fiatoshis);
|
||||
@@ -2713,13 +2713,13 @@ UniValue listunspent(const UniValue& params, bool fHelp)
|
||||
BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
|
||||
CBlockIndex *tipindex,*pindex = it->second;
|
||||
uint64_t interest; uint32_t locktime; int32_t txheight;
|
||||
if ( pindex != 0 && (tipindex= chainActive.Tip()) != 0 )
|
||||
if ( pindex != 0 && (tipindex= chainActive.LastTip()) != 0 )
|
||||
{
|
||||
interest = komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,0,nValue,(int32_t)tipindex->nHeight);
|
||||
//interest = komodo_interest(txheight,nValue,out.tx->nLockTime,tipindex->nTime);
|
||||
entry.push_back(Pair("interest",ValueFromAmount(interest)));
|
||||
}
|
||||
//fprintf(stderr,"nValue %.8f pindex.%p tipindex.%p locktime.%u txheight.%d pindexht.%d\n",(double)nValue/COIN,pindex,chainActive.Tip(),locktime,txheight,pindex->nHeight);
|
||||
//fprintf(stderr,"nValue %.8f pindex.%p tipindex.%p locktime.%u txheight.%d pindexht.%d\n",(double)nValue/COIN,pindex,chainActive.LastTip(),locktime,txheight,pindex->nHeight);
|
||||
}
|
||||
entry.push_back(Pair("confirmations",out.nDepth));
|
||||
entry.push_back(Pair("spendable", out.fSpendable));
|
||||
@@ -2746,7 +2746,7 @@ uint64_t komodo_interestsum()
|
||||
{
|
||||
BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
|
||||
CBlockIndex *tipindex,*pindex = it->second;
|
||||
if ( pindex != 0 && (tipindex= chainActive.Tip()) != 0 )
|
||||
if ( pindex != 0 && (tipindex= chainActive.LastTip()) != 0 )
|
||||
{
|
||||
interest = komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,0,nValue,(int32_t)tipindex->nHeight);
|
||||
//interest = komodo_interest(pindex->nHeight,nValue,out.tx->nLockTime,tipindex->nTime);
|
||||
|
||||
@@ -1819,7 +1819,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
|
||||
|
||||
ShowProgress(_("Rescanning..."), 0); // show rescan progress in GUI as dialog or on splashscreen, if -rescan on startup
|
||||
double dProgressStart = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), pindex, false);
|
||||
double dProgressTip = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.Tip(), false);
|
||||
double dProgressTip = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.LastTip(), false);
|
||||
while (pindex)
|
||||
{
|
||||
if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0)
|
||||
@@ -2299,20 +2299,20 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
|
||||
if ( KOMODO_EXCHANGEWALLET == 0 )
|
||||
{
|
||||
uint32_t locktime; int32_t txheight; CBlockIndex *tipindex;
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.Tip() != 0 && chainActive.Tip()->nHeight >= 60000 )
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.LastTip() != 0 && chainActive.LastTip()->nHeight >= 60000 )
|
||||
{
|
||||
if ( pcoin->vout[i].nValue >= 10*COIN )
|
||||
{
|
||||
if ( (tipindex= chainActive.Tip()) != 0 )
|
||||
if ( (tipindex= chainActive.LastTip()) != 0 )
|
||||
{
|
||||
komodo_accrued_interest(&txheight,&locktime,wtxid,i,0,pcoin->vout[i].nValue,(int32_t)tipindex->nHeight);
|
||||
interest = komodo_interestnew(txheight,pcoin->vout[i].nValue,locktime,tipindex->nTime);
|
||||
} else interest = 0;
|
||||
//interest = komodo_interestnew(chainActive.Tip()->nHeight+1,pcoin->vout[i].nValue,pcoin->nLockTime,chainActive.Tip()->nTime);
|
||||
//interest = komodo_interestnew(chainActive.LastTip()->nHeight+1,pcoin->vout[i].nValue,pcoin->nLockTime,chainActive.LastTip()->nTime);
|
||||
if ( interest != 0 )
|
||||
{
|
||||
//printf("wallet nValueRet %.8f += interest %.8f ht.%d lock.%u/%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,txheight,locktime,pcoin->nLockTime,tipindex->nTime);
|
||||
//fprintf(stderr,"wallet nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,chainActive.Tip()->nHeight+1,pcoin->nLockTime,chainActive.Tip()->nTime);
|
||||
//fprintf(stderr,"wallet nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,chainActive.LastTip()->nHeight+1,pcoin->nLockTime,chainActive.LastTip()->nTime);
|
||||
//ptr = (uint64_t *)&pcoin->vout[i].nValue;
|
||||
//(*ptr) += interest;
|
||||
ptr = (uint64_t *)&pcoin->vout[i].interest;
|
||||
@@ -2687,7 +2687,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
|
||||
int nextBlockHeight = chainActive.Height() + 1;
|
||||
CMutableTransaction txNew = CreateNewContextualCMutableTransaction(
|
||||
Params().GetConsensus(), nextBlockHeight);
|
||||
txNew.nLockTime = (uint32_t)chainActive.Tip()->nTime + 1; // set to a time close to now
|
||||
txNew.nLockTime = (uint32_t)chainActive.LastTip()->nTime + 1; // set to a time close to now
|
||||
|
||||
// Activates after Overwinter network upgrade
|
||||
// Set nExpiryHeight to expiryDelta (default 20) blocks past current block height
|
||||
|
||||
Reference in New Issue
Block a user