This commit is contained in:
jl777
2018-04-16 20:01:00 +03:00
parent 3ad8d2478f
commit e284540042
6 changed files with 10 additions and 12 deletions

View File

@@ -871,9 +871,7 @@ int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],int32_t heigh
}
if ( blocktime < tiptime+60 )
{
fprintf(stderr,"n.%d l.%d\n",notaryid,blocktime-tiptime);
if ( height > 807000 )
return(-2);
fprintf(stderr,"ht.%d n.%d l.%d\n",height,notaryid,blocktime-tiptime);
} else return(1);
} else return(0);
}

View File

@@ -1655,7 +1655,7 @@ bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos, const CMessageHeader::M
return true;
}
bool ReadBlockFromDisk(int32_t height,CBlock& block, const CDiskBlockPos& pos)
bool ReadBlockFromDisk(CBlockIndex *pprev,int32_t height,CBlock& block, const CDiskBlockPos& pos)
{
uint8_t pubkey33[33];
block.SetNull();
@@ -1678,7 +1678,7 @@ bool ReadBlockFromDisk(int32_t height,CBlock& block, const CDiskBlockPos& pos)
}
// Check the header
komodo_block2pubkey33(pubkey33,(CBlock *)&block);
if (!(CheckEquihashSolution(&block, Params()) && CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus(),block.nTime)))
if (!(CheckEquihashSolution(&block, Params()) && CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus(),block.nTime,pprev!=0?pprev->nTime:0)))
{
int32_t i; for (i=0; i<33; i++)
fprintf(stderr,"%02x",pubkey33[i]);
@@ -1693,7 +1693,7 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex)
{
if ( pindex == 0 )
return false;
if (!ReadBlockFromDisk(pindex->nHeight,block, pindex->GetBlockPos()))
if (!ReadBlockFromDisk(pindex->pprev,pindex->nHeight,block, pindex->GetBlockPos()))
return false;
if (block.GetHash() != pindex->GetBlockHash())
return error("ReadBlockFromDisk(CBlock&, CBlockIndex*): GetHash() doesn't match index for %s at %s",
@@ -3808,7 +3808,7 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat
if ( fCheckPOW && !CheckEquihashSolution(&block, Params()) )
return state.DoS(100, error("CheckBlock(): Equihash solution invalid"),REJECT_INVALID, "invalid-solution");
komodo_block2pubkey33(pubkey33,(CBlock *)&block);
if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus(),block.nTime) )
if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus(),block.nTime,pindex->pprev!=0?pindex->pprev->nTime:0) )
return state.DoS(1, error("CheckBlock(): proof of work failed"),REJECT_INVALID, "high-hash");
// Check the merkle root.
if (fCheckMerkleRoot) {

View File

@@ -131,13 +131,13 @@ int32_t KOMODO_LOADINGBLOCKS = 1;
extern std::string NOTARY_PUBKEY;
bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash,unsigned int nBits,const Consensus::Params& params,uint32_t blocktime)
bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash,unsigned int nBits,const Consensus::Params& params,uint32_t blocktime,uint32_t tiptime)
{
extern int32_t KOMODO_REWIND;
bool fNegative,fOverflow; uint8_t origpubkey33[33]; int32_t i,nonzpkeys=0,nonz=0,special=0,special2=0,notaryid=-1,flag = 0, mids[66]; uint32_t tiptime = 0;
arith_uint256 bnTarget; uint8_t pubkeys[66][33];
memcpy(origpubkey33,pubkey33,33);
tiptime = komodo_chainactive_timestamp();
//tiptime = komodo_chainactive_timestamp();
bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
if ( blocktime == 0 || tiptime == 0 )
fprintf(stderr,"nul blocktime.%u or tiptime.%u\n",blocktime,tiptime);

View File

@@ -25,7 +25,7 @@ unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg,
bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams&);
/** Check whether a block hash satisfies the proof-of-work requirement specified by nBits */
bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params&,uint32_t blocktime);
bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params&,uint32_t blocktime,uint32_t tiptime);
arith_uint256 GetBlockProof(const CBlockIndex& block);
/** Return the time it would take to redo the work difference between from and to, assuming the current hashrate corresponds to the difficulty at tip, in seconds. */

View File

@@ -257,7 +257,7 @@ UniValue generate(const UniValue& params, bool fHelp)
LOCK(cs_main);
pblock->nSolution = soln;
solutionTargetChecks.increment();
return CheckProofOfWork(chainActive.Height(),NOTARY_PUBKEY33,pblock->GetHash(), pblock->nBits, Params().GetConsensus(),pblock->nTime);
return CheckProofOfWork(chainActive.Height(),NOTARY_PUBKEY33,pblock->GetHash(), pblock->nBits, Params().GetConsensus(),pblock->nTime,chainActive.Tip()->nTime);
};
bool found = EhBasicSolveUncancellable(n, k, curr_state, validBlock);
ehSolverRuns.increment();

View File

@@ -530,7 +530,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
diskindex.ToString(), pindexNew->ToString());
uint8_t pubkey33[33];
komodo_index2pubkey33(pubkey33,pindexNew,pindexNew->nHeight);
if (!CheckProofOfWork(pindexNew->nHeight,pubkey33,pindexNew->GetBlockHash(), pindexNew->nBits, Params().GetConsensus(),pindexNew->nTime))
if (!CheckProofOfWork(pindexNew->nHeight,pubkey33,pindexNew->GetBlockHash(), pindexNew->nBits, Params().GetConsensus(),pindexNew->nTime,pindexNew->pprev!=0?pindexNew->pprev->nTime:0))
return error("LoadBlockIndex(): CheckProofOfWork failed: %s", pindexNew->ToString());
pcursor->Next();
} else {