replace errors.go with github.com/pkg/errors (1/2) (#3888)

* (1/2) of replace errors.go with github.com/pkg/errors

ref #3862

- step one in removing instances of errors.go in favor of github.com/pkg/errors

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* gofmt

* add in /store
This commit is contained in:
Marko
2019-08-08 14:31:13 +04:00
committed by Anton Kaliaev
parent d70135ec71
commit 8dc39b69b7
13 changed files with 53 additions and 47 deletions
+7 -6
View File
@@ -4,7 +4,8 @@ import (
"fmt"
"sync"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/pkg/errors"
dbm "github.com/tendermint/tm-db"
"github.com/tendermint/tendermint/types"
@@ -67,7 +68,7 @@ func (bs *BlockStore) LoadBlock(height int64) *types.Block {
if err != nil {
// NOTE: The existence of meta should imply the existence of the
// block. So, make sure meta is only saved after blocks are saved.
panic(cmn.ErrorWrap(err, "Error reading block"))
panic(errors.Wrap(err, "Error reading block"))
}
return block
}
@@ -83,7 +84,7 @@ func (bs *BlockStore) LoadBlockPart(height int64, index int) *types.Part {
}
err := cdc.UnmarshalBinaryBare(bz, part)
if err != nil {
panic(cmn.ErrorWrap(err, "Error reading block part"))
panic(errors.Wrap(err, "Error reading block part"))
}
return part
}
@@ -98,7 +99,7 @@ func (bs *BlockStore) LoadBlockMeta(height int64) *types.BlockMeta {
}
err := cdc.UnmarshalBinaryBare(bz, blockMeta)
if err != nil {
panic(cmn.ErrorWrap(err, "Error reading block meta"))
panic(errors.Wrap(err, "Error reading block meta"))
}
return blockMeta
}
@@ -115,7 +116,7 @@ func (bs *BlockStore) LoadBlockCommit(height int64) *types.Commit {
}
err := cdc.UnmarshalBinaryBare(bz, commit)
if err != nil {
panic(cmn.ErrorWrap(err, "Error reading block commit"))
panic(errors.Wrap(err, "Error reading block commit"))
}
return commit
}
@@ -131,7 +132,7 @@ func (bs *BlockStore) LoadSeenCommit(height int64) *types.Commit {
}
err := cdc.UnmarshalBinaryBare(bz, commit)
if err != nil {
panic(cmn.ErrorWrap(err, "Error reading block seen commit"))
panic(errors.Wrap(err, "Error reading block seen commit"))
}
return commit
}
+2 -2
View File
@@ -9,13 +9,13 @@ import (
"testing"
"time"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
db "github.com/tendermint/tm-db"
dbm "github.com/tendermint/tm-db"
cfg "github.com/tendermint/tendermint/config"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/libs/log"
sm "github.com/tendermint/tendermint/state"
@@ -53,7 +53,7 @@ func makeStateAndBlockStore(logger log.Logger) (sm.State, *BlockStore, cleanupFu
stateDB := dbm.NewMemDB()
state, err := sm.LoadStateFromDBOrGenesisFile(stateDB, config.GenesisFile())
if err != nil {
panic(cmn.ErrorWrap(err, "error constructing state from genesis file"))
panic(errors.Wrap(err, "error constructing state from genesis file"))
}
return state, NewBlockStore(blockDB), func() { os.RemoveAll(config.RootDir) }
}