diff --git a/basilisk/basilisk_DEX.c b/basilisk/basilisk_DEX.c index babb9f5ec..d643c81ab 100755 --- a/basilisk/basilisk_DEX.c +++ b/basilisk/basilisk_DEX.c @@ -282,7 +282,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo) free(retstr); basilisk_channelsend(myinfo,issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid),60); numiters = 0; - while ( numiters < 10 && (crc= basilisk_crcsend(myinfo,buf,sizeof(buf),issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid),crcs)) == 0 ) + while ( numiters < 10 && (crc= basilisk_crcsend(myinfo,0,buf,sizeof(buf),issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid),crcs)) == 0 ) { printf("didnt get back what was sent\n"); sleep(3); @@ -305,7 +305,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo) crcs[0] = crcs[1] = 0; numiters = 0; basilisk_channelsend(myinfo,issueR.desthash,issueR.srchash,channel,msgid,data,datalen,INSTANTDEX_LOCKTIME*2); - while ( numiters < 10 && (crc= basilisk_crcsend(myinfo,buf,sizeof(buf),issueR.desthash,issueR.srchash,channel,msgid,data,datalen,crcs)) == 0 ) + while ( numiters < 10 && (crc= basilisk_crcsend(myinfo,0,buf,sizeof(buf),issueR.desthash,issueR.srchash,channel,msgid,data,datalen,crcs)) == 0 ) { //printf("didnt get back what was sent\n"); sleep(3); @@ -577,7 +577,7 @@ HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr) DEX_channel = 'D' + ((uint32_t)'E' << 8) + ((uint32_t)'X' << 16); basilisk_channelsend(myinfo,myinfo->myaddr.persistent,hash,DEX_channel,msgid,serialized,datalen,60); sleep(3); - while ( numiters < 10 && (crc= basilisk_crcsend(myinfo,buf,sizeof(buf),hash,myinfo->myaddr.persistent,DEX_channel,msgid,serialized,datalen,crcs)) == 0 ) + while ( numiters < 10 && (crc= basilisk_crcsend(myinfo,0,buf,sizeof(buf),hash,myinfo->myaddr.persistent,DEX_channel,msgid,serialized,datalen,crcs)) == 0 ) { //printf("didnt get back what was sent\n"); sleep(3); diff --git a/basilisk/basilisk_MSG.c b/basilisk/basilisk_MSG.c index 9dc79f21a..0911e3bb3 100755 --- a/basilisk/basilisk_MSG.c +++ b/basilisk/basilisk_MSG.c @@ -216,9 +216,9 @@ char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int3 msg->expiration = (uint32_t)time(NULL) + duration; HASH_ADD_KEYPTR(hh,myinfo->messagetable,msg->key,msg->keylen,msg); QUEUEITEMS++; - //int32_t i; for (i=0; iexpiration,msg,msg->hh.next,msg->hh.prev); + int32_t i; for (i=0; iexpiration,msg,msg->hh.next,msg->hh.prev); portable_mutex_unlock(&myinfo->messagemutex); if ( myinfo->NOTARY.RELAYID >= 0 ) dpow_handler(myinfo,msg); @@ -435,7 +435,7 @@ uint32_t basilisk_majority32(int32_t *datalenp,uint32_t rawcrcs[64],int32_t data { for (i=0; i numcandidates.%d\n",i,numcandidates); + printf("n.%d -> numcandidates.%d\n",i,numcandidates); if ( numcandidates > 0 ) { for (j=0; j 0 ) @@ -525,7 +525,7 @@ uint32_t basilisk_crcrecv(struct supernet_info *myinfo,uint8_t *verifybuf,int32_ return(crc); } -uint32_t basilisk_crcsend(struct supernet_info *myinfo,uint8_t *verifybuf,int32_t maxlen,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t crcs[2]) +uint32_t basilisk_crcsend(struct supernet_info *myinfo,int32_t width,uint8_t *verifybuf,int32_t maxlen,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t crcs[2]) { uint32_t crc; int32_t recvlen; if ( crcs != 0 ) @@ -536,7 +536,7 @@ uint32_t basilisk_crcsend(struct supernet_info *myinfo,uint8_t *verifybuf,int32_ else { if ( crcs[1] == 0 ) - crcs[1] = basilisk_crcrecv(myinfo,verifybuf,maxlen,&recvlen,srchash,desthash,channel,msgbits); + crcs[1] = basilisk_crcrecv(myinfo,width,verifybuf,maxlen,&recvlen,srchash,desthash,channel,msgbits); if ( crcs[0] == crcs[1] && datalen == recvlen ) return(crcs[0]); } diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index afc76ef5d..853206c50 100755 --- a/basilisk/basilisk_swap.c +++ b/basilisk/basilisk_swap.c @@ -848,7 +848,7 @@ int32_t basilisk_process_swapverify(struct supernet_info *myinfo,void *ptr,int32 int32_t basilisk_swapget(struct supernet_info *myinfo,struct basilisk_swap *swap,uint32_t msgbits,uint8_t *data,int32_t maxlen,int32_t (*basilisk_verify_func)(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen)) { int32_t datalen; uint32_t crc; - if ( (crc= basilisk_crcrecv(myinfo,swap->verifybuf,sizeof(swap->verifybuf),&datalen,swap->I.otherhash,swap->I.myhash,swap->I.req.quoteid,msgbits)) != 0 ) + if ( (crc= basilisk_crcrecv(myinfo,0,swap->verifybuf,sizeof(swap->verifybuf),&datalen,swap->I.otherhash,swap->I.myhash,swap->I.req.quoteid,msgbits)) != 0 ) { if ( datalen > 0 && datalen < maxlen ) { @@ -861,7 +861,7 @@ int32_t basilisk_swapget(struct supernet_info *myinfo,struct basilisk_swap *swap uint32_t basilisk_swapsend(struct supernet_info *myinfo,struct basilisk_swap *swap,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t nextbits,uint32_t crcs[2]) { - if ( basilisk_crcsend(myinfo,swap->verifybuf,sizeof(swap->verifybuf),swap->I.myhash,swap->I.otherhash,swap->I.req.quoteid,msgbits,data,datalen,crcs) != 0 ) + if ( basilisk_crcsend(myinfo,0,swap->verifybuf,sizeof(swap->verifybuf),swap->I.myhash,swap->I.otherhash,swap->I.req.quoteid,msgbits,data,datalen,crcs) != 0 ) return(nextbits); //if ( basilisk_channelsend(myinfo,swap->I.myhash,swap->I.otherhash,swap->I.req.quoteid,msgbits,data,datalen,INSTANTDEX_LOCKTIME*2) == 0 ) // return(nextbits); diff --git a/iguana/dPoW.h b/iguana/dPoW.h index a77b68793..29c84ad9e 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -26,6 +26,7 @@ #define DPOW_KOMODOCONFIRMS 1 #define DPOW_BTCCONFIRMS 1 #define DPOW_MAXRELAYS 64 +#define DPOW_CHECKPOINTFREQ 5 struct dpow_entry { diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 5b23227e4..3233daa2a 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -579,7 +579,7 @@ int32_t dpow_haveutxo(struct supernet_info *myinfo,struct iguana_info *coin,bits uint32_t dpow_send(struct supernet_info *myinfo,struct dpow_block *bp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t crcs[2]) { - return(basilisk_crcsend(myinfo,bp->sendbuf,sizeof(bp->sendbuf),srchash,desthash,channel,msgbits,data,datalen,crcs)); + return(basilisk_crcsend(myinfo,1,bp->sendbuf,sizeof(bp->sendbuf),srchash,desthash,channel,msgbits,data,datalen,crcs)); } cJSON *dpow_createtx(struct iguana_info *coin,cJSON **vinsp,struct dpow_block *bp,int32_t lastk,uint64_t mask,int32_t usesigs) @@ -700,7 +700,7 @@ int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct iguana_info *coin,s basilisk_channelsend(myinfo,srchash,desthash,channel,bp->height,data,datalen,120); }*/ //basilisk_channelsend(myinfo,srchash,zero,channel,bp->height,data,datalen,120); - dpow_send(myinfo,bp,srchash,zero,channel,bp->height,data,datalen,bp->sigcrcs); + dpow_send(myinfo,bp,srchash,bp->hashmsg,channel,bp->height,data,datalen,bp->sigcrcs); retval = 0; break; } // else printf("notmine.(%s)\n",jprint(item,0)); @@ -755,7 +755,7 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_block *bp,uint32_t basilisk_channelsend(myinfo,txid,desthash,(channel == DPOW_SIGBTCCHANNEL) ? DPOW_BTCTXIDCHANNEL : DPOW_TXIDCHANNEL,bp->height,txdata,len+32,120); }*/ //basilisk_channelsend(myinfo,txid,zero,(channel == DPOW_SIGBTCCHANNEL) ? DPOW_BTCTXIDCHANNEL : DPOW_TXIDCHANNEL,bp->height,txdata,len+32,120); - dpow_send(myinfo,bp,txid,zero,(channel == DPOW_SIGBTCCHANNEL) ? DPOW_BTCTXIDCHANNEL : DPOW_TXIDCHANNEL,bp->height,txdata,len+32,bp->txidcrcs); + dpow_send(myinfo,bp,txid,bp->hashmsg,(channel == DPOW_SIGBTCCHANNEL) ? DPOW_BTCTXIDCHANNEL : DPOW_TXIDCHANNEL,bp->height,txdata,len+32,bp->txidcrcs); printf("complete statemachine.%s ht.%d\n",bp->coin->symbol,bp->height); bp->state = 0xffffffff; } else printf("sendtxid mismatch got %s instead of %s\n",bits256_str(str,txid),bits256_str(str2,bp->signedtxid)); @@ -947,7 +947,7 @@ uint32_t dpow_statemachineiterate(struct supernet_info *myinfo,struct dpow_info basilisk_channelsend(myinfo,srchash,desthash,channel,bp->height,data,len,120); }*/ //basilisk_channelsend(myinfo,srchash,zero,channel,bp->height,data,len,120); - dpow_send(myinfo,bp,srchash,zero,channel,bp->height,data,len,bp->utxocrcs); + dpow_send(myinfo,bp,srchash,bp->hashmsg,channel,bp->height,data,len,bp->utxocrcs); bp->state = 2; } break; @@ -1112,7 +1112,7 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he checkpoint = dp->srcfifo[dp->srcconfirms]; printf("%s srcupdate ht.%d destupdated.%u nonz.%d %s\n",dp->symbol,height,dp->destupdated,bits256_nonz(checkpoint.blockhash.hash),bits256_str(str,dp->last.blockhash.hash)); dpow_fifoupdate(myinfo,dp->srcfifo,dp->last); - if ( dp->destupdated != 0 && bits256_nonz(checkpoint.blockhash.hash) != 0 && (checkpoint.blockhash.height % 10) == 0 ) + if ( dp->destupdated != 0 && bits256_nonz(checkpoint.blockhash.hash) != 0 && (checkpoint.blockhash.height % DPOW_CHECKPOINTFREQ) == 0 ) { ptrs = calloc(1,sizeof(void *)*2 + sizeof(struct dpow_checkpoint)); ptrs[0] = (void *)myinfo; diff --git a/includes/iguana_funcs.h b/includes/iguana_funcs.h index bc1ae63e1..818b8db2b 100755 --- a/includes/iguana_funcs.h +++ b/includes/iguana_funcs.h @@ -490,9 +490,9 @@ char *iguana_signunspents(struct supernet_info *myinfo,struct iguana_info *coin, bits256 iguana_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx); int32_t iguana_inv2packet(uint8_t *serialized,int32_t maxsize,int32_t type,bits256 *hashes,int32_t n); int32_t instantdex_inv2data(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,struct exchange_info *exchange); -uint32_t basilisk_crcrecv(struct supernet_info *myinfo,uint8_t *verifybuf,int32_t maxlen,int32_t *datalenp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits); +uint32_t basilisk_crcrecv(struct supernet_info *myinfo,int32_t width,uint8_t *verifybuf,int32_t maxlen,int32_t *datalenp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits); struct iguana_bundlereq *instantdex_recvquotes(struct iguana_info *coin,struct iguana_bundlereq *req,bits256 *encodedhash,int32_t n); -uint32_t basilisk_crcsend(struct supernet_info *myinfo,uint8_t *verifybuf,int32_t maxlen,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t crcs[2]); +uint32_t basilisk_crcsend(struct supernet_info *myinfo,int32_t width,uint8_t *verifybuf,int32_t maxlen,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t crcs[2]); struct exchange_info *exchange_create(char *exchangestr,cJSON *argjson); int32_t iguana_inv2poll(struct supernet_info *myinfo,struct iguana_info *coin); struct iguana_bundlereq *iguana_bundlereq(struct iguana_info *coin,struct iguana_peer *addr,int32_t type,uint8_t *data,int32_t datalen);