This commit is contained in:
jl777
2016-11-19 19:03:56 -03:00
parent 44a80e607a
commit 6eb41a2f0b

View File

@@ -560,14 +560,8 @@ int32_t komodo_longestchain();
void komodo_passport_iteration()
{
static long lastpos[34],didinit; static char userpass[33][1024];
FILE *fp; int32_t baseid,isrealtime,refid,blocks,longest; struct komodo_state *sp; char *retstr,fname[512],*base,symbol[16],dest[16]; cJSON *infoobj,*result; uint16_t port; uint32_t magic,buf[3];
/*if ( didinit == 0 )
{
for (baseid=0; baseid<=32; baseid++)
komodo_userpass(userpass[baseid],CURRENCIES[baseid]);
didinit = 1;
}*/
static long lastpos[34]; static uint64_t prevRTmask; static char userpass[33][1024];
FILE *fp; int32_t baseid,isrealtime,refid,blocks,longest; struct komodo_state *sp; char *retstr,fname[512],*base,symbol[16],dest[16]; cJSON *infoobj,*result; uint64_t RTmask = 0; uint16_t port; uint32_t magic,buf[3];
if ( ASSETCHAINS_SYMBOL[0] == 0 )
refid = 33;
else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1;
@@ -602,7 +596,10 @@ void komodo_passport_iteration()
if ( fread(buf,1,sizeof(buf),fp) == sizeof(buf) )
{
if ( buf[0] != 0 && buf[0] == buf[1] )
{
isrealtime = 1;
RTmask |= (1LL << baseid);
}
}
fclose(fp);
}
@@ -615,32 +612,23 @@ void komodo_passport_iteration()
buf[0] = (uint32_t)chainActive.Tip()->nHeight;
buf[1] = (uint32_t)komodo_longestchain();
if ( buf[0] != 0 && buf[0] == buf[1] )
{
buf[2] = (uint32_t)time(NULL);
RTmask |= (1LL << baseid);
}
if ( fwrite(buf,1,sizeof(buf),fp) != sizeof(buf) )
fprintf(stderr,"[%s] %s error writing realtime\n",ASSETCHAINS_SYMBOL,base);
fclose(fp);
}
}
/*if ( (retstr= komodo_issuemethod(userpass[baseid],(char *)"getinfo",0,port)) != 0 )
{
if ( (infoobj= cJSON_Parse(retstr)) != 0 )
{
if ( (result= jobj(infoobj,(char *)"result")) != 0 )
{
blocks = juint(result,(char *)"blocks");
longest = juint(result,(char *)"longestchain");
//printf("%s.(%d L%d) ",base,blocks,longest);
if ( blocks > 0 && blocks == longest )
isrealtime = 1;
}
free_json(infoobj);
}
else printf("[%s] %s (%s)\n",ASSETCHAINS_SYMBOL,base,retstr);
free(retstr);
} // else printf("%s port.%u no getinfo\n",base,port);*/
if ( sp != 0 )
sp->KOMODO_REALTIME = isrealtime * (uint32_t)time(NULL);
}
if ( RTmask != prevRTmask )
{
printf("[%s] new RTmask %llx\n",ASSETCHAINS_SYMBOL,RTmask);
prevRTmask = RTmask;
}
}
#endif