From a3d045234a8e4e49985077319ccd6b7b7fdd4f5d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Dec 2016 15:15:03 +0200 Subject: [PATCH 1/5] test --- iguana/dpow/dpow_network.c | 2 +- iguana/iguana_exchanges.c | 50 ++++++++++++++++++++++++++++---------- iguana/main.c | 2 +- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 6f2895f6b..7587de146 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -442,7 +442,7 @@ void dpow_bestconsensus(struct dpow_block *bp) bp->notaries[bp->myind].bestk = bp->bestk = bestks[besti]; //printf("set best.%d to (%d %llx) recv.%llx\n",best,bp->bestk,(long long)bp->bestmask,(long long)recvmask); } - bp->recvmask = recvmask; + bp->recvmask |= recvmask; if ( bp->bestmask == 0 )//|| (time(NULL) / 180) != bp->lastepoch ) { bp->bestmask = dpow_notarybestk(bp->recvmask,bp,&bp->bestk); diff --git a/iguana/iguana_exchanges.c b/iguana/iguana_exchanges.c index 47384fbc2..697e45484 100755 --- a/iguana/iguana_exchanges.c +++ b/iguana/iguana_exchanges.c @@ -22,16 +22,18 @@ //char *Exchange_names[] = { "poloniex", "bittrex", "btc38", "huobi", "bitstamp", "bitfinex", "btce", "coinbase", "okcoin", "lakebtc", "quadriga", "truefx", "ecb", "instaforex", "fxcm", "yahoo" }; -int32_t instantdex_updatesources(struct exchange_info *exchange,struct exchange_quote *sortbuf,int32_t n,int32_t max,int32_t ind,int32_t dir,struct exchange_quote *quotes,int32_t numquotes) +int32_t instantdex_updatesources(struct exchange_info *exchange,struct exchange_quote *sortbuf,int32_t n,int32_t max,int32_t ind,int32_t dir,struct exchange_quote *quotes,int32_t numquotes,double offset) { int32_t i; struct exchange_quote *quote; - printf("instantdex_updatesources.%s update dir.%d numquotes.%d\n",exchange->name,dir,numquotes); + //printf("instantdex_updatesources.%s update dir.%d numquotes.%d offset %.6f\n",exchange->name,dir,numquotes,offset); for (i=0; iprice,quote->volume); if ( quote->price > SMALLVAL ) { + //printf("%s n.%d ind.%d i.%d dir.%d price %.8f vol %.8f offset %.6f\n",exchange->name,n,ind,i,dir,quote->price+offset,quote->volume,offset); + quote->price += offset; + quote->satoshis = quote->price * SATOSHIDEN; sortbuf[n] = *quote; sortbuf[n].val = ind; sortbuf[n].exchangebits = exchange->exchangebits; @@ -45,7 +47,7 @@ int32_t instantdex_updatesources(struct exchange_info *exchange,struct exchange_ double instantdex_aveprice(struct supernet_info *myinfo,struct exchange_quote *sortbuf,int32_t max,double *totalvolp,char *base,char *rel,double basevolume,cJSON *argjson) { - char *str; double totalvol,pricesum; uint32_t timestamp; + char *str; double totalvol,pricesum,hblas[64][2],refbid,refask; uint32_t timestamp; struct exchange_quote quote; int32_t i,n,dir,num,depth = 100; struct exchange_info *exchange; struct exchange_request *req,*active[64]; if ( myinfo == 0 ) @@ -86,33 +88,55 @@ double instantdex_aveprice(struct supernet_info *myinfo,struct exchange_quote *s } } } - for (i=0; inumbids > 0 && active[i]->numasks > 0 ) + for (i=0; inumbids > 0 && active[i]->numasks > 0 ) + { + hblas[i][0] = active[i]->bidasks[0].price; + hblas[i][1] = active[i]->bidasks[1].price; + if ( active[i]->exchange != 0 && strcmp("poloniex",active[i]->exchange->name) == 0 ) + refbid = active[i]->bidasks[0].price, refask = active[i]->bidasks[1].price; + //printf("(%6f %.6f) ",hblas[i][0],hblas[i][1]); + } } + //printf(" refbid %.6f refask %.7f\n",refbid,refask); + if ( refbid != 0. && refask != 0. ) + { + for (i=0; inumbids > 0 ) - n = instantdex_updatesources(active[i]->exchange,sortbuf,n,max,i,1,active[i]->bidasks,active[i]->numbids); + n = instantdex_updatesources(active[i]->exchange,sortbuf,n,max,i,1,active[i]->bidasks,active[i]->numbids,hblas[i][0]); else if ( dir > 0 && active[i]->numasks > 0 ) - n = instantdex_updatesources(active[i]->exchange,sortbuf,n,max,i,-1,&active[i]->bidasks[1],active[i]->numasks); + n = instantdex_updatesources(active[i]->exchange,sortbuf,n,max,i,-1,&active[i]->bidasks[1],active[i]->numasks,hblas[i][1]); } - printf("numexchanges.%d dir.%d %s/%s numX.%d n.%d\n",myinfo->numexchanges,dir,base,rel,num,n); + //printf("numexchanges.%d dir.%d %s/%s numX.%d n.%d\n",myinfo->numexchanges,dir,base,rel,num,n); if ( dir < 0 ) revsort64s(&sortbuf[0].satoshis,n,sizeof(*sortbuf)); else sort64s(&sortbuf[0].satoshis,n,sizeof(*sortbuf)); - for (totalvol=pricesum=i=0; iexchange->name,pricesum/totalvol,totalvol); + //printf("dir.%d i.%d of %d %12.8f vol %.8f %s | aveprice %.8f total vol %.8f\n",dir,i,n,sortbuf[i].price,quote.volume,active[quote.val]->exchange->name,pricesum/totalvol,totalvol); } } if ( totalvol > 0. ) diff --git a/iguana/main.c b/iguana/main.c index a6710261a..81d0500b0 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -1627,7 +1627,7 @@ void iguana_main(void *arg) myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("coinbase"),0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("lakebtc"),0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("quadriga"),0); - myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("okcoin"),0); + // prices reversed? myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("okcoin"),0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("btce"),0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("bitstamp"),0); #endif From 31cd2079c503098de956b0b098acc4e221cf4fb3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Dec 2016 15:38:35 +0200 Subject: [PATCH 2/5] test --- basilisk/basilisk.c | 1 + iguana/dPoW.h | 1 + iguana/dpow/dpow_network.c | 14 ++++++++------ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index 4c56f977b..75f3352a7 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -213,6 +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); alreadysent = calloc(IGUANA_MAXPEERS * IGUANA_MAXCOINS,sizeof(*alreadysent)); HASH_ITER(hh,myinfo->allcoins,coin,tmp) { diff --git a/iguana/dPoW.h b/iguana/dPoW.h index 350178645..7ce7f1dcd 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -141,5 +141,6 @@ struct dpow_info 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); #endif diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 7587de146..0c11ec713 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -56,7 +56,7 @@ static int _increasing_ipbits(const void *a,const void *b) void dex_packet(struct supernet_info *myinfo,struct dex_nanomsghdr *dexp,int32_t size) { - printf("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)); + 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)); } int32_t dex_reqsend(struct supernet_info *myinfo,uint8_t *data,int32_t datalen) @@ -717,11 +717,13 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru else bp->destsigsmasks[bestk] &= ~(1LL << senderind); } } - dpow_bestconsensus(bp); - //bp->recvmask |= (1LL << senderind) | (1LL << bp->myind); - //bp->bestmask = dpow_maskmin(bp->recvmask,bp,&bp->bestk); - //if ( bp->paxwdcrc != 0 ) - bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc; + if ( (bp->notaries[bp->myind].paxwdcrc= bp->paxwdcrc) != 0 ) + dpow_bestconsensus(bp); + else + { + bp->recvmask |= (1LL << senderind) | (1LL << bp->myind); + bp->bestmask = dpow_maskmin(bp->recvmask,bp,&bp->bestk); + } if ( bp->bestk >= 0 ) bp->notaries[bp->myind].bestk = bp->bestk; if ( bp->bestmask != 0 ) From 316cb059b9762213472bb8b8a90c748d39bc460e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Dec 2016 16:07:35 +0200 Subject: [PATCH 3/5] test --- basilisk/basilisk.c | 7 +++---- basilisk/basilisk_MSG.c | 6 +++++- basilisk/basilisk_swap.c | 5 +++++ iguana/dPoW.h | 1 + iguana/dpow/dpow_network.c | 14 +++++++++----- 5 files changed, 23 insertions(+), 10 deletions(-) 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; From 4e4c96eb179336a57bc4a70c1db2852e3df8e530 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Dec 2016 17:16:07 +0200 Subject: [PATCH 4/5] test --- basilisk/basilisk_bitcoin.c | 39 ++++++++++++++++++++++++++++++++----- basilisk/basilisk_swap.c | 4 ++-- iguana/dPoW.h | 3 +++ iguana/dpow/dpow_network.c | 31 ++++++++++++++++------------- iguana/dpow/dpow_rpc.c | 2 +- iguana/iguana_payments.c | 20 ++++++++++++++++++- 6 files changed, 77 insertions(+), 22 deletions(-) diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index b56a0e7fd..7c59c74c3 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/basilisk/basilisk_bitcoin.c @@ -584,8 +584,8 @@ char *basilisk_bitcoinrawtx(struct supernet_info *myinfo,struct iguana_info *coi uint8_t buf[4096]; int32_t oplen,offset,minconf,spendlen; cJSON *vins,*addresses,*txobj = 0; uint32_t locktime; char *opreturn,*spendscriptstr,*changeaddr,*rawtx = 0; int64_t amount,txfee,burnamount; if ( valsobj == 0 ) return(clonestr("{\"error\":\"null valsobj\"}")); - if ( myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0 ) - return(clonestr("{\"error\":\"special relays only do OUT and MSG\"}")); + //if ( myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0 ) + // return(clonestr("{\"error\":\"special relays only do OUT and MSG\"}")); vins = 0; changeaddr = jstr(valsobj,"changeaddr"); if ( (amount= j64bits(valsobj,"satoshis")) == 0 ) @@ -882,11 +882,11 @@ cJSON *BTC_makeclaimfunc(struct supernet_info *myinfo,struct exchange_info *exch HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr) { - char *retstr=0,*symbol; uint32_t basilisktag; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis; + char *retstr=0,*symbol,*coinaddr; cJSON *retjson,*txoutjson; uint32_t basilisktag,blocktime; bits256 txid,blockhash; struct basilisk_item *ptr,Lptr; uint64_t value; int32_t timeoutmillis,vout,height; if ( vals == 0 ) return(clonestr("{\"error\":\"null valsobj\"}")); - if ( myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0 ) - return(clonestr("{\"error\":\"special relays only do OUT and MSG\"}")); + //if ( myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0 ) + // return(clonestr("{\"error\":\"special relays only do OUT and MSG\"}")); //if ( coin == 0 ) { if ( (symbol= jstr(vals,"symbol")) != 0 || (symbol= jstr(vals,"coin")) != 0 ) @@ -896,6 +896,35 @@ HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr) jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1)); if ( coin != 0 ) { + if ( coin->FULLNODE < 0 ) + { + txid = jbits256(vals,"txid"); + vout = jint(vals,"vout"); + if ( (txoutjson= dpow_gettxout(myinfo,coin,txid,vout)) != 0 ) + { + if ( (coinaddr= jstr(txoutjson,"address")) != 0 && (value= SATOSHIDEN*jdouble(txoutjson,"value")) != 0 ) + { + retjson = cJSON_CreateObject(); + jaddstr(retjson,"result","success"); + jaddstr(retjson,"address",coinaddr); + jadd64bits(retjson,"satoshis",value); + jaddnum(retjson,"value",dstr(value)); + height = dpow_getchaintip(myinfo,&blockhash,&blocktime,0,0,coin); + jaddnum(retjson,"height",height); + jaddnum(retjson,"numconfirms",jint(txoutjson,"confirmations")); + jaddbits256(retjson,"txid",txid); + jaddnum(retjson,"vout",vout); + jaddstr(retjson,"coin",coin->symbol); + } + else + { + free_json(txoutjson); + return(clonestr("{\"error\":\"return from gettxout missing fields\"}")); + } + free_json(txoutjson); + return(jprint(retjson,1)); + } else return(clonestr("{\"error\":\"null return from gettxout\"}")); + } if ( (basilisktag= juint(vals,"basilisktag")) == 0 ) basilisktag = rand(); if ( (timeoutmillis= juint(vals,"timeout")) <= 0 ) diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index 7699bef8e..48751990e 100755 --- a/basilisk/basilisk_swap.c +++ b/basilisk/basilisk_swap.c @@ -18,8 +18,8 @@ // 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) +// - 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) diff --git a/iguana/dPoW.h b/iguana/dPoW.h index 4e0574bb7..f621e8eba 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -143,5 +143,8 @@ 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); +char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx); +cJSON *dpow_gettxout(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout); +int32_t dpow_getchaintip(struct supernet_info *myinfo,bits256 *blockhashp,uint32_t *blocktimep,bits256 *txs,uint32_t *numtxp,struct iguana_info *coin); #endif diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index e442898a4..763a2831a 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -483,7 +483,7 @@ void dpow_nanoutxoset(struct dpow_nanoutxo *np,struct dpow_block *bp,int32_t isr } else { - //dpow_bestconsensus(bp); + dpow_bestconsensus(bp); np->srcutxo = bp->notaries[bp->myind].src.prev_hash; np->srcvout = bp->notaries[bp->myind].src.prev_vout; np->destutxo = bp->notaries[bp->myind].dest.prev_hash; @@ -691,13 +691,19 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru return; if ( bp->isratify == 0 && bp->state != 0xffffffff && senderind >= 0 && senderind < bp->numnotaries && bits256_nonz(srcutxo) != 0 && bits256_nonz(destutxo) != 0 ) { - bp->notaries[senderind].src.prev_hash = srcutxo; - 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 ( bits256_nonz(srcutxo) != 0 ) + { + bp->notaries[senderind].src.prev_hash = srcutxo; + bp->notaries[senderind].src.prev_vout = srcvout; + } + if ( bits256_nonz(destutxo) != 0 ) + { + bp->notaries[senderind].dest.prev_hash = destutxo; + bp->notaries[senderind].dest.prev_vout = destvout; + } + 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 ) { @@ -720,13 +726,12 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru else bp->destsigsmasks[bestk] &= ~(1LL << senderind); } } - if ( (bp->notaries[bp->myind].paxwdcrc= bp->paxwdcrc) != 0 ) - dpow_bestconsensus(bp); - else + bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc; + if ( bp->bestmask == 0 ) { - //bp->recvmask |= (1LL << senderind) | (1LL << bp->myind); - //bp->bestmask = dpow_maskmin(bp->recvmask,bp,&bp->bestk); - dpow_bestconsensus(bp); + 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; diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 48bf4be3b..ec3356c98 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -405,7 +405,7 @@ int32_t dpow_getchaintip(struct supernet_info *myinfo,bits256 *blockhashp,uint32 coin->lastbestheight = height; if ( height > coin->longestchain ) coin->longestchain = height; - if ( (array= jarray(&n,json,"tx")) != 0 ) + if ( txs != 0 && numtxp != 0 && (array= jarray(&n,json,"tx")) != 0 ) { for (i=0; i> 1; serialized = calloc(1,sizeof(struct iguana_msghdr) + len); decode_hex(&serialized[sizeof(struct iguana_msghdr)],len,signedtx); txid = bits256_doublesha256(0,&serialized[sizeof(struct iguana_msghdr)],len); + if ( coin->FULLNODE < 0 ) + { + if ( (str= dpow_sendrawtransaction(myinfo,coin,signedtx)) != 0 ) + { + if ( is_hexstr(str,0) == sizeof(checktxid)*2 ) + { + decode_hex(checktxid.bytes,sizeof(checktxid),str); + if ( bits256_cmp(txid,checktxid) == 0 ) + { + free(str); + return(txid); + } + } + free(str); + memset(txid.bytes,0,sizeof(txid)); + return(txid); + } + } if ( coin->peers != 0 && (n= coin->peers->numranked) > 0 ) { for (i=0; i<8 && i Date: Fri, 23 Dec 2016 17:37:13 +0200 Subject: [PATCH 5/5] test --- basilisk/basilisk_MSG.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basilisk/basilisk_MSG.c b/basilisk/basilisk_MSG.c index c4e0bb4b1..725378b0e 100755 --- a/basilisk/basilisk_MSG.c +++ b/basilisk/basilisk_MSG.c @@ -307,7 +307,7 @@ 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 ) + if ( 0 && data != 0 && datalen != 0 ) dex_reqsend(myinfo,space,datalen+BASILISK_KEYSIZE); return(basilisk_standardservice("OUT",myinfo,0,jbits256(vals,"desthash"),vals,hexstr,0)); }