Browse Source

Reorg ccdata

pull/4/head
jl777 6 years ago
parent
commit
dfd07d7878
  1. 4
      src/komodo.h
  2. 23
      src/komodo_ccdata.h
  3. 2
      src/komodo_events.h

4
src/komodo.h

@ -797,7 +797,11 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
else
{
if ( pindex->nHeight != hwmheight )
{
printf("%s hwmheight.%d vs pindex->nHeight.%d t.%u reorg.%d\n",ASSETCHAINS_SYMBOL,hwmheight,pindex->nHeight,(uint32_t)pindex->nTime,hwmheight-pindex->nHeight);
komodo_purge_ccdata((int32_t)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,pindex->nTime,0,0,0,0,zero,0);
}

23
src/komodo_ccdata.h

@ -175,6 +175,29 @@ int32_t komodo_MoMoMdata(char *hexstr,int32_t hexsize,struct komodo_ccdataMoMoM
return(retval);
}
void komodo_purge_ccdata(int32_t height)
{
struct komodo_ccdata *ccdata,*tmpptr;
if ( ASSETCHAINS_SYMBOL[0] == 0 )
{
portable_mutex_lock(&KOMODO_CC_mutex);
DL_FOREACH_SAFE(CC_data,ccdata,tmpptr)
{
if ( ccdata->MoMdata.height >= height )
{
printf("PURGE %s notarized.%d\n",ccdata->MoMdata.symbol,ccdata->MoMdata.notarized_height);
DL_DELETE(ccdata);
free(ccdata);
}
}
portable_mutex_unlock(&KOMODO_CC_mutex);
}
else
{
// purge notarized data
}
}
int32_t komodo_rwccdata(char *thischain,int32_t rwflag,struct komodo_ccdata *ccdata,struct komodo_ccdataMoMoM *MoMoMdata)
{
uint256 hash,zero; bits256 tmp; int32_t i; struct komodo_ccdata *ptr; struct notarized_checkpoint *np;

2
src/komodo_events.h

@ -171,7 +171,7 @@ void komodo_eventadd_kmdheight(struct komodo_state *sp,char *symbol,int32_t heig
}
else
{
fprintf(stderr,"REWIND kmdheight.%d\n",kmdheight);
//fprintf(stderr,"REWIND kmdheight.%d\n",kmdheight);
kmdheight = -kmdheight;
komodo_eventadd(sp,height,symbol,KOMODO_EVENT_REWIND,(uint8_t *)&height,sizeof(height));
if ( sp != 0 )

Loading…
Cancel
Save