From 48a3cd18c9c829e9f0e0298e2fcd8b3e4f27e1ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 11:50:57 -0300 Subject: [PATCH] test --- src/komodo_events.h | 2 +- src/komodo_gateway.h | 6 +++--- src/komodo_globals.h | 2 +- src/komodo_utils.h | 12 ++++-------- src/miner.cpp | 6 +++--- src/wallet/rpcwallet.cpp | 4 ++-- 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/komodo_events.h b/src/komodo_events.h index b11b1e101..d7411737f 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -112,7 +112,7 @@ void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height) { if ( ep->height < height ) break; - printf("[%s] undo %s event.%c ht.%d for rewind.%d\n",ASSETCHAINS_SYMBOL,symbol,ep->type,ep->height,height); + //printf("[%s] undo %s event.%c ht.%d for rewind.%d\n",ASSETCHAINS_SYMBOL,symbol,ep->type,ep->height,height); komodo_event_undo(sp,ep); sp->Komodo_numevents--; } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c9a92ac43..f36c71e98 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -136,7 +136,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,uint8_t uint64_t komodo_paxtotal() { struct pax_transaction *pax,*tmp; int32_t ht; uint64_t total = 0; - if ( komodo_isrealtime(&ht,ASSETCHAINS_SYMBOL) == 0 ) + if ( komodo_isrealtime(&ht) == 0 ) return(0); HASH_ITER(hh,PAX,pax,tmp) { @@ -161,7 +161,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to if ( tokomodo == 0 ) { opcode = 'I'; - if ( komodo_isrealtime(&ht,ASSETCHAINS_SYMBOL) == 0 ) + if ( komodo_isrealtime(&ht) == 0 ) return(0); } else opcode = 'X'; @@ -437,7 +437,7 @@ void komodo_passport_iteration() if ( buf[0] != 0 && buf[0] == buf[1] ) { buf[2] = (uint32_t)time(NULL); - RTmask |= (1LL << baseid); + RTmask |= (1LL << baseid) | 1; memcpy(refsp->RTbufs[baseid+1],buf,sizeof(refsp->RTbufs[baseid+1])); if ( refid != 0 ) memcpy(refsp->RTbufs[0],buf,sizeof(refsp->RTbufs[0])); diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 83b8a0ae9..9415a16d6 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -20,7 +20,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) void komodo_init(int32_t height); void komodo_assetchain_pubkeys(char *jsonstr); int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33); -int32_t komodo_isrealtime(int32_t *kmdheightp,char *target); +int32_t komodo_isrealtime(int32_t *kmdheightp); uint64_t komodo_paxtotal(); pthread_mutex_t komodo_mutex; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 96e6a9905..7f23d5af7 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1512,17 +1512,13 @@ struct komodo_state *komodo_stateptr(char *symbol,char *dest) return(komodo_stateptrget(symbol)); } -int32_t komodo_isrealtime(int32_t *kmdheightp,char *target) +int32_t komodo_isrealtime(int32_t *kmdheightp) { - char symbol[16],dest[16]; int32_t baseid; uint64_t mask; struct komodo_state *sp; + char symbol[16],dest[16]; uint64_t mask; struct komodo_state *sp; *kmdheightp = 0; - if ( target == 0 || target[0] == 0 ) - target = (char *)"KMD"; - if ( (sp= komodo_stateptrget(target)) != 0 ) + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) { - if ( (baseid= komodo_baseid(target)) < 0 ) - return(0); - mask = (1LL << 32) | (1LL << baseid); + mask = (1LL << 32) | 1LL; if ( (sp->RTmask & mask) != mask ) { printf("%s not RT mask.%llx vs RTmask.%llx\n",target,(long long)mask,(long long)sp->RTmask); diff --git a/src/miner.cpp b/src/miner.cpp index e74c07702..367584592 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -111,7 +111,7 @@ int32_t komodo_pax_opreturn(uint8_t *opret,int32_t maxsize); uint64_t komodo_paxtotal(); int32_t komodo_is_issuer(); int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *symbol,int32_t tokomodo); -int32_t komodo_isrealtime(int32_t *kmdheightp,char *target); +int32_t komodo_isrealtime(int32_t *kmdheightp); CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { @@ -123,12 +123,12 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) CBlock *pblock = &pblocktemplate->block; // pointer for convenience if ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight >= 100 ) { - isrealtime = komodo_isrealtime(&kmdheight,ASSETCHAINS_SYMBOL); + isrealtime = komodo_isrealtime(&kmdheight); fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u KOMODO_ON_DEMAND.%d\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),isrealtime,KOMODO_ON_DEMAND); while ( KOMODO_ON_DEMAND == 0 ) { deposits = komodo_paxtotal(); - if ( KOMODO_INITDONE == 0 || komodo_isrealtime(&kmdheight,ASSETCHAINS_SYMBOL) == 0 ) + if ( KOMODO_INITDONE == 0 || komodo_isrealtime(&kmdheight) == 0 ) { //fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f\n",KOMODO_INITDONE,isrealtime,(double)deposits/COIN); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fe3b2a854..b96b0a48a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -481,7 +481,7 @@ int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_ extern char ASSETCHAINS_SYMBOL[16]; int32_t komodo_is_issuer(); int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); -int32_t komodo_isrealtime(int32_t *kmdheightp,char *target); +int32_t komodo_isrealtime(int32_t *kmdheightp); Value paxdeposit(const Array& params, bool fHelp) { @@ -529,7 +529,7 @@ Value paxwithdraw(const Array& params, bool fHelp) return 0; if (fHelp || params.size() != 2) throw runtime_error("paxwithdraw \"address\" fiatamount"); - if ( komodo_isrealtime(&kmdheight,(char *)"KMD") == 0 ) + if ( komodo_isrealtime(&kmdheight) == 0 ) return(0); LOCK2(cs_main, pwalletMain->cs_wallet); CBitcoinAddress address(params[0].get_str());