panic wrapper functions

This commit is contained in:
Ethan Buchman
2015-07-21 10:46:05 -04:00
parent 5983088a32
commit 8e50bf15de
45 changed files with 229 additions and 275 deletions
+2 -5
View File
@@ -36,10 +36,7 @@ func (part *Part) Hash() []byte {
return part.hash
} else {
hasher := ripemd160.New()
_, err := hasher.Write(part.Bytes)
if err != nil {
panic(err)
}
hasher.Write(part.Bytes) // doesn't err
part.hash = hasher.Sum(nil)
return part.hash
}
@@ -226,7 +223,7 @@ func (ps *PartSet) IsComplete() bool {
func (ps *PartSet) GetReader() io.Reader {
if !ps.IsComplete() {
panic("Cannot GetReader() on incomplete PartSet")
PanicSanity("Cannot GetReader() on incomplete PartSet")
}
buf := []byte{}
for _, part := range ps.parts {
+2 -2
View File
@@ -305,7 +305,7 @@ type DupeoutTx struct {
}
func (tx *DupeoutTx) WriteSignBytes(chainID string, w io.Writer, n *int64, err *error) {
panic("DupeoutTx has no sign bytes")
PanicSanity("DupeoutTx has no sign bytes")
}
func (tx *DupeoutTx) String() string {
@@ -326,7 +326,7 @@ func TxID(chainID string, tx Tx) []byte {
func jsonEscape(str string) string {
escapedBytes, err := json.Marshal(str)
if err != nil {
panic(Fmt("Error json-escaping a string", str))
PanicSanity(Fmt("Error json-escaping a string", str))
}
return string(escapedBytes)
}
+1 -1
View File
@@ -64,7 +64,7 @@ func (vote *Vote) String() string {
case VoteTypePrecommit:
typeString = "Precommit"
default:
panic("Unknown vote type")
PanicSanity("Unknown vote type")
}
return fmt.Sprintf("Vote{%v/%02d/%v(%v) %X#%v %v}", vote.Height, vote.Round, vote.Type, typeString, Fingerprint(vote.BlockHash), vote.BlockParts, vote.Signature)