|
|
|
@ -91,12 +91,14 @@ const ( |
|
|
|
|
// PeerEvent is an event emitted when peers are either added or dropped from
|
|
|
|
|
// a p2p.Server or when a message is sent or received on a peer connection
|
|
|
|
|
type PeerEvent struct { |
|
|
|
|
Type PeerEventType `json:"type"` |
|
|
|
|
Peer enode.ID `json:"peer"` |
|
|
|
|
Error string `json:"error,omitempty"` |
|
|
|
|
Protocol string `json:"protocol,omitempty"` |
|
|
|
|
MsgCode *uint64 `json:"msg_code,omitempty"` |
|
|
|
|
MsgSize *uint32 `json:"msg_size,omitempty"` |
|
|
|
|
Type PeerEventType `json:"type"` |
|
|
|
|
Peer enode.ID `json:"peer"` |
|
|
|
|
Error string `json:"error,omitempty"` |
|
|
|
|
Protocol string `json:"protocol,omitempty"` |
|
|
|
|
MsgCode *uint64 `json:"msg_code,omitempty"` |
|
|
|
|
MsgSize *uint32 `json:"msg_size,omitempty"` |
|
|
|
|
LocalAddress string `json:"local,omitempty"` |
|
|
|
|
RemoteAddress string `json:"remote,omitempty"` |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Peer represents a connected remote node.
|
|
|
|
@ -354,7 +356,7 @@ func (p *Peer) startProtocols(writeStart <-chan struct{}, writeErr chan<- error) |
|
|
|
|
proto.werr = writeErr |
|
|
|
|
var rw MsgReadWriter = proto |
|
|
|
|
if p.events != nil { |
|
|
|
|
rw = newMsgEventer(rw, p.events, p.ID(), proto.Name) |
|
|
|
|
rw = newMsgEventer(rw, p.events, p.ID(), proto.Name, p.Info().Network.RemoteAddress, p.Info().Network.LocalAddress) |
|
|
|
|
} |
|
|
|
|
p.log.Trace(fmt.Sprintf("Starting protocol %s/%d", proto.Name, proto.Version)) |
|
|
|
|
go func() { |
|
|
|
|