From 138db2bb2a8aad21d676b68d257ca2eff1f2b0bb Mon Sep 17 00:00:00 2001 From: Marko Date: Mon, 25 Mar 2024 17:57:34 +0100 Subject: [PATCH] chore: linting fixes (#19855) Co-authored-by: son trinh --- store/db/rocksdb_noflag.go | 17 +---------------- store/proof/commit_info.go | 8 ++++---- x/params/types/common_test.go | 14 +++++++------- 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/store/db/rocksdb_noflag.go b/store/db/rocksdb_noflag.go index f5b8f98df595..1d1fa4e21d80 100644 --- a/store/db/rocksdb_noflag.go +++ b/store/db/rocksdb_noflag.go @@ -6,7 +6,6 @@ package db import ( corestore "cosmossdk.io/core/store" "cosmossdk.io/store/v2" - "github.com/linxGnu/grocksdb" ) var ( @@ -19,7 +18,7 @@ var ( type RocksDB struct { } -func NewRocksDB(dataDir string) (*RocksDB, error) { +func NewRocksDB(name, dataDir string) (*RocksDB, error) { panic("rocksdb must be built with -tags rocksdb") } @@ -61,10 +60,6 @@ var _ corestore.Iterator = (*rocksDBIterator)(nil) type rocksDBIterator struct { } -func newRocksDBIterator(src *grocksdb.Iterator, start, end []byte, reverse bool) *rocksDBIterator { - panic("rocksdb must be built with -tags rocksdb") -} - func (itr *rocksDBIterator) Domain() (start, end []byte) { panic("rocksdb must be built with -tags rocksdb") } @@ -123,13 +118,3 @@ func (b *rocksDBBatch) Close() error { func (b *rocksDBBatch) GetByteSize() (int, error) { panic("rocksdb must be built with -tags rocksdb") } - -func readOnlySlice(s *grocksdb.Slice) []byte { - panic("rocksdb must be built with -tags rocksdb") -} - -// copyAndFreeSlice will copy a given RocksDB slice and free it. If the slice -// does not exist, will be returned. -func copyAndFreeSlice(s *grocksdb.Slice) []byte { - panic("rocksdb must be built with -tags rocksdb") -} diff --git a/store/proof/commit_info.go b/store/proof/commit_info.go index ad2f21708e03..91299ddca2c0 100644 --- a/store/proof/commit_info.go +++ b/store/proof/commit_info.go @@ -75,7 +75,7 @@ func (ci *CommitInfo) GetStoreProof(storeKey []byte) ([]byte, *CommitmentOp, err leaves := make([][]byte, len(ci.StoreInfos)) for i, si := range ci.StoreInfos { var err error - leaves[i], err = LeafHash([]byte(si.Name), si.GetHash()) + leaves[i], err = LeafHash(si.Name, si.GetHash()) if err != nil { return nil, nil, err } @@ -85,7 +85,7 @@ func (ci *CommitInfo) GetStoreProof(storeKey []byte) ([]byte, *CommitmentOp, err } rootHash, inners := ProofFromByteSlices(leaves, index) - commitmentOp := ConvertCommitmentOp(inners, []byte(storeKey), ci.StoreInfos[index].GetHash()) + commitmentOp := ConvertCommitmentOp(inners, storeKey, ci.StoreInfos[index].GetHash()) return rootHash, &commitmentOp, nil } @@ -96,7 +96,7 @@ func (ci *CommitInfo) encodedSize() int { size += encoding.EncodeVarintSize(ci.Timestamp.UnixNano()) size += encoding.EncodeUvarintSize(uint64(len(ci.StoreInfos))) for _, storeInfo := range ci.StoreInfos { - size += encoding.EncodeBytesSize([]byte(storeInfo.Name)) + size += encoding.EncodeBytesSize(storeInfo.Name) size += encoding.EncodeBytesSize(storeInfo.CommitID.Hash) } return size @@ -124,7 +124,7 @@ func (ci *CommitInfo) Marshal() ([]byte, error) { return nil, err } for _, si := range ci.StoreInfos { - if err := encoding.EncodeBytes(&buf, []byte(si.Name)); err != nil { + if err := encoding.EncodeBytes(&buf, si.Name); err != nil { return nil, err } if err := encoding.EncodeBytes(&buf, si.CommitID.Hash); err != nil { diff --git a/x/params/types/common_test.go b/x/params/types/common_test.go index 09cd49401fca..9fd9b1a535af 100644 --- a/x/params/types/common_test.go +++ b/x/params/types/common_test.go @@ -78,18 +78,18 @@ func validateMaxRedelegationEntries(i interface{}) error { func (p *params) ParamSetPairs() types.ParamSetPairs { return types.ParamSetPairs{ - {keyUnbondingTime, &p.UnbondingTime, validateUnbondingTime}, - {keyMaxValidators, &p.MaxValidators, validateMaxValidators}, - {keyBondDenom, &p.BondDenom, validateBondDenom}, + types.ParamSetPair{Key: keyUnbondingTime, Value: &p.UnbondingTime, ValidatorFn: validateUnbondingTime}, + types.ParamSetPair{Key: keyMaxValidators, Value: &p.MaxValidators, ValidatorFn: validateMaxValidators}, + types.ParamSetPair{Key: keyBondDenom, Value: &p.BondDenom, ValidatorFn: validateBondDenom}, } } func (p *paramsV2) ParamSetPairs() types.ParamSetPairs { return types.ParamSetPairs{ - {keyUnbondingTime, &p.UnbondingTime, validateUnbondingTime}, - {keyMaxValidators, &p.MaxValidators, validateMaxValidators}, - {keyBondDenom, &p.BondDenom, validateBondDenom}, - {keyMaxRedelegationEntries, &p.MaxRedelegationEntries, validateMaxRedelegationEntries}, + types.ParamSetPair{Key: keyUnbondingTime, Value: &p.UnbondingTime, ValidatorFn: validateUnbondingTime}, + types.ParamSetPair{Key: keyMaxValidators, Value: &p.MaxValidators, ValidatorFn: validateMaxValidators}, + types.ParamSetPair{Key: keyBondDenom, Value: &p.BondDenom, ValidatorFn: validateBondDenom}, + types.ParamSetPair{Key: keyMaxRedelegationEntries, Value: &p.MaxRedelegationEntries, ValidatorFn: validateMaxRedelegationEntries}, } }