diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index 75f3352a7..6f20cabd6 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -213,7 +213,7 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ return(-1); } //portable_mutex_lock(&myinfo->allcoins_mutex); - dex_reqsend(myinfo,&data[-(int32_t)sizeof(struct iguana_msghdr)],datalen); + //dex_reqsend(myinfo,&data[-(int32_t)sizeof(struct iguana_msghdr)],datalen); alreadysent = calloc(IGUANA_MAXPEERS * IGUANA_MAXCOINS,sizeof(*alreadysent)); HASH_ITER(hh,myinfo->allcoins,coin,tmp) { @@ -877,7 +877,7 @@ void basilisks_loop(void *arg) startmilli = OS_milliseconds(); basilisk_issued_purge(myinfo,600000); basilisk_p2pQ_process(myinfo,777); - if ( myinfo->NOTARY.RELAYID >= 0 ) + if ( myinfo->IAMNOTARY != 0 ) { if ( relay != 0 ) basilisk_ping_send(myinfo,relay); @@ -895,8 +895,7 @@ void basilisks_loop(void *arg) } else { - if ( myinfo->IAMNOTARY == 0 ) - dex_updateclient(myinfo); + dex_updateclient(myinfo); if ( myinfo->IAMLP != 0 ) endmilli = startmilli + 1000; else endmilli = startmilli + 2000; diff --git a/basilisk/basilisk_MSG.c b/basilisk/basilisk_MSG.c index ba6fd9739..c4e0bb4b1 100755 --- a/basilisk/basilisk_MSG.c +++ b/basilisk/basilisk_MSG.c @@ -291,10 +291,12 @@ HASH_ARRAY_STRING(basilisk,getmessage,hash,vals,hexstr) HASH_ARRAY_STRING(basilisk,sendmessage,hash,vals,hexstr) { int32_t keylen,datalen; uint8_t key[BASILISK_KEYSIZE],space[16384],*data,*ptr = 0; char *retstr=0; + data = get_dataptr(BASILISK_HDROFFSET,&ptr,&datalen,&space[BASILISK_KEYSIZE],sizeof(space)-BASILISK_KEYSIZE,hexstr); if ( myinfo->IAMNOTARY != 0 && myinfo->NOTARY.RELAYID >= 0 ) { keylen = basilisk_messagekey(key,juint(vals,"channel"),juint(vals,"msgid"),jbits256(vals,"srchash"),jbits256(vals,"desthash")); - if ( (data= get_dataptr(BASILISK_HDROFFSET,&ptr,&datalen,space,sizeof(space),hexstr)) != 0 ) + memcpy(space,key,BASILISK_KEYSIZE); + if ( data != 0 ) { retstr = basilisk_respond_addmessage(myinfo,key,keylen,data,datalen,0,juint(vals,"duration")); } else printf("no get_dataptr\n"); @@ -305,6 +307,8 @@ HASH_ARRAY_STRING(basilisk,sendmessage,hash,vals,hexstr) } else printf("not notary.%d relayid.%d\n",myinfo->IAMNOTARY,myinfo->NOTARY.RELAYID); if ( vals != 0 && juint(vals,"fanout") == 0 ) jaddnum(vals,"fanout",MAX(8,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+2)); + if ( data != 0 && datalen != 0 ) + dex_reqsend(myinfo,space,datalen+BASILISK_KEYSIZE); return(basilisk_standardservice("OUT",myinfo,0,jbits256(vals,"desthash"),vals,hexstr,0)); } #include "../includes/iguana_apiundefs.h" diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index 853206c50..7699bef8e 100755 --- a/basilisk/basilisk_swap.c +++ b/basilisk/basilisk_swap.c @@ -17,6 +17,11 @@ // mode to autocreate required outputs // more better LP commands +// depends on just three external functions: +// iguana_sendrawtransaction(myinfo,coin,signedtx); +// basilisk_value(myinfo,rawtx->coin,0,0,myinfo->myaddr.persistent,argjson,0) +// basilisk_bitcoinrawtx(myinfo,rawtx->coin,"",basilisktag,jint(valsobj,"timeout"),valsobj,V) + // included from basilisk.c /* https://bitcointalk.org/index.php?topic=1340621.msg13828271#msg13828271 diff --git a/iguana/dPoW.h b/iguana/dPoW.h index 7ce7f1dcd..4e0574bb7 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -142,5 +142,6 @@ uint64_t dpow_notarybestk(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp) int32_t dpow_paxpending(uint8_t *hex,uint32_t *paxwdcrcp); void dex_updateclient(struct supernet_info *myinfo); int32_t dex_reqsend(struct supernet_info *myinfo,uint8_t *data,int32_t datalen); +char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int32_t keylen,uint8_t *data,int32_t datalen,int32_t sendping,uint32_t duration); #endif diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 0c11ec713..e442898a4 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -56,7 +56,10 @@ static int _increasing_ipbits(const void *a,const void *b) void dex_packet(struct supernet_info *myinfo,struct dex_nanomsghdr *dexp,int32_t size) { + char *retstr; printf("uniq DEX_PACKET.[%d] crc.%x lag.%d\n",size,calc_crc32(0,(void *)((long)dexp+sizeof(dexp->crc32)),(int32_t)(size-sizeof(dexp->crc32))),(int32_t)(time(NULL)-dexp->timestamp)); + if ( (retstr= basilisk_respond_addmessage(myinfo,dexp->packet,BASILISK_KEYSIZE,&dexp->packet[BASILISK_KEYSIZE],dexp->datalen-BASILISK_KEYSIZE,0,BASILISK_DEXDURATION)) != 0 ) + free(retstr); } int32_t dex_reqsend(struct supernet_info *myinfo,uint8_t *data,int32_t datalen) @@ -692,15 +695,15 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru bp->notaries[senderind].src.prev_vout = srcvout; bp->notaries[senderind].dest.prev_hash = destutxo; bp->notaries[senderind].dest.prev_vout = destvout; - if ( bestmask != 0 ) + //if ( bestmask != 0 ) bp->notaries[senderind].bestmask = bestmask; - if ( recvmask != 0 ) + //if ( recvmask != 0 ) bp->notaries[senderind].recvmask = recvmask; if ( (bp->notaries[senderind].paxwdcrc= paxwdcrc) != 0 ) { //fprintf(stderr,"{%d %x} ",senderind,paxwdcrc); } - if ( bestk >= 0 && (bp->notaries[senderind].bestk= bestk) >= 0 ) + if ( (bp->notaries[senderind].bestk= bestk) >= 0 ) { if ( (bp->notaries[senderind].src.siglens[bestk]= siglens[0]) != 0 ) { @@ -721,8 +724,9 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru dpow_bestconsensus(bp); else { - bp->recvmask |= (1LL << senderind) | (1LL << bp->myind); - bp->bestmask = dpow_maskmin(bp->recvmask,bp,&bp->bestk); + //bp->recvmask |= (1LL << senderind) | (1LL << bp->myind); + //bp->bestmask = dpow_maskmin(bp->recvmask,bp,&bp->bestk); + dpow_bestconsensus(bp); } if ( bp->bestk >= 0 ) bp->notaries[bp->myind].bestk = bp->bestk;