-cache
This commit is contained in:
33
src/pow.cpp
33
src/pow.cpp
@@ -116,7 +116,6 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param
|
||||
return true;
|
||||
}
|
||||
|
||||
void komodo_pindex_init(CBlockIndex *pindex,int32_t height);
|
||||
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
||||
int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],int32_t height,uint8_t pubkey33[33],uint32_t timestamp);
|
||||
int32_t komodo_currentheight();
|
||||
@@ -128,15 +127,16 @@ extern char ASSETCHAINS_SYMBOL[];
|
||||
#define KOMODO_ELECTION_GAP 2000
|
||||
|
||||
int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,int32_t *nonzpkeysp,int32_t height);
|
||||
int32_t KOMODO_LOADINGBLOCKS;
|
||||
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)
|
||||
{
|
||||
extern int32_t KOMODO_REWIND;
|
||||
bool fNegative,fOverflow; int32_t i,nonzpkeys=0,nonz=0,special=0,special2=0,notaryid=-1,flag = 0, mids[66]; uint32_t timestamp = 0; CBlockIndex *pindex;
|
||||
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 timestamp = 0; CBlockIndex *pindex=0;
|
||||
arith_uint256 bnTarget; uint8_t pubkeys[66][33];
|
||||
memcpy(origpubkey33,pubkey33,33);
|
||||
timestamp = komodo_chainactive_timestamp();
|
||||
bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
|
||||
if ( height == 0 )
|
||||
@@ -146,13 +146,6 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
||||
}
|
||||
if ( height > 34000 && ASSETCHAINS_SYMBOL[0] == 0 ) // 0 -> non-special notary
|
||||
{
|
||||
if ( KOMODO_LOADINGBLOCKS != 0 )
|
||||
return(true);
|
||||
if ( (pindex= komodo_chainactive(height)) != 0 )
|
||||
{
|
||||
komodo_pindex_init(pindex,height);
|
||||
memcpy(pubkey33,pindex->pubkey33,33);
|
||||
}
|
||||
special = komodo_chosennotary(¬aryid,height,pubkey33,timestamp);
|
||||
for (i=0; i<33; i++)
|
||||
{
|
||||
@@ -166,7 +159,6 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
||||
}
|
||||
flag = komodo_eligiblenotary(pubkeys,mids,&nonzpkeys,height);
|
||||
special2 = komodo_is_special(pubkeys,mids,height,pubkey33,timestamp);
|
||||
fprintf(stderr,"ht.%d notaryid.%d special.%d flag.%d special2.%d\n",height,notaryid,special,flag,special2);
|
||||
if ( notaryid >= 0 )
|
||||
{
|
||||
if ( height > 10000 && height < 80000 && (special != 0 || special2 > 0) )
|
||||
@@ -177,8 +169,12 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
||||
flag = ((height % KOMODO_ELECTION_GAP) > 64 || (height % KOMODO_ELECTION_GAP) == 0);
|
||||
else if ( height == 790833 )
|
||||
flag = 1;
|
||||
else if ( special2 < 0 && height > 792000 )
|
||||
flag = 0;
|
||||
else if ( special2 < 0 )
|
||||
{
|
||||
if ( height > 792000 )
|
||||
flag = 0;
|
||||
else fprintf(stderr,"ht.%d notaryid.%d special.%d flag.%d special2.%d\n",height,notaryid,special,flag,special2);
|
||||
}
|
||||
if ( flag != 0 || special2 > 0 )
|
||||
{
|
||||
//fprintf(stderr,"EASY MINING ht.%d\n",height);
|
||||
@@ -191,17 +187,14 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
||||
// Check proof of work matches claimed amount
|
||||
if ( UintToArith256(hash) > bnTarget )
|
||||
{
|
||||
if ( pindex != 0 )
|
||||
{
|
||||
pindex->didinit = 0;
|
||||
komodo_pindex_init(pindex,height);
|
||||
}
|
||||
return false;
|
||||
if ( KOMODO_LOADINGBLOCKS != 0 )
|
||||
return true;
|
||||
if ( height > 792000 )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
arith_uint256 GetBlockProof(const CBlockIndex& block)
|
||||
{
|
||||
arith_uint256 bnTarget;
|
||||
|
||||
Reference in New Issue
Block a user