From 3785de39363720fc8dab01c75599d187eaf638b9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 14 Dec 2016 08:51:28 +0200 Subject: [PATCH] test --- iguana/dpow/dpow_fsm.c | 8 ++++---- iguana/dpow/dpow_network.c | 18 ++++++++++-------- iguana/dpow/dpow_rpc.c | 9 +++++++-- iguana/dpow/dpow_tx.c | 6 +++--- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 97fb5483b..9f258a446 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -391,8 +391,8 @@ void dpow_statemachinestart(void *ptr) { if ( (starttime= checkpoint.timestamp) == 0 ) bp->starttime = starttime = (uint32_t)time(NULL); - extralen = dpow_paxpending(extras); - bp->paxwdcrc = bp->notaries[bp->myind].paxwdcrc = calc_crc32(0,extras,extralen); + extralen = dpow_paxpending(extras,&bp->paxwdcrc); + bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc; } printf("PAXWDCRC.%x myind.%d isratify.%d DPOW.%s statemachine checkpoint.%d %s start.%u\n",bp->paxwdcrc,bp->myind,bp->isratify,src->symbol,checkpoint.blockhash.height,bits256_str(str,checkpoint.blockhash.hash),checkpoint.timestamp); for (i=0; iDPOWS[0].ratifying != 0 ) break; - extralen = dpow_paxpending(extras); - bp->paxwdcrc = bp->notaries[bp->myind].paxwdcrc = calc_crc32(0,extras,extralen); + extralen = dpow_paxpending(extras,&bp->paxwdcrc); + bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc; } sleep(1); if ( dp->checkpoint.blockhash.height > checkpoint.blockhash.height ) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 14e9d5234..100c47726 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -645,7 +645,7 @@ void dpow_nanoutxoget(struct supernet_info *myinfo,struct dpow_info *dp,struct d void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen) { - struct dpow_nanomsghdr *np; int32_t i,size,extralen=0,sentbytes = 0; uint32_t crc32; uint8_t extras[10000]; + struct dpow_nanomsghdr *np; int32_t i,size,extralen=0,sentbytes = 0; uint32_t crc32,paxwdcrc; uint8_t extras[10000]; if ( bp->myind < 0 ) return; if ( time(NULL) < myinfo->nanoinit+5 ) @@ -666,10 +666,15 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo //printf(" dpow_send.(%d) size.%d numipbits.%d myind.%d\n",datalen,size,np->numipbits,bp->myind); if ( bp->isratify == 0 ) { - extralen = dpow_paxpending(extras); - bp->paxwdcrc = bp->notaries[bp->myind].paxwdcrc = np->notarize.paxwdcrc = calc_crc32(0,extras,extralen); + extralen = dpow_paxpending(extras,&paxwdcrc); + bp->paxwdcrc = bp->notaries[bp->myind].paxwdcrc = np->notarize.paxwdcrc = paxwdcrc; dpow_nanoutxoset(&np->notarize,bp,0); - } else dpow_nanoutxoset(&np->ratify,bp,1); + } + else + { + bp->paxwdcrc = bp->notaries[bp->myind].paxwdcrc = np->notarize.paxwdcrc = 0; + dpow_nanoutxoset(&np->ratify,bp,1); + } np->size = size; np->datalen = datalen; np->crc32 = crc32; @@ -685,13 +690,10 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo strcpy(np->symbol,dp->symbol); np->version0 = DPOW_VERSION & 0xff; np->version1 = (DPOW_VERSION >> 8) & 0xff; - if ( extralen > 0 ) - bp->paxwdcrc = np->notarize.paxwdcrc = calc_crc32(0,extras,extralen); - else bp->paxwdcrc = np->notarize.paxwdcrc = 0; memcpy(np->packet,data,datalen); sentbytes = nn_send(myinfo->dpowsock,np,size,0); free(np); - //printf("NANOSEND ht.%d channel.%08x (%d) crc32.%08x datalen.%d\n",np->height,np->channel,size,np->crc32,datalen); + printf("NANOSEND ht.%d channel.%08x (%d) crc32.%08x datalen.%d\n",np->height,np->channel,size,np->paxwdcrc,datalen); } void dpow_ipbitsadd(struct supernet_info *myinfo,struct dpow_info *dp,uint32_t *ipbits,int32_t numipbits,int32_t fromid,uint32_t senderipbits) diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 17f15f1f4..533462913 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -86,9 +86,10 @@ bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *c return(blockhash); } -int32_t dpow_paxpending(uint8_t *hex) +int32_t dpow_paxpending(uint8_t *hex,uint32_t *paxwdcrcp) { - struct iguana_info *coin; char *retstr,*hexstr; cJSON *retjson; int32_t n=0; + struct iguana_info *coin; char *retstr,*hexstr; cJSON *retjson; int32_t n=0; uint32_t paxwdcrc; + paxwdcrc = 0; if ( (coin= iguana_coinfind("KMD")) != 0 ) { if ( coin->FULLNODE < 0 ) @@ -102,6 +103,8 @@ int32_t dpow_paxpending(uint8_t *hex) n >>= 1; //printf("PAXPENDING.(%s)\n",hexstr); decode_hex(hex,n,hexstr); + paxwdcrc = calc_crc32(0,hex,n) & 0xffffff00; + paxwdcrc |= (n & 0xff); } free_json(retjson); } else printf("dpow_paxpending: parse error.(%s)\n",retstr); @@ -109,6 +112,8 @@ int32_t dpow_paxpending(uint8_t *hex) } else printf("dpow_paxpending: paxwithdraw null return\n"); } else printf("dpow_paxpending: KMD FULLNODE.%d\n",coin->FULLNODE); } else printf("dpow_paxpending: cant find KMD\n"); + if ( *paxwdcrcp != paxwdcrc ) + *paxwdcrcp = paxwdcrc; return(n); } diff --git a/iguana/dpow/dpow_tx.c b/iguana/dpow/dpow_tx.c index d3d1f094d..8888b216c 100755 --- a/iguana/dpow/dpow_tx.c +++ b/iguana/dpow/dpow_tx.c @@ -165,7 +165,7 @@ struct dpow_block *dpow_heightfind(struct supernet_info *myinfo,struct dpow_info int32_t dpow_voutstandard(struct dpow_block *bp,uint8_t *serialized,int32_t m,int32_t src_or_dest,uint8_t pubkeys[][33],int32_t numratified) { - uint32_t locktime=0,numvouts; uint64_t satoshis,satoshisB; int32_t i,n=0,opretlen,len=0; uint8_t opret[16384],data[16384],extras[16384]; + uint32_t paxwdcrc=0,locktime=0,numvouts; uint64_t satoshis,satoshisB; int32_t i,n=0,opretlen,len=0; uint8_t opret[16384],data[16384],extras[16384]; numvouts = 2; if ( pubkeys == 0 || numratified <= 0 ) { @@ -197,11 +197,11 @@ int32_t dpow_voutstandard(struct dpow_block *bp,uint8_t *serialized,int32_t m,in } printf("numvouts.%d len.%d RATIFY vouts\n",numvouts,len); } - if ( (src_or_dest == 0 || strcmp(bp->destcoin->symbol,"BTC") != 0) && (n= dpow_paxpending(extras)) > 0 ) + if ( (src_or_dest == 0 || strcmp(bp->destcoin->symbol,"BTC") != 0) && (n= dpow_paxpending(extras,&paxwdcrc)) > 0 ) { for (i=0; i