|
|
@ -38,6 +38,7 @@ import ( |
|
|
|
"github.com/ethereum/go-ethereum/common/bitutil" |
|
|
|
"github.com/ethereum/go-ethereum/common/bitutil" |
|
|
|
"github.com/ethereum/go-ethereum/crypto" |
|
|
|
"github.com/ethereum/go-ethereum/crypto" |
|
|
|
"github.com/ethereum/go-ethereum/crypto/ecies" |
|
|
|
"github.com/ethereum/go-ethereum/crypto/ecies" |
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/metrics" |
|
|
|
"github.com/ethereum/go-ethereum/rlp" |
|
|
|
"github.com/ethereum/go-ethereum/rlp" |
|
|
|
"github.com/golang/snappy" |
|
|
|
"github.com/golang/snappy" |
|
|
|
"golang.org/x/crypto/sha3" |
|
|
|
"golang.org/x/crypto/sha3" |
|
|
@ -602,6 +603,10 @@ func (rw *rlpxFrameRW) WriteMsg(msg Msg) error { |
|
|
|
msg.Payload = bytes.NewReader(payload) |
|
|
|
msg.Payload = bytes.NewReader(payload) |
|
|
|
msg.Size = uint32(len(payload)) |
|
|
|
msg.Size = uint32(len(payload)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
msg.meterSize = msg.Size |
|
|
|
|
|
|
|
if metrics.Enabled && msg.meterCap.Name != "" { // don't meter non-subprotocol messages
|
|
|
|
|
|
|
|
metrics.GetOrRegisterMeter(fmt.Sprintf("%s/%s/%d/%#02x", MetricsOutboundTraffic, msg.meterCap.Name, msg.meterCap.Version, msg.meterCode), nil).Mark(int64(msg.meterSize)) |
|
|
|
|
|
|
|
} |
|
|
|
// write header
|
|
|
|
// write header
|
|
|
|
headbuf := make([]byte, 32) |
|
|
|
headbuf := make([]byte, 32) |
|
|
|
fsize := uint32(len(ptype)) + msg.Size |
|
|
|
fsize := uint32(len(ptype)) + msg.Size |
|
|
@ -686,6 +691,7 @@ func (rw *rlpxFrameRW) ReadMsg() (msg Msg, err error) { |
|
|
|
return msg, err |
|
|
|
return msg, err |
|
|
|
} |
|
|
|
} |
|
|
|
msg.Size = uint32(content.Len()) |
|
|
|
msg.Size = uint32(content.Len()) |
|
|
|
|
|
|
|
msg.meterSize = msg.Size |
|
|
|
msg.Payload = content |
|
|
|
msg.Payload = content |
|
|
|
|
|
|
|
|
|
|
|
// if snappy is enabled, verify and decompress message
|
|
|
|
// if snappy is enabled, verify and decompress message
|
|
|
|