From fae9b20dd67e0bbfdefaa4dd55883354d6fe4a1a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Oct 2016 10:39:55 -0300 Subject: [PATCH] test --- basilisk/basilisk.c | 22 +++---- basilisk/basilisk_CMD.c | 15 +++-- basilisk/basilisk_bitcoin.c | 2 +- basilisk/basilisk_ping.c | 2 +- iguana/iguana777.c | 2 +- iguana/iguana_chains.c | 4 +- iguana/iguana_init.c | 2 +- iguana/iguana_json.c | 2 +- iguana/iguana_msg.c | 2 +- iguana/iguana_notary.c | 15 ++++- iguana/iguana_wallet.c | 4 +- iguana/ni | 6 +- iguana/tests/addnotarys_7776 | 106 +++++++++++++++++----------------- includes/iguana_apideclares.h | 1 + 14 files changed, 97 insertions(+), 88 deletions(-) diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index 3a7096c5e..b7903983d 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -218,7 +218,7 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ { if ( coin->peers == 0 ) continue; - if ( basilisk_notarycmd(type) != 0 && strcmp(coin->symbol,"NOTARY") != 0 ) + if ( basilisk_notarycmd(type) != 0 && strcmp(coin->symbol,"RELAY") != 0 ) continue; if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 ) cmd[0] = 's'; @@ -235,7 +235,7 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ { s = 0; valid = (addr->supernet != 0); - if ( basilisk_notarycmd(type) != 0 || (strcmp(type,"INF") == 0 && strcmp(coin->symbol,"NOTARY") == 0) ) + if ( basilisk_notarycmd(type) != 0 || (strcmp(type,"INF") == 0 && strcmp(coin->symbol,"RELAY") == 0) ) { valid = 0; /*OS_randombytes((void *)&r2,sizeof(r2)); @@ -359,7 +359,7 @@ struct basilisk_item *basilisk_issueremote(struct supernet_info *myinfo,struct i portable_mutex_unlock(&myinfo->basilisk_mutex); if ( pending->expiration <= OS_milliseconds() ) pending->expiration = OS_milliseconds() + pending->duration; - strcpy(pending->symbol,"NOTARY"); + strcpy(pending->symbol,"RELAY"); strcpy(pending->CMD,CMD); //printf("block for %f\n",pending->expiration - OS_milliseconds()); while ( OS_milliseconds() < pending->expiration ) @@ -416,7 +416,7 @@ struct basilisk_item *basilisk_requestservice(struct supernet_info *myinfo,struc } } if ( symbol == 0 ) - symbol = "NOTARY"; + symbol = "RELAY"; encryptflag = jint(valsobj,"encrypt"); delaymillis = jint(valsobj,"delay"); ptr = basilisk_issueremote(myinfo,addr,&numsent,CMD,symbol,blockflag,valsobj,fanout,numrequired,0,timeoutmillis,0,0,encryptflag,delaymillis,nBits); @@ -684,7 +684,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende return; } else if ( basilisk_notarycmd(CMD) != 0 ) return; - symbol = "NOTARY"; + symbol = "RELAY"; if ( senderipbits == 0 ) expand_ipbits(remoteaddr,myinfo->myaddr.myipbits); else expand_ipbits(remoteaddr,senderipbits); @@ -865,21 +865,21 @@ int32_t basilisk_issued_purge(struct supernet_info *myinfo,int32_t timepad) void basilisks_loop(void *arg) { static uint32_t counter; - struct iguana_info *notary; struct supernet_info *myinfo = arg; int32_t iter; double startmilli,endmilli; + struct iguana_info *relay; struct supernet_info *myinfo = arg; int32_t iter; double startmilli,endmilli; iter = 0; - notary = iguana_coinfind("NOTARY"); + relay = iguana_coinfind("RELAY"); printf("start basilisk loop\n"); while ( 1 ) { - if ( notary == 0 ) - notary = iguana_coinfind("NOTARY"); + if ( relay == 0 ) + relay = iguana_coinfind("RELAY"); startmilli = OS_milliseconds(); basilisk_issued_purge(myinfo,600000); basilisk_p2pQ_process(myinfo,777); if ( myinfo->NOTARY.RELAYID >= 0 ) { - if ( notary != 0 ) - basilisk_ping_send(myinfo,notary); + if ( relay != 0 ) + basilisk_ping_send(myinfo,relay); if ( (counter++ % 10) == 0 && myinfo->DPOW.symbol[0] != 0 && myinfo->DPOW.dest[0] != 0 ) iguana_dPoWupdate(myinfo); endmilli = startmilli + 500; diff --git a/basilisk/basilisk_CMD.c b/basilisk/basilisk_CMD.c index 05a9e0afa..858786d3c 100755 --- a/basilisk/basilisk_CMD.c +++ b/basilisk/basilisk_CMD.c @@ -28,12 +28,12 @@ void basilisk_ensurerelay(struct supernet_info *myinfo,struct iguana_info *notar { char ipaddr[64]; expand_ipbits(ipaddr,ipbits); -#if ISNOTARYNODE - dpow_nanomsginit(myinfo,ipaddr); -#else +//#if ISNOTARYNODE + //dpow_nanomsginit(myinfo,ipaddr); +//#else struct iguana_peer *addr; int32_t i; if ( notaries == 0 || ipbits == myinfo->myaddr.myipbits ) - return(0); + return; if ( (addr= iguana_peerfindipbits(notaries,ipbits,0)) == 0 ) { if ( (addr= iguana_peerslot(notaries,ipbits,0)) != 0 && addr->isrelay == 0 ) @@ -50,8 +50,7 @@ void basilisk_ensurerelay(struct supernet_info *myinfo,struct iguana_info *notar iguana_launch(notaries,"addrelay",iguana_startconnection,addr,IGUANA_CONNTHREAD); } else printf("error getting peerslot\n"); } else addr->isrelay = 1; - return(addr); -#endif +//#endif } static int _increasing_ipbits(const void *a,const void *b) @@ -79,7 +78,7 @@ void basilisk_relay_remap(struct supernet_info *myinfo,struct basilisk_relay *rp void basilisk_setmyid(struct supernet_info *myinfo) { - int32_t i; char ipaddr[64]; struct iguana_info *notaries = iguana_coinfind("NOTARY"); + int32_t i; char ipaddr[64]; struct iguana_info *notaries = iguana_coinfind("RELAY"); for (i=0; iNOTARY.NUMRELAYS; i++) { expand_ipbits(ipaddr,myinfo->NOTARY.RELAYS[i].ipbits); @@ -114,7 +113,7 @@ char *basilisk_addrelay_info(struct supernet_info *myinfo,uint8_t *pubkey33,uint rp = &myinfo->NOTARY.RELAYS[i]; rp->ipbits = ipbits; rp->relayid = myinfo->NOTARY.NUMRELAYS; - basilisk_ensurerelay(myinfo,iguana_coinfind("NOTARY"),rp->ipbits); + basilisk_ensurerelay(myinfo,iguana_coinfind("RELAY"),rp->ipbits); if ( myinfo->NOTARY.NUMRELAYS < sizeof(myinfo->NOTARY.RELAYS)/sizeof(*myinfo->NOTARY.RELAYS) ) myinfo->NOTARY.NUMRELAYS++; qsort(myinfo->NOTARY.RELAYS,myinfo->NOTARY.NUMRELAYS,sizeof(myinfo->NOTARY.RELAYS[0]),_increasing_ipbits); diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index ea674cca7..0ac3574b4 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/basilisk/basilisk_bitcoin.c @@ -445,7 +445,7 @@ void *basilisk_getinfo(struct basilisk_item *Lptr,struct supernet_info *myinfo,s struct basilisk_item *ptr; cJSON *infojson,*retjson; int32_t j,numsent,fanout,numrequired; if ( valsobj == 0 ) return(clonestr("{\"error\":\"null valsobj\"}")); - if ( (myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0) && strcmp(coin->symbol,"NOTARY") != 0 ) + if ( (myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0) && strcmp(coin->symbol,"RELAY") != 0 ) return(0); if ( coin->VALIDATENODE > 0 || coin->FULLNODE > 0 ) { diff --git a/basilisk/basilisk_ping.c b/basilisk/basilisk_ping.c index 3ec6693d3..53d5aa2d4 100755 --- a/basilisk/basilisk_ping.c +++ b/basilisk/basilisk_ping.c @@ -213,7 +213,7 @@ void basilisk_ping_process(struct supernet_info *myinfo,struct iguana_peer *addr { int32_t diff,i,n,len = 0; struct iguana_info *notary; char ipbuf[64]; struct basilisk_relay *rp; uint8_t numrelays; uint16_t sn; uint32_t now = (uint32_t)time(NULL); expand_ipbits(ipbuf,senderipbits); - notary = iguana_coinfind("NOTARY"); + notary = iguana_coinfind("RELAY"); for (i=0; iNOTARY.NUMRELAYS; i++) { rp = &myinfo->NOTARY.RELAYS[i]; diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 5618c4be3..a24f41a93 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -858,7 +858,7 @@ void iguana_coinloop(void *arg) { if ( coin->FULLNODE < 0 ) continue; - if ( strcmp(coin->symbol,"NOTARY") == 0 ) + if ( strcmp(coin->symbol,"RELAY") == 0 ) { if ( myinfo->expiration != 0 && (myinfo->IAMLP != 0 || myinfo->DEXactive > now) ) basilisk_requests_poll(myinfo); diff --git a/iguana/iguana_chains.c b/iguana/iguana_chains.c index 25f296dde..8e7de64c2 100755 --- a/iguana/iguana_chains.c +++ b/iguana/iguana_chains.c @@ -321,7 +321,7 @@ void iguana_chainparms(struct supernet_info *myinfo,struct iguana_chain *chain,c if ( juint(argjson,"p2p") != 0 ) chain->portp2p = juint(argjson,"p2p"); else chain->portp2p = juint(argjson,"portp2p"); - if ( (chain->rpcport= juint(argjson,"rpc")) == 0 && strcmp(chain->symbol,"NOTARY") != 0 ) + if ( (chain->rpcport= juint(argjson,"rpc")) == 0 && strcmp(chain->symbol,"RELAY") != 0 ) { if ( chain->portp2p != 0 ) chain->rpcport = chain->portp2p-1; @@ -504,7 +504,7 @@ void iguana_chaininit(struct supernet_info *myinfo,struct iguana_chain *chain,in if ( strcmp(chain->symbol,"BTC") == 0 ) chain->bundlesize = 100; decode_hex((uint8_t *)chain->genesis_hashdata,32,(char *)chain->genesis_hash); - if ( chain->rpcport == 0 && strcmp(chain->symbol,"NOTARY") != 0 ) + if ( chain->rpcport == 0 && strcmp(chain->symbol,"RELAY") != 0 ) chain->rpcport = chain->portp2p + 1; } diff --git a/iguana/iguana_init.c b/iguana/iguana_init.c index 0552d7a46..2c7abc699 100755 --- a/iguana/iguana_init.c +++ b/iguana/iguana_init.c @@ -550,7 +550,7 @@ struct iguana_info *iguana_coinstart(struct supernet_info *myinfo,struct iguana_ } } } - if ( coin->rpcloop == 0 && strcmp(coin->chain->symbol,"NOTARY") != 0 ) + if ( coin->rpcloop == 0 && strcmp(coin->chain->symbol,"RELAY") != 0 ) { myinfo->argport = coin->chain->rpcport; coin->rpcloop = malloc(sizeof(pthread_t)); diff --git a/iguana/iguana_json.c b/iguana/iguana_json.c index 566f67176..59e93d0b8 100755 --- a/iguana/iguana_json.c +++ b/iguana/iguana_json.c @@ -651,7 +651,7 @@ TWO_STRINGS(iguana,addnode,activecoin,ipaddr) struct iguana_peer *addr; int32_t i,n; if ( coin == 0 ) coin = iguana_coinfind(activecoin); - if ( coin != 0 && strcmp(coin->symbol,"NOTARY") == 0 ) + if ( coin != 0 && strcmp(coin->symbol,"RELAY") == 0 ) basilisk_addrelay_info(myinfo,0,(uint32_t)calc_ipbits(ipaddr),GENESIS_PUBKEY); printf("coin.%p.[%s] addnode.%s -> %s\n",coin,coin!=0?coin->symbol:"",activecoin,ipaddr); if ( coin != 0 && coin->peers != 0 && ipaddr != 0 && is_ipaddr(ipaddr) != 0 ) diff --git a/iguana/iguana_msg.c b/iguana/iguana_msg.c index 69d115c89..ba6c641e4 100755 --- a/iguana/iguana_msg.c +++ b/iguana/iguana_msg.c @@ -1010,7 +1010,7 @@ int32_t iguana_msgparser(struct supernet_info *myinfo,struct iguana_info *coin,s { struct iguana_msgzblock zmsg; struct iguana_msgblock *msg = (void *)&zmsg; struct iguana_zblock *zblocks; uint32_t tmp,n=0; len = 0; - if ( addr != 0 && recvlen >= sizeof(bits256) && strcmp("NOTARY",coin->symbol) != 0 ) + if ( addr != 0 && recvlen >= sizeof(bits256) && strcmp("RELAY",coin->symbol) != 0 ) { if ( ishost == 0 ) { diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 0a1bf3375..bcb964d4f 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -37,13 +37,13 @@ struct dpow_nanomsghdr char *nanomsg_tcpname(char *str,char *ipaddr) { - sprintf(str,"tcp://%s:7774",ipaddr); + sprintf(str,"tcp://%s:7775",ipaddr); return(str); } void dpow_nanomsginit(struct supernet_info *myinfo,char *ipaddr) { - char str[512]; int32_t timeout; + char str[512]; int32_t timeout,retval; if ( myinfo->DPOW.sock < 0 && (myinfo->DPOW.sock= nn_socket(AF_SP,NN_BUS)) >= 0 ) { if ( nn_bind(myinfo->DPOW.sock,nanomsg_tcpname(str,myinfo->ipaddr)) < 0 ) @@ -56,7 +56,10 @@ void dpow_nanomsginit(struct supernet_info *myinfo,char *ipaddr) nn_setsockopt(myinfo->DPOW.sock,NN_SOL_SOCKET,NN_RCVTIMEO,&timeout,sizeof(timeout)); } if ( myinfo->DPOW.sock >= 0 && strcmp(ipaddr,myinfo->ipaddr) != 0 ) - nn_connect(myinfo->DPOW.sock,ipaddr); + { + retval = nn_connect(myinfo->DPOW.sock,ipaddr); + printf("addnotary (%s) retval.%d\n",ipaddr,retval); + } } 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]) @@ -1489,4 +1492,10 @@ TWO_STRINGS(komodo,passthru,function,hex) else return(clonestr("{\"error\":\"KMD not active, start in bitcoind mode\"}")); } +STRING_ARG(iguana,addnotary,ipaddr) +{ + dpow_nanomsginit(myinfo,ipaddr); + return(clonestr("{\"result\":\"notary node added\"}")); +} + #include "../includes/iguana_apiundefs.h" diff --git a/iguana/iguana_wallet.c b/iguana/iguana_wallet.c index 2342142a5..06a6dde5c 100755 --- a/iguana/iguana_wallet.c +++ b/iguana/iguana_wallet.c @@ -1120,7 +1120,7 @@ cJSON *iguana_getinfo(struct supernet_info *myinfo,struct iguana_info *coin) if ( addr->usock >= 0 && addr->supernet != 0 && addr->ipaddr[0] != 0 ) { jaddistr(array,addr->ipaddr); - if ( strcmp(coin->symbol,"NOTARY") == 0 ) + if ( strcmp(coin->symbol,"RELAY") == 0 ) basilisk_addrelay_info(myinfo,0,(uint32_t)calc_ipbits(addr->ipaddr),GENESIS_PUBKEY); } } @@ -1171,7 +1171,7 @@ ZERO_ARGS(bitcoinrpc,getinfo) if ( (fullnodes= jarray(&m,item,"supernet")) != 0 ) { incr = 1; - if ( strcmp(coin->symbol,"NOTARY") == 0 ) + if ( strcmp(coin->symbol,"RELAY") == 0 ) { for (j=0; j