Browse Source

Test

pull/4/head
jl777 6 years ago
parent
commit
d269d79ecc
  1. 45
      src/komodo.h
  2. 15
      src/komodo_ccdata.h
  3. 17
      src/komodo_structs.h

45
src/komodo.h

@ -584,8 +584,9 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
if ( j == 1 && opretlen >= len+offset-opoffset )
{
static int32_t last_rewind; int32_t rewindtarget,validated = 0; CBlockIndex *pindex;//
struct komodo_ccdata ccdata;
struct komodo_ccdata ccdata; struct komodo_ccdataMoMoM MoMoMdata;
memset(&ccdata,0,sizeof(ccdata));
memset(&MoMoMdata,0,sizeof(MoMoMdata));
strncpy(ccdata.symbol,(char *)&scriptbuf[len+offset],sizeof(ccdata.symbol));
if ( matched == 0 && bitweight(signedmask) >= KOMODO_MINRATIFY )
notarized = 1;
@ -622,16 +623,16 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
memset(&MoM,0,sizeof(MoM));
MoMdepth = 0;
len += nameoffset;
ccdata.notarized_height = *notarizedheightp;
ccdata.height = height;
ccdata.txi = i;
ccdata.MoMdata.notarized_height = *notarizedheightp;
ccdata.MoMdata.height = height;
ccdata.MoMdata.txi = i;
//printf("nameoffset.%d len.%d + 36 %d vs opretlen.%d\n",nameoffset,len,len+36,opretlen);
if ( len+36-opoffset <= opretlen )
{
len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&MoM);
len += iguana_rwnum(0,&scriptbuf[len],sizeof(MoMdepth),(uint8_t *)&MoMdepth);
ccdata.MoM = MoM;
ccdata.MoMdepth = MoMdepth;
ccdata.MoMdata.MoM = MoM;
ccdata.MoMdata.MoMdepth = MoMdepth;
if ( len+sizeof(ccdata.CCid) <= opretlen )
{
len += iguana_rwnum(0,&scriptbuf[len],sizeof(ccdata.CCid),(uint8_t *)&ccdata.CCid);
@ -641,23 +642,23 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
// MoMoM, depth, numpairs, (notarization ht, MoMoM offset)
if ( len+48-opoffset <= opretlen && strcmp(ccdata.symbol,ASSETCHAINS_SYMBOL) == 0 )
{
len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&ccdata.MoMoMstart);
len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&ccdata.MoMoMend);
len += iguana_rwbignum(0,&scriptbuf[len],sizeof(ccdata.MoMoM),(uint8_t *)&ccdata.MoMoM);
len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&ccdata.MoMoMdepth);
len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&ccdata.numpairs);
ccdata.len += sizeof(ccdata.MoMoM) + sizeof(uint32_t)*4;
if ( len+ccdata.numpairs*8 == opretlen )
len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.MoMoMstart);
len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.MoMoMend);
len += iguana_rwbignum(0,&scriptbuf[len],sizeof(ccdata.MoMoM),(uint8_t *)&MoMoMdata.MoMoM);
len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.MoMoMdepth);
len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.numpairs);
MoMoMdata.len += sizeof(MoMoMdata.MoMoM) + sizeof(uint32_t)*4;
if ( len+MoMoMdata.numpairs*8-opoffset == opretlen )
{
ccdata.pairs = (struct komodo_ccdatapair *)calloc(ccdata.numpairs,sizeof(*ccdata.pairs));
for (k=0; k<ccdata.numpairs; k++)
MoMoMdata.pairs = (struct komodo_ccdatapair *)calloc(MoMoMdata.numpairs,sizeof(*MoMoMdata.pairs));
for (k=0; k<MoMoMdata.numpairs; k++)
{
len += iguana_rwnum(0,&scriptbuf[len],sizeof(int32_t),(uint8_t *)&ccdata.pairs[k].notarization_height);
len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&ccdata.pairs[k].MoMoMoffset);
ccdata.len += sizeof(uint32_t) * 2;
len += iguana_rwnum(0,&scriptbuf[len],sizeof(int32_t),(uint8_t *)&MoMoMdata.pairs[k].notarization_height);
len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.pairs[k].MoMoMoffset);
MoMoMdata.len += sizeof(uint32_t) * 2;
}
} else ccdata.len = 0;
} else ccdata.len = 0;
} else ccdata.len = MoMoMdata.len = 0;
} else ccdata.len = MoMoMdata.len = 0;
}
}
if ( MoM == zero || MoMdepth > 1440 || MoMdepth < 0 )
@ -667,7 +668,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
}
else
{
komodo_rwccdata(ASSETCHAINS_SYMBOL,1,&ccdata);
komodo_rwccdata(ASSETCHAINS_SYMBOL,1,&ccdata,&MoMoMdata);
//printf("[%s] matched.%d VALID (%s) MoM.%s [%d]\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth);
}
if ( ccdata.pairs != 0 )
@ -675,7 +676,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
memset(&ccdata,0,sizeof(ccdata));
}
else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 )
komodo_rwccdata((char *)"KMD",1,&ccdata);
komodo_rwccdata((char *)"KMD",1,&ccdata,0);
if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height )
{
sp->NOTARIZED_HEIGHT = *notarizedheightp;

15
src/komodo_ccdata.h

@ -21,14 +21,14 @@
struct komodo_ccdata
{
uint32_t CCid;
bits256 MoMoM,MoM;
int32_t MoMoMdepth,numpairs,notarized_height,height,txi;
struct ccdatapair *pairs;
uint256 MoMoM,MoM;
int32_t MoMoMstart,MoMoMend,MoMoMdepth,numpairs,notarized_height,height,txi,len,MoMdepth;
struct komodo_ccdatapair *pairs;
char symbol[65];
};
*/
int32_t komodo_rwccdata(char *thischain,int32_t rwflag,struct komodo_ccdata *ccdata)
int32_t komodo_rwccdata(char *thischain,int32_t rwflag,struct komodo_ccdata *ccdata,struct komodo_ccdataMoMoM *MoMoMdata)
{
bits256 hash; int32_t i;
if ( rwflag == 0 )
@ -36,10 +36,13 @@ int32_t komodo_rwccdata(char *thischain,int32_t rwflag,struct komodo_ccdata *ccd
}
for (i=0; i<32; i++)
hash.bytes[i] = ((uint8_t *)&ccdata->MoM)[31-i];
char str[65]; fprintf(stderr,"[%s] ccdata.%s id.%d notarized_ht.%d MoM.%s height.%d/t%d numpairs.%d\n",ASSETCHAINS_SYMBOL,ccdata->symbol,ccdata->CCid,ccdata->notarized_height,bits256_str(str,hash),ccdata->height,ccdata->txi,ccdata->numpairs);
hash.bytes[i] = ((uint8_t *)&ccdata->MoMdata.MoM)[31-i];
char str[65]; fprintf(stderr,"[%s] ccdata.%s id.%d notarized_ht.%d MoM.%s height.%d/t%d\n",ASSETCHAINS_SYMBOL,ccdata->symbol,ccdata->CCid,ccdata->MoMdata.notarized_height,bits256_str(str,hash),ccdata->MoMdata.height,ccdata->MoMdata.txi);
if ( ASSETCHAINS_SYMBOL[0] == 0 )
{
// find/create entry for CCid
// if KMD, for all CCids, get range and calc MoMoM for RPC retrieval
// given MoM height for CCid chain, find the offset and MoMoM
}
else
{

17
src/komodo_structs.h

@ -89,13 +89,22 @@ struct notarized_checkpoint
int32_t nHeight,notarized_height,MoMdepth;
};
struct komodo_ccdataMoM
{
uint256 MoM;
int32_t MoMdepth,notarized_height,height,txi;
};
struct komodo_ccdataMoMoM
{
uint256 MoMoM;
int32_t MoMoMstart,MoMoMend,MoMoMdepth,numpairs;
struct komodo_ccdatapair *pairs;
};
struct komodo_ccdatapair { int32_t notarization_height; uint32_t MoMoMoffset; };
struct komodo_ccdata
{
uint32_t CCid;
uint256 MoMoM,MoM;
int32_t MoMoMstart,MoMoMend,MoMoMdepth,numpairs,notarized_height,height,txi,len,MoMdepth;
struct komodo_ccdatapair *pairs;
struct komodo_ccdataMoM MoMdata;
uint32_t CCid,len;
char symbol[65];
};

Loading…
Cancel
Save