Clean fix and speedup
This commit is contained in:
31
src/pow.cpp
31
src/pow.cpp
@@ -116,6 +116,7 @@ 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();
|
||||
@@ -134,7 +135,7 @@ 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;
|
||||
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;
|
||||
arith_uint256 bnTarget; uint8_t pubkeys[66][33];
|
||||
timestamp = komodo_chainactive_timestamp();
|
||||
bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
|
||||
@@ -145,6 +146,13 @@ 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++)
|
||||
{
|
||||
@@ -158,7 +166,7 @@ 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);
|
||||
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) )
|
||||
@@ -182,7 +190,26 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
||||
return error("CheckProofOfWork(): nBits below minimum work");
|
||||
// Check proof of work matches claimed amount
|
||||
if ( UintToArith256(hash) > bnTarget )
|
||||
{
|
||||
for (i=31; i>=0; i--)
|
||||
printf("%02x",((uint8_t *)&hash)[i]);
|
||||
printf(" hash vs ");
|
||||
for (i=31; i>=0; i--)
|
||||
printf("%02x",((uint8_t *)&bnTarget)[i]);
|
||||
printf(" ht.%d special.%d notaryid.%d ht.%d mod.%d error\n",height,special,notaryid,height,(height % 35));
|
||||
if ( pindex != 0 )
|
||||
{
|
||||
pindex->didinit = 0;
|
||||
komodo_pindex_init(pindex,height);
|
||||
}
|
||||
for (i=0; i<33; i++)
|
||||
printf("%02x",pubkey33[i]);
|
||||
printf(" <- pubkey\n");
|
||||
for (i=0; i<66; i++)
|
||||
printf("%d ",mids[i]);
|
||||
printf(" minerids from ht.%d pindex.%p\n",height,pindex);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user