test
This commit is contained in:
52
src/komodo.h
52
src/komodo.h
@@ -124,7 +124,18 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char
|
||||
errs++;
|
||||
//if ( matched != 0 ) global independent states -> inside *sp
|
||||
printf("%s load[%s] ht.%d\n",ASSETCHAINS_SYMBOL,symbol,kheight);
|
||||
komodo_eventadd_kmdheight(sp,symbol,ht,kheight);
|
||||
komodo_eventadd_kmdheight(sp,symbol,ht,kheight,0);
|
||||
}
|
||||
else if ( func == 'T' )
|
||||
{
|
||||
int32_t kheight,ktimestamp;
|
||||
if ( fread(&kheight,1,sizeof(kheight),fp) != sizeof(kheight) )
|
||||
errs++;
|
||||
if ( fread(&ktimestamp,1,sizeof(ktimestamp),fp) != sizeof(ktimestamp) )
|
||||
errs++;
|
||||
//if ( matched != 0 ) global independent states -> inside *sp
|
||||
printf("%s load[%s] ht.%d t.%u\n",ASSETCHAINS_SYMBOL,symbol,kheight,ktimestamp);
|
||||
komodo_eventadd_kmdheight(sp,symbol,ht,kheight,ktimestamp);
|
||||
}
|
||||
else if ( func == 'R' )
|
||||
{
|
||||
@@ -167,7 +178,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char
|
||||
} else return(-1);
|
||||
}
|
||||
|
||||
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)
|
||||
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,uint32_t KMDtimestamp,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],symbol[16],dest[16]; int32_t ht,func; uint8_t num,pubkeys[64][33];
|
||||
@@ -194,12 +205,25 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar
|
||||
//printf("fpos.%ld ",ftell(fp));
|
||||
if ( KMDheight != 0 )
|
||||
{
|
||||
fputc('K',fp);
|
||||
if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) )
|
||||
errs++;
|
||||
if ( fwrite(&KMDheight,1,sizeof(KMDheight),fp) != sizeof(KMDheight) )
|
||||
errs++;
|
||||
komodo_eventadd_kmdheight(sp,symbol,height,KMDheight);
|
||||
if ( KMDtimestamp != 0 )
|
||||
{
|
||||
fputc('T',fp);
|
||||
if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) )
|
||||
errs++;
|
||||
if ( fwrite(&KMDheight,1,sizeof(KMDheight),fp) != sizeof(KMDheight) )
|
||||
errs++;
|
||||
if ( fwrite(&KMDtimestamp,1,sizeof(KMDtimestamp),fp) != sizeof(KMDtimestamp) )
|
||||
errs++;
|
||||
}
|
||||
else
|
||||
{
|
||||
fputc('K',fp);
|
||||
if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) )
|
||||
errs++;
|
||||
if ( fwrite(&KMDheight,1,sizeof(KMDheight),fp) != sizeof(KMDheight) )
|
||||
errs++;
|
||||
}
|
||||
komodo_eventadd_kmdheight(sp,symbol,height,KMDheight,KMDtimestamp);
|
||||
}
|
||||
else if ( opretbuf != 0 && opretlen > 0 )
|
||||
{
|
||||
@@ -347,7 +371,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
|
||||
sp->NOTARIZED_HEIGHT = *notarizedheightp;
|
||||
sp->NOTARIZED_HASH = kmdtxid;
|
||||
sp->NOTARIZED_DESTTXID = desttxid;
|
||||
komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0);
|
||||
komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0);
|
||||
// extract X opreturns here
|
||||
} else printf("reject ht.%d NOTARIZED.%d %s.%s DESTTXID.%s (%s)\n",height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len]);
|
||||
}
|
||||
@@ -370,7 +394,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
|
||||
}
|
||||
}
|
||||
if ( *isratificationp == 0 )
|
||||
komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,value,&scriptbuf[len],opretlen,j);
|
||||
komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j);
|
||||
}
|
||||
}
|
||||
return(notaryid);
|
||||
@@ -423,7 +447,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
{
|
||||
printf("hwmheight.%d vs pindex->nHeight.%d reorg.%d\n",hwmheight,pindex->nHeight,hwmheight-pindex->nHeight);
|
||||
komodo_event_rewind(sp,symbol,pindex->nHeight);
|
||||
komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,0,0,0,0);
|
||||
komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0);
|
||||
}
|
||||
komodo_currentheight_set(chainActive.Tip()->nHeight);
|
||||
/*if ( komodo_is_issuer() != 0 )
|
||||
@@ -506,14 +530,14 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
if ( ((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1) )
|
||||
{
|
||||
memset(&txhash,0,sizeof(txhash));
|
||||
komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0);
|
||||
komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0,0);
|
||||
printf("RATIFIED! >>>>>>>>>> new notaries.%d newheight.%d from height.%d\n",numvalid,(((height+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,height);
|
||||
} else printf("signedmask.%llx numvalid.%d wt.%d numnotaries.%d\n",(long long)signedmask,numvalid,bitweight(signedmask),numnotaries);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( pindex->nHeight == hwmheight && (hwmheight % 100) == 0 )
|
||||
komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,0,0,0,0);
|
||||
if ( pindex->nHeight == hwmheight )
|
||||
komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,pindex->nHeight,0,0,0,0);
|
||||
} else printf("komodo_connectblock: unexpected null pindex\n");
|
||||
KOMODO_INITDONE = (uint32_t)time(NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user