From 95386444da68c8d290b22683e9982564cf39e264 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 4 Jul 2019 23:16:37 -1100 Subject: [PATCH] Polling tweaks netinfo --- src/komodo_nSPV.h | 63 +++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/src/komodo_nSPV.h b/src/komodo_nSPV.h index f67fe7385..5b9e8eca0 100644 --- a/src/komodo_nSPV.h +++ b/src/komodo_nSPV.h @@ -790,6 +790,8 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req } // nSPV client. VERY simplistic "single threaded" networking model. for production GUI best to multithread, etc. +#define NSPV_POLLITERS 15 +#define NSPV_POLLMICROS 100000 CAmount AmountFromValue(const UniValue& value); int32_t bitcoin_base58decode(uint8_t *data,char *coinaddr); @@ -882,25 +884,6 @@ UniValue _NSPV_getinfo_json(struct NSPV_inforesp *ptr) return(result); } -UniValue NSPV_getinfo_json() -{ - uint8_t msg[64]; int32_t i,len = 0; struct NSPV_inforesp I; - //if ( NSPV_inforesult.height != 0 ) - // return(_NSPV_getinfo_json(&NSPV_inforesult)); - msg[len++] = NSPV_INFO; - if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 ) - { - for (i=0; i<10; i++) - { - usleep(100000); - if ( NSPV_inforesult.height != 0 ) - return(_NSPV_getinfo_json(&NSPV_inforesult)); - } - } - memset(&I,0,sizeof(I)); - return(_NSPV_getinfo_json(&NSPV_inforesult)); -} - UniValue NSPV_utxoresp_json(struct NSPV_utxoresp *utxos,int32_t numutxos) { UniValue array(UniValue::VARR); int32_t i; @@ -1003,6 +986,28 @@ UniValue NSPV_login(char *wifstr) return(result); } +UniValue NSPV_getinfo_json() +{ + uint8_t msg[64]; int32_t i,len = 0; struct NSPV_inforesp I; + NSPV_inforesp_purge(&NSPV_inforesult); + msg[len++] = NSPV_INFO; + for (iters=0; iters<3; iters++) + { + fprintf(stderr,"issue getinfo\n"); + if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 ) + { + for (i=0; i>1) != 0 ) { - for (i=0; i<10; i++) + for (i=0; i= NSPV_inforesult.height ) return(NSPV_utxosresp_json(&NSPV_utxosresult)); } @@ -1046,9 +1051,9 @@ UniValue NSPV_notarizations(int32_t height) len += iguana_rwnum(1,&msg[len],sizeof(height),&height); if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 ) { - for (i=0; i<10; i++) + for (i=0; i= height ) return(NSPV_ntzs_json(&NSPV_ntzsresult)); } @@ -1067,9 +1072,9 @@ UniValue NSPV_hdrsproof(int32_t prevheight,int32_t nextheight) len += iguana_rwnum(1,&msg[len],sizeof(nextheight),&nextheight); if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 ) { - for (i=0; i<10; i++) + for (i=0; i= nextheight ) return(NSPV_ntzsproof_json(&NSPV_ntzsproofresult)); } @@ -1089,9 +1094,9 @@ UniValue NSPV_txproof(uint256 txid,int32_t height) //fprintf(stderr,"req txproof %s at height.%d\n",txid.GetHex().c_str(),height); if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 ) { - for (i=0; i<10; i++) + for (i=0; i>1) != 0 ) { - for (i=0; i<10; i++) + for (i=0; i