Browse Source

test

blackjok3r
blackjok3r 6 years ago
parent
commit
dbb4590618
  1. 20
      iguana/dpow/dpow_fsm.c
  2. 18
      iguana/dpow/dpow_rpc.c

20
iguana/dpow/dpow_fsm.c

@ -615,18 +615,19 @@ void dpow_statemachinestart(void *ptr)
dp->ratifying -= bp->isratify; 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, // 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; int8_t dest_confs = 0, src_confs = 0, destnotarized = 0, srcnotarized = 0;
char desttx[32768],srctx[32768]; char *retstr=0;
while ( 1 ) while ( 1 )
{ {
// If the round was sucessful and both notarizations were created successfully we will make sure they are in the chain. // 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 ) if ( bits256_cmp(bp->desttxid,zero) == 0 )
break; break;
if ( bits256_cmp(bp->srctxid,zero) == 0 ) if ( bits256_cmp(bp->srctxid,zero) == 0 )
break; break;
// get the confirms for desttxid // 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 ) if ( dest_confs > 2 )
{ {
@ -637,7 +638,12 @@ void dpow_statemachinestart(void *ptr)
else if ( dest_confs == 0 ) else if ( dest_confs == 0 )
{ {
// not confirmed, rebroadcast it. // 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)); } 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)); 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. // wait for approx one block before checking again.
sleep(60); sleep(30);
if ( destnotarized != 0 ) break; if ( destnotarized != 0 ) break;
} }

18
iguana/dpow/dpow_rpc.c

@ -541,24 +541,26 @@ char *dpow_decoderawtransaction(struct supernet_info *myinfo,struct iguana_info
return(retstr); 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 ) if ( (txobj= dpow_gettransaction(myinfo, coin, txid)) != 0 )
{ {
rawtx= jstr(txobj, "hex"));
if ( (confirms= juint(txobj, "confirmations")) != 0 ) if ( (confirms= juint(txobj, "confirmations")) != 0 )
{ {
return(confirms); ret = confirms;
} }
else if ( confirms == 1 && juint(txobj, "rawconfirmations") > 100 ) else if ( confirms == 1 && juint(txobj, "rawconfirmations") > 100 )
return(100); ret = 100;
else else
return(0); ret = 0;
} } else ret = -1;
return(-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; char buf[128],str[65],*retstr=0; cJSON *json = 0;
if ( coin->FULLNODE < 0 ) if ( coin->FULLNODE < 0 )

Loading…
Cancel
Save