Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
88fe08f91d
  1. 8
      iguana/SuperNET_category.c
  2. 3
      iguana/iguana_exchanges.c
  3. 10
      iguana/iguana_instantdex.c
  4. 2
      iguana/iguana_rpc.c

8
iguana/SuperNET_category.c

@ -332,15 +332,11 @@ char *SuperNET_categorymulticast(struct supernet_info *myinfo,int32_t surveyflag
void category_init(struct supernet_info *myinfo)
{
bits256 pangeahash,instantdexhash;
//exchanges777_init(0);
bits256 pangeahash;
category_subscribe(myinfo,GENESIS_PUBKEY,GENESIS_PUBKEY);
pangeahash = calc_categoryhashes(0,"pangea",0);
category_subscribe(myinfo,pangeahash,GENESIS_PUBKEY);
category_processfunc(pangeahash,pangea_hexmsg);
category_chain_functions(myinfo,pangeahash,GENESIS_PUBKEY,sizeof(bits256),sizeof(bits256),0,0,0,0);
instantdexhash = calc_categoryhashes(0,"InstantDEX",0);
printf("InstantDEX:\n");
category_subscribe(myinfo,instantdexhash,GENESIS_PUBKEY);
category_processfunc(instantdexhash,InstantDEX_hexmsg);
exchanges777_init(myinfo,0,0);
}

3
iguana/iguana_exchanges.c

@ -930,7 +930,8 @@ void exchanges777_init(struct supernet_info *myinfo,cJSON *exchanges,int32_t sle
free_json(argjson);
}
instantdexhash = calc_categoryhashes(0,"InstantDEX",0);
category_subscribe(SuperNET_MYINFO(0),instantdexhash,GENESIS_PUBKEY);
printf("InstantDEX:\n");
category_subscribe(myinfo,instantdexhash,GENESIS_PUBKEY);
category_processfunc(instantdexhash,InstantDEX_hexmsg);
}

10
iguana/iguana_instantdex.c

@ -46,7 +46,7 @@ struct instantdex_msghdr *instantdex_msgcreate(struct supernet_info *myinfo,stru
char *instantdex_sendcmd(struct supernet_info *myinfo,cJSON *argjson,char *cmdstr,char *ipaddr,int32_t hops)
{
char *reqstr,hexstr[8192]; uint8_t _msg[4096]; uint64_t nxt64bits; int32_t datalen;
char *reqstr,hexstr[8192]; uint8_t _msg[4096]; uint64_t nxt64bits; int32_t i,datalen;
bits256 instantdexhash; struct instantdex_msghdr *msg;
msg = (struct instantdex_msghdr *)_msg;
memset(msg,0,sizeof(*msg));
@ -55,6 +55,9 @@ char *instantdex_sendcmd(struct supernet_info *myinfo,cJSON *argjson,char *cmdst
if ( ipaddr == 0 || ipaddr[0] == 0 || strncmp(ipaddr,"127.0.0.1",strlen("127.0.0.1")) == 0 )
return(clonestr("{\"error\":\"no ipaddr, need to send your ipaddr for now\"}"));
jaddstr(argjson,"cmd",cmdstr);
for (i=0; i<sizeof(msg->cmd); i++)
if ( (msg->cmd[i]= cmdstr[i]) == 0 )
break;
jaddstr(argjson,"agent","SuperNET");
jaddstr(argjson,"method","DHT");
jaddstr(argjson,"traderip",ipaddr);
@ -223,12 +226,15 @@ char *instantdex_parse(struct supernet_info *myinfo,struct instantdex_msghdr *ms
cmdbits = stringbits(msg->cmd);
for (i=0; i<sizeof(cmds)/sizeof(*cmds); i++)
{
printf("%llx vs ",(long long)cmds[i].cmdbits);
if ( cmds[i].cmdbits == cmdbits )
{
printf("parsed.(%s)\n",cmds[i].cmdstr);
retstr = (*cmds[i].func)(myinfo,msg,argjson,remoteaddr,signerbits,data,datalen);
break;
}
}
printf("%llx (%s)\n",(long long)cmdbits,msg->cmd);
return(retstr);
}
@ -252,7 +258,7 @@ char *InstantDEX_hexmsg(struct supernet_info *myinfo,void *ptr,int32_t len,char
else if ( (signerbits= acct777_validate(&msg->sig,acct777_msgprivkey(data,datalen),msg->sig.pubkey)) != 0 )
{
flag++;
printf("<<<<<<<<<<<<< sigsize.%ld VALIDATED [%ld] len.%d t%u allocsize.%d (%s) [%d]\n",sizeof(msg->sig),(long)data-(long)msg,datalen,msg->sig.timestamp,msg->sig.allocsize,(char *)msg->serialized,data[datalen-1]);
printf("InstantDEX_hexmsg <<<<<<<<<<<<< sigsize.%ld VALIDATED [%ld] len.%d t%u allocsize.%d (%s) [%d]\n",sizeof(msg->sig),(long)data-(long)msg,datalen,msg->sig.timestamp,msg->sig.allocsize,(char *)msg->serialized,data[datalen-1]);
if ( data[datalen-1] == 0 && (argjson= cJSON_Parse((char *)msg->serialized)) != 0 )
retstr = instantdex_parse(myinfo,msg,argjson,remoteaddr,signerbits,data,datalen);
else

2
iguana/iguana_rpc.c

@ -962,7 +962,7 @@ void iguana_rpcloop(void *args)
sprintf(hdrs,"Content-Length: %8d\r\n",(int32_t)strlen(retstr));
send(sock,hdrs,strlen(hdrs),MSG_NOSIGNAL);*/
char *response,hdrs[1024];
if ( jsonflag != 0 )
if ( jsonflag != 0 || postflag != 0 )
{
response = malloc(strlen(retstr)+1024+1);
sprintf(hdrs,"HTTP/1.1 200 OK\r\nAccess-Control-Allow-Origin: *\r\nAccess-Control-Allow-Credentials: true\r\nAccess-Control-Allow-Methods: GET, POST\r\nCache-Control : no-cache, no-store, must-revalidate\r\nContent-Length : %8d\r\n\r\n",(int32_t)strlen(retstr));

Loading…
Cancel
Save