This commit is contained in:
jl777
2016-11-21 11:10:35 -03:00
parent 71da283a42
commit f42f928860
4 changed files with 6 additions and 4 deletions

View File

@@ -192,10 +192,8 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar
komodo_statefname(fname,ASSETCHAINS_SYMBOL,(char *)"komodostate");
if ( (fp= fopen(fname,"rb+")) != 0 )
{
pthread_mutex_lock(&komodo_mutex);
while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 )
;
pthread_mutex_unlock(&komodo_mutex);
} else fp = fopen(fname,"wb+");
printf("fname.(%s) fpos.%ld\n",fname,ftell(fp));
KOMODO_INITDONE = (uint32_t)time(NULL);
@@ -208,7 +206,6 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar
if ( fp != 0 ) // write out funcid, height, other fields, call side effect function
{
//printf("fpos.%ld ",ftell(fp));
pthread_mutex_lock(&komodo_mutex);
if ( KMDheight != 0 )
{
if ( KMDtimestamp != 0 )
@@ -313,7 +310,6 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar
//komodo_notarized_update(height,NOTARIZED_HEIGHT,NOTARIZED_HASH,NOTARIZED_DESTTXID);
}
fflush(fp);
pthread_mutex_unlock(&komodo_mutex);
}
}

View File

@@ -19,6 +19,7 @@
struct komodo_event *komodo_eventadd(struct komodo_state *sp,int32_t height,char *symbol,uint8_t type,uint8_t *data,uint16_t datalen)
{
struct komodo_event *ep; uint16_t len = (uint16_t)(sizeof(*ep) + datalen);
portable_mutex_lock(&komodo_mutex);
ep = (struct komodo_event *)calloc(1,len);
ep->len = len;
ep->height = height;
@@ -28,6 +29,7 @@ struct komodo_event *komodo_eventadd(struct komodo_state *sp,int32_t height,char
memcpy(ep->space,data,datalen);
sp->Komodo_events = (struct komodo_event **)realloc(sp->Komodo_events,(1 + sp->Komodo_numevents) * sizeof(*sp->Komodo_events));
sp->Komodo_events[sp->Komodo_numevents++] = ep;
portable_mutex_unlock(&komodo_mutex);
return(ep);
}

View File

@@ -168,6 +168,7 @@ void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t not
printf("komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight);
return;
}
portable_mutex_lock(&komodo_mutex);
sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS));
np = &sp->NPOINTS[sp->NUM_NPOINTS++];
memset(np,0,sizeof(*np));
@@ -175,6 +176,7 @@ void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t not
sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height;
sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash;
sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid;
portable_mutex_unlock(&komodo_mutex);
}
//struct komodo_state *komodo_stateptr(char *symbol,char *dest);

View File

@@ -285,10 +285,12 @@ void komodo_pvals(int32_t height,uint32_t *pvals,uint8_t numpvals)
KMDBTC = ((double)kmdbtc / (1000000000. * 1000.));
BTCUSD = ((double)btcusd / (1000000000. / 1000.));
CNYUSD = ((double)cnyusd / 1000000000.);
portable_mutex_lock(&komodo_mutex);
PVALS = (uint32_t *)realloc(PVALS,(NUM_PRICES+1) * sizeof(*PVALS) * 36);
PVALS[36 * NUM_PRICES] = height;
memcpy(&PVALS[36 * NUM_PRICES + 1],pvals,sizeof(*pvals) * 35);
NUM_PRICES++;
portable_mutex_unlock(&komodo_mutex);
if ( 0 )
printf("OP_RETURN.%d KMD %.8f BTC %.6f CNY %.6f NUM_PRICES.%d (%llu %llu %llu)\n",height,KMDBTC,BTCUSD,CNYUSD,NUM_PRICES,(long long)kmdbtc,(long long)btcusd,(long long)cnyusd);
}