@@ -616,7 +616,7 @@ int32_t komodo_electednotary(uint8_t *pubkey33,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];
|
||||
if ( (pindex= chainActive[height]) != 0 )
|
||||
if ( pubkey33 == 0 && (pindex= chainActive[height]) != 0 )
|
||||
{
|
||||
if ( pubkey33 == 0 )
|
||||
{
|
||||
@@ -633,17 +633,22 @@ int8_t komodo_minerid(int32_t height,uint8_t *pubkey33)
|
||||
return(komodo_electednotary(pubkey33,height));
|
||||
}
|
||||
|
||||
int32_t komodo_eligiblenotary(int32_t *mids,int32_t *nonzpkeysp,int32_t height)
|
||||
int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,int32_t *nonzpkeysp,int32_t height)
|
||||
{
|
||||
int32_t i,duplicate; CBlockIndex *pindex; uint8_t pubkey33[33];
|
||||
int32_t i,j,duplicate; CBlockIndex *pindex; uint8_t pubkey33[33];
|
||||
memset(mids,-1,sizeof(*mids)*66);
|
||||
for (i=duplicate=0; i<66; i++)
|
||||
{
|
||||
if ( (pindex= komodo_chainactive(height-i)) != 0 )
|
||||
{
|
||||
komodo_index2pubkey33(pubkey33,pindex,height-i);
|
||||
for (j=0; j<33; j++)
|
||||
pubkeys[i][j] = pubkey33[j];
|
||||
if ( (mids[i]= komodo_minerid(height-i,pubkey33)) >= 0 )
|
||||
{
|
||||
//mids[i] = *(int32_t *)pubkey33;
|
||||
(*nonzpkeysp)++;
|
||||
}
|
||||
if ( mids[0] >= 0 && i > 0 && mids[i] == mids[0] )
|
||||
duplicate++;
|
||||
}
|
||||
|
||||
@@ -132,8 +132,10 @@ int32_t komodo_electednotary(uint8_t *pubkey33,int32_t height)
|
||||
for (i=0; i<sizeof(Notaries_elected)/sizeof(*Notaries_elected); i++)
|
||||
{
|
||||
if ( strcmp(pubkeystr,(char *)Notaries_elected[i][1]) == 0 )
|
||||
{
|
||||
//printf("i.%d -> elected %s\n",i,(char *)Notaries_elected[i][1]);
|
||||
return(i);
|
||||
//printf("%s\n",(char *)Notaries_elected[i][1]);
|
||||
}
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
@@ -154,6 +156,13 @@ int32_t komodo_ratify_threshold(int32_t height,uint64_t signedmask)
|
||||
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height)
|
||||
{
|
||||
int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp;
|
||||
if ( height >= 180000 )
|
||||
{
|
||||
n = (int32_t)(sizeof(Notaries_elected)/sizeof(*Notaries_elected));
|
||||
for (i=0; i<n; i++)
|
||||
decode_hex(pubkeys[i],33,(char *)Notaries_elected[i][1]);
|
||||
return(n);
|
||||
}
|
||||
htind = height / KOMODO_ELECTION_GAP;
|
||||
pthread_mutex_lock(&komodo_mutex);
|
||||
n = Pubkeys[htind].numnotaries;
|
||||
|
||||
@@ -520,7 +520,8 @@ static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& rese
|
||||
}
|
||||
|
||||
int32_t komodo_baseid(char *origbase);
|
||||
int32_t komodo_eligiblenotary(int32_t *mids,int32_t *nonzpkeysp,int32_t height);
|
||||
int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,int32_t *nonzpkeysp,int32_t height);
|
||||
int32_t FOUND_BLOCK;
|
||||
|
||||
void static BitcoinMiner(CWallet *pwallet)
|
||||
{
|
||||
@@ -615,21 +616,34 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
//
|
||||
// Search
|
||||
//
|
||||
int mids[66],nonzpkeys,j; uint32_t savebits; int64_t nStart = GetTime();
|
||||
uint8_t pubkeys[66][33]; int mids[66],nonzpkeys,i,j; uint32_t savebits; int64_t nStart = GetTime();
|
||||
savebits = pblock->nBits;
|
||||
arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits);
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && notaryid >= 0 )//komodo_is_special(pindexPrev->nHeight+1,NOTARY_PUBKEY33) > 0 )
|
||||
{
|
||||
if ( (Mining_height % KOMODO_ELECTION_GAP) > 64 || (Mining_height % KOMODO_ELECTION_GAP) == 0 )
|
||||
{
|
||||
komodo_eligiblenotary(mids,&nonzpkeys,pindexPrev->nHeight);
|
||||
komodo_eligiblenotary(pubkeys,mids,&nonzpkeys,pindexPrev->nHeight);
|
||||
if ( nonzpkeys > 0 )
|
||||
{
|
||||
if ( notaryid < 2 )
|
||||
if ( NOTARY_PUBKEY33[0] != 0 && notaryid < 1 )
|
||||
{
|
||||
for (j=0; j<65; j++)
|
||||
fprintf(stderr,"%d ",mids[j]);
|
||||
fprintf(stderr," <- prev minerids from ht.%d notary.%d\n",pindexPrev->nHeight,notaryid);
|
||||
for (i=1; i<66; i++)
|
||||
if ( memcmp(pubkeys[i],pubkeys[0],33) == 0 )
|
||||
break;
|
||||
if ( i != 66 )
|
||||
{
|
||||
printf("VIOLATION at %d\n",i);
|
||||
for (i=0; i<66; i++)
|
||||
{
|
||||
for (j=0; j<33; j++)
|
||||
printf("%02x",pubkeys[i][j]);
|
||||
printf(" p%d -> %d\n",i,komodo_minerid(pindexPrev->nHeight-i,pubkeys[i]));
|
||||
}
|
||||
for (j=0; j<65; j++)
|
||||
fprintf(stderr,"%d ",mids[j]);
|
||||
fprintf(stderr," <- prev minerids from ht.%d notary.%d VIOLATION\n",pindexPrev->nHeight,notaryid);
|
||||
}
|
||||
}
|
||||
for (j=0; j<65; j++)
|
||||
if ( mids[j] == notaryid )
|
||||
@@ -706,6 +720,8 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
ehSolverRuns.increment();
|
||||
throw boost::thread_interrupted();
|
||||
}
|
||||
//if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 )
|
||||
// sleep(1800);
|
||||
return true;
|
||||
};
|
||||
std::function<bool(EhSolverCancelCheck)> cancelled = [&m_cs, &cancelSolver](EhSolverCancelCheck pos) {
|
||||
@@ -756,7 +772,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
for (i=0; i<32; i++)
|
||||
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
|
||||
fprintf(stderr," <- %s Block found %d\n",ASSETCHAINS_SYMBOL,Mining_height);
|
||||
sleep(60); // avoid mining forks
|
||||
FOUND_BLOCK = 1;
|
||||
break;
|
||||
}
|
||||
} catch (EhSolverCancelledException&) {
|
||||
@@ -769,6 +785,12 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
// Check for stop or if block needs to be rebuilt
|
||||
boost::this_thread::interruption_point();
|
||||
// Regtest mode doesn't require peers
|
||||
if ( FOUND_BLOCK != 0 )
|
||||
{
|
||||
FOUND_BLOCK = 0;
|
||||
fprintf(stderr,"FOUND_BLOCK!\n");
|
||||
sleep(2000);
|
||||
}
|
||||
if (vNodes.empty() && chainparams.MiningRequiresPeers())
|
||||
{
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height > ASSETCHAINS_MINHEIGHT )
|
||||
|
||||
@@ -113,7 +113,7 @@ void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height)
|
||||
extern int32_t KOMODO_CHOSEN_ONE;
|
||||
#define KOMODO_ELECTION_GAP 2000
|
||||
|
||||
int32_t komodo_eligiblenotary(int32_t *mids,int32_t *nonzpkeysp,int32_t height);
|
||||
int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,int32_t *nonzpkeysp,int32_t height);
|
||||
|
||||
|
||||
extern std::string NOTARY_PUBKEY;
|
||||
@@ -122,7 +122,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
||||
{
|
||||
extern int32_t KOMODO_REWIND;
|
||||
bool fNegative,fOverflow; int32_t i,nonzpkeys=0,nonz=0,special=0,special2=0,notaryid=-1,duplicate,flag = 0, mids[66];
|
||||
arith_uint256 bnTarget; CBlockIndex *pindex;
|
||||
arith_uint256 bnTarget; CBlockIndex *pindex; uint8_t pubkeys[66][33];
|
||||
|
||||
bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
|
||||
if ( height == 0 )
|
||||
@@ -131,7 +131,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
||||
//for (i=0; i<33; i++)
|
||||
// printf("%02x",pubkey33[i]);
|
||||
//printf(" <- ht.%d\n",height);
|
||||
flag = komodo_eligiblenotary(mids,&nonzpkeys,height);
|
||||
flag = komodo_eligiblenotary(pubkeys,mids,&nonzpkeys,height);
|
||||
if ( height > 34000 ) // 0 -> non-special notary
|
||||
{
|
||||
for (i=0; i<33; i++)
|
||||
@@ -185,7 +185,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
||||
return error("CheckProofOfWork(): hash doesn't match nBits");
|
||||
}
|
||||
}
|
||||
if ( height > 180000 && nonzpkeys > 0 && strcmp((char *)NOTARY_PUBKEY.c_str(),"03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828") == 0 )
|
||||
if ( 0 && height > 180000 && nonzpkeys > 0 && strcmp((char *)NOTARY_PUBKEY.c_str(),"03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828") == 0 )
|
||||
{
|
||||
for (i=0; i<66; i++)
|
||||
fprintf(stderr,"%d ",mids[i]);
|
||||
|
||||
Reference in New Issue
Block a user