Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
bc19158fa8
  1. 6
      iguana/iguana777.c
  2. 2
      iguana/iguana777.h
  3. 7
      iguana/iguana_accept.c
  4. 2
      iguana/iguana_bundles.c
  5. 4
      iguana/iguana_init.c
  6. 8
      iguana/iguana_peers.c
  7. 13
      iguana/iguana_recv.c
  8. 8
      iguana/iguana_unspents.c

6
iguana/iguana777.c

@ -440,7 +440,7 @@ void iguana_coinloop(void *arg)
{ {
} }
coin = coins[0]; coin = coins[0];
iguana_possible_peer(coin,"127.0.0.1"); iguana_launchpeer(coin,"127.0.0.1");
memset(zero.bytes,0,sizeof(zero)); memset(zero.bytes,0,sizeof(zero));
if ( (bp= iguana_bundlecreate(coin,&bundlei,0,*(bits256 *)coin->chain->genesis_hashdata,zero,1)) != 0 ) if ( (bp= iguana_bundlecreate(coin,&bundlei,0,*(bits256 *)coin->chain->genesis_hashdata,zero,1)) != 0 )
bp->bundleheight = 0; bp->bundleheight = 0;
@ -494,15 +494,15 @@ void iguana_coinloop(void *arg)
coin->lastpossible = iguana_possible_peer(coin,0); // tries to connect to new peers coin->lastpossible = iguana_possible_peer(coin,0); // tries to connect to new peers
} }
} }
if ( now > coin->peers.lastmetrics+6 ) if ( now > coin->peers.lastmetrics+3 )
{ {
//fprintf(stderr,"metrics\n"); //fprintf(stderr,"metrics\n");
coin->peers.lastmetrics = iguana_updatemetrics(coin); // ranks peers coin->peers.lastmetrics = iguana_updatemetrics(coin); // ranks peers
iguana_bundlestats(coin,str); iguana_bundlestats(coin,str);
} }
flag += iguana_processrecv(coin);
if ( coin->longestchain+10000 > coin->blocks.maxbits ) if ( coin->longestchain+10000 > coin->blocks.maxbits )
iguana_recvalloc(coin,coin->longestchain + 100000); iguana_recvalloc(coin,coin->longestchain + 100000);
flag += iguana_processrecv(coin);
} }
coin->idletime = (uint32_t)time(NULL); coin->idletime = (uint32_t)time(NULL);
} }

2
iguana/iguana777.h

@ -27,6 +27,7 @@ typedef int32_t (*blockhashfunc)(uint8_t *blockhashp,uint8_t *serialized,int32_t
//#define IGUANA_SERIALIZE_BALANCEGEN //#define IGUANA_SERIALIZE_BALANCEGEN
//#define IGUANA_DISABLEPEERS //#define IGUANA_DISABLEPEERS
#define _IGUANA_MAXSTUCKTIME 300 #define _IGUANA_MAXSTUCKTIME 300
#define IGUANA_MAXITERATIONS 10000
#define IGUANA_MAXCOINS 64 #define IGUANA_MAXCOINS 64
#define IGUANA_MAXDELAY_MILLIS (3600 * 1000) #define IGUANA_MAXDELAY_MILLIS (3600 * 1000)
@ -827,6 +828,7 @@ void iguana_coinpurge(struct iguana_info *coin);
int32_t iguana_setmaxbundles(struct iguana_info *coin); int32_t iguana_setmaxbundles(struct iguana_info *coin);
void iguana_bundlepurgefiles(struct iguana_info *coin,struct iguana_bundle *bp); void iguana_bundlepurgefiles(struct iguana_info *coin,struct iguana_bundle *bp);
uint32_t iguana_sparseaddtx(uint8_t *bits,int32_t width,uint32_t tablesize,bits256 txid,struct iguana_txid *T,uint32_t txidind,struct iguana_ramchain *ramchain); uint32_t iguana_sparseaddtx(uint8_t *bits,int32_t width,uint32_t tablesize,bits256 txid,struct iguana_txid *T,uint32_t txidind,struct iguana_ramchain *ramchain);
void iguana_launchpeer(struct iguana_info *coin,char *ipaddr);
extern int32_t HDRnet,netBLOCKS; extern int32_t HDRnet,netBLOCKS;

7
iguana/iguana_accept.c

@ -66,7 +66,14 @@ void iguana_acceptloop(void *args)
struct pollfd pfd; int32_t sock; struct iguana_accept *ptr; uint16_t port = coin->chain->portp2p; struct pollfd pfd; int32_t sock; struct iguana_accept *ptr; uint16_t port = coin->chain->portp2p;
socklen_t clilen; struct sockaddr_in cli_addr; char ipaddr[64]; uint32_t i,ipbits; socklen_t clilen; struct sockaddr_in cli_addr; char ipaddr[64]; uint32_t i,ipbits;
while ( (coin->bindsock= iguana_socket(1,"0.0.0.0",port)) < 0 ) while ( (coin->bindsock= iguana_socket(1,"0.0.0.0",port)) < 0 )
{
if ( coin->peers.localaddr != 0 )
{
printf("another daemon running, no need to have iguana accept connections\n");
return;
}
sleep(5); sleep(5);
}
printf(">>>>>>>>>>>>>>>> iguana_bindloop 127.0.0.1:%d bind sock.%d\n",port,coin->bindsock); printf(">>>>>>>>>>>>>>>> iguana_bindloop 127.0.0.1:%d bind sock.%d\n",port,coin->bindsock);
printf("START ACCEPTING\n"); printf("START ACCEPTING\n");
while ( coin->bindsock >= 0 ) while ( coin->bindsock >= 0 )

2
iguana/iguana_bundles.c

@ -929,7 +929,7 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru
if ( coin->stucktime != 0 ) if ( coin->stucktime != 0 )
{ {
lag = time(NULL)-coin->stucktime; lag = time(NULL)-coin->stucktime;
if ( lag/coin->MAXSTUCKTIME > coin->stuckiters ) if ( ((lag/coin->MAXSTUCKTIME)>>1) > coin->stuckiters )
{ {
coin->stuckiters = (int32_t)lag/60; coin->stuckiters = (int32_t)lag/60;
while ( (breq= queue_dequeue(&coin->blocksQ,0)) != 0 ) while ( (breq= queue_dequeue(&coin->blocksQ,0)) != 0 )

4
iguana/iguana_init.c

@ -423,9 +423,9 @@ struct iguana_info *iguana_coinstart(struct iguana_info *coin,int32_t initialhei
coin->longestchain = 1; coin->longestchain = 1;
memset(&coin->blocks.hwmchain,0,sizeof(coin->blocks.hwmchain)); memset(&coin->blocks.hwmchain,0,sizeof(coin->blocks.hwmchain));
coin->blocks.hwmchain.height = 0; coin->blocks.hwmchain.height = 0;
if ( (coin->myservices & NODE_NETWORK) != 0 && coin->peers.acceptloop == 0 ) printf("MYSERVICES.%llx\n",(long long)coin->myservices);
if ( (coin->myservices & NODE_NETWORK) != 0 && coin->peers.acceptloop == 0 && coin->peers.localaddr == 0 )
{ {
printf("MYSERVICES.%llx\n",(long long)coin->myservices);
coin->peers.acceptloop = malloc(sizeof(pthread_t)); coin->peers.acceptloop = malloc(sizeof(pthread_t));
if ( OS_thread_create(coin->peers.acceptloop,NULL,(void *)iguana_acceptloop,(void *)coin) != 0 ) if ( OS_thread_create(coin->peers.acceptloop,NULL,(void *)iguana_acceptloop,(void *)coin) != 0 )
{ {

8
iguana/iguana_peers.c

@ -607,6 +607,7 @@ void iguana_startconnection(void *arg)
printf("iguana_startconnection.%s mismatched coin.%p (%s) vs (%s)\n",addr->ipaddr,coin,coin->symbol,addr->coinstr); printf("iguana_startconnection.%s mismatched coin.%p (%s) vs (%s)\n",addr->ipaddr,coin,coin->symbol,addr->coinstr);
return; return;
} }
printf("MYSERVICES.%llx\n",(long long)coin->myservices);
if ( strcmp("127.0.0.1",addr->ipaddr) == 0 && (coin->myservices & NODE_NETWORK) != 0 ) if ( strcmp("127.0.0.1",addr->ipaddr) == 0 && (coin->myservices & NODE_NETWORK) != 0 )
{ {
iguana_iAkill(coin,addr,0); iguana_iAkill(coin,addr,0);
@ -699,6 +700,13 @@ struct iguana_peer *iguana_peerslot(struct iguana_info *coin,uint64_t ipbits,int
return(0); return(0);
} }
void iguana_launchpeer(struct iguana_info *coin,char *ipaddr)
{
struct iguana_peer *addr; uint32_t ipbits = (uint32_t)calc_ipbits(ipaddr);
if ( (addr= iguana_peerslot(coin,ipbits,0)) != 0 )
iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD);
}
void *iguana_iAddriterator(struct iguana_info *coin,struct iguana_iAddr *iA) void *iguana_iAddriterator(struct iguana_info *coin,struct iguana_iAddr *iA)
{ {
struct iguana_peer *addr = 0; struct iguana_peer *addr = 0;

13
iguana/iguana_recv.c

@ -903,7 +903,7 @@ int32_t iguana_blockreq(struct iguana_info *coin,int32_t height,int32_t priority
int32_t iguana_reqblocks(struct iguana_info *coin) int32_t iguana_reqblocks(struct iguana_info *coin)
{ {
int32_t hdrsi,lflag,bundlei,flag = 0; bits256 hash2; struct iguana_block *next,*block; struct iguana_bundle *bp; int32_t hdrsi,lflag,bundlei,iters=0,flag = 0; bits256 hash2; struct iguana_block *next,*block; struct iguana_bundle *bp;
/*if ( 0 && (bp= coin->current) != 0 && bp->numsaved < bp->n ) /*if ( 0 && (bp= coin->current) != 0 && bp->numsaved < bp->n )
{ {
for (hdrsi=numissued=0; hdrsi<coin->MAXBUNDLES && coin->current->hdrsi+hdrsi<coin->bundlescount && numissued<100; hdrsi++) for (hdrsi=numissued=0; hdrsi<coin->MAXBUNDLES && coin->current->hdrsi+hdrsi<coin->bundlescount && numissued<100; hdrsi++)
@ -973,8 +973,9 @@ int32_t iguana_reqblocks(struct iguana_info *coin)
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1); queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1);
}*/ }*/
lflag = 1; lflag = 1;
while ( coin->active != 0 && lflag != 0 ) while ( coin->active != 0 && iters < IGUANA_MAXITERATIONS )
{ {
iters++;
lflag = 0; lflag = 0;
hdrsi = (coin->blocks.hwmchain.height+1) / coin->chain->bundlesize; hdrsi = (coin->blocks.hwmchain.height+1) / coin->chain->bundlesize;
bundlei = (coin->blocks.hwmchain.height+1) % coin->chain->bundlesize; bundlei = (coin->blocks.hwmchain.height+1) % coin->chain->bundlesize;
@ -1099,12 +1100,14 @@ int32_t iguana_processrecvQ(struct iguana_info *coin,int32_t *newhwmp) // single
*newhwmp = 0; *newhwmp = 0;
while ( coin->active != 0 && (req= queue_dequeue(&coin->recvQ,0)) != 0 ) while ( coin->active != 0 && (req= queue_dequeue(&coin->recvQ,0)) != 0 )
{ {
//fprintf(stderr,"%s recvQ.%p type.%c n.%d\n",req->addr != 0 ? req->addr->ipaddr : "0",req,req->type,req->n); if ( (flag % 100) == 50 )
iguana_reqblocks(coin);
flag++;
//fprintf(stderr,"flag.%d %s recvQ.%p type.%c n.%d\n",flag,req->addr != 0 ? req->addr->ipaddr : "0",req,req->type,req->n);
if ( req->type == 'B' ) // one block with all txdata if ( req->type == 'B' ) // one block with all txdata
{ {
netBLOCKS--; netBLOCKS--;
req = iguana_recvblock(coin,req->addr,req,&req->block,req->numtx,req->datalen,req->recvlen,newhwmp); req = iguana_recvblock(coin,req->addr,req,&req->block,req->numtx,req->datalen,req->recvlen,newhwmp);
flag++;
} }
else if ( req->type == 'H' ) // blockhdrs (doesnt have txn_count!) else if ( req->type == 'H' ) // blockhdrs (doesnt have txn_count!)
{ {
@ -1133,8 +1136,6 @@ int32_t iguana_processrecvQ(struct iguana_info *coin,int32_t *newhwmp) // single
myfree(req,req->allocsize), req = 0; myfree(req,req->allocsize), req = 0;
if ( flag >= IGUANA_BUNDLELOOP ) if ( flag >= IGUANA_BUNDLELOOP )
break; break;
if ( (flag % 100) == 0 )
iguana_reqblocks(coin);
} }
iguana_reqblocks(coin); iguana_reqblocks(coin);
return(flag); return(flag);

8
iguana/iguana_unspents.c

@ -247,7 +247,7 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl
for (x=j=0; j<width; j++) for (x=j=0; j<width; j++)
{ {
x <<= 1; x <<= 1;
x |= GETBIT(bits,bitoffset+j) != 0; x |= GETBIT(bits,bitoffset+width-1-j) != 0;
} }
if ( x != setind ) if ( x != setind )
printf("x.%d vs setind.%d ind.%d bitoffset.%d\n",x,setind,ind,(int32_t)bitoffset); printf("x.%d vs setind.%d ind.%d bitoffset.%d\n",x,setind,ind,(int32_t)bitoffset);
@ -727,7 +727,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,struct iguana_bundle *bp,int3
return(-1); return(-1);
} }
iguana_ramchain_prefetch(coin,ramchain); iguana_ramchain_prefetch(coin,ramchain);
printf("BALANCEGEN.%d hdrs.%d\n",bp->bundleheight,bp->hdrsi); //printf("BALANCEGEN.%d hdrs.%d\n",bp->bundleheight,bp->hdrsi);
txidind = spendind = rdata->firsti; txidind = spendind = rdata->firsti;
for (i=0; i<bp->n; i++) for (i=0; i<bp->n; i++)
{ {
@ -822,7 +822,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,struct iguana_bundle *bp,int3
printf("iguana_balancegen: emit %d != %d ramchain->numXspends\n",emit,ramchain->numXspends); printf("iguana_balancegen: emit %d != %d ramchain->numXspends\n",emit,ramchain->numXspends);
errs++; errs++;
} }
printf(">>>>>>>> balances.%d done errs.%d spendind.%d\n",bp->hdrsi,errs,n); //printf(">>>>>>>> balances.%d done errs.%d spendind.%d\n",bp->hdrsi,errs,n);
return(-errs); return(-errs);
} }
@ -1402,7 +1402,7 @@ int32_t iguana_balancecalc(struct iguana_info *coin,struct iguana_bundle *bp,int
{ {
if ( bp->hdrsi >= coin->balanceswritten ) if ( bp->hdrsi >= coin->balanceswritten )
{ {
printf("balancecalc for %d when %d\n",bp->hdrsi,coin->balanceswritten); //printf("balancecalc for %d when %d\n",bp->hdrsi,coin->balanceswritten);
starttime = (uint32_t)time(NULL); starttime = (uint32_t)time(NULL);
for (j=0; j<=bp->hdrsi; j++) for (j=0; j<=bp->hdrsi; j++)
iguana_allocvolatile(coin,&coin->bundles[j]->ramchain); iguana_allocvolatile(coin,&coin->bundles[j]->ramchain);

Loading…
Cancel
Save