Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
47c91d8c4f
  1. 31
      iguana/iguana777.c
  2. 2
      iguana/iguana777.h
  3. 3
      iguana/iguana_instantdex.c

31
iguana/iguana777.c

@ -142,11 +142,35 @@ double iguana_metric(struct iguana_peer *addr,uint32_t now,double decay)
return(metric);
}
int32_t iguana_inv2poll(struct supernet_info *myinfo,struct iguana_info *coin)
{
struct exchange_info *exchange; int32_t i,n=0; struct iguana_peer *addr;
//printf("peermetrics\n");
if ( (exchange= exchanges777_find("bitcoin")) != 0 && strcmp(coin->symbol,"BTCD") == 0 )
{
if ( time(NULL) > coin->lastinv2+10 )
{
coin->lastinv2 = (uint32_t)time(NULL);
for (i=n=0; i<coin->MAXPEERS; i++)
{
addr = &coin->peers.active[i];
if ( addr->usock < 0 || addr->dead != 0 || addr->ready == 0 || addr->ipbits == 0 )
continue;
if ( addr->supernet != 0 )
{
instantdex_inv2data(myinfo,coin,addr,exchange);
n++;
}
}
}
}
return(n);
}
int32_t iguana_peermetrics(struct supernet_info *myinfo,struct iguana_info *coin)
{
struct exchange_info *exchange; int32_t i,ind,n; double *sortbuf,sum; uint32_t now; struct iguana_peer *addr,*slowest = 0;
int32_t i,ind,n; double *sortbuf,sum; uint32_t now; struct iguana_peer *addr,*slowest = 0;
//printf("peermetrics\n");
exchange = exchanges777_find("bitcoin");
sortbuf = mycalloc('s',coin->MAXPEERS,sizeof(double)*2);
coin->peers.mostreceived = 0;
now = (uint32_t)time(NULL);
@ -161,8 +185,6 @@ int32_t iguana_peermetrics(struct supernet_info *myinfo,struct iguana_info *coin
//printf("[%.0f %.0f] ",addr->recvblocks,addr->recvtotal);
sortbuf[n*2 + 0] = iguana_metric(addr,now,.995);
sortbuf[n*2 + 1] = i;
if ( exchange != 0 && addr->supernet != 0 && strcmp(coin->symbol,"BTCD") == 0 )
instantdex_inv2data(myinfo,coin,addr,exchange);
n++;
}
if ( n > 0 )
@ -722,6 +744,7 @@ void iguana_coinloop(void *arg)
flag += iguana_processrecv(myinfo,coin);
}
coin->idletime = (uint32_t)time(NULL);
iguana_inv2poll(myinfo,coin);
}
}
if ( flag == 0 && coin->isRT == 0 )

2
iguana/iguana777.h

@ -493,7 +493,7 @@ struct iguana_info
int64_t mining,totalfees,TMPallocated,MAXRECVCACHE,MAXMEM,PREFETCHLAG,estsize,activebundles;
int32_t MAXPEERS,MAXPENDINGREQUESTS,MAXBUNDLES,MAXSTUCKTIME,active,closestbundle,numemitted,lastsweep,numemit,startutc,newramchain,numcached,cachefreed,helperdepth,startPEND,endPEND,enableCACHE,RELAYNODE,VALIDATENODE,origbalanceswritten,balanceswritten,RTheight,RTdatabad;
bits256 balancehash,allbundles;
uint32_t lastsync,parsetime,numiAddrs,lastpossible,bundlescount,savedblocks,backlog,spendvectorsaved,laststats; char VALIDATEDIR[512];
uint32_t lastsync,parsetime,numiAddrs,lastpossible,bundlescount,savedblocks,backlog,spendvectorsaved,laststats,lastinv2; char VALIDATEDIR[512];
int32_t longestchain,badlongestchain,longestchain_strange,RTramchain_busy,emitbusy,stuckiters;
struct tai starttime; double startmillis;
struct iguana_chain *chain;

3
iguana/iguana_instantdex.c

@ -796,7 +796,7 @@ bits256 instantdex_encodehash(char *base,char *rel,int64_t price,uint64_t orderi
int32_t instantdex_inv2data(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,struct exchange_info *exchange)
{
struct instantdex_accept PAD,*ap; uint32_t now,n=0,len; bits256 hashes[100]; uint8_t serialized[100*36 + 1024];
printf("instantdex_inv2data exchange.%p\n");
printf("instantdex_inv2data exchange.%p (%s)\n",exchange,addr->ipaddr);
if ( exchange == 0 )
return(0);
now = (uint32_t)time(NULL);
@ -830,6 +830,7 @@ struct instantdex_accept *instantdex_quotefind(struct supernet_info *myinfo,stru
struct iguana_bundlereq *instantdex_recvquotes(struct iguana_info *coin,struct iguana_bundlereq *req,bits256 *quotes,int32_t n)
{
int32_t i,len,m = 0; uint8_t serialized[10000];
printf("received quotes.%d\n",n);
for (i=0; i<n; i++)
{
if ( instantdex_quotefind(0,coin,req->addr,quotes[i]) != 0 )

Loading…
Cancel
Save