From dae9e3bbf14ca1cb9bd0eb46518a5f394deb325f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 21 Oct 2016 08:57:30 -0300 Subject: [PATCH] test --- src/komodo.h | 8 ++++---- src/pow.cpp | 14 ++++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index a3b6e8a51..20f423dd2 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -270,11 +270,11 @@ void komodo_notarysinit(int32_t height,uint8_t pubkeys[64][33],int32_t num) 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 - 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); HASH_FIND(hh,Pubkeys[height/KOMODO_ELECTION_GAP].Notaries,pubkey33,33,kp); 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 ) { - notaryid = kp->notaryid; + *notaryidp = kp->notaryid; modval = ((height % numnotaries) == kp->notaryid); //printf("found notary.%d ht.%d modval.%d\n",kp->notaryid,height,modval); } else printf("unexpected zero notaries at height.%d\n",height); diff --git a/src/pow.cpp b/src/pow.cpp index a2a965f39..ad2afbe15 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -104,18 +104,17 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param 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 fNegative,fOverflow; int32_t special; + bool fNegative,fOverflow; int32_t i,nonz=0,special,notaryid,flag = 0; arith_uint256 bnTarget; bnTarget.SetCompact(nBits, &fNegative, &fOverflow); if ( height > 34000 ) // 0 -> non-special notary { - int32_t i,nonz = 0; - special = komodo_heightnotary(height,pubkey33); + special = komodo_heightnotary(¬aryid,height,pubkey33); for (i=0; i<33; i++) { 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 return true; bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); + flag = 1; } //else bnTarget /= 8; } // 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"); } + 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; }