mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
p2p: golint fixes
This commit is contained in:
parent
370cb95b7f
commit
77c0dc13f1
5 changed files with 33 additions and 8 deletions
|
|
@ -70,10 +70,12 @@ func (msg Msg) Discard() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MsgReader provides reading of encoded message
|
||||||
type MsgReader interface {
|
type MsgReader interface {
|
||||||
ReadMsg() (Msg, error)
|
ReadMsg() (Msg, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MsgWriter provides reading of encoded message
|
||||||
type MsgWriter interface {
|
type MsgWriter interface {
|
||||||
// WriteMsg sends a message. It will block until the message's
|
// WriteMsg sends a message. It will block until the message's
|
||||||
// Payload has been consumed by the other end.
|
// Payload has been consumed by the other end.
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,17 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
MetricsInboundTraffic = "p2p/ingress" // Name for the registered inbound traffic meter
|
// MetricsInboundTraffic is the name for the registered inbound traffic meter
|
||||||
MetricsOutboundTraffic = "p2p/egress" // Name for the registered outbound traffic meter
|
MetricsInboundTraffic = "p2p/ingress"
|
||||||
MetricsOutboundConnects = "p2p/dials" // Name for the registered outbound connects meter
|
// MetricsOutboundTraffic is the name for the registered outbound traffic meter
|
||||||
MetricsInboundConnects = "p2p/serves" // Name for the registered inbound connects meter
|
MetricsOutboundTraffic = "p2p/egress"
|
||||||
|
// MetricsOutboundConnects is the name for the registered outbound connects meter
|
||||||
|
MetricsOutboundConnects = "p2p/dials"
|
||||||
|
// MetricsInboundConnects is the name for the registered inbound connects meter
|
||||||
|
MetricsInboundConnects = "p2p/serves"
|
||||||
|
|
||||||
MeteredPeerLimit = 1024 // This amount of peers are individually metered
|
// MeteredPeerLimit is the amount of peers are individually metered
|
||||||
|
MeteredPeerLimit = 1024
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -45,8 +50,10 @@ var (
|
||||||
egressTrafficMeter = metrics.NewRegisteredMeter(MetricsOutboundTraffic, nil) // Meter metering the cumulative egress traffic
|
egressTrafficMeter = metrics.NewRegisteredMeter(MetricsOutboundTraffic, nil) // Meter metering the cumulative egress traffic
|
||||||
activePeerGauge = metrics.NewRegisteredGauge("p2p/peers", nil) // Gauge tracking the current peer count
|
activePeerGauge = metrics.NewRegisteredGauge("p2p/peers", nil) // Gauge tracking the current peer count
|
||||||
|
|
||||||
PeerIngressRegistry = metrics.NewPrefixedChildRegistry(metrics.EphemeralRegistry, MetricsInboundTraffic+"/") // Registry containing the peer ingress
|
// PeerIngressRegistry is a registry containing the peer ingress
|
||||||
PeerEgressRegistry = metrics.NewPrefixedChildRegistry(metrics.EphemeralRegistry, MetricsOutboundTraffic+"/") // Registry containing the peer egress
|
PeerIngressRegistry = metrics.NewPrefixedChildRegistry(metrics.EphemeralRegistry, MetricsInboundTraffic+"/")
|
||||||
|
// PeerEgressRegistry is a registry containing the peer egress
|
||||||
|
PeerEgressRegistry = metrics.NewPrefixedChildRegistry(metrics.EphemeralRegistry, MetricsOutboundTraffic+"/")
|
||||||
|
|
||||||
meteredPeerFeed event.Feed // Event feed for peer metrics
|
meteredPeerFeed event.Feed // Event feed for peer metrics
|
||||||
meteredPeerCount int32 // Actually stored peer connection count
|
meteredPeerCount int32 // Actually stored peer connection count
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// ErrShuttingDown is the shutting down error
|
||||||
ErrShuttingDown = errors.New("shutting down")
|
ErrShuttingDown = errors.New("shutting down")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -193,6 +194,7 @@ func newPeer(log log.Logger, conn *conn, protocols []Protocol) *Peer {
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log will return the logger
|
||||||
func (p *Peer) Log() log.Logger {
|
func (p *Peer) Log() log.Logger {
|
||||||
return p.log
|
return p.log
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,21 +54,35 @@ func (pe *peerError) Error() string {
|
||||||
|
|
||||||
var errProtocolReturned = errors.New("protocol returned")
|
var errProtocolReturned = errors.New("protocol returned")
|
||||||
|
|
||||||
|
// DiscReason is the code for a disconnect reason
|
||||||
type DiscReason uint
|
type DiscReason uint
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// DiscRequested is disconnect requested
|
||||||
DiscRequested DiscReason = iota
|
DiscRequested DiscReason = iota
|
||||||
|
// DiscNetworkError is a network error
|
||||||
DiscNetworkError
|
DiscNetworkError
|
||||||
|
// DiscProtocolError is a breach of protocol
|
||||||
DiscProtocolError
|
DiscProtocolError
|
||||||
|
// DiscUselessPeer is a useless peer
|
||||||
DiscUselessPeer
|
DiscUselessPeer
|
||||||
|
// DiscTooManyPeers is too many peers
|
||||||
DiscTooManyPeers
|
DiscTooManyPeers
|
||||||
|
// DiscAlreadyConnected is already connected
|
||||||
DiscAlreadyConnected
|
DiscAlreadyConnected
|
||||||
|
// DiscIncompatibleVersion is an incompatible p2p protocol version
|
||||||
DiscIncompatibleVersion
|
DiscIncompatibleVersion
|
||||||
|
// DiscInvalidIdentity is invalid node entity
|
||||||
DiscInvalidIdentity
|
DiscInvalidIdentity
|
||||||
|
// DiscQuitting is client quitting
|
||||||
DiscQuitting
|
DiscQuitting
|
||||||
|
// DiscUnexpectedIdentity is an unexpected identity
|
||||||
DiscUnexpectedIdentity
|
DiscUnexpectedIdentity
|
||||||
|
// DiscSelf is connected to self
|
||||||
DiscSelf
|
DiscSelf
|
||||||
|
// DiscReadTimeout is read timeout
|
||||||
DiscReadTimeout
|
DiscReadTimeout
|
||||||
|
// DiscSubprotocolError is subprotocol error
|
||||||
DiscSubprotocolError = 0x10
|
DiscSubprotocolError = 0x10
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -363,7 +363,7 @@ func (srv *Server) RemoveTrustedPeer(node *enode.Node) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SubscribePeers subscribes the given channel to peer events
|
// SubscribeEvents subscribes to peer events and returns the event subscription
|
||||||
func (srv *Server) SubscribeEvents(ch chan *PeerEvent) event.Subscription {
|
func (srv *Server) SubscribeEvents(ch chan *PeerEvent) event.Subscription {
|
||||||
return srv.peerFeed.Subscribe(ch)
|
return srv.peerFeed.Subscribe(ch)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue