diff --git a/blockchain/blockchain.go b/blockchain/blockchain.go index 56a2b44..1adec41 100644 --- a/blockchain/blockchain.go +++ b/blockchain/blockchain.go @@ -868,10 +868,6 @@ func (chain *Blockchain) Add_Complete_Block(cbl *block.Complete_Block) (err erro if bl_current.Height == 0 { // if it's genesis block if ss, err = chain.Store.Balance_store.LoadSnapshot(0); err != nil { panic(err) - } else if balance_tree, err = ss.GetTree(config.BALANCE_TREE); err != nil { - panic(err) - } else if sc_meta, err = ss.GetTree(config.SC_META); err != nil { - panic(err) } } else { // we already have a block before us, use it @@ -886,13 +882,12 @@ func (chain *Blockchain) Add_Complete_Block(cbl *block.Complete_Block) (err erro if err != nil { panic(err) } - - if balance_tree, err = ss.GetTree(config.BALANCE_TREE); err != nil { - panic(err) - } - if sc_meta, err = ss.GetTree(config.SC_META); err != nil { - panic(err) - } + } + if balance_tree, err = ss.GetTree(config.BALANCE_TREE); err != nil { + panic(err) + } + if sc_meta, err = ss.GetTree(config.SC_META); err != nil { + panic(err) } fees_collected := uint64(0) diff --git a/blockchain/storefs.go b/blockchain/storefs.go index 89b7d57..57ea3a5 100644 --- a/blockchain/storefs.go +++ b/blockchain/storefs.go @@ -59,6 +59,7 @@ func (s *storefs) ReadBlock(h [32]byte) ([]byte, error) { return nil, os.ErrNotExist } +// on windows, we see an odd behaviour where some files could not be deleted, since they may exist only in cache func (s *storefs) DeleteBlock(h [32]byte) error { dir := filepath.Join(filepath.Join(s.basedir, "bltx_store"), fmt.Sprintf("%02x", h[0]), fmt.Sprintf("%02x", h[1]), fmt.Sprintf("%02x", h[2])) @@ -74,7 +75,7 @@ func (s *storefs) DeleteBlock(h [32]byte) error { file := filepath.Join(filepath.Join(s.basedir, "bltx_store"), fmt.Sprintf("%02x", h[0]), fmt.Sprintf("%02x", h[1]), fmt.Sprintf("%02x", h[2]), file.Name()) err = os.Remove(file) if err != nil { - return err + //return err } found = true } @@ -123,10 +124,15 @@ func (chain *Blockchain) ReadBlockSnapshotVersion(h [32]byte) (uint64, error) { func (s *storefs) ReadBlockSnapshotVersion(h [32]byte) (uint64, error) { dir := filepath.Join(filepath.Join(s.basedir, "bltx_store"), fmt.Sprintf("%02x", h[0]), fmt.Sprintf("%02x", h[1]), fmt.Sprintf("%02x", h[2])) - files, err := os.ReadDir(dir) + files, err := os.ReadDir(dir) // this always returns the sorted list if err != nil { return 0, err } + // windows has a caching issue, so earlier versions may exist at the same time + // so we mitigate it, by using the last version, below 3 lines reverse the already sorted arrray + for left, right := 0, len(files)-1; left < right; left, right = left+1, right-1 { + files[left], files[right] = files[right], files[left] + } filename_start := fmt.Sprintf("%x.block", h[:]) for _, file := range files { diff --git a/config/version.go b/config/version.go index 252f6ef..e400d0b 100644 --- a/config/version.go +++ b/config/version.go @@ -20,4 +20,4 @@ import "github.com/blang/semver/v4" // right now it has to be manually changed // do we need to include git commitsha?? -var Version = semver.MustParse("3.4.92-1.DEROHE.STARGATE+25112021") +var Version = semver.MustParse("3.4.93-1.DEROHE.STARGATE+25112021")