From 43450135b580c27628eaef8ad7e8bdacc36a7971 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 18:07:04 -0300 Subject: [PATCH] test --- src/komodo_gateway.h | 17 ++++++++++------- src/main.cpp | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index aec40dab6..418774fad 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -560,7 +560,7 @@ void komodo_iteration(char *symbol) 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; uint16_t port; uint32_t magic; + 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; if ( didinit == 0 ) { for (baseid=0; baseid<=32; baseid++) @@ -598,14 +598,17 @@ void komodo_passport_iteration() { if ( (infoobj= cJSON_Parse(retstr)) != 0 ) { - blocks = juint(infoobj,(char *)"blocks"); - longest = juint(infoobj,(char *)"longestchain"); - printf("(%s %d %d) ",base,blocks,longest); - if ( blocks > 0 && blocks == longest ) - isrealtime = 1; + if ( (result= jobj(infoobj,"result")) != 0 ) + { + blocks = juint(infoobj,(char *)"blocks"); + longest = juint(infoobj,(char *)"longestchain"); + printf("%s.(%d L%d) ",base,blocks,longest); + if ( blocks > 0 && blocks == longest ) + isrealtime = 1; + } free_json(infoobj); } - printf("(%s)\n",retstr); + //printf("(%s)\n",retstr); free(retstr); } else printf("%s port.%u no getinfo\n",base,port); } else printf("fname.(%s) cant open\n",fname); diff --git a/src/main.cpp b/src/main.cpp index d070178d5..822fc76ce 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -535,10 +535,10 @@ CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& loc // Find the first block the caller has in the main chain BOOST_FOREACH(const uint256& hash, locator.vHave) { BlockMap::iterator mi = mapBlockIndex.find(hash); - if (mi != mapBlockIndex.end()) + if (mi != 0 && mi != mapBlockIndex.end()) { CBlockIndex* pindex = (*mi).second; - if (chain.Contains(pindex)) + if (pindex != 0 && chain.Contains(pindex)) return pindex; } }