mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-31 12:11:58 +00:00
cleanup go-config/viper and some unnamed imports
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
. "github.com/tendermint/tmlibs/common"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -36,20 +36,20 @@ type (
|
||||
)
|
||||
|
||||
func (e ErrUnknownBlock) Error() string {
|
||||
return Fmt("Could not find block #%d", e.Height)
|
||||
return cmn.Fmt("Could not find block #%d", e.Height)
|
||||
}
|
||||
|
||||
func (e ErrBlockHashMismatch) Error() string {
|
||||
return Fmt("App block hash (%X) does not match core block hash (%X) for height %d", e.AppHash, e.CoreHash, e.Height)
|
||||
return cmn.Fmt("App block hash (%X) does not match core block hash (%X) for height %d", e.AppHash, e.CoreHash, e.Height)
|
||||
}
|
||||
|
||||
func (e ErrAppBlockHeightTooHigh) Error() string {
|
||||
return Fmt("App block height (%d) is higher than core (%d)", e.AppHeight, e.CoreHeight)
|
||||
return cmn.Fmt("App block height (%d) is higher than core (%d)", e.AppHeight, e.CoreHeight)
|
||||
}
|
||||
func (e ErrLastStateMismatch) Error() string {
|
||||
return Fmt("Latest tendermint block (%d) LastAppHash (%X) does not match app's AppHash (%X)", e.Height, e.Core, e.App)
|
||||
return cmn.Fmt("Latest tendermint block (%d) LastAppHash (%X) does not match app's AppHash (%X)", e.Height, e.Core, e.App)
|
||||
}
|
||||
|
||||
func (e ErrStateMismatch) Error() string {
|
||||
return Fmt("State after replay does not match saved state. Got ----\n%v\nExpected ----\n%v\n", e.Got, e.Expected)
|
||||
return cmn.Fmt("State after replay does not match saved state. Got ----\n%v\nExpected ----\n%v\n", e.Got, e.Expected)
|
||||
}
|
||||
|
@@ -6,11 +6,11 @@ import (
|
||||
|
||||
fail "github.com/ebuchman/fail-test"
|
||||
abci "github.com/tendermint/abci/types"
|
||||
. "github.com/tendermint/tmlibs/common"
|
||||
crypto "github.com/tendermint/go-crypto"
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
"github.com/tendermint/tendermint/state/txindex"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
)
|
||||
|
||||
//--------------------------------------------------
|
||||
@@ -126,7 +126,7 @@ func updateValidators(validators *types.ValidatorSet, changedValidators []*abci.
|
||||
power := int64(v.Power)
|
||||
// mind the overflow from uint64
|
||||
if power < 0 {
|
||||
return errors.New(Fmt("Power (%d) overflows int64", v.Power))
|
||||
return errors.New(cmn.Fmt("Power (%d) overflows int64", v.Power))
|
||||
}
|
||||
|
||||
_, val := validators.GetByAddress(address)
|
||||
@@ -134,20 +134,20 @@ func updateValidators(validators *types.ValidatorSet, changedValidators []*abci.
|
||||
// add val
|
||||
added := validators.Add(types.NewValidator(pubkey, power))
|
||||
if !added {
|
||||
return errors.New(Fmt("Failed to add new validator %X with voting power %d", address, power))
|
||||
return errors.New(cmn.Fmt("Failed to add new validator %X with voting power %d", address, power))
|
||||
}
|
||||
} else if v.Power == 0 {
|
||||
// remove val
|
||||
_, removed := validators.Remove(address)
|
||||
if !removed {
|
||||
return errors.New(Fmt("Failed to remove validator %X)"))
|
||||
return errors.New(cmn.Fmt("Failed to remove validator %X)"))
|
||||
}
|
||||
} else {
|
||||
// update val
|
||||
val.VotingPower = power
|
||||
updated := validators.Update(val)
|
||||
if !updated {
|
||||
return errors.New(Fmt("Failed to update validator %X with voting power %d", address, power))
|
||||
return errors.New(cmn.Fmt("Failed to update validator %X with voting power %d", address, power))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,8 +156,8 @@ func updateValidators(validators *types.ValidatorSet, changedValidators []*abci.
|
||||
|
||||
// return a bit array of validators that signed the last commit
|
||||
// NOTE: assumes commits have already been authenticated
|
||||
func commitBitArrayFromBlock(block *types.Block) *BitArray {
|
||||
signed := NewBitArray(len(block.LastCommit.Precommits))
|
||||
func commitBitArrayFromBlock(block *types.Block) *cmn.BitArray {
|
||||
signed := cmn.NewBitArray(len(block.LastCommit.Precommits))
|
||||
for i, precommit := range block.LastCommit.Precommits {
|
||||
if precommit != nil {
|
||||
signed.SetIndex(i, true) // val_.LastCommitHeight = block.Height - 1
|
||||
@@ -187,7 +187,7 @@ func (s *State) validateBlock(block *types.Block) error {
|
||||
}
|
||||
} else {
|
||||
if len(block.LastCommit.Precommits) != s.LastValidators.Size() {
|
||||
return errors.New(Fmt("Invalid block commit size. Expected %v, got %v",
|
||||
return errors.New(cmn.Fmt("Invalid block commit size. Expected %v, got %v",
|
||||
s.LastValidators.Size(), len(block.LastCommit.Precommits)))
|
||||
}
|
||||
err := s.LastValidators.VerifyCommit(
|
||||
|
@@ -8,8 +8,7 @@ import (
|
||||
|
||||
"github.com/spf13/viper"
|
||||
abci "github.com/tendermint/abci/types"
|
||||
cfg "github.com/tendermint/go-config"
|
||||
. "github.com/tendermint/tmlibs/common"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
dbm "github.com/tendermint/tmlibs/db"
|
||||
|
||||
"github.com/tendermint/go-wire"
|
||||
@@ -66,7 +65,7 @@ func loadState(db dbm.DB, key []byte) *State {
|
||||
wire.ReadBinaryPtr(&s, r, 0, n, err)
|
||||
if *err != nil {
|
||||
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
|
||||
Exit(Fmt("LoadState: Data has been corrupted or its spec has changed: %v\n", *err))
|
||||
cmn.Exit(cmn.Fmt("LoadState: Data has been corrupted or its spec has changed: %v\n", *err))
|
||||
}
|
||||
// TODO: ensure that buf is completely read.
|
||||
}
|
||||
@@ -110,7 +109,7 @@ func (s *State) LoadABCIResponses() *ABCIResponses {
|
||||
wire.ReadBinaryPtr(abciResponses, r, 0, n, err)
|
||||
if *err != nil {
|
||||
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
|
||||
Exit(Fmt("LoadABCIResponses: Data has been corrupted or its spec has changed: %v\n", *err))
|
||||
cmn.Exit(cmn.Fmt("LoadABCIResponses: Data has been corrupted or its spec has changed: %v\n", *err))
|
||||
}
|
||||
// TODO: ensure that buf is completely read.
|
||||
}
|
||||
@@ -125,7 +124,7 @@ func (s *State) Bytes() []byte {
|
||||
buf, n, err := new(bytes.Buffer), new(int), new(error)
|
||||
wire.WriteBinary(s, buf, n, err)
|
||||
if *err != nil {
|
||||
PanicCrisis(*err)
|
||||
cmn.PanicCrisis(*err)
|
||||
}
|
||||
return buf.Bytes()
|
||||
}
|
||||
@@ -205,7 +204,7 @@ func (a *ABCIResponses) Bytes() []byte {
|
||||
buf, n, err := new(bytes.Buffer), new(int), new(error)
|
||||
wire.WriteBinary(*a, buf, n, err)
|
||||
if *err != nil {
|
||||
PanicCrisis(*err)
|
||||
cmn.PanicCrisis(*err)
|
||||
}
|
||||
return buf.Bytes()
|
||||
}
|
||||
@@ -219,11 +218,11 @@ func (a *ABCIResponses) Bytes() []byte {
|
||||
func MakeGenesisStateFromFile(db dbm.DB, genDocFile string) *State {
|
||||
genDocJSON, err := ioutil.ReadFile(genDocFile)
|
||||
if err != nil {
|
||||
Exit(Fmt("Couldn't read GenesisDoc file: %v", err))
|
||||
cmn.Exit(cmn.Fmt("Couldn't read GenesisDoc file: %v", err))
|
||||
}
|
||||
genDoc, err := types.GenesisDocFromJSON(genDocJSON)
|
||||
if err != nil {
|
||||
Exit(Fmt("Error reading GenesisDoc: %v", err))
|
||||
cmn.Exit(cmn.Fmt("Error reading GenesisDoc: %v", err))
|
||||
}
|
||||
return MakeGenesisState(db, genDoc)
|
||||
}
|
||||
@@ -233,7 +232,7 @@ func MakeGenesisStateFromFile(db dbm.DB, genDocFile string) *State {
|
||||
// Used in tests.
|
||||
func MakeGenesisState(db dbm.DB, genDoc *types.GenesisDoc) *State {
|
||||
if len(genDoc.Validators) == 0 {
|
||||
Exit(Fmt("The genesis file has no validators"))
|
||||
cmn.Exit(cmn.Fmt("The genesis file has no validators"))
|
||||
}
|
||||
|
||||
if genDoc.GenesisTime.IsZero() {
|
||||
|
Reference in New Issue
Block a user