experiment continued

This commit is contained in:
William Banfield
2022-10-19 11:14:18 -04:00
parent 8989fb4a79
commit 833e4a15d4
2 changed files with 17 additions and 10 deletions
+10 -7
View File
@@ -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)))
}
+7 -3
View File
@@ -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)))
}