From f8c843e2e3f73b24ad8e63b327bca5225f3e69fc Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Tue, 4 Feb 2014 22:30:34 -0600 Subject: [PATCH] Rename bytesRead/Written to bytesReceived/Sent. This makes it a little more clear the variables reprsent bytes sent across the network as opposed to from disk. --- peer.go | 12 ++++++------ server.go | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/peer.go b/peer.go index b4c105da..cef56ebb 100644 --- a/peer.go +++ b/peer.go @@ -137,8 +137,8 @@ type peer struct { timeConnected time.Time lastSend time.Time lastRecv time.Time - bytesRead uint64 - bytesWritten uint64 + bytesReceived uint64 + bytesSent uint64 inbound bool connected int32 disconnect int32 // only to be used atomically @@ -956,10 +956,10 @@ func (p *peer) handlePongMsg(msg *btcwire.MsgPong) { func (p *peer) readMessage() (btcwire.Message, []byte, error) { n, msg, buf, err := btcwire.ReadMessageN(p.conn, p.protocolVersion, p.btcnet) if err != nil { - p.bytesRead += uint64(n) + p.bytesReceived += uint64(n) return nil, nil, err } - p.bytesRead += uint64(n) + p.bytesReceived += uint64(n) // Use closures to log expensive operations so they are only run when // the logging level requires it. @@ -1025,12 +1025,12 @@ func (p *peer) writeMessage(msg btcwire.Message) { // Write the message to the peer. n, err := btcwire.WriteMessageN(p.conn, msg, p.protocolVersion, p.btcnet) if err != nil { - p.bytesWritten += uint64(n) + p.bytesSent += uint64(n) p.Disconnect() p.logError("Can't send message: %v", err) return } - p.bytesWritten += uint64(n) + p.bytesSent += uint64(n) } // isAllowedByRegression returns whether or not the passed error is allowed by diff --git a/server.go b/server.go index fef6c9e7..c02d8a2c 100644 --- a/server.go +++ b/server.go @@ -330,8 +330,8 @@ func (s *server) handleQuery(querymsg interface{}, state *peerState) { Services: fmt.Sprintf("%08d", p.services), LastSend: p.lastSend.Unix(), LastRecv: p.lastRecv.Unix(), - BytesSent: p.bytesWritten, - BytesRecv: p.bytesRead, + BytesSent: p.bytesSent, + BytesRecv: p.bytesReceived, ConnTime: p.timeConnected.Unix(), Version: p.protocolVersion, SubVer: p.userAgent,