Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
8278556926
  1. 5
      iguana/iguana777.h
  2. 8
      iguana/iguana_accept.c
  3. 22
      iguana/iguana_msg.c
  4. 2
      iguana/main.c
  5. 1
      iguana/tests/getpeers

5
iguana/iguana777.h

@ -128,7 +128,7 @@ extern int32_t IGUANA_NUMHELPERS;
#define NODE_GETUTXO (1 << 1)
#define NODE_BLOOM (1 << 2)
#define PROTOCOL_VERSION 70001
#define PROTOCOL_VERSION 70002
#define INIT_PROTO_VERSION 209 // initial proto version, to be increased after version/verack negotiation
#define GETHEADERS_VERSION 31800 // In this version, 'getheaders' was introduced.
#define MIN_PEER_PROTO_VERSION GETHEADERS_VERSION // disconnect from peers older than this proto version
@ -141,6 +141,7 @@ extern int32_t IGUANA_NUMHELPERS;
#define BIP0031_VERSION 60000 // BIP 0031, pong message, is enabled for all versions AFTER this one
#define MEMPOOL_GD_VERSION 60002 // "mempool" command, enhanced "getdata" behavior starts with this version
#define NO_BLOOM_VERSION 70011 // "filter*" disabled without NODE_BLOOM after and including this version
#define PROTOCOL_HEADERS_VERSION 70012
#define MSG_TX 1
#define MSG_BLOCK 2
@ -418,7 +419,7 @@ struct iguana_peer
char ipaddr[64],lastcommand[16],coinstr[16],symbol[16];
uint64_t pingnonce,totalsent,totalrecv,ipbits; double pingtime,sendmillis,pingsum,getdatamillis;
uint32_t lastcontact,sendtime,ready,startsend,startrecv,pending,lastgotaddr,lastblockrecv,pendtime,lastflush,lastpoll,myipbits,persistent_peer,protover;
int32_t supernet,dead,addrind,usock,lastheight,relayflag,numpackets,numpings,ipv6,height,rank,pendhdrs,pendblocks,recvhdrs,lastlefti,validpub,othervalid,dirty[2],laggard;
int32_t supernet,dead,addrind,usock,lastheight,relayflag,numpackets,numpings,ipv6,height,rank,pendhdrs,pendblocks,recvhdrs,lastlefti,validpub,othervalid,dirty[2],laggard,headerserror;
double recvblocks,recvtotal;
int64_t allocated,freed;
bits256 RThashes[IGUANA_MAXBUNDLESIZE]; int32_t numRThashes;

8
iguana/iguana_accept.c

@ -264,7 +264,7 @@ int32_t iguana_peerdatarequest(struct iguana_info *coin,struct iguana_peer *addr
int32_t iguana_peerhdrrequest(struct iguana_info *coin,uint8_t *serialized,int32_t maxsize,struct iguana_peer *addr,bits256 hash2)
{
int32_t len=0,i,height,hdrsi,bundlei,bundlesize,firstvout,retval=-1; struct iguana_block *block; struct iguana_msgblock msgB; bits256 checkhash2; struct iguana_bundle *bp;
int32_t len=0,i,flag=0,height,hdrsi,bundlei,bundlesize,firstvout,retval=-1; struct iguana_block *block; struct iguana_msgblock msgB; bits256 checkhash2; struct iguana_bundle *bp;
if ( (firstvout= iguana_unspentindfind(coin,0,0,0,0,&height,hash2,0,coin->bundlescount-1)) != 0 )
{
bundlesize = coin->chain->bundlesize;
@ -278,6 +278,7 @@ int32_t iguana_peerhdrrequest(struct iguana_info *coin,uint8_t *serialized,int32
{
iguana_blockunconv(&msgB,block,1);
len += iguana_rwblock(1,&checkhash2,&serialized[sizeof(struct iguana_msghdr) + len],&msgB);
flag++;
if ( bits256_cmp(checkhash2,block->RO.hash2) != 0 )
{
char str[65],str2[65];
@ -287,8 +288,9 @@ int32_t iguana_peerhdrrequest(struct iguana_info *coin,uint8_t *serialized,int32
} else printf("cant find block at ht.%d\n",height+i);
}
}
retval = iguana_queue_send(coin,addr,0,serialized,"headers",len,0,0);
printf("hdrs request retval.%d len.%d\n",retval,len);
if ( flag != 0 )
retval = iguana_queue_send(coin,addr,0,serialized,"headers",len,0,0);
//printf("hdrs request retval.%d len.%d\n",retval,len);
} //else printf("couldnt find header\n");
return(retval);
}

22
iguana/iguana_msg.c

@ -159,6 +159,7 @@ void iguana_gotversion(struct iguana_info *coin,struct iguana_peer *addr,struct
if ( (vers->nServices & NODE_NETWORK) != 0 )//&& vers->nonce != coin->instance_nonce )
{
addr->protover = (vers->nVersion < PROTOCOL_VERSION) ? vers->nVersion : PROTOCOL_VERSION;
//printf("(%s) proto.%d -> %d\n",addr->ipaddr,vers->nVersion,addr->protover);
addr->relayflag = vers->relayflag;
addr->height = vers->nStartingHeight;
addr->relayflag = 1;
@ -669,7 +670,9 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc
if ( len == recvlen && addr != 0 )
addr->msgcounts.headers++;
} else printf("got unexpected n.%d for headers\n",n);
} else len = iguana_peergetrequest(coin,addr,data,recvlen,0);
}
else if ( addr->headerserror == 0 )
len = iguana_peergetrequest(coin,addr,data,recvlen,0);
}
}
else if ( (ishost= (strcmp(H->command,"version") == 0)) || strcmp(H->command,"verack") == 0 )
@ -783,12 +786,19 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc
}
else if ( strcmp(H->command,"reject") == 0 )
{
for (i=0; i<recvlen; i++)
printf("%02x ",data[i]);
printf("reject.(%s) recvlen.%d\n",data+1,recvlen);
if ( addr != 0 )
{
if ( strncmp((char *)data+1,"headers",7) == 0 )
addr->headerserror++;
else
{
for (i=0; i<recvlen; i++)
printf("%02x ",data[i]);
printf("reject.(%s) recvlen.%d %s proto.%d\n",data+1,recvlen,addr->ipaddr,addr->protover);
addr->msgcounts.reject++;
}
}
len = recvlen;
if ( len == recvlen && addr != 0 )
addr->msgcounts.reject++;
}
else if ( strcmp(H->command,"alert") == 0 )
{

2
iguana/main.c

@ -1156,7 +1156,7 @@ void iguana_appletests(struct supernet_info *myinfo)
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"RELAY\":1,\"VALIDATE\":1,\"prefetchlag\":-1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":64,\"newcoin\":\"BTC\",\"active\":1,\"numhelpers\":4,\"poll\":100}"),0,myinfo->rpcport)) != 0 )
{
free(str);
if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":1024,\"maxpeers\":256,\"newcoin\":\"BTCD\",\"active\":1}"),0,myinfo->rpcport)) != 0 )
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"RELAY\":1,\"VALIDATE\":1,\"prefetchlag\":-1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":64,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":4,\"poll\":100}"),0,myinfo->rpcport)) != 0 )
{
free(str);
if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"login\",\"handle\":\"alice\",\"password\":\"alice\",\"passphrase\":\"alice\"}"),0,myinfo->rpcport)) != 0 )

1
iguana/tests/getpeers

@ -0,0 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"SuperNET\",\"method\":\"getpeers\",\"activecoin\":\"BTCD\"}"
Loading…
Cancel
Save