test
This commit is contained in:
@@ -270,11 +270,11 @@ void komodo_notarysinit(int32_t height,uint8_t pubkeys[64][33],int32_t num)
|
|||||||
pthread_mutex_unlock(&komodo_mutex);
|
pthread_mutex_unlock(&komodo_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t komodo_heightnotary(int32_t height,uint8_t *pubkey33)
|
int32_t komodo_heightnotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33)
|
||||||
{
|
{
|
||||||
// -1 if not notary, 0 if notary, 1 if special notary
|
// -1 if not notary, 0 if notary, 1 if special notary
|
||||||
struct knotary_entry *kp; int32_t numnotaries,notaryid = -1,modval = -1;
|
struct knotary_entry *kp; int32_t numnotaries,modval = -1;
|
||||||
|
*notaryidp = -1;
|
||||||
pthread_mutex_lock(&komodo_mutex);
|
pthread_mutex_lock(&komodo_mutex);
|
||||||
HASH_FIND(hh,Pubkeys[height/KOMODO_ELECTION_GAP].Notaries,pubkey33,33,kp);
|
HASH_FIND(hh,Pubkeys[height/KOMODO_ELECTION_GAP].Notaries,pubkey33,33,kp);
|
||||||
pthread_mutex_unlock(&komodo_mutex);
|
pthread_mutex_unlock(&komodo_mutex);
|
||||||
@@ -282,7 +282,7 @@ int32_t komodo_heightnotary(int32_t height,uint8_t *pubkey33)
|
|||||||
{
|
{
|
||||||
if ( (numnotaries= Pubkeys[height/KOMODO_ELECTION_GAP].numnotaries) > 0 )
|
if ( (numnotaries= Pubkeys[height/KOMODO_ELECTION_GAP].numnotaries) > 0 )
|
||||||
{
|
{
|
||||||
notaryid = kp->notaryid;
|
*notaryidp = kp->notaryid;
|
||||||
modval = ((height % numnotaries) == kp->notaryid);
|
modval = ((height % numnotaries) == kp->notaryid);
|
||||||
//printf("found notary.%d ht.%d modval.%d\n",kp->notaryid,height,modval);
|
//printf("found notary.%d ht.%d modval.%d\n",kp->notaryid,height,modval);
|
||||||
} else printf("unexpected zero notaries at height.%d\n",height);
|
} else printf("unexpected zero notaries at height.%d\n",height);
|
||||||
|
|||||||
14
src/pow.cpp
14
src/pow.cpp
@@ -104,18 +104,17 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t komodo_heightnotary(int32_t height,uint8_t *pubkey33);
|
int32_t komodo_heightnotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33);
|
||||||
|
|
||||||
bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params& params)
|
bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params& params)
|
||||||
{
|
{
|
||||||
bool fNegative,fOverflow; int32_t special;
|
bool fNegative,fOverflow; int32_t i,nonz=0,special,notaryid,flag = 0;
|
||||||
arith_uint256 bnTarget;
|
arith_uint256 bnTarget;
|
||||||
|
|
||||||
bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
|
bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
|
||||||
if ( height > 34000 ) // 0 -> non-special notary
|
if ( height > 34000 ) // 0 -> non-special notary
|
||||||
{
|
{
|
||||||
int32_t i,nonz = 0;
|
special = komodo_heightnotary(¬aryid,height,pubkey33);
|
||||||
special = komodo_heightnotary(height,pubkey33);
|
|
||||||
for (i=0; i<33; i++)
|
for (i=0; i<33; i++)
|
||||||
{
|
{
|
||||||
if ( pubkey33[i] != 0 )
|
if ( pubkey33[i] != 0 )
|
||||||
@@ -130,6 +129,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
|||||||
if (UintToArith256(hash) <= bnTarget) // accept normal diff
|
if (UintToArith256(hash) <= bnTarget) // accept normal diff
|
||||||
return true;
|
return true;
|
||||||
bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
|
bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
|
||||||
|
flag = 1;
|
||||||
} //else bnTarget /= 8;
|
} //else bnTarget /= 8;
|
||||||
}
|
}
|
||||||
// Check range
|
// Check range
|
||||||
@@ -140,6 +140,12 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
|||||||
{
|
{
|
||||||
return error("CheckProofOfWork(): hash doesn't match nBits");
|
return error("CheckProofOfWork(): hash doesn't match nBits");
|
||||||
}
|
}
|
||||||
|
if ( flag != 0 )
|
||||||
|
{
|
||||||
|
for (i=0; i<33; i++)
|
||||||
|
fprintf(stderr,"%02x",pubkey33[i]);
|
||||||
|
fprintf(stderr," <- Round Robin ht.%d for notary.%d special.%d\n",height,notaryid,special);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user