From dbb45906183bcba0c5b5d2afb663637dd99d86af Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 6 Mar 2019 16:44:26 +0800 Subject: [PATCH] test --- iguana/dpow/dpow_fsm.c | 20 +++++++++++--------- iguana/dpow/dpow_rpc.c | 18 ++++++++++-------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 96578678c..d199667cd 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -615,18 +615,19 @@ void dpow_statemachinestart(void *ptr) dp->ratifying -= bp->isratify; // We need to wait for notarized confirm here. If the notarization is reorged for any reason we need to rebroadcast it, - // becasue the mempool is stupid after the sapling update! + // because the mempool is stupid after the sapling update, or Alright might be playing silly games. int8_t dest_confs = 0, src_confs = 0, destnotarized = 0, srcnotarized = 0; + char desttx[32768],srctx[32768]; char *retstr=0; while ( 1 ) { // If the round was sucessful and both notarizations were created successfully we will make sure they are in the chain. if ( bits256_cmp(bp->desttxid,zero) == 0 ) break; - if ( bits256_cmp(bp->srctxid,zero) == 0 ) + if ( bits256_cmp(bp->srctxid,zero) == 0 ) break; // get the confirms for desttxid - if ( destnotarized == 0 && (dest_confs= dpow_txconfirms(myinfo, bp->destcoin, bp->desttxid)) != -1 ) + if ( destnotarized == 0 && (dest_confs= dpow_txconfirms(myinfo, bp->destcoin, bp->desttxid, &desttx)) != -1 ) { if ( dest_confs > 2 ) { @@ -637,7 +638,12 @@ void dpow_statemachinestart(void *ptr) else if ( dest_confs == 0 ) { // not confirmed, rebroadcast it. - fprintf(stderr, "[%s] txid.%s is not confirmed at all rebroadcasting.... \n",dp->dest, bits256_str(str,bp->desttxid)); + fprintf(stderr, "[%s] txid.%s is not confirmed rebroadcasting.... \n tx.%s",dp->dest, bits256_str(str,bp->desttxid), desttx); + if ( desttx[0] != 0 ) + { + if ( dpow_sendrawtransaction(myinfo, bp->destcoin, desttx) == 0 ) + fprintf(stderr, "rebroadcast failed!\n"); + } } } else fprintf(stderr, "[%s] txid.%s returned error for txconfirms",dp->dest, bits256_str(str,bp->desttxid)); @@ -650,13 +656,9 @@ void dpow_statemachinestart(void *ptr) fprintf(stderr, "[%s] txid.%s is notarized or has 100 confirms \n",bp->symbol, bits256_str(str,bp->srctxid)); } } */ - // check here for confirms exists in return JSON, if no confirms, keep rebroadcasting. - // if confirms > 2 exit loop. - - // as a safety, if rawconfirmations > 100 exit this loop. // wait for approx one block before checking again. - sleep(60); + sleep(30); if ( destnotarized != 0 ) break; } diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 4ca46839e..a763344dc 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -541,24 +541,26 @@ char *dpow_decoderawtransaction(struct supernet_info *myinfo,struct iguana_info return(retstr); } -int32_t dpow_txconfirms(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid) +int32_t dpow_txconfirms(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid, char *rawtx) { - cJSON *txobj; int32_t confirms = 0; + cJSON *txobj; int32_t confirms = 0, ret = 0; if ( (txobj= dpow_gettransaction(myinfo, coin, txid)) != 0 ) { + rawtx= jstr(txobj, "hex")); if ( (confirms= juint(txobj, "confirmations")) != 0 ) { - return(confirms); + ret = confirms; } else if ( confirms == 1 && juint(txobj, "rawconfirmations") > 100 ) - return(100); + ret = 100; else - return(0); - } - return(-1); + ret = 0; + } else ret = -1; + free_json(txobj); + return(ret); } -cJSON *dpow_gettransaction(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid) +cJSON *dpow_gettransaction(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid, ) { char buf[128],str[65],*retstr=0; cJSON *json = 0; if ( coin->FULLNODE < 0 )