Fix syntax errors because I don't know C++ well enough to type 1000 lines of code without syntax errors

This commit is contained in:
jl777
2018-04-12 16:35:37 +03:00
parent 51dab14914
commit 1b491957e4
3 changed files with 23 additions and 23 deletions

View File

@@ -59,7 +59,7 @@ int32_t komodo_MoMoMdata(char *hexstr,int32_t hexsize,struct komodo_ccdataMoMoM
{ {
if ( ccdata->MoMdata.height < kmdheight ) if ( ccdata->MoMdata.height < kmdheight )
{ {
fprintf(stderr,"%s notarized.%d kmd.%d\n",ccdata->symbol,ccdata->MoMdata.notarized_height,ccdata->MoMdata.height); fprintf(stderr,"%s notarized.%d kmd.%d\n",ccdata->symbol,ccdata->MoMdata.notarization_height,ccdata->MoMdata.height);
if ( strcmp(ccdata->symbol,symbol) == 0 ) if ( strcmp(ccdata->symbol,symbol) == 0 )
{ {
if ( endi == 0 ) if ( endi == 0 )
@@ -67,16 +67,16 @@ int32_t komodo_MoMoMdata(char *hexstr,int32_t hexsize,struct komodo_ccdataMoMoM
len += iguana_rwnum(1,&hexdata[len],sizeof(ccdata->CCid),(uint8_t *)&ccdata->CCid); len += iguana_rwnum(1,&hexdata[len],sizeof(ccdata->CCid),(uint8_t *)&ccdata->CCid);
endi = ccdata->MoMdata.height; endi = ccdata->MoMdata.height;
} }
if ( (mdata.numpairs == 1 && notarized_height == 0) || ccdata->MoMdata.notarized_height <= notarized_height ) if ( (mdata->numpairs == 1 && notarized_height == 0) || ccdata->MoMdata.notarization_height <= notarized_height )
{ {
starti = ccdata->MoMdata.height + 1; starti = ccdata->MoMdata.height + 1;
break; break;
} }
item = cJSON_CreateArray(); item = cJSON_CreateArray();
jaddinum(item,ccdata->MoMdata.notarized_height); jaddinum(item,ccdata->MoMdata.notarization_height);
jaddinum(item,offset); jaddinum(item,offset);
jaddi(pairs,item); jaddi(pairs,item);
mdata.numpairs++; mdata->numpairs++;
} }
if ( offset >= max ) if ( offset >= max )
{ {
@@ -99,30 +99,30 @@ int32_t komodo_MoMoMdata(char *hexstr,int32_t hexsize,struct komodo_ccdataMoMoM
MoMoM = iguana_merkle(tree,offset); MoMoM = iguana_merkle(tree,offset);
jaddbits256(retjson,(char *)"MoMoM",MoMoM); jaddbits256(retjson,(char *)"MoMoM",MoMoM);
jaddnum(retjson,(char *)"MoMoMdepth",offset); jaddnum(retjson,(char *)"MoMoMdepth",offset);
if ( mdata.numpairs > 0 && mdata.numpairs == cJSON_GetArraySize(pairs) ) if ( mdata->numpairs > 0 && mdata.numpairs == cJSON_GetArraySize(pairs) )
{ {
len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->kmdstarti); len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->kmdstarti);
len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->kmdendi); len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->kmdendi);
len += iguana_rwbignum(1,&hexdata[len],sizeof(mdata->MoMoM),(uint8_t *)&mdata->MoMoM); len += iguana_rwbignum(1,&hexdata[len],sizeof(mdata->MoMoM),(uint8_t *)&mdata->MoMoM);
len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->MoMoMdepth); len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->MoMoMdepth);
len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->numpairs); len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->numpairs);
mdata.pairs = (struct komodo_ccdatapair *)calloc(mdata.numpairs,sizeof(*mdata.pairs)); mdata->pairs = (struct komodo_ccdatapair *)calloc(mdata->numpairs,sizeof(*mdata->pairs));
for (i=0; i<mdata.numpairs; i++) for (i=0; i<mdata->numpairs; i++)
{ {
if ( len + sizeof(uint32_t)*2 > sizeof(hexdata) ) if ( len + sizeof(uint32_t)*2 > sizeof(hexdata) )
{ {
fprintf(stderr,"%s %d %d i.%d of %d exceeds hexdata.%d\n",symbol,kmdheight,notarized_height,i,mdata.numpairs,(int32_t)sizeof(hexdata)); fprintf(stderr,"%s %d %d i.%d of %d exceeds hexdata.%d\n",symbol,kmdheight,notarized_height,i,mdata->numpairs,(int32_t)sizeof(hexdata));
break; break;
} }
item = jitem(pairs,i); item = jitem(pairs,i);
mdata.pairs[i].notarization_height = juint(0,jitem(item,0)); mdata->pairs[i].notarization_height = juint(0,jitem(item,0));
mdata.pairs[i].MoMoMoffset = juint(0,jitem(item,1)); mdata->pairs[i].MoMoMoffset = juint(0,jitem(item,1));
len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata.pairs[i].notarization_height); len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->pairs[i].notarization_height);
len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata.pairs[i].MoMoMoffset); len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->pairs[i].MoMoMoffset);
} }
if ( i == mdata.numpairs && len*2+1 < hexsize ) if ( i == mdata->numpairs && len*2+1 < hexsize )
{ {
init_hexbyte_noT(hexstr,hexdata,len); init_hexbytes_noT(hexstr,hexdata,len);
retval = 0; retval = 0;
} else fprintf(stderr,"%s %d %d too much hexdata[%d] for hexstr[%d]\n",symbol,kmdheight,notarized_height,len,hexsize); } else fprintf(stderr,"%s %d %d too much hexdata[%d] for hexstr[%d]\n",symbol,kmdheight,notarized_height,len,hexsize);
} }
@@ -137,7 +137,7 @@ int32_t komodo_MoMoMdata(char *hexstr,int32_t hexsize,struct komodo_ccdataMoMoM
int32_t komodo_rwccdata(char *thischain,int32_t rwflag,struct komodo_ccdata *ccdata,struct komodo_ccdataMoMoM *MoMoMdata) int32_t komodo_rwccdata(char *thischain,int32_t rwflag,struct komodo_ccdata *ccdata,struct komodo_ccdataMoMoM *MoMoMdata)
{ {
bits256 hash; int32_t i; struct komodo_ccdata *ptr; struct notarized_checkpoint *np; bits256 hash,zero; int32_t i; struct komodo_ccdata *ptr; struct notarized_checkpoint *np;
if ( rwflag == 0 ) if ( rwflag == 0 )
{ {
// load from disk // load from disk
@@ -150,7 +150,7 @@ int32_t komodo_rwccdata(char *thischain,int32_t rwflag,struct komodo_ccdata *ccd
CC_firstheight = ccdata->MoMdata.height; CC_firstheight = ccdata->MoMdata.height;
for (i=0; i<32; i++) for (i=0; i<32; i++)
hash.bytes[i] = ((uint8_t *)&ccdata->MoMdata.MoM)[31-i]; 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); 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.notarization_height,hash.ToString().c_str(),ccdata->MoMdata.height,ccdata->MoMdata.txi);
if ( ASSETCHAINS_SYMBOL[0] == 0 ) if ( ASSETCHAINS_SYMBOL[0] == 0 )
{ {
if ( CC_data != 0 && (CC_data->MoMdata.height > ccdata->MoMdata.height || (CC_data->MoMdata.height == ccdata->MoMdata.height && CC_data->MoMdata.txi >= ccdata->MoMdata.txi)) ) if ( CC_data != 0 && (CC_data->MoMdata.height > ccdata->MoMdata.height || (CC_data->MoMdata.height == ccdata->MoMdata.height && CC_data->MoMdata.txi >= ccdata->MoMdata.txi)) )
@@ -172,9 +172,10 @@ int32_t komodo_rwccdata(char *thischain,int32_t rwflag,struct komodo_ccdata *ccd
{ {
for (i=0; i<MoMoMdata->numpairs; i++) for (i=0; i<MoMoMdata->numpairs; i++)
{ {
if ( (np= komodo_npptr(MoMoMdata->pairs[i].notarized_height)) != 0 ) if ( (np= komodo_npptr(MoMoMdata->pairs[i].notarization_height)) != 0 )
{ {
if ( bits256_nonz(np->MoMoM) == 0 ) memset(&zero,0,sizeof(zero));
if ( np->MoMoM == zero )
{ {
np->MoMoM = MoMoMdata->MoMoM; np->MoMoM = MoMoMdata->MoMoM;
np->MoMoMdepth = MoMoMdata->MoMoMdepth; np->MoMoMdepth = MoMoMdata->MoMoMdepth;
@@ -182,10 +183,9 @@ int32_t komodo_rwccdata(char *thischain,int32_t rwflag,struct komodo_ccdata *ccd
np->kmdstarti = MoMoMdata->kmdstarti; np->kmdstarti = MoMoMdata->kmdstarti;
np->kmdendi = MoMoMdata->kmdendi; np->kmdendi = MoMoMdata->kmdendi;
} }
else if ( bits256_cmp(np->MoMoM,MoMoMdata->MoMoM) != 0 || np->MoMoMdepth != MoMoMdata->MoMoMdepth || np->MoMoMoffset != MoMoMdata->MoMoMoffset || np->kmdstarti != MoMoMdata->kmdstarti || np->kmdendi != MoMoMdata->kmdendi ) else if ( np->MoMoM != MoMoMdata->MoMoM || np->MoMoMdepth != MoMoMdata->MoMoMdepth || np->MoMoMoffset != MoMoMdata->MoMoMoffset || np->kmdstarti != MoMoMdata->kmdstarti || np->kmdendi != MoMoMdata->kmdendi )
{ {
char str[65],str2[65]; fprintf(stderr,"preexisting MoMoM mismatch: %s (%d %d %d %d) vs %s (%d %d %d %d)\n",np->MoMoM.ToString().c_str(),np->MoMoMdepth,np->MoMoMoffset,np->kmdstarti,np->kmdendi,MoMoMdata->MoMoM.ToString().c_str(),,MoMoMdata->MoMoMdepth,MoMoMdata->MoMoMoffset,MoMoMdata->kmdstarti,MoMoMdata->kmdendi);
fprintf(stderr,"preexisting MoMoM mismatch: %s (%d %d %d %d) vs %s (%d %d %d %d)\n",bits256_str(str,np->MoMoM),np->MoMoMdepth,np->MoMoMoffset,np->kmdstarti,np->kmdendi,bits256_str(str2,MoMoMdata->MoMoM),,MoMoMdata->MoMoMdepth,MoMoMdata->MoMoMoffset,MoMoMdata->kmdstarti,MoMoMdata->kmdendi);
} }
} }
} }

View File

@@ -423,7 +423,7 @@ int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,in
*MoMoMoffsetp = np->MoMoMoffset; *MoMoMoffsetp = np->MoMoMoffset;
*MoMoMdepthp = np->MoMoMdepth; *MoMoMdepthp = np->MoMoMdepth;
*kmdstartip = np->kmdstarti; *kmdstartip = np->kmdstarti;
*kmdendip = np->kmdendip; *kmdendip = np->kmdendi;
return(np->MoMdepth); return(np->MoMdepth);
} }
*notarized_htp = *MoMoMoffsetp = *MoMoMdepthp = *kmdstartip = *kmdendip = 0; *notarized_htp = *MoMoMoffsetp = *MoMoMdepthp = *kmdstartip = *kmdendip = 0;

View File

@@ -100,7 +100,7 @@ struct komodo_ccdatapair { int32_t notarization_height; uint32_t MoMoMoffset; };
struct komodo_ccdataMoMoM struct komodo_ccdataMoMoM
{ {
uint256 MoMoM; uint256 MoMoM;
int32_t kmdstarti,kmdendi,MoMoMdepth,numpairs,len; int32_t kmdstarti,kmdendi,MoMoMoffset,MoMoMdepth,numpairs,len;
struct komodo_ccdatapair *pairs; struct komodo_ccdatapair *pairs;
}; };