Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
fa44c2e6d5
  1. 3
      iguana/iguana777.h
  2. 6
      iguana/iguana_accept.c
  3. 33
      iguana/iguana_unspents.c

3
iguana/iguana777.h

@ -484,7 +484,7 @@ struct iguana_info
{
char name[64],symbol[8],statusstr[512],scriptsfname[2][512];
struct iguana_peers peers; struct iguana_peer internaladdr;
struct hhbits256 *fastfind,*tmpfastfind; FILE *fastfps[0x100]; bits256 *fast[0x100]; long fastsizes[0x100];
uint32_t fastfind; FILE *fastfps[0x100]; bits256 *fast[0x100]; long fastsizes[0x100];
uint64_t instance_nonce,myservices,totalsize,totalrecv,totalpackets,sleeptime;
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;
@ -900,6 +900,7 @@ int32_t iguana_validated(struct iguana_info *coin);
void iguana_volatilesalloc(struct iguana_info *coin,struct iguana_ramchain *ramchain,int32_t copyflag);
int32_t iguana_send_ping(struct iguana_info *coin,struct iguana_peer *addr);
int32_t iguana_process_msgrequestQ(struct iguana_info *coin);
int32_t iguana_fastfindinit(struct iguana_info *coin);
extern int32_t HDRnet,netBLOCKS;

6
iguana/iguana_accept.c

@ -280,9 +280,6 @@ int32_t iguana_peergetrequest(struct iguana_info *coin,struct iguana_peer *addr,
else addr->msgcounts.getheaders++;
len = iguana_rwnum(0,&data[0],sizeof(uint32_t),&reqvers);
len += iguana_rwvarint32(0,&data[len],(uint32_t *)&n);
//for (i=0; i<10; i++)
// printf("%02x ",data[i]);
//printf("version.%d num blocks.%d recvlen.%d\n",reqvers,n,recvlen);
for (i=0; i<n&&len<recvlen-sizeof(bits256)*2; i++)
{
len += iguana_rwbignum(0,&data[len],sizeof(bits256),hash2.bytes);
@ -297,6 +294,9 @@ int32_t iguana_peergetrequest(struct iguana_info *coin,struct iguana_peer *addr,
}
}
len += iguana_rwbignum(0,&data[len],sizeof(bits256),hash2.bytes);
for (i=0; i<69; i++)
printf("%02x ",data[i]);
printf("version.%d num blocks.%d recvlen.%d len.%d\n",reqvers,n,recvlen,len);
return(len);
}

33
iguana/iguana_unspents.c

@ -747,7 +747,7 @@ int32_t iguana_txidfastfind(struct iguana_info *coin,int32_t *heightp,bits256 tx
val = 0;
if ( (i= hashtable[val]) == 0 )
return(-1);
else if ( memcmp(&txid,&sorted[i],sizeof(bits256)-sizeof(uint32_t)-sizeof(uint16_t)) == 0 )
else if ( memcmp(&txid,&sorted[i],sizeof(uint64_t)) == 0 )
{
*heightp = sorted[i].uints[7];
return(sorted[i].ushorts[13]);
@ -792,7 +792,25 @@ static int _bits256_cmp(const void *a,const void *b)
return(bits256_cmp(*(bits256 *)a,*(bits256 *)b));
}
int64_t iguana_fastfindinit(struct iguana_info *coin)
int32_t iguana_fastfindinit(struct iguana_info *coin)
{
int32_t i,j; char fname[1024];
for (i=0; i<0x100; i++)
{
sprintf(fname,"DB/%s/fastfind/%02x",coin->symbol,i), OS_compatible_path(fname);
if ( (coin->fast[i]= OS_mapfile(fname,&coin->fastsizes[i],0)) == 0 )
{
for (j=0; j<i; j++)
munmap(coin->fast[i],coin->fastsizes[i]);
return(-1);
}
}
coin->fastfind = (uint32_t)time(NULL);
printf("initialized fastfind.%s\n",coin->symbol);
return(0);
}
int64_t iguana_fastfindcreate(struct iguana_info *coin)
{
int32_t i,j,val,iter,errs,num,ind,tablesize,*hashtable; bits256 *sortbuf,hash2; long allocsize; struct iguana_bundle *bp; char fname[512]; uint8_t buf[14]; int64_t total = 0;
if ( coin->current != 0 && coin->bundlescount == coin->current->hdrsi+1 )
@ -878,6 +896,8 @@ int64_t iguana_fastfindinit(struct iguana_info *coin)
} else printf("couldnt load sortbuf (%s)\n",fname);
}
printf("initialized with errs.%d\n",errs);
if ( errs == 0 )
coin->fastfind = (uint32_t)time(NULL);
}
}
return(total);
@ -899,17 +919,18 @@ struct iguana_bundle *iguana_fastexternalspent(struct iguana_info *coin,bits256
{
if ( ind < rdata->numexternaltxids )
{
char str[65];
X = (void *)(long)((long)rdata + rdata->Xoffset);
*prevhashp = prev_hash = X[ind];
if ( (firstvout= iguana_txidfastfind(coin,&height,prev_hash,spent_hdrsi-1)) >= 0 )
{
if ( (++counter % 100) == 0 )
printf("searches.%ld\n",counter);
printf("searches.%ld found.(%s)\n",counter,bits256_str(str,prev_hash));
*unspentindp = firstvout + prev_vout;
hdrsi = height / coin->chain->bundlesize;
if ( hdrsi >= 0 && hdrsi < coin->bundlescount )
return(coin->bundles[hdrsi]);
}
} else printf("couldnt find (%s)\n",bits256_str(str,prev_hash));
} else return(0);
}
else if ( ind < rdata->numtxids )
@ -1748,6 +1769,7 @@ void iguana_initfinal(struct iguana_info *coin,bits256 lastbundle)
hash2 = iguana_blockhash(coin,coin->balanceswritten * coin->chain->bundlesize);
if ( bits256_nonz(hash2) != 0 && (block= iguana_blockfind("initfinal",coin,hash2)) != 0 )
_iguana_chainlink(coin,block);
iguana_fastfindinit(coin);
}
int32_t iguana_balanceflush(struct iguana_info *coin,int32_t refhdrsi)
@ -2377,8 +2399,7 @@ STRING_ARG(iguana,initfastfind,activecoin)
{
if ( (coin= iguana_coinfind(activecoin)) != 0 )
{
iguana_fastfindinit(coin);
coin->fastfind = coin->tmpfastfind;
iguana_fastfindcreate(coin);
return(clonestr("{\"result\":\"fast find initialized\"}"));
} else return(clonestr("{\"error\":\"no coin to initialize\"}"));
}

Loading…
Cancel
Save