Skip to content

Commit

Permalink
fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
p0mvn committed Mar 28, 2022
1 parent f56de3a commit ff9f32d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cmd/iavlserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 7 additions & 4 deletions mutable_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions nodedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -946,6 +945,7 @@ func (ndb *nodeDB) decrVersionReaders(version int64) {

// Utility and test functions

// nolint: unused
func (ndb *nodeDB) leafNodes() ([]*Node, error) {
leaves := []*Node{}

Expand All @@ -963,6 +963,7 @@ func (ndb *nodeDB) leafNodes() ([]*Node, error) {
return leaves, nil
}

// nolint: unused
func (ndb *nodeDB) nodes() ([]*Node, error) {
nodes := []*Node{}

Expand All @@ -978,6 +979,7 @@ func (ndb *nodeDB) nodes() ([]*Node, error) {
return nodes, nil
}

// nolint: unused
func (ndb *nodeDB) orphans() ([][]byte, error) {
orphans := [][]byte{}

Expand Down

0 comments on commit ff9f32d

Please sign in to comment.