Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
36c4a5918c
  1. 2
      iguana/iguana777.h
  2. 7
      iguana/iguana_json.c
  3. 3
      iguana/iguana_msg.c
  4. 17
      iguana/main.c

2
iguana/iguana777.h

@ -561,7 +561,7 @@ double dxblend(double *destp,double val,double decay);
// json
int32_t iguana_processjsonQ(struct iguana_info *coin); // reentrant, can be called during any idletime
char *iguana_JSON(char *jsonstr);
char *SuperNET_p2p(struct iguana_info *coin,int32_t *delaymillisp,char *ipaddr,uint8_t *data,int32_t datalen);
char *SuperNET_p2p(struct iguana_info *coin,struct iguana_peer *addr,int32_t *delaymillisp,char *ipaddr,uint8_t *data,int32_t datalen);
char *mbstr(char *str,double);
int init_hexbytes_noT(char *hexbytes,unsigned char *message,long len);

7
iguana/iguana_json.c

@ -386,8 +386,11 @@ void SuperNET_parsepeers(struct supernet_info *myinfo,cJSON *array,int32_t n,int
ZERO_ARGS(SuperNET,stop)
{
iguana_exit();
return(clonestr("{\"result\":\"exit started\"}"));
if ( remoteaddr == 0 || strncmp(remoteaddr,"127.0.0.1",strlen("127.0.0.1")) == 0 )
{
iguana_exit();
return(clonestr("{\"result\":\"exit started\"}"));
} else return(clonestr("{\"error\":\"cant do a remote stop of this node\"}"));
}
TWO_ARRAYS(SuperNET,mypeers,supernet,rawpeers)

3
iguana/iguana_msg.c

@ -446,8 +446,9 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc
if ( strcmp(H->command,"SuperNET") == 0 )
{
addr->supernet = 1;
addr->msgcounts.verack++;
len = recvlen;
if ( (retstr= SuperNET_p2p(coin,&delay,addr->ipaddr,data,recvlen)) != 0 )
if ( (retstr= SuperNET_p2p(coin,addr,&delay,addr->ipaddr,data,recvlen)) != 0 )
{
iguana_send_supernet(coin,addr,retstr,delay);
free(retstr);

17
iguana/main.c

@ -159,7 +159,7 @@ char *iguana_JSON(char *jsonstr)
return(retstr);
}
char *SuperNET_p2p(struct iguana_info *coin,int32_t *delaymillisp,char *ipaddr,uint8_t *data,int32_t datalen)
char *SuperNET_p2p(struct iguana_info *coin,struct iguana_peer *addr,int32_t *delaymillisp,char *ipaddr,uint8_t *data,int32_t datalen)
{
cJSON *json,*retjson; char *agent,*method,*retstr = 0;
*delaymillisp = 0;
@ -168,6 +168,12 @@ char *SuperNET_p2p(struct iguana_info *coin,int32_t *delaymillisp,char *ipaddr,u
printf("GOT >>>>>>>> SUPERNET P2P.(%s) from.%s\n",(char *)data,coin->symbol);
if ( (agent= jstr(json,"agent")) != 0 && (method= jstr(json,"method")) != 0 )
{
if ( strcmp(agent,"SuperNET") == 0 && strcmp(method,"stop") == 0 )
{
addr->dead = (uint32_t)time(NULL);
free_json(json);
return(clonestr("{\"result\":\"peer marked as dead\"}"));
}
jaddstr(json,"fromp2p",coin->symbol);
if ( (retstr= SuperNET_JSON(0,json,ipaddr)) != 0 )
{
@ -191,22 +197,27 @@ char *SuperNET_p2p(struct iguana_info *coin,int32_t *delaymillisp,char *ipaddr,u
void iguana_exit()
{
int32_t i,j,k;
int32_t i,j,k; char *stopstr = "{\"agent\":\"SuperNET\",\"method\":\"stop\"}";
printf("start EXIT\n");
for (i=0; i<IGUANA_MAXCOINS; i++)
{
if ( Coins[i] != 0 )
{
for (j=0; j<IGUANA_MAXPEERS; j++)
Coins[i]->peers.active[j].dead = (uint32_t)time(NULL);
{
if ( Coins[i]->peers.active[j].usock >= 0 )
iguana_send_supernet(Coins[i],&Coins[i]->peers.active[j],stopstr,0);
}
}
}
sleep(3);
for (i=0; i<IGUANA_MAXCOINS; i++)
{
if ( Coins[i] != 0 )
{
for (j=0; j<IGUANA_MAXPEERS; j++)
{
Coins[i]->peers.active[j].dead = (uint32_t)time(NULL);
for (k=0; k<3; k++)
{
if ( Coins[i]->peers.active[j].usock >= 0 )

Loading…
Cancel
Save