mirror of
https://github.com/QuilibriumNetwork/ceremonyclient.git
synced 2026-03-09 10:17:42 +08:00
fix: shut the fuck up, peer log
This commit is contained in:
parent
f6bade89bf
commit
e0393aa34d
@ -20,6 +20,8 @@ type PeerConnector interface {
|
||||
Connect(context.Context) error
|
||||
}
|
||||
|
||||
// TODO(2.1.1+): metrics only, no debug logging unless configurable logging, too
|
||||
// noisy
|
||||
type peerConnector struct {
|
||||
ctx context.Context
|
||||
logger *zap.Logger
|
||||
@ -94,7 +96,6 @@ func (pc *peerConnector) connectToPeer(
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-time.After(identify.DefaultTimeout / 2):
|
||||
logger.Debug("identifying peer timed out")
|
||||
atomic.AddUint32(failure, 1)
|
||||
_ = conn.Close()
|
||||
case <-pc.idService.IdentifyWait(conn):
|
||||
@ -114,7 +115,6 @@ func (pc *peerConnector) connectToPeers(
|
||||
logger := pc.logger.With(zap.String("peer_id", p.ID.String()))
|
||||
|
||||
if atomic.LoadUint32(success) >= uint32(pc.minPeers) {
|
||||
logger.Debug("reached max findings")
|
||||
return
|
||||
}
|
||||
|
||||
@ -140,16 +140,7 @@ func (pc *peerConnector) connectToPeers(
|
||||
func (pc *peerConnector) connect() {
|
||||
logger := pc.logger
|
||||
|
||||
logger.Debug("initiating peer connections")
|
||||
var success, failure, duplicate uint32
|
||||
defer func() {
|
||||
logger.Debug(
|
||||
"completed peer connections",
|
||||
zap.Uint32("success", success),
|
||||
zap.Uint32("failure", failure),
|
||||
zap.Uint32("duplicate", duplicate),
|
||||
)
|
||||
}()
|
||||
ctx, cancel := context.WithCancel(pc.ctx)
|
||||
defer cancel()
|
||||
|
||||
|
||||
@ -20,7 +20,10 @@ type staticPeerSource struct {
|
||||
}
|
||||
|
||||
// Peers implements PeerSource.
|
||||
func (s *staticPeerSource) Peers(context.Context) (<-chan peer.AddrInfo, error) {
|
||||
func (s *staticPeerSource) Peers(context.Context) (
|
||||
<-chan peer.AddrInfo,
|
||||
error,
|
||||
) {
|
||||
peers := s.peers
|
||||
if s.permute {
|
||||
peers = Permuted(s.peers)
|
||||
@ -45,12 +48,19 @@ type routingDiscoveryPeerSource struct {
|
||||
}
|
||||
|
||||
// Peers implements PeerSource.
|
||||
func (d *routingDiscoveryPeerSource) Peers(ctx context.Context) (<-chan peer.AddrInfo, error) {
|
||||
func (d *routingDiscoveryPeerSource) Peers(ctx context.Context) (
|
||||
<-chan peer.AddrInfo,
|
||||
error,
|
||||
) {
|
||||
return d.discovery.FindPeers(ctx, d.namespace, discovery.Limit(d.limit))
|
||||
}
|
||||
|
||||
// NewRoutingDiscoveryPeerSource creates a new discovery peer source.
|
||||
func NewRoutingDiscoveryPeerSource(discovery *routing.RoutingDiscovery, namespace string, limit int) PeerSource {
|
||||
func NewRoutingDiscoveryPeerSource(
|
||||
discovery *routing.RoutingDiscovery,
|
||||
namespace string,
|
||||
limit int,
|
||||
) PeerSource {
|
||||
return &routingDiscoveryPeerSource{
|
||||
discovery: discovery,
|
||||
namespace: namespace,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user