From 9e1c7bdfb8062362bd5314d8227e312e388bb8b2 Mon Sep 17 00:00:00 2001 From: William Banfield Date: Fri, 21 Oct 2022 11:58:57 -0400 Subject: [PATCH] remove superflous functions in consensus --- consensus/msgs.go | 26 ++------------------------ consensus/reactor.go | 11 ----------- 2 files changed, 2 insertions(+), 35 deletions(-) diff --git a/consensus/msgs.go b/consensus/msgs.go index 6aaacba83..a038bb681 100644 --- a/consensus/msgs.go +++ b/consensus/msgs.go @@ -4,8 +4,6 @@ import ( "errors" "fmt" - "github.com/cosmos/gogoproto/proto" - cstypes "github.com/tendermint/tendermint/consensus/types" "github.com/tendermint/tendermint/libs/bits" tmmath "github.com/tendermint/tendermint/libs/math" @@ -16,6 +14,8 @@ import ( ) // MsgToProto takes a consensus message type and returns the proto defined consensus message. +// +// TODO: This needs to be removed, but WALToProto depends on this. func MsgToProto(msg Message) (*tmcons.Message, error) { if msg == nil { return nil, errors.New("consensus: message is nil") @@ -143,14 +143,6 @@ func MsgToProto(msg Message) (*tmcons.Message, error) { return &pb, nil } -func MustMsgToProto(msg Message) *tmcons.Message { - m, err := MsgToProto(msg) - if err != nil { - panic(err) - } - return m -} - // MsgFromProto takes a consensus proto message and returns the native go type func MsgFromProto(msg *tmcons.Message) (Message, error) { if msg == nil { @@ -268,20 +260,6 @@ func MsgFromProto(msg *tmcons.Message) (Message, error) { return pb, nil } -// MustEncode takes the reactors msg, makes it proto and marshals it -// this mimics `MustMarshalBinaryBare` in that is panics on error -func MustEncode(msg Message) []byte { - pb, err := MsgToProto(msg) - if err != nil { - panic(err) - } - enc, err := proto.Marshal(pb) - if err != nil { - panic(err) - } - return enc -} - // WALToProto takes a WAL message and return a proto walMessage and error func WALToProto(msg WALMessage) (*tmcons.WALMessage, error) { var pb tmcons.WALMessage diff --git a/consensus/reactor.go b/consensus/reactor.go index ffa84f9dd..073e49f44 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -7,8 +7,6 @@ import ( "sync" "time" - "github.com/cosmos/gogoproto/proto" - cstypes "github.com/tendermint/tendermint/consensus/types" "github.com/tendermint/tendermint/libs/bits" tmevents "github.com/tendermint/tendermint/libs/events" @@ -1511,15 +1509,6 @@ func init() { tmjson.RegisterType(&VoteSetBitsMessage{}, "tendermint/VoteSetBits") } -func decodeMsg(bz []byte) (msg Message, err error) { - pb := &tmcons.Message{} - if err = proto.Unmarshal(bz, pb); err != nil { - return msg, err - } - - return MsgFromProto(pb) -} - //------------------------------------- // NewRoundStepMessage is sent for every step taken in the ConsensusState.