From 2d657c5bac193ca7c24d639dd3eb4a72ff2e192f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 31 Oct 2016 16:51:59 -0300 Subject: [PATCH] test --- src/komodo.h | 15 +++++++++------ src/komodo_gateway.h | 22 ++++++---------------- src/komodo_globals.h | 2 +- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 8ccd7c8cf..a338787c2 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -343,12 +343,15 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) uint8_t scriptbuf[4096],pubkeys[64][33]; uint256 kmdtxid,btctxid,txhash; int32_t i,j,k,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count; komodo_init(); - KOMODO_INITDONE = (uint32_t)time(NULL); -#ifdef KOMODO_ISSUER - komodo_gateway_issuer(); -#else - komodo_gateway_redeemer(); -#endif + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + { + while ( KOMODO_REALTIME == 0 || time(NULL) < KOMODO_REALTIME+10 ) + { + fprintf(stderr,"komodo_connect.(%s) waiting for realtime\n",ASSETCHAINS_SYMBOL); + sleep(3); + } + KOMODO_INITDONE = (uint32_t)time(NULL); + } if ( pindex != 0 ) { height = pindex->nHeight; diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f010c5649..dc4e98788 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -211,9 +211,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { uint8_t rmd160[20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo=0; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; int64_t fiatoshis,checktoshis; const char *typestr = "unknown"; tokomodo = (komodo_is_issuer() == 0); - for (i=0; i %s ",opretbuf[0],tokomodo,dstr(fiatoshis),shortflag!=0?'-':'+',base,coinaddr); + //for (i=0; i %s ",opretbuf[0],tokomodo,dstr(fiatoshis),shortflag!=0?'-':'+',base,coinaddr); if ( opretbuf[0] == ((tokomodo == 0) ? 'D' : 'W') ) { if ( opretlen == 34 ) @@ -377,6 +377,7 @@ void komodo_gateway_iteration(char *symbol) char *retstr; int32_t i,kmdheight; cJSON *infoobj,*result; uint256 zero; uint16_t port = 7771; if ( KMDHEIGHT <= 0 ) KMDHEIGHT = 1; + KOMODO_REALTIME = 0; if ( (retstr= komodo_issuemethod((char *)"getinfo",0,port)) != 0 ) { if ( (infoobj= cJSON_Parse(retstr)) != 0 ) @@ -396,6 +397,8 @@ void komodo_gateway_iteration(char *symbol) printf("error KMDHEIGHT %d\n",KMDHEIGHT); break; } + if ( KMDHEIGHT == kmdheight ) + KOMODO_REALTIME = (uint32_t)time(NULL); usleep(10000); } } @@ -409,16 +412,3 @@ void komodo_gateway_iteration(char *symbol) sleep(30); } } - -#ifdef KOMODO_ISSUER -void komodo_gateway_issuer() // from "assetchain" connectblock() -{ - // check for redeems -} -#else - -void komodo_gateway_redeemer() // from "KMD" connectblock() -{ - -} -#endif diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 11062e866..4cd550141 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -29,6 +29,6 @@ uint64_t ASSETCHAINS_SUPPLY = 10; int32_t NOTARIZED_HEIGHT,Num_nutxos,KMDHEIGHT = 43000; uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID; pthread_mutex_t komodo_mutex; -uint32_t KOMODO_INITDONE; +uint32_t KOMODO_INITDONE,KOMODO_REALTIME; char KMDUSERPASS[1024]; uint16_t BITCOIND_PORT = 7771; uint64_t KOMODO_DEPOSIT,PENDING_KOMODO_TX;