Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Oct 23, 2023
1 parent 33f1295 commit 75af523
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions memiavl/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
DefaultSnapshotInterval = 1000
LockFileName = "LOCK"
DefaultSnapshotWriterLimit = 4
TmpSuffix = "-tmp"
)

var errReadOnly = errors.New("db is read-only")
Expand Down Expand Up @@ -265,7 +266,7 @@ func removeTmpDirs(rootDir string) error {
}

for _, entry := range entries {
if !entry.IsDir() || !strings.HasSuffix(entry.Name(), "-tmp") {
if !entry.IsDir() || !strings.HasSuffix(entry.Name(), TmpSuffix) {
continue
}

Expand Down Expand Up @@ -636,7 +637,7 @@ func (db *DB) RewriteSnapshot() error {
}

snapshotDir := snapshotName(db.lastCommitInfo.Version)
tmpDir := snapshotDir + "-tmp"
tmpDir := snapshotDir + TmpSuffix
path := filepath.Join(db.dir, tmpDir)
if err := db.MultiTree.WriteSnapshot(path, db.snapshotWriterPool); err != nil {
return errors.Join(err, os.RemoveAll(path))
Expand Down Expand Up @@ -978,7 +979,7 @@ func traverseSnapshots(dir string, ascending bool, callback func(int64) (bool, e

// atomicRemoveDir is equavalent to `mv snapshot snapshot-tmp && rm -r snapshot-tmp`
func atomicRemoveDir(path string) error {
tmpPath := path + "-tmp"
tmpPath := path + TmpSuffix
if err := os.Rename(path, tmpPath); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion memiavl/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestRemoveSnapshotDir(t *testing.T) {
defer os.RemoveAll(dbDir)

snapshotDir := filepath.Join(dbDir, snapshotName(0))
tmpDir := snapshotDir + "-tmp"
tmpDir := snapshotDir + TmpSuffix
if err := os.MkdirAll(tmpDir, os.ModePerm); err != nil {
t.Fatalf("Failed to create dummy snapshot directory: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion memiavl/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewMultiTreeImporter(dir string, height uint64) (*MultiTreeImporter, error)
}

func (mti *MultiTreeImporter) tmpDir() string {
return filepath.Join(mti.dir, mti.snapshotDir+"-tmp")
return filepath.Join(mti.dir, mti.snapshotDir+TmpSuffix)
}

func (mti *MultiTreeImporter) Add(item interface{}) error {
Expand Down
2 changes: 1 addition & 1 deletion x/cronos/keeper/mock/ibckeeper_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (i IbcKeeperMock) Transfer(goCtx context.Context, msg *types.MsgTransfer) (
}

func (i IbcKeeperMock) GetDenomTrace(ctx sdk.Context, denomTraceHash tmbytes.HexBytes) (types.DenomTrace, bool) {
if denomTraceHash.String() == "6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD5D19762F541EC971ACB0865" { //nolint:gosec // test only
if denomTraceHash.String() == "6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD5D19762F541EC971ACB0865" {
return types.DenomTrace{
Path: "transfer/channel-0",
BaseDenom: "basetcro",
Expand Down

0 comments on commit 75af523

Please sign in to comment.