Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
e7acf10dfb
  1. 5
      iguana/iguana777.c
  2. 3
      iguana/iguana_init.c
  3. 5
      iguana/iguana_peers.c
  4. 24
      iguana/iguana_ramchain.c
  5. 10
      iguana/iguana_unspents.c
  6. 12
      iguana/main.c
  7. 4
      iguana/peggy_update.c
  8. 17
      iguana/ramchain_api.c
  9. 2
      pnacl_main.h

5
iguana/iguana777.c

@ -721,7 +721,10 @@ struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,
sprintf(dirname,"%s/%s/spends",GLOBAL_DBDIR,symbol), OS_ensure_directory(dirname);
sprintf(dirname,"%s/%s/vouts",GLOBAL_DBDIR,symbol), OS_ensure_directory(dirname);
if ( coin->VALIDATEDIR[0] != 0 )
{
sprintf(dirname,"%s",coin->VALIDATEDIR), OS_ensure_directory(dirname);
sprintf(dirname,"%s/%s",coin->VALIDATEDIR,symbol), OS_ensure_directory(dirname);
}
sprintf(dirname,"%s/%s",GLOBAL_TMPDIR,symbol), OS_ensure_directory(dirname);
if ( coin->chain == 0 && (coin->chain= iguana_createchain(json)) == 0 )
{
@ -736,7 +739,7 @@ struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,
else coin->VALIDATENODE = 1;
if ( jobj(json,"validatedir") != 0 )
safecopy(coin->VALIDATEDIR,jstr(json,"validatedir"),sizeof(coin->VALIDATEDIR));
else strcpy(coin->VALIDATEDIR,"purgeable");
else strcpy(coin->VALIDATEDIR,GLOBAL_VALIDATEDIR);
if ( (peers= jarray(&m,json,"peers")) != 0 )
{
for (j=0; j<m; j++)

3
iguana/iguana_init.c

@ -490,8 +490,7 @@ struct iguana_info *iguana_coinstart(struct iguana_info *coin,int32_t initialhei
}
}
#endif
sprintf(fname,"%s/%s_%s.txt",GLOBAL_CONFSDIR,coin->symbol,(iter == 0) ? "peers" : "hdrs");
OS_compatible_path(fname);
sprintf(fname,"%s/%s_%s.txt",GLOBAL_CONFSDIR,coin->symbol,(iter == 0) ? "peers" : "hdrs"), OS_compatible_path(fname);
//sprintf(fname,"confs/%s_%s.txt",coin->symbol,(iter == 0) ? "peers" : "hdrs");
//sprintf(fname,"tmp/%s/%s.txt",coin->symbol,(iter == 0) ? "peers" : "hdrs");
OS_compatible_path(fname);

5
iguana/iguana_peers.c

@ -108,8 +108,7 @@ struct iguana_iAddr *iguana_iAddrhashfind(struct iguana_info *coin,uint64_t ipbi
uint32_t iguana_rwiAddrind(struct iguana_info *coin,int32_t rwflag,struct iguana_iAddr *iA,uint32_t ind)
{
FILE *fp; char fname[512],hexstr[65],ipaddr[64]; uint32_t ipbits; int32_t i,n,m,retval = 0; struct iguana_iAddr tmp,*ptr;
sprintf(fname,"DB/%s_peers.dat",coin->symbol);
OS_compatible_path(fname);
sprintf(fname,"%s/%s_peers.dat",GLOBAL_DBDIR,coin->symbol), OS_compatible_path(fname);
if ( rwflag < 0 || iA == 0 )
{
coin->numiAddrs = 0;
@ -986,7 +985,7 @@ int64_t iguana_peerallocated(struct iguana_info *coin,struct iguana_peer *addr)
int32_t iguana_voutsfname(struct iguana_info *coin,char *fname,int32_t slotid)
{
sprintf(fname,"DB/%s/vouts/%04d.vouts",coin->symbol,slotid);
sprintf(fname,"%s/%s/vouts/%04d.vouts",GLOBAL_DBDIR,coin->symbol,slotid);
return((int32_t)strlen(fname));
}

24
iguana/iguana_ramchain.c

@ -90,10 +90,7 @@ void iguana_blocksetcounters(struct iguana_info *coin,struct iguana_block *block
int32_t iguana_peerfname(struct iguana_info *coin,int32_t *hdrsip,char *dirname,char *fname,uint32_t ipbits,bits256 hash2,bits256 prevhash2,int32_t numblocks,int32_t dispflag)
{
struct iguana_bundle *bp; int32_t bundlei; char str[65],*prefix = "";
#ifdef __PNACL__
prefix = "";
#endif
struct iguana_bundle *bp; int32_t bundlei; char str[65];
*hdrsip = -1; ipbits = 0;
fname[0] = 0;
//if ( ipbits == 0 )
@ -114,16 +111,16 @@ int32_t iguana_peerfname(struct iguana_info *coin,int32_t *hdrsip,char *dirname,
if ( numblocks == 1 )
{
if ( bits256_nonz(bp->hashes[bundlei]) != 0 )
sprintf(fname,"%s%s/%s/%d/%s_%u.%d",prefix,dirname,coin->symbol,bp->bundleheight,bits256_str(str,bp->hashes[bundlei]),ipbits>1?ipbits:*hdrsip,bundlei);
sprintf(fname,"%s/%s/%d/%s_%u.%d",dirname,coin->symbol,bp->bundleheight,bits256_str(str,bp->hashes[bundlei]),ipbits>1?ipbits:*hdrsip,bundlei);
else
{
printf("no hash for [%d:%d]\n",bp->hdrsi,bundlei);
return(-3);
}
}
else if ( strncmp("DB",dirname,strlen("DB")) == 0 )
sprintf(fname,"%s%s/%s/%s_%d.%u",prefix,dirname,coin->symbol,bits256_str(str,hash2),numblocks,ipbits>1?ipbits:*hdrsip);
else sprintf(fname,"%s%s/%s.%u",prefix,dirname,bits256_str(str,hash2),bp->bundleheight);
else if ( strncmp(GLOBAL_DBDIR,dirname,strlen(GLOBAL_DBDIR)) == 0 )
sprintf(fname,"%s/%s/%s_%d.%u",dirname,coin->symbol,bits256_str(str,hash2),numblocks,ipbits>1?ipbits:*hdrsip);
else sprintf(fname,"%s/%s.%u",dirname,bits256_str(str,hash2),bp->bundleheight);
OS_compatible_path(fname);
return(bundlei);
}
@ -1247,10 +1244,10 @@ int32_t iguana_bundleremove(struct iguana_info *coin,int32_t hdrsi,int32_t tmpfi
iguana_ramchain_free(coin,&bp->ramchain,0);
if ( iguana_bundlefname(coin,bp,fname) == 0 )
OS_removefile(fname,0);
sprintf(fname,"DB/%s/spends/%s.%d",coin->symbol,bits256_str(str,bp->hashes[0]),bp->bundleheight), OS_removefile(fname,0);
sprintf(fname,"DB/%s/accounts/debits.%d",coin->symbol,bp->bundleheight), OS_removefile(fname,0);
sprintf(fname,"DB/%s/accounts/lastspends.%d",coin->symbol,bp->bundleheight), OS_removefile(fname,0);
sprintf(fname,"DB/%s/validated/%d",coin->symbol,bp->bundleheight), OS_removefile(fname,0);
sprintf(fname,"%s/%s/spends/%s.%d",GLOBAL_DBDIR,coin->symbol,bits256_str(str,bp->hashes[0]),bp->bundleheight), OS_removefile(fname,0);
sprintf(fname,"%s/%s/accounts/debits.%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight), OS_removefile(fname,0);
sprintf(fname,"%s/%s/accounts/lastspends.%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight), OS_removefile(fname,0);
sprintf(fname,"%s/%s/validated/%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight), OS_removefile(fname,0);
bp->utxofinish = bp->startutxo = bp->balancefinish = bp->validated = bp->emitfinish = bp->converted = 0;
return(0);
}
@ -1281,8 +1278,7 @@ int32_t iguana_Xspendmap(struct iguana_info *coin,struct iguana_ramchain *ramcha
int32_t iter; bits256 sha256; char str[65],fname[1024]; void *ptr; long filesize;
for (iter=0; iter<2; iter++)
{
sprintf(fname,"DB/%s%s/spends/%s.%d",iter==0?"ro/":"",coin->symbol,bits256_str(str,bp->hashes[0]),bp->bundleheight);
//sprintf(dirname,"DB/%s%s/spends",iter==0?"ro/":"",coin->symbol);
sprintf(fname,"%s/%s%s/spends/%s.%d",iter==0?"ro/":"",GLOBAL_DBDIR,coin->symbol,bits256_str(str,bp->hashes[0]),bp->bundleheight);
//if ( iguana_peerfname(coin,&hdrsi,dirname,fname,0,bp->hashes[0],zero,bp->n) >= 0 )
{
if ( (ptr= OS_mapfile(fname,&filesize,0)) != 0 )

10
iguana/iguana_unspents.c

@ -190,7 +190,7 @@ int32_t iguana_volatilesmap(struct iguana_info *coin,struct iguana_ramchain *ram
int32_t iter,numhdrsi,err = -1; char fname[1024]; bits256 balancehash,allbundles;
for (iter=0; iter<2; iter++)
{
sprintf(fname,"DB/%s%s/accounts/debits.%d",iter==0?"ro/":"",coin->symbol,ramchain->H.data->height);
sprintf(fname,"%s/%s%s/accounts/debits.%d",GLOBAL_DBDIR,iter==0?"ro/":"",coin->symbol,ramchain->H.data->height);
if ( (ramchain->debitsfileptr= OS_mapfile(fname,&ramchain->debitsfilesize,0)) != 0 && ramchain->debitsfilesize == sizeof(int32_t) + 2*sizeof(bits256) + sizeof(*ramchain->A) * ramchain->H.data->numpkinds )
{
ramchain->from_roA = (iter == 0);
@ -206,7 +206,7 @@ int32_t iguana_volatilesmap(struct iguana_info *coin,struct iguana_ramchain *ram
if ( numhdrsi == coin->balanceswritten && memcmp(balancehash.bytes,coin->balancehash.bytes,sizeof(balancehash)) == 0 && memcmp(allbundles.bytes,coin->allbundles.bytes,sizeof(allbundles)) == 0 )
{
ramchain->A = (void *)((long)ramchain->debitsfileptr + sizeof(numhdrsi) + 2*sizeof(bits256));
sprintf(fname,"DB/%s%s/accounts/lastspends.%d",iter==0?"ro/":"",coin->symbol,ramchain->H.data->height);
sprintf(fname,"%s/%s%s/accounts/lastspends.%d",GLOBAL_DBDIR,iter==0?"ro/":"",coin->symbol,ramchain->H.data->height);
if ( (ramchain->lastspendsfileptr= OS_mapfile(fname,&ramchain->lastspendsfilesize,0)) != 0 && ramchain->lastspendsfilesize == sizeof(int32_t) + 2*sizeof(bits256) + sizeof(*ramchain->Uextras) * ramchain->H.data->numunspents )
{
numhdrsi = *(int32_t *)ramchain->lastspendsfileptr;
@ -886,7 +886,7 @@ int32_t iguana_spendvectorsave(struct iguana_info *coin,struct iguana_bundle *bp
printf("iguana_spendvectorconv error [%d] at %d of %d/%d\n",bp->hdrsi,i,emit,n);
return(-1);
}
sprintf(fname,"DB/%s/spends/%s.%d",coin->symbol,bits256_str(str,bp->hashes[0]),bp->bundleheight);
sprintf(fname,"%s/%s/spends/%s.%d",GLOBAL_DBDIR,coin->symbol,bits256_str(str,bp->hashes[0]),bp->bundleheight);
vcalc_sha256(0,sha256.bytes,(void *)ptr,(int32_t)(sizeof(*ptr) * emit));
if ( (fp= fopen(fname,"wb")) != 0 )
{
@ -1239,7 +1239,7 @@ int32_t iguana_volatilesinit(struct iguana_info *coin)
vupdate_sha256(balancehash.bytes,&vstate,0,0);
vupdate_sha256(allbundles.bytes,&bstate,0,0);
filecrc = 0;
sprintf(crcfname,"DB/%s/balancecrc.%d",coin->symbol,coin->balanceswritten);
sprintf(crcfname,"%s/%s/balancecrc.%d",GLOBAL_DBDIR,coin->symbol,coin->balanceswritten);
if ( (fp= fopen(crcfname,"rb")) != 0 )
{
if ( fread(&filecrc,1,sizeof(filecrc),fp) != sizeof(filecrc) )
@ -1870,7 +1870,7 @@ int32_t iguana_bundlevalidate(struct iguana_info *coin,struct iguana_bundle *bp,
FILE *fp; char fname[1024]; uint8_t *blockspace; int32_t i,max,len,errs = 0; int64_t total = 0;
if ( bp->validated <= 1 || forceflag != 0 )
{
sprintf(fname,"DB/%s/validated/%d",coin->symbol,bp->bundleheight);
sprintf(fname,"%s/%s/validated/%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight);
if ( (fp= fopen(fname,"rb")) != 0 )
{
if ( forceflag == 0 )

12
iguana/main.c

@ -68,17 +68,17 @@ int32_t HDRnet,netBLOCKS;
cJSON *API_json;
#ifdef __PNACL__
char GLOBAL_VALIDATEDIR[512] = "/DB/purgeable";
char GLOBAL_HELPDIR[512] = "/DB/help";
char GLOBAL_TMPDIR[512] = "/tmp";
char GLOBAL_DBDIR[512] = "/DB";
char GLOBAL_HELPDIR[512] = "/DB/help";
char GLOBAL_VALIDATEDIR[512] = "/DB/purgeable";
char GLOBAL_CONFSDIR[512] = "/DB/confs";
char GLOBAL_TMPDIR[512] = "/tmp";
int32_t IGUANA_NUMHELPERS = 2;
int32_t IGUANA_NUMHELPERS = 1;
#else
char GLOBAL_VALIDATEDIR[512] = "purgeable";
char GLOBAL_TMPDIR[512] = "tmp";
char GLOBAL_HELPDIR[512] = "help";
char GLOBAL_DBDIR[512] = "DB";
char GLOBAL_TMPDIR[512] = "tmp";
char GLOBAL_VALIDATEDIR[512] = "DB/purgeable";
char GLOBAL_CONFSDIR[512] = "confs";
int32_t IGUANA_NUMHELPERS = 4;
#endif

4
iguana/peggy_update.c

@ -360,7 +360,7 @@ int32_t ecb_matrix(double matrix[32][32],char *date)
FILE *fp=0; int32_t n=0,datenum,year=0,seconds,month=0,day=0,loaded = 0; char fname[64],_date[64];
if ( date == 0 )
date = _date, memset(_date,0,sizeof(_date));
sprintf(fname,"DB/ECB/%s",date), OS_compatible_path(fname);
sprintf(fname,"%s/ECB/%s",GLOBAL_DBDIR,date), OS_compatible_path(fname);
if ( date[0] != 0 && (fp= fopen(fname,"rb")) != 0 )
{
if ( fread(matrix,1,sizeof(matrix[0][0])*32*32,fp) == sizeof(matrix[0][0])*32*32 )
@ -374,7 +374,7 @@ int32_t ecb_matrix(double matrix[32][32],char *date)
year = datenum / 10000, month = (datenum / 100) % 100, day = (datenum % 100);
if ( (n= PAX_ecbprices(date,&matrix[0][0],year,month,day)) > 0 )
{
sprintf(fname,"DB/ECB/%s",date), OS_compatible_path(fname);
sprintf(fname,"%s/ECB/%s",GLOBAL_DBDIR,date), OS_compatible_path(fname);
if ( (fp= fopen(fname,"wb")) != 0 )
{
if ( fwrite(matrix,1,sizeof(matrix[0][0])*32*32,fp) == sizeof(matrix[0][0])*32*32 )

17
iguana/ramchain_api.c

@ -40,31 +40,28 @@ STRING_ARG(iguana,validate,activecoin)
STRING_ARG(iguana,removecoin,activecoin)
{
struct iguana_bundle *bp; int32_t i; char fname[1024],*prefix = "";
#ifdef __PNACL__
prefix = "/";
#endif
struct iguana_bundle *bp; int32_t i; char fname[1024];
if ( (coin= iguana_coinfind(activecoin)) != 0 )
{
coin->active = 0;
coin->started = 0;
for (i=0; i<IGUANA_MAXPEERS; i++)
{
sprintf(fname,"%sDB/%s/vouts/%04d.vouts",prefix,coin->symbol,i), OS_removefile(fname,0);
sprintf(fname,"%spurgeable/%s/%04d.vins",prefix,coin->symbol,i), OS_removefile(fname,0);
sprintf(fname,"%s/%s/vouts/%04d.vouts",GLOBAL_DBDIR,coin->symbol,i), OS_removefile(fname,0);
sprintf(fname,"%s/%s/%04d.vins",coin->VALIDATEDIR,coin->symbol,i), OS_removefile(fname,0);
}
sprintf(fname,"%sDB/%s/vouts/*",prefix,coin->symbol), OS_removefile(fname,0);
sprintf(fname,"%s%s/%s/*",prefix,coin->VALIDATEDIR,coin->symbol), OS_removefile(fname,0);
sprintf(fname,"%s/%s/vouts/*",GLOBAL_DBDIR,coin->symbol), OS_removefile(fname,0);
sprintf(fname,"%s/%s/*",coin->VALIDATEDIR,coin->symbol), OS_removefile(fname,0);
for (i=0; i<coin->bundlescount; i++)
{
sprintf(fname,"%sDB/%s/balancecrc.%d",prefix,coin->symbol,i), OS_removefile(fname,0);
sprintf(fname,"%s/%s/balancecrc.%d",GLOBAL_DBDIR,coin->symbol,i), OS_removefile(fname,0);
if ( (bp= coin->bundles[i]) != 0 )
{
iguana_bundlepurgefiles(coin,bp);
iguana_bundleremove(coin,bp->hdrsi,1);
}
}
sprintf(fname,"%sDB/%s/*",prefix,coin->symbol), OS_removefile(fname,0);
sprintf(fname,"%s/%s/*",GLOBAL_DBDIR,coin->symbol), OS_removefile(fname,0);
}
return(clonestr("{\"error\":\"no active coin\"}"));
}

2
pnacl_main.h

@ -363,7 +363,7 @@ static PP_Bool Instance_DidCreate(PP_Instance instance,uint32_t argc,const char*
mkdir("/tmp",0755);
mkdir("/DB",0755);
mount("","/tmp","html5fs",0,"type=TEMPORARY,expected_size=2000000000");
mount("confs","/DB","html5fs",0,"type=PERSISTENT,expected_size=10000000000");
mount("","/DB","html5fs",0,"type=PERSISTENT,expected_size=10000000000");
/*mount("", // source. Use relative URL
"/http", // target
"httpfs", // filesystemtype

Loading…
Cancel
Save