test
This commit is contained in:
@@ -192,10 +192,8 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar
|
|||||||
komodo_statefname(fname,ASSETCHAINS_SYMBOL,(char *)"komodostate");
|
komodo_statefname(fname,ASSETCHAINS_SYMBOL,(char *)"komodostate");
|
||||||
if ( (fp= fopen(fname,"rb+")) != 0 )
|
if ( (fp= fopen(fname,"rb+")) != 0 )
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&komodo_mutex);
|
|
||||||
while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 )
|
while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 )
|
||||||
;
|
;
|
||||||
pthread_mutex_unlock(&komodo_mutex);
|
|
||||||
} else fp = fopen(fname,"wb+");
|
} else fp = fopen(fname,"wb+");
|
||||||
printf("fname.(%s) fpos.%ld\n",fname,ftell(fp));
|
printf("fname.(%s) fpos.%ld\n",fname,ftell(fp));
|
||||||
KOMODO_INITDONE = (uint32_t)time(NULL);
|
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
|
if ( fp != 0 ) // write out funcid, height, other fields, call side effect function
|
||||||
{
|
{
|
||||||
//printf("fpos.%ld ",ftell(fp));
|
//printf("fpos.%ld ",ftell(fp));
|
||||||
pthread_mutex_lock(&komodo_mutex);
|
|
||||||
if ( KMDheight != 0 )
|
if ( KMDheight != 0 )
|
||||||
{
|
{
|
||||||
if ( KMDtimestamp != 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);
|
//komodo_notarized_update(height,NOTARIZED_HEIGHT,NOTARIZED_HASH,NOTARIZED_DESTTXID);
|
||||||
}
|
}
|
||||||
fflush(fp);
|
fflush(fp);
|
||||||
pthread_mutex_unlock(&komodo_mutex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 *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);
|
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 = (struct komodo_event *)calloc(1,len);
|
||||||
ep->len = len;
|
ep->len = len;
|
||||||
ep->height = height;
|
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);
|
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 = (struct komodo_event **)realloc(sp->Komodo_events,(1 + sp->Komodo_numevents) * sizeof(*sp->Komodo_events));
|
||||||
sp->Komodo_events[sp->Komodo_numevents++] = ep;
|
sp->Komodo_events[sp->Komodo_numevents++] = ep;
|
||||||
|
portable_mutex_unlock(&komodo_mutex);
|
||||||
return(ep);
|
return(ep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
printf("komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
portable_mutex_lock(&komodo_mutex);
|
||||||
sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS));
|
sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS));
|
||||||
np = &sp->NPOINTS[sp->NUM_NPOINTS++];
|
np = &sp->NPOINTS[sp->NUM_NPOINTS++];
|
||||||
memset(np,0,sizeof(*np));
|
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_HEIGHT = np->notarized_height = notarized_height;
|
||||||
sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash;
|
sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash;
|
||||||
sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid;
|
sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid;
|
||||||
|
portable_mutex_unlock(&komodo_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
//struct komodo_state *komodo_stateptr(char *symbol,char *dest);
|
//struct komodo_state *komodo_stateptr(char *symbol,char *dest);
|
||||||
|
|||||||
@@ -285,10 +285,12 @@ void komodo_pvals(int32_t height,uint32_t *pvals,uint8_t numpvals)
|
|||||||
KMDBTC = ((double)kmdbtc / (1000000000. * 1000.));
|
KMDBTC = ((double)kmdbtc / (1000000000. * 1000.));
|
||||||
BTCUSD = ((double)btcusd / (1000000000. / 1000.));
|
BTCUSD = ((double)btcusd / (1000000000. / 1000.));
|
||||||
CNYUSD = ((double)cnyusd / 1000000000.);
|
CNYUSD = ((double)cnyusd / 1000000000.);
|
||||||
|
portable_mutex_lock(&komodo_mutex);
|
||||||
PVALS = (uint32_t *)realloc(PVALS,(NUM_PRICES+1) * sizeof(*PVALS) * 36);
|
PVALS = (uint32_t *)realloc(PVALS,(NUM_PRICES+1) * sizeof(*PVALS) * 36);
|
||||||
PVALS[36 * NUM_PRICES] = height;
|
PVALS[36 * NUM_PRICES] = height;
|
||||||
memcpy(&PVALS[36 * NUM_PRICES + 1],pvals,sizeof(*pvals) * 35);
|
memcpy(&PVALS[36 * NUM_PRICES + 1],pvals,sizeof(*pvals) * 35);
|
||||||
NUM_PRICES++;
|
NUM_PRICES++;
|
||||||
|
portable_mutex_unlock(&komodo_mutex);
|
||||||
if ( 0 )
|
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);
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user