Skip to content

Commit

Permalink
fix lint in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
mossid committed Sep 16, 2018
1 parent 70c03b3 commit a43b50f
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions store/cache/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func (ci *Store) Write() {
ci.cache = make(map[string]cValue)
}

// Implements types.KVStore
func (ci *Store) CacheWrap() types.CacheKVStore {
return NewStore(ci)
}
Expand Down
1 change: 1 addition & 0 deletions store/cachemulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func (cms Store) GetTracer() *types.Tracer {
return cms.tracer
}

// Implements MultiStore
func (cms Store) GetGasTank() *types.GasTank {
return cms.tank
}
Expand Down
3 changes: 3 additions & 0 deletions store/iavl/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ func NewKey(name string) *KVStoreKey {
}
}

// Implements StoreKey
func (key *KVStoreKey) Name() string {
return key.name
}

// Implements StoreKey
func (key *KVStoreKey) String() string {
return fmt.Sprintf("KVStoreKey{%p, %s}", key, key.name)
}

// Implements StoreKey
func (key *KVStoreKey) NewStore() types.CommitStore {
return &Store{}
}
4 changes: 2 additions & 2 deletions store/iavl/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ const (
)

// load the iavl store
func (store *Store) LoadKVStoreVersion(db dbm.DB, id types.CommitID) error {
func (st *Store) LoadKVStoreVersion(db dbm.DB, id types.CommitID) error {
tree := iavl.NewMutableTree(db, defaultIAVLCacheSize)
_, err := tree.LoadVersion(id.Version)
if err != nil {
return err
}
iavl := newIAVLStore(tree, int64(0), int64(0))
*store = *iavl
*st = *iavl
return nil
}

Expand Down
1 change: 1 addition & 0 deletions store/prefix/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

var _ types.KVStore = Store{}

// Store with key prefixed
type Store struct {
parent types.KVStore
prefix []byte
Expand Down
4 changes: 2 additions & 2 deletions store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"github.com/cosmos/cosmos-sdk/store/types"
)

// nolint: reexport
// nolint - reexport
type (
CommitMultiStore = rootmulti.Store
)

// nolint: reexport
// nolint - reexport
func NewCommitMultiStore(db dbm.DB) *rootmulti.Store {
return rootmulti.NewStore(db)
}
Expand Down
15 changes: 14 additions & 1 deletion store/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,31 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
)

// ABCICodeType - combined codetype / codespace
type ABCICodeType uint32

// CodeType - code identifier within codespace
type CodeType uint16

// CodespaceType - codespace identifier
type CodespaceType uint16

// get the abci code from the local code and codespace
func ToABCICode(code CodeType) ABCICodeType {
if code == CodeOK {
return ABCICodeOK
}
return ABCICodeType((uint32(CodespaceRoot) << 16) | uint32(code))
}

// SDK error codes
const (
// Using same code with sdk/errors.go to reduce confusion

// ABCI error codes
ABCICodeOK ABCICodeType = 0

// Base error codes
CodeOK CodeType = 0
CodeInternal CodeType = 1
CodeTxDecode CodeType = 2
Expand All @@ -39,6 +47,7 @@ func unknownCodeMsg(code CodeType) string {
return fmt.Sprintf("unknown code %d", code)
}

// nolint: gocyclo
func CodeToDefaultMsg(code CodeType) string {
switch code {
case CodeInternal:
Expand Down Expand Up @@ -69,6 +78,7 @@ func ErrUnknownRequest(msg string) Error {

type cmnError = cmn.Error

// Query error type
type Error interface {
cmnError

Expand Down Expand Up @@ -99,6 +109,7 @@ func parseCmnError(err string) string {
}

// Copied from types/errors.go
// Implements Error
func (err *queryError) ABCILog() string {
cdc := codec.New()
parsedErrMsg := parseCmnError(err.cmnError.Error())
Expand All @@ -114,16 +125,18 @@ func (err *queryError) ABCILog() string {
return stringifiedJSON
}

// Implements Error
func (err *queryError) QueryResult() abci.ResponseQuery {
return abci.ResponseQuery{
Code: uint32(ToABCICode(err.code)),
Log: err.ABCILog(),
}
}

// TODO: Do we need Codespace/ABCICode here?
type humanReadableError struct {
Codespace CodespaceType `json:"codespace"`
Code CodeType `json:"code"`
ABCICode ABCICodeType `json:"abci_code"`
Message string `json:message`
Message string `json:"message"`
}

0 comments on commit a43b50f

Please sign in to comment.