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
|
||||
}
|
||||
|
||||
// MsgReader provides reading of encoded message
|
||||
type MsgReader interface {
|
||||
ReadMsg() (Msg, error)
|
||||
}
|
||||
|
||||
// MsgWriter provides reading of encoded message
|
||||
type MsgWriter interface {
|
||||
// WriteMsg sends a message. It will block until the message's
|
||||
// Payload has been consumed by the other end.
|
||||
|
|
|
|||
|
|
@ -30,12 +30,17 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
MetricsInboundTraffic = "p2p/ingress" // Name for the registered inbound traffic meter
|
||||
MetricsOutboundTraffic = "p2p/egress" // Name for the registered outbound traffic meter
|
||||
MetricsOutboundConnects = "p2p/dials" // Name for the registered outbound connects meter
|
||||
MetricsInboundConnects = "p2p/serves" // Name for the registered inbound connects meter
|
||||
// MetricsInboundTraffic is the name for the registered inbound traffic meter
|
||||
MetricsInboundTraffic = "p2p/ingress"
|
||||
// MetricsOutboundTraffic is the name for the registered outbound traffic 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 (
|
||||
|
|
@ -45,8 +50,10 @@ var (
|
|||
egressTrafficMeter = metrics.NewRegisteredMeter(MetricsOutboundTraffic, nil) // Meter metering the cumulative egress traffic
|
||||
activePeerGauge = metrics.NewRegisteredGauge("p2p/peers", nil) // Gauge tracking the current peer count
|
||||
|
||||
PeerIngressRegistry = metrics.NewPrefixedChildRegistry(metrics.EphemeralRegistry, MetricsInboundTraffic+"/") // Registry containing the peer ingress
|
||||
PeerEgressRegistry = metrics.NewPrefixedChildRegistry(metrics.EphemeralRegistry, MetricsOutboundTraffic+"/") // Registry containing the peer egress
|
||||
// PeerIngressRegistry is a registry containing the peer ingress
|
||||
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
|
||||
meteredPeerCount int32 // Actually stored peer connection count
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
// ErrShuttingDown is the shutting down error
|
||||
ErrShuttingDown = errors.New("shutting down")
|
||||
)
|
||||
|
||||
|
|
@ -193,6 +194,7 @@ func newPeer(log log.Logger, conn *conn, protocols []Protocol) *Peer {
|
|||
return p
|
||||
}
|
||||
|
||||
// Log will return the logger
|
||||
func (p *Peer) Log() log.Logger {
|
||||
return p.log
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,21 +54,35 @@ func (pe *peerError) Error() string {
|
|||
|
||||
var errProtocolReturned = errors.New("protocol returned")
|
||||
|
||||
// DiscReason is the code for a disconnect reason
|
||||
type DiscReason uint
|
||||
|
||||
const (
|
||||
// DiscRequested is disconnect requested
|
||||
DiscRequested DiscReason = iota
|
||||
// DiscNetworkError is a network error
|
||||
DiscNetworkError
|
||||
// DiscProtocolError is a breach of protocol
|
||||
DiscProtocolError
|
||||
// DiscUselessPeer is a useless peer
|
||||
DiscUselessPeer
|
||||
// DiscTooManyPeers is too many peers
|
||||
DiscTooManyPeers
|
||||
// DiscAlreadyConnected is already connected
|
||||
DiscAlreadyConnected
|
||||
// DiscIncompatibleVersion is an incompatible p2p protocol version
|
||||
DiscIncompatibleVersion
|
||||
// DiscInvalidIdentity is invalid node entity
|
||||
DiscInvalidIdentity
|
||||
// DiscQuitting is client quitting
|
||||
DiscQuitting
|
||||
// DiscUnexpectedIdentity is an unexpected identity
|
||||
DiscUnexpectedIdentity
|
||||
// DiscSelf is connected to self
|
||||
DiscSelf
|
||||
// DiscReadTimeout is read timeout
|
||||
DiscReadTimeout
|
||||
// DiscSubprotocolError is subprotocol error
|
||||
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 {
|
||||
return srv.peerFeed.Subscribe(ch)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue