test
This commit is contained in:
34
src/komodo.h
34
src/komodo.h
@@ -22,15 +22,16 @@
|
|||||||
int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY;
|
int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY;
|
||||||
std::string NOTARY_PUBKEY;
|
std::string NOTARY_PUBKEY;
|
||||||
|
|
||||||
int32_t komodo_is_notaryblock(uint8_t *pblock)
|
void komodo_connectblock(CBlock *block)
|
||||||
{
|
{
|
||||||
/*int32_t i;
|
// update voting results and official (height, notaries[])
|
||||||
for (i=0; i<5; i++)
|
}
|
||||||
printf("%02x",coinbase[i]);
|
|
||||||
printf(" <- coinbase\n");
|
int32_t komodo_is_notaryblock(CBlockHeader *blockhdr)
|
||||||
for (i=0; i<35; i++)
|
{
|
||||||
printf("%02x",minerout[i]);
|
// extract height from coinbase
|
||||||
printf(" <- minerout\n");*/
|
// extract miner's pubkey from vout[0]
|
||||||
|
// compare against elected notary pubkeys as of height
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +41,22 @@ int32_t komodo_checkmsg(void *bitcoinpeer,uint8_t *data,int32_t datalen)
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t komodo_blockcheck(void *block,uint32_t *nBitsp)
|
int32_t komodo_blockhdrcheck(CBlockHeader *blockhdr,uint32_t *nBitsp)
|
||||||
|
{
|
||||||
|
if ( komodo_is_notaryblock(blockhdr) != 0 )
|
||||||
|
*nBitsp = KOMODO_MINDIFF_NBITS;
|
||||||
|
//fprintf(stderr,"check block %p\n",block);
|
||||||
|
// 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)
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"check block %p\n",block);
|
//fprintf(stderr,"check block %p\n",block);
|
||||||
// 1 -> valid notary block, change nBits to KOMODO_MINDIFF_NBITS
|
// 1 -> valid notary block, change nBits to KOMODO_MINDIFF_NBITS
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ using namespace std;
|
|||||||
# error "Bitcoin cannot be compiled without assertions."
|
# error "Bitcoin cannot be compiled without assertions."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t komodo_blockcheck(void *block,uint32_t *nBitsp);
|
#include "komodo.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global state
|
* Global state
|
||||||
@@ -1352,7 +1352,7 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos)
|
|||||||
|
|
||||||
// Check the header
|
// Check the header
|
||||||
nBits = block.nBits;
|
nBits = block.nBits;
|
||||||
if ( (retval= komodo_blockcheck((void *)&block,&nBits)) == 0 )
|
if ( (retval= komodo_blockcheck(&block,&nBits)) == 0 )
|
||||||
{
|
{
|
||||||
if (!(CheckEquihashSolution(&block, Params()) && CheckProofOfWork(block.GetHash(), nBits, Params().GetConsensus())))
|
if (!(CheckEquihashSolution(&block, Params()) && CheckProofOfWork(block.GetHash(), nBits, Params().GetConsensus())))
|
||||||
return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
|
return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
|
||||||
@@ -2503,6 +2503,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
|
|||||||
BOOST_FOREACH(const CTransaction &tx, pblock->vtx) {
|
BOOST_FOREACH(const CTransaction &tx, pblock->vtx) {
|
||||||
SyncWithWallets(tx, pblock);
|
SyncWithWallets(tx, pblock);
|
||||||
}
|
}
|
||||||
|
komodo_connectblock(pblock);
|
||||||
// Update cached incremental witnesses
|
// Update cached incremental witnesses
|
||||||
GetMainSignals().ChainTip(pindexNew, pblock, oldTree, true);
|
GetMainSignals().ChainTip(pindexNew, pblock, oldTree, true);
|
||||||
|
|
||||||
@@ -2950,7 +2951,7 @@ 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 ( (retval= komodo_blockcheck((void *)&block,&nBits)) == 0 )
|
if ( (retval= komodo_blockhdrcheck(&block,&nBits)) == 0 )
|
||||||
{
|
{
|
||||||
// Check Equihash solution is valid
|
// Check Equihash solution is valid
|
||||||
if ( fCheckPOW && !CheckEquihashSolution(&block, Params()) )
|
if ( fCheckPOW && !CheckEquihashSolution(&block, Params()) )
|
||||||
@@ -4106,7 +4107,6 @@ string GetWarnings(string strFor)
|
|||||||
//
|
//
|
||||||
// Messages
|
// Messages
|
||||||
//
|
//
|
||||||
#include "komodo.h"
|
|
||||||
|
|
||||||
|
|
||||||
bool static AlreadyHave(const CInv& inv)
|
bool static AlreadyHave(const CInv& inv)
|
||||||
|
|||||||
@@ -16,14 +16,14 @@
|
|||||||
|
|
||||||
#include "sodium.h"
|
#include "sodium.h"
|
||||||
|
|
||||||
int32_t komodo_is_notaryblock(uint8_t *pblock);
|
int32_t komodo_is_notaryblock(const CBlockHeader *pblock);
|
||||||
|
|
||||||
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
|
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
|
||||||
{
|
{
|
||||||
unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact();
|
unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact();
|
||||||
|
|
||||||
// Genesis block
|
// Genesis block
|
||||||
if (pindexLast == NULL || komodo_is_notaryblock((uint8_t *)pblock) != 0 )
|
if (pindexLast == NULL || komodo_is_notaryblock(pblock) != 0 )
|
||||||
return nProofOfWorkLimit;
|
return nProofOfWorkLimit;
|
||||||
|
|
||||||
// Find the first block in the averaging interval
|
// Find the first block in the averaging interval
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ Value getgenerate(const Array& params, bool fHelp)
|
|||||||
return GetBoolArg("-gen", false);
|
return GetBoolArg("-gen", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t komodo_blockcheck(void *block,uint32_t *nBitsp);
|
int32_t komodo_blockcheck(CBlock *block,uint32_t *nBitsp);
|
||||||
|
|
||||||
Value generate(const Array& params, bool fHelp)
|
Value generate(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
@@ -196,7 +196,7 @@ Value generate(const Array& params, bool fHelp)
|
|||||||
int32_t retval; uint32_t nBits;
|
int32_t retval; uint32_t nBits;
|
||||||
pblock->nSolution = soln;
|
pblock->nSolution = soln;
|
||||||
nBits = pblock->nBits;
|
nBits = pblock->nBits;
|
||||||
if ( (retval= komodo_blockcheck((void *)pblock,&nBits)) == 0 )
|
if ( (retval= komodo_blockcheck(pblock,&nBits)) == 0 )
|
||||||
{
|
{
|
||||||
return CheckProofOfWork(pblock->GetHash(), nBits, Params().GetConsensus());
|
return CheckProofOfWork(pblock->GetHash(), nBits, Params().GetConsensus());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t komodo_blockcheck(void *block,uint32_t *nBitsp);
|
int32_t komodo_blockindexcheck(CBlockIndex *pindex,uint32_t *nBitsp);
|
||||||
|
|
||||||
bool CBlockTreeDB::LoadBlockIndexGuts()
|
bool CBlockTreeDB::LoadBlockIndexGuts()
|
||||||
{
|
{
|
||||||
@@ -308,7 +308,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
|
|||||||
|
|
||||||
int32_t retval; uint32_t nBits;
|
int32_t retval; uint32_t nBits;
|
||||||
nBits = pindexNew->nBits;
|
nBits = pindexNew->nBits;
|
||||||
if ( (retval= komodo_blockcheck((void *)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());
|
||||||
|
|||||||
Reference in New Issue
Block a user