libs/common: remove deprecated PanicXXX functions (#3595)

* Remove deprecated PanicXXX functions from codebase

As per discussion over
[here](https://github.com/tendermint/tendermint/pull/3456#discussion_r278423492),
we need to remove these `PanicXXX` functions and eliminate our
dependence on them. In this PR, each and every `PanicXXX` function call
is replaced with a simple `panic` call.

* add a changelog entry
This commit is contained in:
Thane Thomson
2019-04-26 14:23:43 +04:00
committed by Anton Kaliaev
parent 90997ab1b5
commit 70592cc4d8
21 changed files with 57 additions and 97 deletions
-32
View File
@@ -212,35 +212,3 @@ func (fe FmtError) String() string {
func (fe FmtError) Format() string {
return fe.format
}
//----------------------------------------
// Panic wrappers
// XXX DEPRECATED
// A panic resulting from a sanity check means there is a programmer error
// and some guarantee is not satisfied.
// XXX DEPRECATED
func PanicSanity(v interface{}) {
panic(fmt.Sprintf("Panicked on a Sanity Check: %v", v))
}
// A panic here means something has gone horribly wrong, in the form of data corruption or
// failure of the operating system. In a correct/healthy system, these should never fire.
// If they do, it's indicative of a much more serious problem.
// XXX DEPRECATED
func PanicCrisis(v interface{}) {
panic(fmt.Sprintf("Panicked on a Crisis: %v", v))
}
// Indicates a failure of consensus. Someone was malicious or something has
// gone horribly wrong. These should really boot us into an "emergency-recover" mode
// XXX DEPRECATED
func PanicConsensus(v interface{}) {
panic(fmt.Sprintf("Panicked on a Consensus Failure: %v", v))
}
// For those times when we're not sure if we should panic
// XXX DEPRECATED
func PanicQ(v interface{}) {
panic(fmt.Sprintf("Panicked questionably: %v", v))
}
+1 -1
View File
@@ -300,7 +300,7 @@ func cRandBytes(numBytes int) []byte {
b := make([]byte, numBytes)
_, err := crand.Read(b)
if err != nil {
PanicCrisis(err)
panic(err)
}
return b
}
+1 -2
View File
@@ -194,8 +194,7 @@ func (bs *BaseService) Reset() error {
// OnReset implements Service by panicking.
func (bs *BaseService) OnReset() error {
PanicSanity("The service cannot be reset")
return nil
panic("The service cannot be reset")
}
// IsRunning implements Service by returning true or false depending on the
+4 -6
View File
@@ -9,8 +9,6 @@ import (
"github.com/syndtr/goleveldb/leveldb/errors"
"github.com/syndtr/goleveldb/leveldb/iterator"
"github.com/syndtr/goleveldb/leveldb/opt"
cmn "github.com/tendermint/tendermint/libs/common"
)
func init() {
@@ -67,7 +65,7 @@ func (db *GoLevelDB) Set(key []byte, value []byte) {
value = nonNilBytes(value)
err := db.db.Put(key, value, nil)
if err != nil {
cmn.PanicCrisis(err)
panic(err)
}
}
@@ -77,7 +75,7 @@ func (db *GoLevelDB) SetSync(key []byte, value []byte) {
value = nonNilBytes(value)
err := db.db.Put(key, value, &opt.WriteOptions{Sync: true})
if err != nil {
cmn.PanicCrisis(err)
panic(err)
}
}
@@ -86,7 +84,7 @@ func (db *GoLevelDB) Delete(key []byte) {
key = nonNilBytes(key)
err := db.db.Delete(key, nil)
if err != nil {
cmn.PanicCrisis(err)
panic(err)
}
}
@@ -95,7 +93,7 @@ func (db *GoLevelDB) DeleteSync(key []byte) {
key = nonNilBytes(key)
err := db.db.Delete(key, &opt.WriteOptions{Sync: true})
if err != nil {
cmn.PanicCrisis(err)
panic(err)
}
}