Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
e0920ea1b3
  1. 6
      iguana/SuperNET.c
  2. 2
      iguana/iguana777.h
  3. 8
      iguana/iguana_msg.c
  4. 45
      iguana/iguana_payments.c
  5. 2
      iguana/iguana_peers.c
  6. 2
      iguana/main.c

6
iguana/SuperNET.c

@ -469,7 +469,7 @@ bits256 iguana_actualpubkey(int32_t *offsetp,uint8_t *cipher,int32_t cipherlen,b
return(destpubkey);
}
int32_t iguana_send_supernet(struct iguana_info *coin,struct iguana_peer *addr,char *jsonstr,int32_t delaymillis)
int32_t iguana_send_supernet(struct iguana_peer *addr,char *jsonstr,int32_t delaymillis)
{
int32_t datalen,cipherlen,qlen = -1; uint8_t *serialized,space2[32768],*cipher; cJSON *json;
struct supernet_info *myinfo; uint16_t checkc;
@ -600,7 +600,7 @@ char *SuperNET_DHTsend(struct supernet_info *myinfo,uint64_t destipbits,bits256
if ( strcmp("0.0.0.0",addr->ipaddr) != 0 && strcmp("127.0.0.1",addr->ipaddr) != 0 )
{
char str[65]; printf("BROADCAST[%d] crc.%x %s SEND.(%d) to %s\n",j,calc_crc32(0,jsonstr,(int32_t)strlen(jsonstr)),bits256_str(str,categoryhash),(int32_t)strlen(jsonstr),addr->ipaddr);
iguana_send_supernet(Coins[i],addr,jsonstr,maxdelay==0?0:(rand()%maxdelay));
iguana_send_supernet(addr,jsonstr,maxdelay==0?0:(rand()%maxdelay));
}
}
}
@ -613,7 +613,7 @@ char *SuperNET_DHTsend(struct supernet_info *myinfo,uint64_t destipbits,bits256
if ( SuperNET_hexmsgfind(myinfo,categoryhash,subhash,hexmsg,1) >= 0 )
{
printf("SEND.(%s) to %s\n",jsonstr,addr->ipaddr);
iguana_send_supernet(coin,addr,jsonstr,maxdelay==0?0:(rand()%maxdelay));
iguana_send_supernet(addr,jsonstr,maxdelay==0?0:(rand()%maxdelay));
return(clonestr("{\"result\":\"packet sent directly\"}"));
}
return(clonestr("{\"result\":\"no appropriate peers to send to\"}"));

2
iguana/iguana777.h

@ -772,7 +772,7 @@ struct iguana_info *iguana_coinfind(const char *symbol);
struct iguana_info *iguana_coinadd(const char *symbol,cJSON *json);
struct iguana_ramchain *iguana_bundleload(struct iguana_info *coin,struct iguana_ramchain *ramchain,struct iguana_bundle *bp,int32_t extraflag);
int32_t iguana_sendblockreq(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_bundle *bp,int32_t bundlei,bits256 hash2,int32_t iamthreadsafe);
int32_t iguana_send_supernet(struct iguana_info *coin,struct iguana_peer *addr,char *jsonstr,int32_t delay);
int32_t iguana_send_supernet(struct iguana_peer *addr,char *jsonstr,int32_t delay);
struct iguana_waccount *iguana_waccountfind(struct supernet_info *myinfo,struct iguana_info *coin,char *account);
struct iguana_waddress *iguana_waccountadd(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_waccount **wacctp,char *walletaccount,char *coinaddr);

8
iguana/iguana_msg.c

@ -224,7 +224,7 @@ void iguana_gotverack(struct iguana_info *coin,struct iguana_peer *addr)
if ( addr->supernet != 0 )
{
printf("send getpeers to %s\n",addr->ipaddr);
iguana_send_supernet(coin,addr,SUPERNET_GETPEERSTR,0);
iguana_send_supernet(addr,SUPERNET_GETPEERSTR,0);
}
}
}
@ -258,7 +258,7 @@ void iguana_gotping(struct iguana_info *coin,struct iguana_peer *addr,uint64_t n
iguana_queue_send(addr,0,serialized,"pong",len,0,0);
if ( addr->supernet != 0 )
{
iguana_send_supernet(coin,addr,SUPERNET_GETPEERSTR,0);
iguana_send_supernet(addr,SUPERNET_GETPEERSTR,0);
}
}
@ -275,7 +275,7 @@ int32_t iguana_send_ping(struct iguana_info *coin,struct iguana_peer *addr)
iguana_queue_send(addr,0,serialized,"getaddr",0,0,0);
len = iguana_rwnum(1,&serialized[sizeof(struct iguana_msghdr)],sizeof(uint64_t),&nonce);
if ( addr->supernet != 0 )
iguana_send_supernet(coin,addr,SUPERNET_GETPEERSTR,0);
iguana_send_supernet(addr,SUPERNET_GETPEERSTR,0);
return(iguana_queue_send(addr,0,serialized,"ping",len,0,0));
}
@ -586,7 +586,7 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc
;
}
}
iguana_send_supernet(coin,addr,retstr,delay);
iguana_send_supernet(addr,retstr,delay);
free(retstr);
}
//printf("GOT.(%s) [%s] len.%d from %s -> (%s)\n",H->command,data,recvlen,addr->ipaddr,retstr==0?"null":retstr);

45
iguana/iguana_payments.c

@ -374,7 +374,7 @@ void iguana_unspentslock(struct supernet_info *myinfo,struct iguana_info *coin,c
char *iguana_rawtxissue(struct supernet_info *myinfo,uint32_t rawtxtag,char *symbol,cJSON **vinsp,uint32_t locktime,uint64_t satoshis,char *changeaddr,uint64_t txfee,cJSON *addresses,int32_t minconf,char *spendscriptstr)
{
struct rawtx_queue *ptr; struct iguana_peer *addr; uint8_t buf[IGUANA_MAXSCRIPTSIZE]; int32_t i,j,n,spendlen,delay = 0; cJSON *hexjson,*reqjson,*valsobj,*txobj = 0; char *str,*rawtx = 0; double expiration; struct iguana_info *coin;
struct rawtx_queue *ptr; struct iguana_peer *addr; uint8_t buf[IGUANA_MAXSCRIPTSIZE]; int32_t i,j,spendlen,delay = 0; cJSON *hexjson,*reqjson,*valsobj,*txobj = 0; char *str,*rawtx = 0; double expiration; struct iguana_info *coin;
*vinsp = 0;
if ( (coin= iguana_coinfind(symbol)) != 0 && (coin->VALIDATENODE != 0 || coin->RELAYNODE != 0) )
{
@ -426,13 +426,13 @@ char *iguana_rawtxissue(struct supernet_info *myinfo,uint32_t rawtxtag,char *sym
expiration = OS_milliseconds() + 3333;
for (i=0; i<IGUANA_MAXCOINS; i++)
{
if ( (coin= Coins[i]) != 0 && (n= coin->peers.numranked) > 0 )
if ( (coin= Coins[i]) != 0 )
{
for (j=0; j<IGUANA_MAXPEERS; j++)
{
if ( (addr= &coin->peers.active[j]) != 0 && addr->supernet != 0 && addr->usock >= 0 )
{
iguana_send_supernet(coin,addr,jprint(reqjson,0),delay);
iguana_send_supernet(addr,jprint(reqjson,0),delay);
}
}
}
@ -539,7 +539,7 @@ char *iguana_createrawtx(struct supernet_info *myinfo,uint32_t rawtxtag,char *sy
STRING_ARRAY_OBJ_STRING(iguana,rawtx,changeaddr,addresses,vals,spendscriptstr)
{
cJSON *vins=0,*retjson; char *rawtx=0,*symbol=0; int64_t txfee,satoshis; uint32_t locktime,minconf,rawtxtag;
cJSON *vins=0,*retjson,*hexjson; char buf[IGUANA_MAXSCRIPTSIZE],*str,*rawtx=0,*symbol=0; int64_t txfee,satoshis; uint32_t i,locktime,minconf,rawtxtag; struct iguana_peer *addr;
printf("RAWTX changeaddr.%s (%s)\n",changeaddr==0?"":changeaddr,jprint(json,0));
retjson = cJSON_CreateObject();
if ( spendscriptstr != 0 && spendscriptstr[0] != 0 && (symbol= jstr(vals,"coin")) != 0 )
@ -552,12 +552,37 @@ STRING_ARRAY_OBJ_STRING(iguana,rawtx,changeaddr,addresses,vals,spendscriptstr)
OS_randombytes((uint8_t *)&rawtxtag,sizeof(rawtxtag));
if ( (rawtx= iguana_createrawtx(myinfo,rawtxtag,symbol,&vins,locktime,satoshis,spendscriptstr,changeaddr,txfee,minconf,addresses)) != 0 )
{
jaddstr(retjson,"rawtx",rawtx);
jaddstr(retjson,"agent","iguana");
jaddstr(retjson,"method","rawtx_result");
jaddnum(retjson,"request",1);
jaddnum(retjson,"rawtxtag",rawtxtag);
jadd(retjson,"vins",vins);
if ( remoteaddr != 0 && remoteaddr[0] != 0 && (coin= iguana_coinfind(symbol)) != 0 )
{
hexjson = cJSON_CreateObject();
jaddstr(hexjson,"rawtx",rawtx);
jaddstr(hexjson,"agent","iguana");
jaddstr(hexjson,"method","rawtx_result");
jaddnum(hexjson,"request",1);
jaddnum(hexjson,"rawtxtag",rawtxtag);
jadd(hexjson,"vins",vins);
str = jprint(hexjson,1);
init_hexbytes_noT(buf,(uint8_t *)str,(int32_t)strlen(str));
free(str);
retjson = cJSON_CreateObject();
jaddstr(retjson,"agent","SuperNET");
jaddstr(retjson,"method","DHT");
jaddnum(retjson,"plaintext",1);
jaddbits256(retjson,"categoryhash",myinfo->bitcoin_category);
jaddnum(retjson,"request",1);
jaddnum(retjson,"timeout",5000);
jaddstr(retjson,"hexmsg",buf);
for (i=0; i<IGUANA_MAXPEERS; i++)
{
if ( (addr= &coin->peers.active[i]) != 0 && addr->supernet != 0 && addr->usock >= 0 && strcmp(addr->ipaddr,remoteaddr) == 0 )
{
printf("send back rawtx_result\n");
iguana_send_supernet(addr,jprint(retjson,0),0);
break;
}
}
}
free(rawtx);
} else jaddstr(retjson,"error","couldnt create rawtx");
}

2
iguana/iguana_peers.c

@ -1167,7 +1167,7 @@ void iguana_dedicatedloop(struct supernet_info *myinfo,struct iguana_info *coin,
run = 0;
else if ( 0 && addr->supernet != 0 && time(NULL) > lastping+SUPERNET_PINGGAP )
{
iguana_send_supernet(coin,addr,SUPERNET_GETPEERSTR,0);
iguana_send_supernet(addr,SUPERNET_GETPEERSTR,0);
lastping = (uint32_t)time(NULL);
}
if ( addr->persistent_peer != 0 )

2
iguana/main.c

@ -357,7 +357,7 @@ void iguana_exit()
{
case 0:
if ( Coins[i]->peers.active[j].usock >= 0 && Coins[i]->peers.active[j].supernet != 0 )
iguana_send_supernet(Coins[i],&Coins[i]->peers.active[j],stopstr,0);
iguana_send_supernet(&Coins[i]->peers.active[j],stopstr,0);
break;
case 1: Coins[i]->peers.active[j].dead = (uint32_t)time(NULL); break;
case 2:

Loading…
Cancel
Save