diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 3dfbcbe20..e4f66ddb4 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -787,7 +787,7 @@ int32_t iguana_bundleready(struct iguana_info *coin,struct iguana_bundle *bp,int bp->blocks[i] = iguana_blockhashset("ready",coin,bp->bundleheight+i,prevhash2,1); iguana_hash2set(coin,"ready",bp,i,prevhash2); prevhash2 = zero; - if ( (ptr= iguana_bundlefile(coin,fname,&filesize,bp,i)) != 0 ) + if ( (ptr= iguana_bundlefile(coin,fname,&filesize,bp,i,0)) != 0 ) { if ( iguana_mapchaininit(fname,coin,&R,bp,i,block,ptr,filesize) >= 0 ) { diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index b44a56303..cd00e47ae 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -2074,7 +2074,11 @@ void iguana_blockunmark(struct iguana_info *coin,struct iguana_block *block,stru //printf("checki.%d vs %d mismatch? %s\n",checki,i,fname); } if ( fname[0] != 0 ) + { + OS_removefile(fname,0); + strcat(fname,".tmp"); OS_removefile(fname,0); + } } } @@ -2118,9 +2122,9 @@ int32_t iguana_oldbundlefiles(struct iguana_info *coin,uint32_t *ipbits,void **p return(num); } -void *iguana_bundlefile(struct iguana_info *coin,char *fname,long *filesizep,struct iguana_bundle *bp,int32_t bundlei) +void *iguana_bundlefile(struct iguana_info *coin,char *fname,long *filesizep,struct iguana_bundle *bp,int32_t bundlei,int32_t renameflag) { - int32_t checki,hdrsi; void *ptr = 0; FILE *fp; static const bits256 zero; + int32_t checki,hdrsi; void *ptr = 0; FILE *fp; char renamed[1024]; static const bits256 zero; *filesizep = 0; fname[0] = 0; if ( (checki= iguana_peerfname(coin,&hdrsi,GLOBAL_TMPDIR,fname,0,bp->hashes[bundlei],zero,1,1)) != bundlei || bundlei < 0 || bundlei >= coin->chain->bundlesize ) @@ -2133,6 +2137,12 @@ void *iguana_bundlefile(struct iguana_info *coin,char *fname,long *filesizep,str else { fclose(fp); + if ( renameflag != 0 ) + { + sprintf(renamed,"%s.tmp",fname); + OS_renamefile(fname,renamed); + strcpy(fname,renamed); + } if ( (ptr= OS_mapfile(fname,filesizep,0)) == 0 ) { printf("error mapping.(%s) bundlei.%d\n",fname,bundlei); @@ -2148,7 +2158,7 @@ int32_t iguana_bundlefiles(struct iguana_info *coin,uint32_t *ipbits,void **ptrs int32_t bundlei,num = 0; char fname[1024]; for (bundlei=starti; bundlei<=endi; bundlei++) { - if ( (ptrs[num]= iguana_bundlefile(coin,fname,&filesizes[num],bp,bundlei)) != 0 ) + if ( (ptrs[num]= iguana_bundlefile(coin,fname,&filesizes[num],bp,bundlei,1)) != 0 ) num++; else { diff --git a/includes/iguana_funcs.h b/includes/iguana_funcs.h index 7cef48aee..559673299 100755 --- a/includes/iguana_funcs.h +++ b/includes/iguana_funcs.h @@ -353,7 +353,7 @@ int64_t iguana_ramchainopen(char *fname,struct iguana_info *coin,struct iguana_r int32_t iguana_ramchain_free(struct iguana_info *coin,struct iguana_ramchain *ramchain,int32_t deleteflag); void iguana_blocksetcounters(struct iguana_info *coin,struct iguana_block *block,struct iguana_ramchain * ramchain); int32_t iguana_ramchain_iterate(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_ramchain *dest,struct iguana_ramchain *ramchain,struct iguana_bundle *bp,int16_t bundlei); -void *iguana_bundlefile(struct iguana_info *coin,char *fname,long *filesizep,struct iguana_bundle *bp,int32_t bundlei); +void *iguana_bundlefile(struct iguana_info *coin,char *fname,long *filesizep,struct iguana_bundle *bp,int32_t bundlei,int32_t renameflag); int32_t iguana_mapchaininit(char *fname,struct iguana_info *coin,struct iguana_ramchain *mapchain,struct iguana_bundle *bp,int32_t bundlei,struct iguana_block *block,void *ptr,long filesize); void iguana_RTdataset_free(struct iguana_info *coin); void iguana_autoextend(struct iguana_info *coin,struct iguana_bundle *bp);