|
|
|
@ -96,6 +96,7 @@ type PeerEvent struct { |
|
|
|
|
// Peer represents a connected remote node.
|
|
|
|
|
type Peer struct { |
|
|
|
|
rw *conn |
|
|
|
|
isInbound bool // Cached from rw.flags to avoid a race condition
|
|
|
|
|
running map[string]*protoRW |
|
|
|
|
log log.Logger |
|
|
|
|
created mclock.AbsTime |
|
|
|
@ -160,13 +161,14 @@ func (p *Peer) String() string { |
|
|
|
|
|
|
|
|
|
// Inbound returns true if the peer is an inbound connection
|
|
|
|
|
func (p *Peer) Inbound() bool { |
|
|
|
|
return p.rw.flags&inboundConn != 0 |
|
|
|
|
return p.isInbound |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func newPeer(conn *conn, protocols []Protocol) *Peer { |
|
|
|
|
protomap := matchProtocols(protocols, conn.caps, conn) |
|
|
|
|
p := &Peer{ |
|
|
|
|
rw: conn, |
|
|
|
|
isInbound: conn.is(inboundConn), |
|
|
|
|
running: protomap, |
|
|
|
|
created: mclock.Now(), |
|
|
|
|
disc: make(chan DiscReason), |
|
|
|
|