Skip to content

Commit

Permalink
Remove redudant func
Browse files Browse the repository at this point in the history
  • Loading branch information
cabrador committed Dec 8, 2023
1 parent dd12f03 commit 9d531d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
6 changes: 5 additions & 1 deletion executor/extension/tracker/progress_tracker.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tracker

import (
"fmt"
"sync"
"time"

Expand Down Expand Up @@ -95,7 +96,10 @@ func (t *progressTracker) PostBlock(state executor.State[*substate.Substate], ct
info := t.overallInfo
t.lock.Unlock()

disk := utils.GetDirectorySize(ctx.StateDbPath)
disk, err := utils.GetDirectorySize(ctx.StateDbPath)
if err != nil {
return fmt.Errorf("cannot size of directory (%v); %v", ctx.StateDbPath, err)
}
m := ctx.State.GetMemoryUsage()

memory := uint64(0)
Expand Down
22 changes: 3 additions & 19 deletions utils/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package utils

import (
"fmt"
"io/fs"
"os"
"path/filepath"

Expand Down Expand Up @@ -65,7 +64,7 @@ func useExistingStateDB(cfg *Config) (state.StateDB, string, error) {
return nil, "", fmt.Errorf("failed to create a temporary directory; %v", err)
}

size, err := FindDirSize(cfg.StateDbSrc)
size, err := GetDirectorySize(cfg.StateDbSrc)
if err != nil {
return nil, "", err
}
Expand Down Expand Up @@ -258,23 +257,8 @@ func DeleteDestroyedAccountsFromStateDB(db state.StateDB, cfg *Config, target ui
return nil
}

// GetDirectorySize computes the size of all files in the given directory in bytes.
func GetDirectorySize(directory string) int64 {
var sum int64 = 0
filepath.Walk(directory, func(path string, info fs.FileInfo, err error) error {
if err != nil {
return nil
}
if !info.IsDir() {
sum += info.Size()
}
return nil
})
return sum
}

// FindDirSize iterates over all files inside given directory (including subdirectories) and returns size in bytes.
func FindDirSize(path string) (int64, error) {
// GetDirectorySize iterates over all files inside given directory (including subdirectories) and returns size in bytes.
func GetDirectorySize(path string) (int64, error) {
var size int64
err := filepath.Walk(path, func(_ string, info os.FileInfo, err error) error {
if err != nil {
Expand Down

0 comments on commit 9d531d9

Please sign in to comment.