test
This commit is contained in:
@@ -460,7 +460,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
sleep(30);
|
||||
}
|
||||
}*/
|
||||
sp->KOMODO_REALTIME = KOMODO_INITDONE = (uint32_t)time(NULL);
|
||||
KOMODO_INITDONE = (uint32_t)time(NULL);
|
||||
if ( pindex != 0 )
|
||||
{
|
||||
height = pindex->nHeight;
|
||||
|
||||
@@ -127,6 +127,8 @@ void komodo_setkmdheight(struct komodo_state *sp,int32_t kmdheight,uint32_t time
|
||||
sp->SAVEDHEIGHT = kmdheight;
|
||||
sp->SAVEDTIMESTAMP = timestamp;
|
||||
}
|
||||
if ( kmdheight > sp->CURRENT_HEIGHT )
|
||||
sp->CURRENT_HEIGHT = kmdheight;
|
||||
}
|
||||
|
||||
void komodo_eventadd_kmdheight(struct komodo_state *sp,char *symbol,int32_t height,int32_t kmdheight,uint32_t timestamp)
|
||||
|
||||
@@ -560,7 +560,7 @@ void komodo_iteration(char *symbol)
|
||||
void komodo_passport_iteration()
|
||||
{
|
||||
static long lastpos[34];
|
||||
FILE *fp; int32_t baseid,refid; struct komodo_state *sp; char fname[512],*base,symbol[16],dest[16];
|
||||
FILE *fp; int32_t baseid,isrealtime,refid,block,longest; struct komodo_state *sp; char *retstr,fname[512],*base,symbol[16],dest[16]; cJSON *infoobj; uint16_t port; uint32_t magic;
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
refid = 33;
|
||||
else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1;
|
||||
@@ -572,6 +572,9 @@ void komodo_passport_iteration()
|
||||
base = (char *)CURRENCIES[baseid];
|
||||
komodo_statefname(fname,baseid<32?base:(char *)"");
|
||||
komodo_nameset(symbol,dest,base);
|
||||
port = komodo_port(base,10,&magic);
|
||||
sp = 0;
|
||||
isrealtime = 0;
|
||||
if ( (fp= fopen(fname,"rb")) != 0 && (sp= komodo_stateptrget(symbol)) != 0 )
|
||||
{
|
||||
//printf("refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base);
|
||||
@@ -585,7 +588,22 @@ void komodo_passport_iteration()
|
||||
//printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]);
|
||||
} //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp));
|
||||
fclose(fp);
|
||||
if ( (retstr= komodo_issuemethod((char *)"getinfo",0,port)) != 0 )
|
||||
{
|
||||
if ( (infoobj= cJSON_Parse(retstr)) != 0 )
|
||||
{
|
||||
blocks = juint(infoobj,"blocks");
|
||||
longest = juint(infoobj,"longestchain");
|
||||
printf("(%s %d %d) ",base,blocks,longest);
|
||||
if ( blocks > 0 && blocks == longest )
|
||||
isrealtime = 1;
|
||||
free_json(infoobj);
|
||||
}
|
||||
free(retstr);
|
||||
}
|
||||
} else printf("fname.(%s) cant open\n",fname);
|
||||
if ( sp != 0 )
|
||||
sp->KOMODO_REALTIME = isrealtime * (uint32_t)time(NULL);
|
||||
} // else use direct data for self via connect
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1358,6 +1358,8 @@ void komodo_configfile(char *symbol,uint16_t port)
|
||||
uint32_t komodo_assetmagic(char *symbol,uint64_t supply)
|
||||
{
|
||||
uint8_t buf[512]; int32_t len = 0;
|
||||
if ( strcmp(symbol,"KMD") == 0 )
|
||||
return(0x8de4eef9);
|
||||
len = iguana_rwnum(1,&buf[len],sizeof(supply),(void *)&supply);
|
||||
strcpy((char *)&buf[len],symbol);
|
||||
len += strlen(symbol);
|
||||
@@ -1379,11 +1381,18 @@ uint32_t komodo_assetmagic(char *symbol,uint64_t supply)
|
||||
|
||||
uint16_t komodo_assetport(uint32_t magic)
|
||||
{
|
||||
return(8000 + (magic % 7777));
|
||||
if ( magic == 0x8de4eef9 )
|
||||
return(7771);
|
||||
else return(8000 + (magic % 7777));
|
||||
}
|
||||
|
||||
uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp)
|
||||
{
|
||||
if ( symbol == 0 || symbol[0] == 0 || strcmp("KMD",symbol) == 0 )
|
||||
{
|
||||
*magicp = 0x8de4eef9;
|
||||
return(7771);
|
||||
}
|
||||
*magicp = komodo_assetmagic(symbol,supply);
|
||||
return(komodo_assetport(*magicp));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user