From ff9f32d4fa6d3fb36e4ff3ff25970e7cdb3bdd8b Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 28 Mar 2022 13:15:25 -0700 Subject: [PATCH] fix linter --- cmd/iavlserver/main.go | 3 ++- mutable_tree.go | 11 +++++++---- node.go | 1 + nodedb.go | 6 ++++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cmd/iavlserver/main.go b/cmd/iavlserver/main.go index 6697bcf04..e925f4f4b 100644 --- a/cmd/iavlserver/main.go +++ b/cmd/iavlserver/main.go @@ -19,6 +19,7 @@ import ( "github.com/pkg/errors" dbm "github.com/tendermint/tm-db" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/grpclog" pb "github.com/cosmos/iavl/proto" @@ -110,7 +111,7 @@ func startRPCGateway() error { runtime.WithProtoErrorHandler(runtime.DefaultHTTPProtoErrorHandler), ) - dialOpts := []grpc.DialOption{grpc.WithInsecure(), grpc.WithBlock()} + dialOpts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()} err := pb.RegisterIAVLServiceHandlerFromEndpoint( context.Background(), gatewayMux, *gRPCEndpoint, dialOpts, diff --git a/mutable_tree.go b/mutable_tree.go index 6b493c145..05e54225c 100644 --- a/mutable_tree.go +++ b/mutable_tree.go @@ -183,11 +183,11 @@ func (tree *MutableTree) Iterate(fn func(key []byte, value []byte) bool) (stoppe // Iterator returns an iterator over the mutable tree. // CONTRACT: no updates are made to the tree while an iterator is active. -func (t *MutableTree) Iterator(start, end []byte, ascending bool) dbm.Iterator { - if t.IsFastCacheEnabled() { - return NewUnsavedFastIterator(start, end, ascending, t.ndb, t.unsavedFastNodeAdditions, t.unsavedFastNodeRemovals) +func (tree *MutableTree) Iterator(start, end []byte, ascending bool) dbm.Iterator { + if tree.IsFastCacheEnabled() { + return NewUnsavedFastIterator(start, end, ascending, tree.ndb, tree.unsavedFastNodeAdditions, tree.unsavedFastNodeRemovals) } - return t.ImmutableTree.Iterator(start, end, ascending) + return tree.ImmutableTree.Iterator(start, end, ascending) } func (tree *MutableTree) set(key []byte, value []byte) (orphans []*Node, updated bool) { @@ -521,6 +521,7 @@ func (tree *MutableTree) IsUpgradeable() bool { // enableFastStorageAndCommitIfNotEnabled if nodeDB doesn't mark fast storage as enabled, enable it, and commit the update. // Checks whether the fast cache on disk matches latest live state. If not, deletes all existing fast nodes and repopulates them // from latest tree. +// nolint: unparam func (tree *MutableTree) enableFastStorageAndCommitIfNotEnabled() (bool, error) { shouldForceUpdate := tree.ndb.shouldForceFastStorageUpgrade() isFastStorageEnabled := tree.ndb.hasUpgradedToFastStorage() @@ -768,11 +769,13 @@ func (tree *MutableTree) saveFastNodeVersion() error { return tree.ndb.setFastStorageVersionToBatch() } +// nolint: unused func (tree *MutableTree) getUnsavedFastNodeAdditions() map[string]*FastNode { return tree.unsavedFastNodeAdditions } // getUnsavedFastNodeRemovals returns unsaved FastNodes to remove +// nolint: unused func (tree *MutableTree) getUnsavedFastNodeRemovals() map[string]interface{} { return tree.unsavedFastNodeRemovals } diff --git a/node.go b/node.go index 912ce0d8d..b7e369727 100644 --- a/node.go +++ b/node.go @@ -444,6 +444,7 @@ func (node *Node) calcBalance(t *ImmutableTree) int { } // traverse is a wrapper over traverseInRange when we want the whole tree +// nolint: unparam func (node *Node) traverse(t *ImmutableTree, ascending bool, cb func(*Node) bool) bool { return node.traverseInRange(t, nil, nil, ascending, false, false, func(node *Node) bool { return cb(node) diff --git a/nodedb.go b/nodedb.go index 1413d616a..06e887002 100644 --- a/nodedb.go +++ b/nodedb.go @@ -476,7 +476,6 @@ func (ndb *nodeDB) DeleteVersionsFrom(version int64) error { // Delete fast node entries err = ndb.traverseFastNodes(func(keyWithPrefix, v []byte) error { key := keyWithPrefix[1:] - // nolint: govet fastNode, err := DeserializeFastNode(key, v) if err != nil { @@ -750,6 +749,7 @@ func (ndb *nodeDB) traverseOrphansVersion(version int64, fn func(k, v []byte) er } // Traverse all keys and return error if any, nil otherwise +// nolint: unused func (ndb *nodeDB) traverse(fn func(key, value []byte) error) error { return ndb.traverseRange(nil, nil, fn) } @@ -885,7 +885,6 @@ func (ndb *nodeDB) getRoot(version int64) ([]byte, error) { return ndb.db.Get(ndb.rootKey(version)) } -//nolint:unparam func (ndb *nodeDB) getRoots() (roots map[int64][]byte, err error) { roots = make(map[int64][]byte) err = ndb.traversePrefix(rootKeyFormat.Key(), func(k, v []byte) error { @@ -946,6 +945,7 @@ func (ndb *nodeDB) decrVersionReaders(version int64) { // Utility and test functions +// nolint: unused func (ndb *nodeDB) leafNodes() ([]*Node, error) { leaves := []*Node{} @@ -963,6 +963,7 @@ func (ndb *nodeDB) leafNodes() ([]*Node, error) { return leaves, nil } +// nolint: unused func (ndb *nodeDB) nodes() ([]*Node, error) { nodes := []*Node{} @@ -978,6 +979,7 @@ func (ndb *nodeDB) nodes() ([]*Node, error) { return nodes, nil } +// nolint: unused func (ndb *nodeDB) orphans() ([][]byte, error) { orphans := [][]byte{}