This commit is contained in:
jl777
2016-10-18 11:08:37 -03:00
parent fffef49eca
commit 0570045c87
4 changed files with 18 additions and 23 deletions

View File

@@ -34,36 +34,31 @@ void komodo_connectblock(CBlock *block)
// update voting results and official (height, notaries[])
}
int32_t komodo_is_notaryblock(CBlockHeader *blockhdr)
int32_t komodo_blockindexcheck(CBlockIndex *pindex,uint32_t *nBitsp)
{
// extract height from coinbase
// extract miner's pubkey from vout[0]
// compare against elected notary pubkeys as of height
return(0); // normal PoW block
}
int32_t komodo_is_notaryblock(CBlockHeader& blockhdr)
{
// 1 -> valid notary block, change nBits to KOMODO_MINDIFF_NBITS
// -1 -> invalid, ie, prior to notarized block
return(0);
}
int32_t komodo_blockhdrcheck(const CBlockHeader *blockhdr,uint32_t *nBitsp)
int32_t komodo_blockhdrcheck(CBlockHeader& blockhdr,uint32_t *nBitsp)
{
if ( komodo_is_notaryblock((CBlockHeader *)blockhdr) != 0 )
if ( komodo_is_notaryblock(blockhdr) != 0 )
*nBitsp = KOMODO_MINDIFF_NBITS;
// 1 -> valid notary block, change nBits to KOMODO_MINDIFF_NBITS
// -1 -> invalid, ie, prior to notarized block
return(0); // normal PoW block
}
int32_t komodo_blockindexcheck(CBlockIndex *pindex,uint32_t *nBitsp)
int32_t komodo_blockcheck(CBlock& block,uint32_t *nBitsp)
{
return(0); // normal PoW block
}
int32_t komodo_blockcheck(CBlock *block,uint32_t *nBitsp)
{
CBlockIndex *bindex = 0;//new CBlockIndex(block->GetBlockHeader());
if ( bindex != 0 && bindex->nHeight <= NOTARIZED_HEIGHT )
return(-1);
// 1 -> valid notary block, change nBits to KOMODO_MINDIFF_NBITS
// -1 -> invalid, ie, prior to notarized block
return(0); // normal PoW block
komodo_blockhdrcheck(block,nBitsp);
}
#endif

View File

@@ -1343,7 +1343,7 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos)
// Check the header
nBits = block.nBits;
if ( (retval= komodo_blockcheck(&block,&nBits)) == 0 )
if ( (retval= komodo_blockcheck(block,&nBits)) == 0 )
{
if (!(CheckEquihashSolution(&block, Params()) && CheckProofOfWork(block.GetHash(), nBits, Params().GetConsensus())))
return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
@@ -2951,7 +2951,7 @@ bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool f
if (block.GetBlockTime() > GetAdjustedTime() + 60)
return state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),REJECT_INVALID, "time-too-new");
nBits = block.nBits;
if ( (retval= komodo_blockhdrcheck(&block,&nBits)) == 0 )
if ( (retval= komodo_blockhdrcheck(block,&nBits)) == 0 )
{
// Check Equihash solution is valid
if ( fCheckPOW && !CheckEquihashSolution(&block, Params()) )

View File

@@ -16,14 +16,14 @@
#include "sodium.h"
int32_t komodo_is_notaryblock(CBlockHeader *pblock);
int32_t komodo_is_notaryblock(CBlockHeader& block);
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
{
unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact();
// Genesis block
if (pindexLast == NULL || komodo_is_notaryblock((CBlockHeader *)pblock) != 0 )
if (pindexLast == NULL || komodo_is_notaryblock(*pblock) != 0 )
return nProofOfWorkLimit;
// Find the first block in the averaging interval

View File

@@ -115,7 +115,7 @@ Value getgenerate(const Array& params, bool fHelp)
return GetBoolArg("-gen", false);
}
int32_t komodo_blockcheck(CBlock *block,uint32_t *nBitsp);
int32_t komodo_blockcheck(CBlock& block,uint32_t *nBitsp);
Value generate(const Array& params, bool fHelp)
{
@@ -196,7 +196,7 @@ Value generate(const Array& params, bool fHelp)
int32_t retval; uint32_t nBits;
pblock->nSolution = soln;
nBits = pblock->nBits;
if ( (retval= komodo_blockcheck(pblock,&nBits)) == 0 )
if ( (retval= komodo_blockcheck(*pblock,&nBits)) == 0 )
{
return CheckProofOfWork(pblock->GetHash(), nBits, Params().GetConsensus());
} else if ( retval < 0 ) // komodo rejects, ie. prior to notarized blockhash