This commit is contained in:
jl777
2017-02-02 16:01:41 +02:00
parent a353db460c
commit c142de7e72
3 changed files with 14 additions and 10 deletions

View File

@@ -608,12 +608,16 @@ void komodo_connectpindex(CBlockIndex *pindex)
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height);
int32_t komodo_electednotary(uint8_t *pubkey33,int32_t height);
int8_t komodo_minerid(int32_t height)
int8_t komodo_minerid(int32_t height,uint8_t *pubkey33)
{
int32_t num,i; CBlockIndex *pindex; uint8_t pubkey33[33],pubkeys[64][33];
int32_t num,i; CBlockIndex *pindex; uint8_t _pubkey33[33],pubkeys[64][33];
if ( (pindex= chainActive[height]) != 0 )
{
komodo_index2pubkey33(pubkey33,pindex,height);
if ( pubkey33 == 0 )
{
pubkey33 = _pubkey33;
komodo_index2pubkey33(pubkey33,pindex,height);
}
if ( (num= komodo_notaries(pubkeys,height)) > 0 )
{
for (i=0; i<num; i++)
@@ -631,7 +635,7 @@ int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width)
{
if ( height-i <= 0 )
break;
minerids[i] = komodo_minerid(height - i);
minerids[i] = komodo_minerid(height - i,0);
}
return(n);
}
@@ -649,7 +653,7 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33])
else limit = 66;
for (i=1; i<limit; i++)
{
if ( komodo_minerid(height-i) == notaryid )
if ( komodo_minerid(height-i,pubkey33) == notaryid )
{
//fprintf(stderr,"ht.%d notaryid.%d already mined -i.%d\n",height,notaryid,i);
return(-1);

View File

@@ -455,7 +455,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&
//
// Internal miner
//
int8_t komodo_minerid(int32_t height);
int8_t komodo_minerid(int32_t height,uint8_t *pubkey33);
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey)
{
@@ -481,7 +481,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey)
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
{
for (i=0; i<65; i++)
fprintf(stderr,"%d ",komodo_minerid(chainActive.Tip()->nHeight-i));
fprintf(stderr,"%d ",komodo_minerid(chainActive.Tip()->nHeight-i,0));
fprintf(stderr," minerids.special %d from ht.%d\n",komodo_is_special(chainActive.Tip()->nHeight+1,NOTARY_PUBKEY33),chainActive.Tip()->nHeight);
}
return CreateNewBlock(scriptPubKey);

View File

@@ -107,7 +107,7 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33);
int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]);
int32_t komodo_currentheight();
int8_t komodo_minerid(int32_t height);
int8_t komodo_minerid(int32_t height,uint8_t *pubkey33);
extern int32_t KOMODO_CHOSEN_ONE;
#define KOMODO_ELECTION_GAP 2000
@@ -120,9 +120,9 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
if ( height == 0 )
height = komodo_currentheight() + 1;
special = komodo_chosennotary(&notaryid,height,pubkey33);
if ( height > 34000 ) // 0 -> non-special notary
{
special = komodo_chosennotary(&notaryid,height,pubkey33);
for (i=0; i<33; i++)
{
if ( pubkey33[i] != 0 )
@@ -168,7 +168,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
printf("%02x",pubkey33[i]);
printf(" <- pubkey\n");
for (i=0; i<66; i++)
printf("%d ",komodo_minerid(height-i));
printf("%d ",komodo_minerid(height-i,pubkey33));
printf(" minerids from ht.%d\n",height);
if ( height < 90000 || (height > 110000 && KOMODO_REWIND == 0) )
return error("CheckProofOfWork(): hash doesn't match nBits");