2023-06-23 12:42:55 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2023-06-16 09:53:15 +00:00
|
|
|
"github.com/ethereum/go-ethereum/rlp"
|
2023-06-23 12:42:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|