Browse Source

fix remove file and move file for windows

release/v0.1
jl777 8 years ago
parent
commit
b0136f16b8
  1. 21
      crypto777/OS_nonportable.c
  2. 2
      iguana/coins/genbtcd
  3. 43
      iguana/iguana777.c
  4. 2
      iguana/iguana_blocks.c
  5. 4
      iguana/iguana_bundles.c
  6. 4
      iguana/iguana_ramchain.c
  7. 3
      iguana/main.c
  8. 2
      includes/iguana_defines.h

21
crypto777/OS_nonportable.c

@ -607,20 +607,23 @@ void *OS_nonportable_mapfile(char *fname,long *filesizep,int32_t enablewrite)
return(ptr);
}
int32_t OS_nonportable_renamefile(char *fname,char *newfname)
{
char tmp[1024],tmp2[1024];
strcpy(tmp,fname), strcpy(tmp2,newfname);
OS_nonportable_path(tmp), OS_nonportable_path(tmp2);
return((MoveFile(tmp,tmp2) == 0) ? -1 : 0);
}
int32_t OS_nonportable_removefile(char *fname)
{
char tmp[512];
strcpy(tmp,fname);
OS_portable_path(tmp);
return((DeleteFile(tmp) == 0) ? -1 : 0);
return((DeleteFileA(tmp) == 0) ? -1 : 0);
}
int32_t OS_nonportable_renamefile(char *fname,char *newfname)
{
char tmp[1024],tmp2[1024]; int32_t retval,retvaldel;
strcpy(tmp,fname), strcpy(tmp2,newfname);
OS_nonportable_path(tmp), OS_nonportable_path(tmp2);
retvaldel = OS_nonportable_removefile(tmp2);
retval = MoveFileA(tmp,tmp2);
//printf("call Movefile(%s -> %s) retval.%d retvaldel.%d %d\n",tmp,tmp2,retval,retvaldel,GetLastError());
return((retval == 0) ? -1 : 0);
}
int32_t OS_nonportable_launch(char *args[])

2
iguana/coins/genbtcd

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":-1,\"poll\":50,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTCD\",\"startpend\":64,\"endpend\":16,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":14631,\"rpc\":14632}"
curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":-1,\"poll\":50,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTCD\",\"startpend\":256,\"endpend\":256,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":14631,\"rpc\":14632}"

43
iguana/iguana777.c

@ -267,21 +267,36 @@ void iguana_emitQ(struct iguana_info *coin,struct iguana_bundle *bp)
void iguana_bundleQ(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,int32_t timelimit)
{
struct iguana_helper *ptr;
struct iguana_helper *ptr; struct iguana_bundle *tmp; int32_t i,n = 0;
if ( 0 && bp->queued == 0 && bp->emitfinish <= 1 && iguana_bundleready(myinfo,coin,bp,0) == bp->n )
printf("bundle.[%d] is ready\n",bp->hdrsi);
bp->queued = (uint32_t)time(NULL);
ptr = mycalloc('q',1,sizeof(*ptr));
ptr->allocsize = sizeof(*ptr);
ptr->coin = coin;
ptr->bp = bp, ptr->hdrsi = bp->hdrsi;
ptr->type = 'B';
ptr->starttime = (uint32_t)time(NULL);
ptr->timelimit = timelimit;
coin->numbundlesQ++;
if ( 0 && bp->hdrsi > 170 )
printf("%s %p bundle.%d[%d] ht.%d emitfinish.%u\n",coin->symbol,bp,ptr->hdrsi,bp->n,bp->bundleheight,bp->emitfinish);
queue_enqueue("bundlesQ",&bundlesQ,&ptr->DL,0);
if ( bp->queued != 0 )
return;
for (i=n=0; i<coin->bundlescount; i++)
{
if ( (tmp= coin->bundles[i]) != 0 && tmp->queued != 0 )
n++;
}
if ( n < coin->MAXBUNDLES )
{
bp->queued = (uint32_t)time(NULL);
ptr = mycalloc('q',1,sizeof(*ptr));
ptr->allocsize = sizeof(*ptr);
ptr->coin = coin;
ptr->bp = bp, ptr->hdrsi = bp->hdrsi;
ptr->type = 'B';
ptr->starttime = (uint32_t)time(NULL);
ptr->timelimit = timelimit;
coin->numbundlesQ++;
//if ( 0 && bp->hdrsi > 170 )
printf("%s.%d %p bundle.%d[%d] ht.%d emitfinish.%u\n",coin->symbol,n,bp,ptr->hdrsi,bp->n,bp->bundleheight,bp->emitfinish);
queue_enqueue("bundlesQ",&bundlesQ,&ptr->DL,0);
}
else
{
bp->queued = 0;
//printf("MAXBUNDLES.%d reached.%d\n",coin->MAXBUNDLES,n);
}
}
void iguana_validateQ(struct iguana_info *coin,struct iguana_bundle *bp)
@ -691,7 +706,7 @@ void iguana_helper(void *arg)
allcurrent = 0;
//printf("h.%d [%d] bundleQ size.%d lag.%ld\n",helperid,bp->hdrsi,queue_size(&bundlesQ),time(NULL) - bp->nexttime);
coin->numbundlesQ--;
if ( coin->started != 0 && (bp->nexttime == 0 || time(NULL) >= bp->nexttime) && coin->active != 0 )
if ( coin->started != 0 && time(NULL) >= bp->nexttime && coin->active != 0 )
{
flag += iguana_bundleiters(myinfo,ptr->coin,&MEM,MEMB,bp,ptr->timelimit,IGUANA_DEFAULTLAG);
}

2
iguana/iguana_blocks.c

@ -630,7 +630,7 @@ struct iguana_block *_iguana_chainlink(struct supernet_info *myinfo,struct iguan
}
}
bp = iguana_bundlecreate(coin,&bundlei,block->height,block->RO.hash2,zero,0);
//if ( bp != 0 && bp->hdrsi == coin->bundlescount-1 )
if ( bp != 0 && bp->hdrsi == coin->bundlescount-1 )
{
//printf("created last bundle ht.%d\n",bp->bundleheight);
iguana_blockreq(coin,block->height,1);

4
iguana/iguana_bundles.c

@ -1441,7 +1441,11 @@ void iguana_bundlestats(struct supernet_info *myinfo,struct iguana_info *coin,ch
if ( (bp= firstgap) != 0 )//&& coin->PREFETCHLAG < 0 )
{
if ( bp != coin->current )
{
printf("new 1st.%d\n",bp->hdrsi);
if ( bp->queued == 0 )
iguana_bundleQ(myinfo,coin,bp,0);
}
//else printf("issue 1st.%d\n",bp->hdrsi);
for (i=0; i<bp->n; i++)
if ( GETBIT(bp->haveblock,i) == 0 )

4
iguana/iguana_ramchain.c

@ -2056,10 +2056,8 @@ void iguana_blockdelete(struct iguana_info *coin,bits256 hash2,int32_t i)
if ( fname[0] != 0 )
{
OS_removefile(fname,0);
#ifndef WIN32
strcat(fname,".tmp");
OS_removefile(fname,0);
#endif
}
}
@ -2145,14 +2143,12 @@ void *iguana_bundlefile(struct iguana_info *coin,char *fname,long *filesizep,str
else
{
fclose(fp);
#ifndef WIN32
if ( renameflag != 0 )
{
sprintf(renamed,"%s.tmp",fname);
OS_renamefile(fname,renamed);
strcpy(fname,renamed);
}
#endif
if ( (ptr= OS_mapfile(fname,filesizep,0)) == 0 )
{
printf("error mapping.(%s) bundlei.%d\n",fname,bundlei);

3
iguana/main.c

@ -1560,6 +1560,9 @@ void iguana_main(void *arg)
do_OStests = 1;
#ifdef IGUANA_OSTESTS
do_OStests = 1;
#endif
#ifdef WIN32
do_OStests = 1;
#endif
if ( do_OStests != 0 )
{

2
includes/iguana_defines.h

@ -45,7 +45,7 @@
#define IGUANA_TAILPERCENTAGE 1.0
#define IGUANA_MAXPENDHDRS 1
#define IGUANA_MAXPENDINGREQUESTS 3
#define IGUANA_PENDINGREQUESTS 500
#define IGUANA_PENDINGREQUESTS 64
#define IGUANA_MINPENDBUNDLES 4
#define IGUANA_MAXPENDBUNDLES 64
#define IGUANA_RPCPORT 7778

Loading…
Cancel
Save