@@ -338,6 +338,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
|
||||
if ( i == 0 && j == 0 && memcmp(NOTARY_PUBKEY33,scriptbuf+1,33) == 0 )
|
||||
{
|
||||
printf("%s KOMODO_LASTMINED.%d -> %d\n",ASSETCHAINS_SYMBOL,KOMODO_LASTMINED,height);
|
||||
prevKOMODO_LASTMINED = KOMODO_LASTMINED;
|
||||
KOMODO_LASTMINED = height;
|
||||
}
|
||||
decode_hex(crypto777,33,(char *)CRYPTO777_PUBSECPSTR);
|
||||
|
||||
@@ -116,6 +116,12 @@ void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height)
|
||||
struct komodo_event *ep;
|
||||
if ( sp != 0 )
|
||||
{
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_LASTMINED && prevKOMODO_LASTMINED != 0 )
|
||||
{
|
||||
printf("undo KOMODO_LASTMINED %d <- %d\n",KOMODO_LASTMINED,prevKOMODO_LASTMINED);
|
||||
KOMODO_LASTMINED = prevKOMODO_LASTMINED;
|
||||
prevKOMODO_LASTMINED = 0;
|
||||
}
|
||||
while ( sp->Komodo_events != 0 && sp->Komodo_numevents > 0 )
|
||||
{
|
||||
if ( (ep= sp->Komodo_events[sp->Komodo_numevents-1]) != 0 )
|
||||
|
||||
@@ -40,7 +40,7 @@ struct komodo_state KOMODO_STATES[34];
|
||||
int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
|
||||
|
||||
int32_t IS_KOMODO_NOTARY,KOMODO_REWIND,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET;
|
||||
int32_t KOMODO_LASTMINED;
|
||||
int32_t KOMODO_LASTMINED,prevKOMODO_LASTMINED;
|
||||
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES;
|
||||
uint8_t NOTARY_PUBKEY33[33];
|
||||
|
||||
@@ -55,4 +55,4 @@ char KMDUSERPASS[4096],BTCUSERPASS[4096]; uint16_t BITCOIND_PORT = 7771;
|
||||
uint64_t PENDING_KOMODO_TX;
|
||||
|
||||
struct komodo_kv *KOMODO_KV;
|
||||
pthread_mutex_t KOMODO_KV_mutex;
|
||||
pthread_mutex_t KOMODO_KV_mutex;
|
||||
|
||||
@@ -124,7 +124,7 @@ const char *Notaries_elected[][2] =
|
||||
|
||||
int32_t komodo_electednotary(uint8_t *pubkey33,int32_t height)
|
||||
{
|
||||
char pubkeystr[67]; int32_t i;
|
||||
char pubkeystr[67]; int32_t i; uint8_t legacy33[33];
|
||||
for (i=0; i<33; i++)
|
||||
sprintf(&pubkeystr[i*2],"%02x",pubkey33[i]);
|
||||
pubkeystr[66] = 0;
|
||||
@@ -137,6 +137,20 @@ int32_t komodo_electednotary(uint8_t *pubkey33,int32_t height)
|
||||
return(i);
|
||||
}
|
||||
}
|
||||
/*if ( height < 300000 )
|
||||
{
|
||||
for (i=0; i<sizeof(Notaries_genesis)/sizeof(*Notaries_genesis); i++)
|
||||
{
|
||||
if ( strcmp(pubkeystr,(char *)Notaries_genesis[i][1]) == 0 )
|
||||
{
|
||||
//printf("i.%d -> elected %s\n",i,(char *)Notaries_elected[i][1]);
|
||||
return(i+64);
|
||||
}
|
||||
}
|
||||
decode_hex(legacy33,33,(char *)"0252b6185bf8ea7efe8bbc345ddc8da87329149f30233088387abd716d4aa9e974");
|
||||
if ( memcmp(pubkey33,legacy33,33) == 0 )
|
||||
return(128);
|
||||
}*/
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@@ -203,7 +217,7 @@ void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num)
|
||||
memcpy(kp->pubkey,pubkeys[k],33);
|
||||
kp->notaryid = k;
|
||||
HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp);
|
||||
if ( 0 && height > 10000 )
|
||||
if ( 1 && height > 10000 )
|
||||
{
|
||||
for (i=0; i<33; i++)
|
||||
printf("%02x",pubkeys[k][i]);
|
||||
@@ -246,6 +260,8 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33)
|
||||
return(modval);
|
||||
}
|
||||
}
|
||||
if ( height >= 300000 )
|
||||
return(-1);
|
||||
htind = height / KOMODO_ELECTION_GAP;
|
||||
pthread_mutex_lock(&komodo_mutex);
|
||||
HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp);
|
||||
@@ -258,7 +274,7 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33)
|
||||
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);
|
||||
}
|
||||
} //else printf("cant find kp at htind.%d ht.%d\n",htind,height);
|
||||
//int32_t i; for (i=0; i<33; i++)
|
||||
// printf("%02x",pubkey33[i]);
|
||||
//printf(" ht.%d notary.%d special.%d htind.%d num.%d\n",height,*notaryidp,modval,htind,numnotaries);
|
||||
@@ -352,7 +368,7 @@ void komodo_init(int32_t height)
|
||||
// Minerids[i] = -2;
|
||||
didinit = 1;
|
||||
}
|
||||
else if ( height == KOMODO_MAINNET_START )
|
||||
else if ( 0 && height == KOMODO_MAINNET_START )
|
||||
{
|
||||
n = (int32_t)(sizeof(Notaries_elected)/sizeof(*Notaries_elected));
|
||||
for (k=0; k<n; k++)
|
||||
|
||||
@@ -3872,6 +3872,7 @@ bool LoadBlockIndex()
|
||||
return false;
|
||||
}
|
||||
KOMODO_LOADINGBLOCKS = 0;
|
||||
fprintf(stderr,"finished loading blocks\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -522,7 +522,7 @@ static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& rese
|
||||
|
||||
int32_t komodo_baseid(char *origbase);
|
||||
int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,int32_t *nonzpkeysp,int32_t height);
|
||||
int32_t FOUND_BLOCK;
|
||||
int32_t FOUND_BLOCK,KOMODO_MAYBEMINED;
|
||||
extern int32_t KOMODO_LASTMINED;
|
||||
|
||||
void static BitcoinMiner(CWallet *pwallet)
|
||||
@@ -667,7 +667,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
if ( mids[j] == notaryid )
|
||||
break;
|
||||
} else fprintf(stderr,"no nonz pubkeys\n");
|
||||
if ( j == 65 && Mining_height > KOMODO_LASTMINED+64 )
|
||||
if ( j == 65 && Mining_height > KOMODO_MAYBEMINED+3 && Mining_height > KOMODO_LASTMINED+64 )
|
||||
{
|
||||
hashTarget = arith_uint256().SetCompact(KOMODO_MINDIFF_NBITS);
|
||||
fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1);
|
||||
@@ -792,6 +792,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
|
||||
fprintf(stderr," <- %s Block found %d\n",ASSETCHAINS_SYMBOL,Mining_height);
|
||||
FOUND_BLOCK = 1;
|
||||
KOMODO_MAYBEMINED = Mining_height;
|
||||
break;
|
||||
}
|
||||
} catch (EhSolverCancelledException&) {
|
||||
|
||||
@@ -447,7 +447,7 @@ Value kvsearch(const Array& params, bool fHelp)
|
||||
|
||||
Value minerids(const Array& params, bool fHelp)
|
||||
{
|
||||
Object ret; Array a; uint8_t minerids[2000],pubkeys[64][33]; int32_t i,j,n,numnotaries,tally[65];
|
||||
Object ret; Array a; uint8_t minerids[2000],pubkeys[65][33]; int32_t i,j,n,numnotaries,tally[129];
|
||||
if ( fHelp || params.size() != 1 )
|
||||
throw runtime_error("minerids needs height\n");
|
||||
LOCK(cs_main);
|
||||
@@ -463,7 +463,7 @@ Value minerids(const Array& params, bool fHelp)
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
if ( minerids[i] >= numnotaries )
|
||||
tally[64]++;
|
||||
tally[128]++;
|
||||
else tally[minerids[i]]++;
|
||||
}
|
||||
for (i=0; i<64; i++)
|
||||
@@ -488,7 +488,7 @@ Value minerids(const Array& params, bool fHelp)
|
||||
}
|
||||
Object item;
|
||||
item.push_back(Pair("pubkey", (char *)"external miners"));
|
||||
item.push_back(Pair("blocks", tally[64]));
|
||||
item.push_back(Pair("blocks", tally[128]));
|
||||
a.push_back(item);
|
||||
}
|
||||
ret.push_back(Pair("mined", a));
|
||||
|
||||
Reference in New Issue
Block a user