From 0f789382230fe3e9db85c755ac49a13c1a366684 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 26 Apr 2016 12:49:37 -0500 Subject: [PATCH] test --- crypto777/iguana_OS.c | 2 +- iguana/iguana_bundles.c | 29 ++++++++++++++--------------- iguana/iguana_ramchain.c | 2 +- iguana/iguana_wallet.c | 2 +- iguana/main.c | 2 +- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/crypto777/iguana_OS.c b/crypto777/iguana_OS.c index a4e58b932..8c49ccdfa 100755 --- a/crypto777/iguana_OS.c +++ b/crypto777/iguana_OS.c @@ -532,7 +532,7 @@ void OS_remove_directory(char *dirname) sprintf(buf,"rmdir %s",dirname); if ( system(buf) != 0 ) { - printf("error doing (%s)\n",buf); + //printf("error doing (%s)\n",buf); sprintf(buf,"rm %s/*",dirname); if ( system(buf) != 0 ) printf("error doing (%s)\n",buf); diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index cc3bc1fff..bd2ca2375 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -419,29 +419,29 @@ struct iguana_txid *iguana_bundletx(struct iguana_info *coin,struct iguana_bundl void iguana_bundlepurgefiles(struct iguana_info *coin,struct iguana_bundle *bp) { static const bits256 zero; - char fname[1024]; FILE *fp; int32_t hdrsi,j,m = 0; uint32_t ipbits = 0; + char fname[1024]; FILE *fp; int32_t subdir,hdrsi,j,m = 0; uint32_t ipbits = 0; if ( bp->purgetime == 0 && time(NULL) > bp->emitfinish+30 ) { - printf("purged hdrsi.[%d] lag.%ld\n",bp->hdrsi,time(NULL) - bp->emitfinish); for (j=m=0; jn; j++) { - //if ( (ipbits= (uint32_t)coin->peers.active[j].ipbits) != 0 ) + if ( iguana_peerfname(coin,&hdrsi,GLOBAL_TMPDIR,fname,ipbits,bp->hashes[j],zero,1,1) >= 0 ) { - if ( iguana_peerfname(coin,&hdrsi,GLOBAL_TMPDIR,fname,ipbits,bp->hashes[j],zero,1,1) >= 0 ) + if ( (fp= fopen(fname,"rb")) != 0 ) { - if ( (fp= fopen(fname,"rb")) != 0 ) - { - printf("purge.(%s)\n",fname); - fclose(fp); - if ( OS_removefile(fname,0) > 0 ) - coin->peers.numfiles--, m++; - } + printf("purge.(%s)\n",fname); + fclose(fp); + if ( OS_removefile(fname,0) > 0 ) + coin->peers.numfiles--, m++; } - else printf("error removing.(%s)\n",fname); } + else printf("error removing.(%s)\n",fname); } - //sprintf(dirname,"%s/%s/%d",GLOBAL_TMPDIR,coin->symbol,bp->bundleheight), OS_remove_directory(dirname); + subdir = bp->bundleheight / IGUANA_SUBDIRDIVISOR; + sprintf(fname,"%s/%s/%d/%d",GLOBAL_TMPDIR,coin->symbol,subdir,bp->bundleheight), OS_remove_directory(fname); + printf("purged hdrsi.[%d] subdir.%d lag.%ld\n",bp->hdrsi,subdir,time(NULL) - bp->emitfinish); bp->purgetime = (uint32_t)time(NULL); + if ( subdir > 2 ) + sprintf(fname,"%s/%s/%d",GLOBAL_TMPDIR,coin->symbol,subdir-2), OS_remove_directory(fname); } } @@ -1208,8 +1208,7 @@ void iguana_bundlestats(struct iguana_info *coin,char *str,int32_t lag) { numemit++; //printf("finished.[%d]\n",bp->hdrsi); - if ( firstgap != 0 && bp->hdrsi > firstgap->hdrsi-3 && firstgap->validated > 1 ) - iguana_bundlepurgefiles(coin,firstgap); + iguana_bundlepurgefiles(coin,bp); } } else diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index 435d387c6..011a327bb 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -2621,7 +2621,7 @@ int32_t iguana_bundlesaveHT(struct iguana_info *coin,struct OS_memspace *mem,str if ( retval == 0 ) { //char dirname[1024]; - printf("delete %d files hdrs.%d retval.%d bp_n.%d\n",num,bp->hdrsi,retval,bp_n); + printf("delete %d files hdrs.[%d] retval.%d bp_n.%d\n",num,bp->hdrsi,retval,bp_n); if ( iguana_bundleload(coin,&newchain,bp,0) == 0 ) retval = -1; else if ( bp_n == bp->n && bp->n == coin->chain->bundlesize && bp->hdrsi < coin->bundlescount-3 ) diff --git a/iguana/iguana_wallet.c b/iguana/iguana_wallet.c index a2c8c9819..a58a42440 100755 --- a/iguana/iguana_wallet.c +++ b/iguana/iguana_wallet.c @@ -184,7 +184,7 @@ void iguana_walletlock(struct supernet_info *myinfo) memset(&myinfo->persistent_priv,0,sizeof(myinfo->persistent_priv)); memset(myinfo->secret,0,sizeof(myinfo->secret)); memset(myinfo->permanentfile,0,sizeof(myinfo->permanentfile)); - printf("wallet locked\n"); + //printf("wallet locked\n"); } uint8_t *iguana_rmdarray(struct iguana_info *coin,int32_t *numrmdsp,cJSON *array,int32_t firsti) diff --git a/iguana/main.c b/iguana/main.c index 09dc129d2..83818e182 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -415,7 +415,7 @@ void mainloop(struct supernet_info *myinfo) while ( 1 ) { //printf("main iteration\n"); - if ( myinfo->expiration != 0 && time(NULL) > myinfo->expiration ) + if ( myinfo->expiration != 0 && time(NULL) > myinfo->expiration && myinfo->secret[0] != 0 ) iguana_walletlock(myinfo); flag = 0; isRT = 1;