From 3863885c719f448694e26112ab1d309c1144f990 Mon Sep 17 00:00:00 2001 From: Petabyte Storage Date: Sun, 12 Nov 2017 22:11:15 -0800 Subject: [PATCH] WIP: begin parallel refactoring with go-wire Write methods and MConnection --- p2p/connection.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/p2p/connection.go b/p2p/connection.go index 30935c71e..11578eb8e 100644 --- a/p2p/connection.go +++ b/p2p/connection.go @@ -11,10 +11,13 @@ import ( "time" wire "github.com/tendermint/go-wire" + tmencoding "github.com/tendermint/go-wire/nowriter/tmencoding" cmn "github.com/tendermint/tmlibs/common" flow "github.com/tendermint/tmlibs/flowrate" ) +var legacy = tmencoding.Legacy + const ( numBatchMsgPackets = 10 minReadBufferSize = 1024 @@ -308,12 +311,12 @@ FOR_LOOP: } case <-c.pingTimer.Ch: c.Logger.Debug("Send Ping") - wire.WriteByte(packetTypePing, c.bufWriter, &n, &err) + legacy.WriteOctet(packetTypePing, c.bufWriter, &n, &err) c.sendMonitor.Update(int(n)) c.flush() case <-c.pong: c.Logger.Debug("Send Pong") - wire.WriteByte(packetTypePong, c.bufWriter, &n, &err) + legacy.WriteOctet(packetTypePong, c.bufWriter, &n, &err) c.sendMonitor.Update(int(n)) c.flush() case <-c.quit: @@ -661,7 +664,7 @@ func (ch *Channel) writeMsgPacketTo(w io.Writer) (n int, err error) { } func writeMsgPacketTo(packet msgPacket, w io.Writer, n *int, err *error) { - wire.WriteByte(packetTypeMsg, w, n, err) + legacy.WriteOctet(packetTypeMsg, w, n, err) wire.WriteBinary(packet, w, n, err) }