From 833e4a15d4ba41cc0041d7a8237d74395e4ba831 Mon Sep 17 00:00:00 2001 From: William Banfield Date: Wed, 19 Oct 2022 11:14:18 -0400 Subject: [PATCH] experiment continued --- consensus/reactor.go | 17 ++++++++++------- p2p/peer.go | 10 +++++++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/consensus/reactor.go b/consensus/reactor.go index b0d3e3675..a768b96bf 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -292,13 +292,16 @@ func (conR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) { default: panic("Bad VoteSetBitsMessage field Type. Forgot to add a check in ValidateBasic?") } - src.TrySend(VoteSetBitsChannel, MustEncode(&VoteSetBitsMessage{ - Height: msg.Height, - Round: msg.Round, - Type: msg.Type, - BlockID: msg.BlockID, - Votes: ourVotes, - })) + src.NewTrySend(p2p.Envelope{ + ChannelID: VoteSetBitsChannel, + Message: MsgToProto(&VoteSetBitsMessage{ + Height: msg.Height, + Round: msg.Round, + Type: msg.Type, + BlockID: msg.BlockID, + Votes: ourVotes, + }), + }) default: conR.Logger.Error(fmt.Sprintf("Unknown message type %v", reflect.TypeOf(msg))) } diff --git a/p2p/peer.go b/p2p/peer.go index c90b5f7a9..1cda272d2 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -8,6 +8,7 @@ import ( "github.com/tendermint/tendermint/libs/cmap" "github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/service" + "google.golang.org/protobuf/proto" tmconn "github.com/tendermint/tendermint/p2p/conn" ) @@ -262,12 +263,15 @@ func (p *peer) NewSend(e Envelope) bool { } else if !p.hasChannel(e.ChannelID) { return false } - msgBytes := MustEncode(e.Message) - res := p.mconn.Send(e.chID, msgBytes) + msgBytes, err := proto.Marshal(e.Message) + if err != nil { + panic(err) + } + res := p.mconn.Send(e.ChannelID, msgBytes) if res { labels := []string{ "peer_id", string(p.ID()), - "chID", fmt.Sprintf("%#x", chID), + "chID", fmt.Sprintf("%#x", e.ChannelID), } p.metrics.PeerSendBytesTotal.With(labels...).Add(float64(len(msgBytes))) }