Browse Source

self-healing

release/v0.1
jl777 9 years ago
parent
commit
92e407c0a8
  1. 2
      iguana/iguana777.h
  2. 13
      iguana/iguana_bundles.c
  3. 19
      iguana/iguana_ramchain.c
  4. 2
      iguana/iguana_unspents.c
  5. BIN
      iguana/pnacl/Release/iguana.pexe

2
iguana/iguana777.h

@ -873,6 +873,8 @@ void iguana_allocvolatile(struct iguana_info *coin,struct iguana_ramchain *ramch
int32_t iguana_peerhdrrequest(struct iguana_info *coin,struct iguana_peer *addr,bits256 hash2);
int32_t iguana_peerinvdata(struct iguana_info *coin,struct iguana_peer *addr,uint8_t *space,int32_t max);
int32_t iguana_bundlefname(struct iguana_info *coin,struct iguana_bundle *bp,char *fname);
int32_t iguana_bundleremove(struct iguana_info *coin,int32_t hdrsi);
extern int32_t HDRnet,netBLOCKS;

13
iguana/iguana_bundles.c

@ -363,6 +363,19 @@ struct iguana_bundle *iguana_bundlecreate(struct iguana_info *coin,int32_t *bund
return(0);
}
int32_t iguana_bundlefname(struct iguana_info *coin,struct iguana_bundle *bp,char *fname)
{
int32_t hdrsi; static bits256 zero;
iguana_peerfname(coin,&hdrsi,"DB",fname,0,bp->hashes[0],zero,bp->n,1);
if ( hdrsi == bp->hdrsi )
return(0);
else
{
fname[0] = 0;
return(-1);
}
}
struct iguana_txid *iguana_bundletx(struct iguana_info *coin,struct iguana_bundle *bp,int32_t bundlei,struct iguana_txid *tx,int32_t txidind)
{
static const bits256 zero;

19
iguana/iguana_ramchain.c

@ -1222,6 +1222,25 @@ int32_t iguana_ramchain_free(struct iguana_info *coin,struct iguana_ramchain *ra
return(0);
}
int32_t iguana_bundleremove(struct iguana_info *coin,int32_t hdrsi)
{
struct iguana_bundle *bp; char fname[1024],str[65];
if ( hdrsi >= 0 && hdrsi < coin->bundlescount && (bp= coin->bundles[hdrsi]) != 0 )
{
printf("delete bundle.[%d]\n",hdrsi);
iguana_ramchain_free(coin,&bp->ramchain,1);
if ( iguana_bundlefname(coin,bp,fname) == 0 )
{
printf("delete.(%s)\n",fname);
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);
return(0);
}
return(-1);
}
int32_t iguana_ramchain_extras(struct iguana_info *coin,struct iguana_ramchain *ramchain,struct OS_memspace *hashmem,int32_t extraflag)
{
RAMCHAIN_DECLARE; int32_t err=0;

2
iguana/iguana_unspents.c

@ -305,6 +305,8 @@ int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struc
}
}
printf("iguana_volatileupdate: [%d] spent.(u%u %.8f pkind.%d) double spend? at ht.%d [%d] spendind.%d\n",spent_hdrsi,spent_unspentind,dstr(spent_value),spent_pkind,fromheight,fromheight/coin->chain->bundlesize,spendind);
iguana_bundleremove(coin,spent_hdrsi);
iguana_bundleremove(coin,fromheight/coin->chain->bundlesize);
exit(-1);
}
return(-1);

BIN
iguana/pnacl/Release/iguana.pexe

Binary file not shown.
Loading…
Cancel
Save