Browse Source

stronger addnode

release/v0.1
jl777 9 years ago
parent
commit
c3d7156bc6
  1. 18
      iguana/iguana_json.c
  2. 2
      iguana/iguana_peers.c
  3. 4
      iguana/iguana_rpc.c
  4. 2
      iguana/main.c
  5. 14
      includes/iguana_apideclares.h

18
iguana/iguana_json.c

@ -617,10 +617,22 @@ STRING_ARG(iguana,pausecoin,activecoin)
TWO_STRINGS(iguana,addnode,activecoin,ipaddr)
{
if ( coin != 0 && ipaddr != 0 )
struct iguana_peer *addr;
if ( coin == 0 )
coin = iguana_coinfind(activecoin);
printf("coin.%p.[%s] addnode.%s -> %s\n",coin,coin!=0?coin->symbol:"",activecoin,ipaddr);
if ( coin != 0 && ipaddr != 0 && is_ipaddr(ipaddr) != 0 )
{
iguana_possible_peer(coin,ipaddr);
return(clonestr("{\"result\":\"addnode submitted\"}"));
//iguana_possible_peer(coin,ipaddr);
if ( (addr= iguana_peerslot(coin,(uint32_t)calc_ipbits(ipaddr),0)) != 0 )
{
if ( addr->pending == 0 )
{
addr->pending = (uint32_t)time(NULL);
iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD);
return(clonestr("{\"result\":\"addnode submitted\"}"));
} else return(clonestr("{\"result\":\"addnode connection was already pending\"}"));
} else return(clonestr("{\"result\":\"addnode cant find peer slot\"}"));
}
else if ( coin == 0 )
return(clonestr("{\"error\":\"addnode needs active coin, do an addcoin first\"}"));

2
iguana/iguana_peers.c

@ -443,9 +443,9 @@ int32_t iguana_recv(char *ipaddr,int32_t usock,uint8_t *recvbuf,int32_t len)
{
if ( (recvlen= (int32_t)recv(usock,recvbuf,remains,0)) < 0 )
{
printf("%s recv errno.%d %s\n",ipaddr,errno,strerror(errno));
if ( errno == EAGAIN )
{
printf("%s recv errno.%d %s\n",ipaddr,errno,strerror(errno));
//printf("EAGAIN for len %d, remains.%d\n",len,remains);
sleep(1);
} else return(-errno);

4
iguana/iguana_rpc.c

@ -728,7 +728,9 @@ char *SuperNET_rpcparse(struct supernet_info *myinfo,char *retbuf,int32_t bufsiz
if ( (filestr= SuperNET_htmlstr("index7778.html",retbuf,bufsize,0)) != 0 )
printf("created index7778.html size %ld\n",strlen(filestr));
}
return(filestr);
if ( filestr != 0 )
return(filestr);
else return(clonestr("{\"error\":\"cant find index7778\"}"));
}
else if ( (filestr= OS_filestr(&filesize,url+1)) != 0 )
return(filestr);

2
iguana/main.c

@ -354,7 +354,7 @@ void iguana_main(void *arg)
strcpy(MYINFO.rpcsymbol,"BTCD");
iguana_launchcoin(MYINFO.rpcsymbol,cJSON_Parse("{}"));
if ( 0 && (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"wallet\":\"password\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":128,\"maxpeers\":3,\"newcoin\":\"BTCD\",\"active\":0}"),0)) != 0 )
if ( 0 && (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"wallet\":\"password\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":128,\"maxpeers\":3,\"newcoin\":\"BTCD\",\"active\":1}"),0)) != 0 )
{
printf("got.(%s)\n",str);
free(str);

14
includes/iguana_apideclares.h

@ -16,8 +16,14 @@
STRING_ARG(SuperNET,bitcoinrpc,setcoin);
ZERO_ARGS(SuperNET,myipaddr);
STRING_ARG(SuperNET,setmyipaddr,ipaddr);
HASH_AND_STRING(ramchain,verifytx,txid,txbytes);
TWO_STRINGS_AND_TWO_DOUBLES(InstantDEX,BTCoffer,othercoin,otherassetid,maxprice,othervolume);
TWO_STRINGS_AND_TWO_DOUBLES(InstantDEX,minaccept,base,rel,minprice,basevolume);
TWO_STRINGS_AND_TWO_DOUBLES(InstantDEX,maxaccept,base,rel,maxprice,basevolume);
STRING_AND_TWO_DOUBLES(InstantDEX,ALToffer,basecoin,minprice,basevolume);
STRING_AND_TWO_DOUBLES(InstantDEX,NXToffer,assetid,minprice,basevolume);
HASH_AND_STRING(ramchain,verifytx,txid,txbytes);
INT_ARG(ramchain,getblockhash,height);
HASH_AND_INT(ramchain,getblock,blockhash,remoteonly);
HASH_AND_INT(ramchain,getrawtransaction,txid,verbose);
@ -46,12 +52,6 @@ STRING_AND_INT(InstantDEX,pollgap,exchange,pollgap);
ZERO_ARGS(InstantDEX,allexchanges);
STRING_ARG(InstantDEX,allpairs,exchange);
STRING_AND_TWO_DOUBLES(InstantDEX,ALToffer,basecoin,minprice,basevolume);
STRING_AND_TWO_DOUBLES(InstantDEX,NXToffer,assetid,minprice,basevolume);
TWO_STRINGS_AND_TWO_DOUBLES(InstantDEX,BTCoffer,othercoin,otherassetid,maxprice,othervolume);
TWO_STRINGS_AND_TWO_DOUBLES(InstantDEX,minaccept,base,rel,minprice,basevolume);
TWO_STRINGS_AND_TWO_DOUBLES(InstantDEX,maxaccept,base,rel,maxprice,basevolume);
//TWOSTRINGS_AND_TWOHASHES_AND_TWOINTS(InstantDEX,proposal,reference,message,basetxid,reltxid,duration,flags);
//TWOSTRINGS_AND_TWOHASHES_AND_TWOINTS(InstantDEX,accept,reference,message,basetxid,reltxid,duration,flags);
//TWOSTRINGS_AND_TWOHASHES_AND_TWOINTS(InstantDEX,confirm,reference,message,basetxid,reltxid,baseheight,relheight);

Loading…
Cancel
Save