From 75af523df668e20bb3af6d0392d347d79321f5f3 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 23 Oct 2023 18:58:41 +0800 Subject: [PATCH] fix lint --- memiavl/db.go | 7 ++++--- memiavl/db_test.go | 2 +- memiavl/import.go | 2 +- x/cronos/keeper/mock/ibckeeper_mock.go | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/memiavl/db.go b/memiavl/db.go index 457b357c00..cdfac6de5f 100644 --- a/memiavl/db.go +++ b/memiavl/db.go @@ -20,6 +20,7 @@ const ( DefaultSnapshotInterval = 1000 LockFileName = "LOCK" DefaultSnapshotWriterLimit = 4 + TmpSuffix = "-tmp" ) var errReadOnly = errors.New("db is read-only") @@ -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 } @@ -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)) @@ -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 } diff --git a/memiavl/db_test.go b/memiavl/db_test.go index fc56916e17..f8d99222cd 100644 --- a/memiavl/db_test.go +++ b/memiavl/db_test.go @@ -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) } diff --git a/memiavl/import.go b/memiavl/import.go index a64be6d0a8..6cb245ede5 100644 --- a/memiavl/import.go +++ b/memiavl/import.go @@ -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 { diff --git a/x/cronos/keeper/mock/ibckeeper_mock.go b/x/cronos/keeper/mock/ibckeeper_mock.go index 4c1293ebaf..7647a20b68 100644 --- a/x/cronos/keeper/mock/ibckeeper_mock.go +++ b/x/cronos/keeper/mock/ibckeeper_mock.go @@ -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",