test
This commit is contained in:
14
src/komodo.h
14
src/komodo.h
@@ -170,19 +170,19 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char
|
||||
void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout)
|
||||
{
|
||||
static FILE *fp; static int32_t errs;
|
||||
struct komodo_state *sp; char fname[512],fname2[512],symbol[16],dest[16]; int32_t ht,func; uint8_t num,pubkeys[64][33];
|
||||
struct komodo_state *sp; char fname[512],symbol[16],dest[16]; int32_t ht,func; uint8_t num,pubkeys[64][33];
|
||||
if ( (sp= komodo_stateptr(symbol,dest)) == 0 )
|
||||
return;
|
||||
if ( fp == 0 )
|
||||
{
|
||||
#ifdef WIN32
|
||||
sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),(char *)"komodostate");
|
||||
sprintf(fname2,"%s\\%s",GetDataDir(false).string().c_str(),(char *)"minerids");
|
||||
//sprintf(fname2,"%s\\%s",GetDataDir(false).string().c_str(),(char *)"minerids");
|
||||
#else
|
||||
sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),(char *)"komodostate");
|
||||
sprintf(fname2,"%s/%s",GetDataDir(false).string().c_str(),(char *)"minerids");
|
||||
//sprintf(fname2,"%s/%s",GetDataDir(false).string().c_str(),(char *)"minerids");
|
||||
#endif
|
||||
memset(Minerids,0xfe,sizeof(Minerids));
|
||||
/*memset(Minerids,0xfe,sizeof(Minerids));
|
||||
if ( (Minerfp= fopen(fname2,"rb+")) == 0 )
|
||||
{
|
||||
if ( (Minerfp= fopen(fname2,"wb")) != 0 )
|
||||
@@ -193,7 +193,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar
|
||||
Minerfp = fopen(fname2,"rb+");
|
||||
}
|
||||
if ( Minerfp != 0 && fread(Minerids,1,sizeof(Minerids),Minerfp) != sizeof(Minerids) )
|
||||
printf("read error Minerids\n");
|
||||
printf("read error Minerids\n");*/
|
||||
if ( (fp= fopen(fname,"rb+")) != 0 )
|
||||
{
|
||||
while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 )
|
||||
@@ -456,7 +456,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
memcpy(scriptbuf,(uint8_t *)&block.vtx[i].vout[j].scriptPubKey[0],len);
|
||||
#endif
|
||||
notaryid = komodo_voutupdate(&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue);
|
||||
if ( i == 0 && j == 0 && komodo_chosennotary(&nid,height,scriptbuf + 1) >= 0 )
|
||||
/*if ( i == 0 && j == 0 && komodo_chosennotary(&nid,height,scriptbuf + 1) >= 0 )
|
||||
{
|
||||
if ( height < sizeof(Minerids)/sizeof(*Minerids) )
|
||||
{
|
||||
@@ -470,7 +470,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
if ( 0 && i > 0 )
|
||||
{
|
||||
for (k=0; k<len; k++)
|
||||
|
||||
@@ -377,7 +377,7 @@ void komodo_disconnect(CBlockIndex *pindex,CBlock& block)
|
||||
{
|
||||
//int32_t i; uint256 hash;
|
||||
komodo_init(pindex->nHeight);
|
||||
Minerids[pindex->nHeight] = -2;
|
||||
//Minerids[pindex->nHeight] = -2;
|
||||
//hash = block.GetHash();
|
||||
//for (i=0; i<32; i++)
|
||||
// printf("%02x",((uint8_t *)&hash)[i]);
|
||||
@@ -492,53 +492,17 @@ int8_t komodo_minerid(int32_t height)
|
||||
}
|
||||
}
|
||||
return(-1);
|
||||
/*if ( Minerids[height] >= -1 )
|
||||
{
|
||||
printf("cached[%d] -> %d\n",height,Minerids[height]);
|
||||
return(Minerids[height]);
|
||||
}
|
||||
if ( depth < 1 )
|
||||
{
|
||||
if ( (pindex= chainActive[height]) != 0 )
|
||||
{
|
||||
depth++;
|
||||
komodo_index2pubkey33(pubkey33,pindex,height);
|
||||
komodo_chosennotary(¬aryid,height,pubkey33);
|
||||
if ( notaryid >= -1 )
|
||||
{
|
||||
Minerids[height] = notaryid;
|
||||
if ( Minerfp != 0 )
|
||||
{
|
||||
fseek(Minerfp,height,SEEK_SET);
|
||||
fputc(Minerids[height],Minerfp);
|
||||
fflush(Minerfp);
|
||||
}
|
||||
}
|
||||
depth--;
|
||||
return(notaryid);
|
||||
}
|
||||
}
|
||||
return(-2);*/
|
||||
}
|
||||
|
||||
int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33])
|
||||
{
|
||||
int32_t i,notaryid;
|
||||
int32_t i,notaryid,minerid;
|
||||
komodo_chosennotary(¬aryid,height,pubkey33);
|
||||
if ( height >= 34000 && notaryid >= 0 )
|
||||
{
|
||||
for (i=1; i<64; i++)
|
||||
{
|
||||
if ( Minerids[height-i] == -2 )
|
||||
{
|
||||
Minerids[height-i] = komodo_minerid(height-i);
|
||||
if ( Minerids[height - i] == -2 )
|
||||
{
|
||||
fprintf(stderr,"second -2 for Minerids[%d] current.%d\n",height-i,height);
|
||||
return(-2);
|
||||
}
|
||||
}
|
||||
if ( Minerids[height-i] == notaryid )
|
||||
if ( komodo_minerid(height-i) == notaryid )
|
||||
return(-1);
|
||||
}
|
||||
return(1);
|
||||
@@ -567,7 +531,7 @@ int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 has
|
||||
return(-1);
|
||||
}
|
||||
} else fprintf(stderr,"unexpected error notary_hash %s ht.%d at ht.%d\n",notarized_hash.ToString().c_str(),notarized_height,notary->nHeight);
|
||||
} else if ( notarized_height > 0 )
|
||||
} else if ( notarized_height > 0 && notarized_height != 73880 )
|
||||
fprintf(stderr,"couldnt find notary_hash %s ht.%d\n",notarized_hash.ToString().c_str(),notarized_height);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33)
|
||||
|
||||
pthread_mutex_t komodo_mutex;
|
||||
|
||||
FILE *Minerfp;
|
||||
int8_t Minerids[KOMODO_MAXBLOCKS]; // 5 million blocks
|
||||
//FILE *Minerfp;
|
||||
//int8_t Minerids[KOMODO_MAXBLOCKS]; // 5 million blocks
|
||||
#define KOMODO_ELECTION_GAP ((ASSETCHAINS_SYMBOL[0] == 0) ? 2000 : 100)
|
||||
|
||||
int32_t KMDHEIGHT = 43000;
|
||||
|
||||
@@ -264,8 +264,8 @@ void komodo_init(int32_t height)
|
||||
komodo_notarysinit(0,pubkeys,k);
|
||||
}
|
||||
memset(&zero,0,sizeof(zero));
|
||||
for (i=0; i<sizeof(Minerids); i++)
|
||||
Minerids[i] = -2;
|
||||
//for (i=0; i<sizeof(Minerids); i++)
|
||||
// Minerids[i] = -2;
|
||||
didinit = 1;
|
||||
}
|
||||
komodo_stateupdate(0,0,0,0,zero,0,0,0,0,0,0,0,0,0);
|
||||
|
||||
Reference in New Issue
Block a user