notarized checkpoint
This commit is contained in:
@@ -19,8 +19,9 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY;
|
int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,NOTARIZED_HEIGHT;
|
||||||
std::string NOTARY_PUBKEY;
|
std::string NOTARY_PUBKEY;
|
||||||
|
uint256 NOTARIZED_HASH;
|
||||||
|
|
||||||
int32_t komodo_checkmsg(void *bitcoinpeer,uint8_t *data,int32_t datalen)
|
int32_t komodo_checkmsg(void *bitcoinpeer,uint8_t *data,int32_t datalen)
|
||||||
{
|
{
|
||||||
@@ -57,6 +58,8 @@ int32_t komodo_blockindexcheck(CBlockIndex *pindex,uint32_t *nBitsp)
|
|||||||
|
|
||||||
int32_t komodo_blockcheck(CBlock *block,uint32_t *nBitsp)
|
int32_t komodo_blockcheck(CBlock *block,uint32_t *nBitsp)
|
||||||
{
|
{
|
||||||
|
if ( block.GetHeight() <= NOTARIZED_HEIGHT )
|
||||||
|
return(-1);
|
||||||
// 1 -> valid notary block, change nBits to KOMODO_MINDIFF_NBITS
|
// 1 -> valid notary block, change nBits to KOMODO_MINDIFF_NBITS
|
||||||
// -1 -> invalid, ie, prior to notarized block
|
// -1 -> invalid, ie, prior to notarized block
|
||||||
return(0); // normal PoW block
|
return(0); // normal PoW block
|
||||||
|
|||||||
@@ -2952,6 +2952,8 @@ bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool f
|
|||||||
if (block.GetBlockTime() > GetAdjustedTime() + 60)
|
if (block.GetBlockTime() > GetAdjustedTime() + 60)
|
||||||
return state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),REJECT_INVALID, "time-too-new");
|
return state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),REJECT_INVALID, "time-too-new");
|
||||||
nBits = block.nBits;
|
nBits = block.nBits;
|
||||||
|
if ( block.GetHeight() < NOTARIZED_HEIGHT || (block.GetHeight() == NOTARIZED_HEIGHT && NOTARIZED_HASH != block.GetBlockHash()) )
|
||||||
|
return(false);
|
||||||
if ( (retval= komodo_blockhdrcheck(&block,&nBits)) == 0 )
|
if ( (retval= komodo_blockhdrcheck(&block,&nBits)) == 0 )
|
||||||
{
|
{
|
||||||
// Check Equihash solution is valid
|
// Check Equihash solution is valid
|
||||||
|
|||||||
@@ -199,8 +199,7 @@ Value generate(const Array& params, bool fHelp)
|
|||||||
if ( (retval= komodo_blockcheck(pblock,&nBits)) == 0 )
|
if ( (retval= komodo_blockcheck(pblock,&nBits)) == 0 )
|
||||||
{
|
{
|
||||||
return CheckProofOfWork(pblock->GetHash(), nBits, Params().GetConsensus());
|
return CheckProofOfWork(pblock->GetHash(), nBits, Params().GetConsensus());
|
||||||
}
|
} else if ( retval < 0 ) // komodo rejects, ie. prior to notarized blockhash
|
||||||
else if ( retval < 0 ) // komodo rejects, ie. prior to notarized blockhash
|
|
||||||
return(false);
|
return(false);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -267,6 +267,8 @@ bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t komodo_blockindexcheck(CBlockIndex *pindex,uint32_t *nBitsp);
|
int32_t komodo_blockindexcheck(CBlockIndex *pindex,uint32_t *nBitsp);
|
||||||
|
extern int32_t NOTARIZED_HEIGHT;
|
||||||
|
extern uint256 NOTARIZED_HASH;
|
||||||
|
|
||||||
bool CBlockTreeDB::LoadBlockIndexGuts()
|
bool CBlockTreeDB::LoadBlockIndexGuts()
|
||||||
{
|
{
|
||||||
@@ -308,12 +310,13 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
|
|||||||
|
|
||||||
int32_t retval; uint32_t nBits;
|
int32_t retval; uint32_t nBits;
|
||||||
nBits = pindexNew->nBits;
|
nBits = pindexNew->nBits;
|
||||||
|
if ( pindexNew->nHeight < NOTARIZED_HEIGHT || (pindexNew->nHeight == NOTARIZED_HEIGHT && NOTARIZED_HASH != pindexNew->GetBlockHash()) )
|
||||||
|
return(false);
|
||||||
if ( (retval= komodo_blockindexcheck(pindexNew,&nBits)) == 0 )
|
if ( (retval= komodo_blockindexcheck(pindexNew,&nBits)) == 0 )
|
||||||
{
|
{
|
||||||
if (!CheckProofOfWork(pindexNew->GetBlockHash(), nBits, Params().GetConsensus()))
|
if (!CheckProofOfWork(pindexNew->GetBlockHash(), nBits, Params().GetConsensus()))
|
||||||
return error("LoadBlockIndex(): CheckProofOfWork failed: %s", pindexNew->ToString());
|
return error("LoadBlockIndex(): CheckProofOfWork failed: %s", pindexNew->ToString());
|
||||||
}
|
} else if ( retval < 0 ) // komodo rejects, ie. prior to notarized blockhash
|
||||||
else if ( retval < 0 ) // komodo rejects, ie. prior to notarized blockhash
|
|
||||||
return(false);
|
return(false);
|
||||||
pcursor->Next();
|
pcursor->Next();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user