Skip to content

Commit

Permalink
DERO-HE STARGATE Testnet Release32
Browse files Browse the repository at this point in the history
  • Loading branch information
CaptainDero committed Nov 29, 2021
1 parent 484639b commit 2388bdd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
17 changes: 6 additions & 11 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions blockchain/storefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]))

Expand All @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion config/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit 2388bdd

Please sign in to comment.