Roy Crihfield
ebc2eb37e7
* refactor packages, flags, subscriptions * DRY refactor builder tests * use mockgen to generate mocks * update README * MODE=statediff no longer needed for unit tests * simplify func names, clean up metrics * move write params to service field * sql indexer: confirm quit after ipld cache reset prevents negative waitgroup panic * don't let TotalDifficulty become nil * use forked plugeth, plugeth-utils for now
24 lines
450 B
Go
24 lines
450 B
Go
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/ethereum/go-ethereum/rlp"
|
|
)
|
|
|
|
// Fatalf formats a message to standard error and exits the program.
|
|
func Fatalf(format string, args ...interface{}) {
|
|
fmt.Fprintf(os.Stderr, "Fatal: "+format+"\n", args...)
|
|
os.Exit(1)
|
|
}
|
|
|
|
func MustDecode[T any](buf []byte) *T {
|
|
var ret T
|
|
err := rlp.DecodeBytes(buf, &ret)
|
|
if err != nil {
|
|
panic(fmt.Errorf("error decoding RLP %T: %w", ret, err))
|
|
}
|
|
return &ret
|
|
}
|