From 3cf750c2a42f025e2deaa3ab72a66933b125d5c9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 7 Aug 2019 07:29:21 +0800 Subject: [PATCH] colour --- basilisk/basilisk_DEX.c | 3 +-- iguana/dPoW.h | 4 ++-- iguana/dpow/dpow_fsm.c | 3 +-- iguana/dpow/dpow_network.c | 15 +-------------- iguana/dpow/dpow_rpc.c | 6 ++++-- iguana/dpow/dpow_tx.c | 3 +-- iguana/iguana_payments.c | 2 +- includes/iguana_defines.h | 18 ++++++++++++++++++ 8 files changed, 29 insertions(+), 25 deletions(-) diff --git a/basilisk/basilisk_DEX.c b/basilisk/basilisk_DEX.c index 902f9d5eb..13bbb1699 100755 --- a/basilisk/basilisk_DEX.c +++ b/basilisk/basilisk_DEX.c @@ -532,7 +532,6 @@ char *basilisk_sendrawtransaction(struct supernet_info *myinfo,struct iguana_inf { retstr = _dex_sendrawtransaction(myinfo,coin->symbol,signedtx); } - else retstr = dpow_sendrawtransaction(myinfo,coin,signedtx); + else retstr = dpow_sendrawtransaction(myinfo,coin,signedtx,0); return(retstr); } - diff --git a/iguana/dPoW.h b/iguana/dPoW.h index 670537343..5a17a21b7 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -116,7 +116,7 @@ struct dpow_block struct dpow_recvdata recv[64]; struct dpow_entry notaries[DPOW_MAXRELAYS]; uint32_t MoMdepth,state,starttime,timestamp,waiting,sigcrcs[2],txidcrcs[2],utxocrcs[2],lastepoch,paxwdcrc,lastnanosend; - int32_t rawratifiedlens[2],height,numnotaries,numerrors,completed,minsigs,duration,numratified,isratify,require0,scores[DPOW_MAXRELAYS],destht_start; + int32_t rawratifiedlens[2],height,numnotaries,numerrors,completed,minsigs,duration,numratified,isratify,require0,scores[DPOW_MAXRELAYS]; int8_t myind,bestk,ratifybestk,pendingbestk,pendingratifybestk,matches,bestmatches; cJSON *ratified; uint16_t CCid; @@ -179,7 +179,7 @@ cJSON *dpow_gettransaction(struct supernet_info *myinfo,struct iguana_info *coin cJSON *dpow_getblock(struct supernet_info *myinfo,struct iguana_info *coin,bits256 blockhash); bits256 dpow_getblockhash(struct supernet_info *myinfo,struct iguana_info *coin,int32_t height); bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *coin); -char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx); +char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx, int32_t mine); cJSON *dpow_gettxout(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout); char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address); char *dpow_validateaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address); diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 2fe1c60a8..bef1d8873 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -145,7 +145,7 @@ int32_t dpow_checkutxo(struct supernet_info *myinfo,struct dpow_info *dp,struct jaddistr(addresses,coinaddr); if ( myinfo->nosplit == 0 && (rawtx= iguana_utxoduplicates(myinfo,coin,dp->minerkey33,DPOW_UTXOSIZE,n,&completed,&signedtxid,0,addresses)) != 0 ) { - if ( (sendtx= dpow_sendrawtransaction(myinfo,coin,rawtx)) != 0 ) + if ( (sendtx= dpow_sendrawtransaction(myinfo,coin,rawtx,0)) != 0 ) { printf("sendrawtransaction.(%s)\n",sendtx); free(sendtx); @@ -309,7 +309,6 @@ void dpow_statemachinestart(void *ptr) bp->srccoin = src; bp->destcoin = dest; bp->myind = -1; - bp->destht_start = bp->destcoin->longestchain; for (i=0; inotaries)/sizeof(*bp->notaries); i++) bp->notaries[i].bestk = -1; bp->opret_symbol = dp->symbol; diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 188d8e746..12b772a0f 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -667,7 +667,7 @@ return(clonestr("{\"error\":\"basilisk disabled\"}")); } else if ( dexreq.func == 'S' ) { - retstr = dpow_sendrawtransaction(myinfo,coin,(char *)&dexp->packet[datalen]); + retstr = dpow_sendrawtransaction(myinfo,coin,(char *)&dexp->packet[datalen],0); } else if ( dexreq.func == '*' ) { @@ -2000,19 +2000,6 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru bp->bestmask = dpow_maskmin(bp->recvmask,bp,&bp->bestk); } - // check that block has advanced by 1 on KMD before allowing bestmask to be calculated - if ( strcmp(bp->destcoin->symbol,"KMD") == 0 ) - { - if ( bp->destht_start == bp->destcoin->longestchain ) - return; - } - else - { - if ( bp->height == bp->srccoin->longestchain ) - return; - } - //fprintf(stderr, "[%s] checkpoint ht.%i vs longestchain.%i\n",bp->srccoin->symbol, bp->destht_start, bp->destcoin->longestchain); - dpow_bestconsensus(dp,bp); if ( bp->bestk >= 0 ) bp->notaries[bp->myind].bestk = bp->bestk; diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index c19264855..8208b287e 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -741,7 +741,7 @@ cJSON *dpow_kvsearch(struct supernet_info *myinfo,struct iguana_info *coin,char } -char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx) +char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx, int32_t mine) { bits256 txid; cJSON *json,*array; char *paramstr,*retstr; if ( coin->FULLNODE < 0 ) @@ -750,7 +750,9 @@ char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *c jaddistr(array,signedtx); paramstr = jprint(array,1); retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"sendrawtransaction",paramstr); - printf(">>>>>>>>>>> %s dpow_sendrawtransaction (%s)\n",coin->symbol,retstr); + char colour[16]; + sprintf(colour,mine != 0 ? GREEN : RED); + fprintf(stderr,"%s>>>>>>>>>>> %s dpow_sendrawtransaction (%s)\n"RESET,colour,coin->symbol,retstr); free(paramstr); return(retstr); } diff --git a/iguana/dpow/dpow_tx.c b/iguana/dpow/dpow_tx.c index 1e72dabae..3a7578907 100755 --- a/iguana/dpow/dpow_tx.c +++ b/iguana/dpow/dpow_tx.c @@ -627,7 +627,7 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo bp->state = 1; if ( bits256_nonz(signedtxid) != 0 && numsigs == bp->minsigs ) { - if ( (retstr= dpow_sendrawtransaction(myinfo,coin,bp->signedtx)) != 0 ) + if ( (retstr= dpow_sendrawtransaction(myinfo,coin,bp->signedtx,(bestmask & (1LL << bp->myind)) != 0)) != 0 ) { //printf("sendrawtransaction.(%s)\n",retstr); if ( is_hexstr(retstr,0) == sizeof(txid)*2 ) @@ -669,4 +669,3 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo } else printf("numsigs.%d vs required.%d\n",numsigs,bp->minsigs); } } - diff --git a/iguana/iguana_payments.c b/iguana/iguana_payments.c index 3051c728e..8d2441d43 100755 --- a/iguana/iguana_payments.c +++ b/iguana/iguana_payments.c @@ -303,7 +303,7 @@ bits256 iguana_sendrawtransaction(struct supernet_info *myinfo,struct iguana_inf if ( coin->FULLNODE < 0 || coin->notarychain >= 0 ) { if ( coin->FULLNODE < 0 ) - str = dpow_sendrawtransaction(myinfo,coin,signedtx); + str = dpow_sendrawtransaction(myinfo,coin,signedtx,0); else str = _dex_sendrawtransaction(myinfo,coin->symbol,signedtx); if ( str != 0 ) { diff --git a/includes/iguana_defines.h b/includes/iguana_defines.h index 29f764bf0..1011b276e 100755 --- a/includes/iguana_defines.h +++ b/includes/iguana_defines.h @@ -211,4 +211,22 @@ extern int32_t IGUANA_NUMHELPERS; #define IGUANA_MAXSCRIPTSIZE 10001 +#define RESET "\033[0m" +#define BLACK "\033[30m" /* Black */ +#define RED "\033[31m" /* Red */ +#define GREEN "\033[32m" /* Green */ +#define YELLOW "\033[33m" /* Yellow */ +#define BLUE "\033[34m" /* Blue */ +#define MAGENTA "\033[35m" /* Magenta */ +#define CYAN "\033[36m" /* Cyan */ +#define WHITE "\033[37m" /* White */ +#define BOLDBLACK "\033[1m\033[30m" /* Bold Black */ +#define BOLDRED "\033[1m\033[31m" /* Bold Red */ +#define BOLDGREEN "\033[1m\033[32m" /* Bold Green */ +#define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */ +#define BOLDBLUE "\033[1m\033[34m" /* Bold Blue */ +#define BOLDMAGENTA "\033[1m\033[35m" /* Bold Magenta */ +#define BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */ +#define BOLDWHITE "\033[1m\033[37m" /* Bold White */ + #endif