Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
81ce273e49
  1. 2
      iguana/iguana_bundles.c
  2. 2
      iguana/iguana_peers.c
  3. 10
      iguana/main.c
  4. 25
      iguana/ramchain_api.c
  5. 2
      includes/iguana_apideclares.h

2
iguana/iguana_bundles.c

@ -441,6 +441,8 @@ void iguana_bundlestats(struct iguana_info *coin,char *str)
{
printf("%s\n",str);
lastdisp = (uint32_t)time(NULL);
if ( coin->peers.ranked[0] != 0 )
iguana_send_ping(coin,coin->peers.ranked[0]);
}
strcpy(coin->statusstr,str);
coin->estsize = estsize;

2
iguana/iguana_peers.c

@ -587,6 +587,8 @@ void iguana_startconnection(void *arg)
printf("PEER CONNECTED.%d:%d of max.%d! %s:%d usock.%d\n",coin->peers.numconnected,n,coin->MAXPEERS,addr->ipaddr,coin->chain->portp2p,addr->usock);
if ( strcmp("127.0.0.1",addr->ipaddr) == 0 )
coin->peers.localaddr = addr;
else if ( coin->peers.numranked == 0 )
coin->peers.ranked[0] = addr;
#ifdef IGUANA_DEDICATED_THREADS
//iguana_launch("recv",iguana_dedicatedrecv,addr,IGUANA_RECVTHREAD);
iguana_dedicatedloop(coin,addr);

10
iguana/main.c

@ -71,10 +71,10 @@ int32_t iguana_jsonQ()
}
if ( (ptr= queue_dequeue(&jsonQ,0)) != 0 )
{
//printf("process.(%s)\n",ptr->jsonstr);
printf("process.(%s)\n",ptr->jsonstr);
if ( (*ptr->retjsonstrp= SuperNET_jsonstr(ptr->myinfo,ptr->jsonstr,ptr->remoteaddr)) == 0 )
*ptr->retjsonstrp = clonestr("{\"error\":\"null return from iguana_jsonstr\"}");
//printf("finished.(%s)\n",ptr->jsonstr);
printf("finished.(%s)\n",ptr->jsonstr);
queue_enqueue("finishedQ",&finishedQ,&ptr->DL,0);
return(1);
}
@ -114,7 +114,7 @@ char *iguana_blockingjsonstr(struct supernet_info *myinfo,char *jsonstr,uint64_t
char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr)
{
cJSON *retjson; uint64_t tag; uint32_t timeout; char *jsonstr; char *retjsonstr,*retstr = 0;
printf("SuperNET_JSON.(%s)\n",jprint(json,0));
printf("SuperNET_JSON.(%s) remoteaddr.(%s)\n",jprint(json,0),remoteaddr!=0?remoteaddr:"");
if ( json != 0 )
{
if ( (tag= j64bits(json,"tag")) == 0 )
@ -170,10 +170,12 @@ char *SuperNET_p2p(struct iguana_info *coin,int32_t *delaymillisp,char *ipaddr,u
jaddstr(json,"fromp2p",coin->symbol);
if ( (retstr= SuperNET_JSON(0,json,ipaddr)) != 0 )
{
printf("retstr.(%s)\n",retstr);
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
if ( jobj(retjson,"result") != 0 || jobj(retjson,"error") != 0 || jobj(retjson,"method") == 0 )
{
printf("it is a result, dont return\n");
free(retstr);
retstr = 0;
}
@ -241,7 +243,7 @@ void iguana_main(void *arg)
#ifdef __APPLE__
sleep(1);
char *str;
if ( (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":0,\"maxpeers\":2,\"activecoin\":\"BTC\",\"active\":1}"),0)) != 0 )
if ( (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":0,\"maxpeers\":2,\"activecoin\":\"BTCD\",\"active\":1}"),0)) != 0 )
{
printf("got.(%s)\n",str);
free(str);

25
iguana/ramchain_api.c

@ -16,25 +16,30 @@
#include "iguana777.h"
#include "../includes/iguana_apidefs.h"
ZERO_ARGS(ramchain,getpeers)
STRING_ARG(ramchain,getpeers,activecoin)
{
int32_t i,r,j,iter,n; struct iguana_peer *addr; cJSON *array = cJSON_CreateArray();
cJSON *retjson = cJSON_CreateObject();
r = rand();
for (iter=n=0; iter<2; iter++)
printf("inside getpeers coin.%p\n",coin);
if ( coin != 0 )
{
for (j=0; j<IGUANA_MAXPEERS; j++)
r = rand();
for (iter=n=0; iter<2; iter++)
{
i = (r + j) % IGUANA_MAXPEERS;
addr = &coin->peers.active[i];
if ( addr->usock >= 0 && (iter == 1 || addr->supernet != 0) )
for (j=0; j<IGUANA_MAXPEERS; j++)
{
jaddistr(array,addr->ipaddr);
if ( ++n >= 64 )
break;
i = (r + j) % IGUANA_MAXPEERS;
addr = &coin->peers.active[i];
if ( addr->usock >= 0 && (iter == 1 || addr->supernet != 0) )
{
jaddistr(array,addr->ipaddr);
if ( ++n >= 64 )
break;
}
}
}
}
jadd(retjson,"peers",array);
return(jprint(retjson,1));
}

2
includes/iguana_apideclares.h

@ -28,7 +28,7 @@ TWO_STRINGS(iguana,removenode,activecoin,ipaddr);
TWO_STRINGS(iguana,oneshot,activecoin,ipaddr);
TWO_STRINGS(iguana,nodestatus,activecoin,ipaddr);
ZERO_ARGS(ramchain,getpeers);
STRING_ARG(ramchain,getpeers,activecoin);
ZERO_ARGS(ramchain,getinfo);
ZERO_ARGS(ramchain,getbestblockhash);
ZERO_ARGS(ramchain,getblockcount);

Loading…
Cancel
Save