mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 16:08:26 -05:00
Minor Improvements (#6353)
* minor improvements * Update beacon-chain/sync/deadlines.go * go fmt
This commit is contained in:
@@ -102,10 +102,12 @@ func (ds *Server) getPeer(pid peer.ID) (*pbrpc.DebugPeerResponse, error) {
|
||||
}
|
||||
addresses := peerStore.Addrs(pid)
|
||||
stringAddrs := []string{}
|
||||
stringAddrs = append(stringAddrs, addr.String())
|
||||
if addr != nil {
|
||||
stringAddrs = append(stringAddrs, addr.String())
|
||||
}
|
||||
for _, a := range addresses {
|
||||
// Do not double count address
|
||||
if addr.String() == a.String() {
|
||||
if addr != nil && addr.String() == a.String() {
|
||||
continue
|
||||
}
|
||||
stringAddrs = append(stringAddrs, a.String())
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var defaultReadDuration = ttfbTimeout
|
||||
@@ -19,7 +20,11 @@ func setStreamReadDeadline(stream network.Stream, duration time.Duration) {
|
||||
// libp2p uses the system clock time for determining the deadline so we use
|
||||
// time.Now() instead of the synchronized roughtime.Now().
|
||||
if err := stream.SetReadDeadline(time.Now().Add(duration)); err != nil {
|
||||
log.WithError(err).Debug("Failed to set stream deadline")
|
||||
log.WithError(err).WithFields(logrus.Fields{
|
||||
"peer": stream.Conn().RemotePeer(),
|
||||
"protocol": stream.Protocol(),
|
||||
"direction": stream.Stat().Direction,
|
||||
}).Debug("Failed to set stream deadline")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +32,10 @@ func setStreamWriteDeadline(stream network.Stream, duration time.Duration) {
|
||||
// libp2p uses the system clock time for determining the deadline so we use
|
||||
// time.Now() instead of the synchronized roughtime.Now().
|
||||
if err := stream.SetWriteDeadline(time.Now().Add(duration)); err != nil {
|
||||
log.WithError(err).Debug("Failed to set stream deadline")
|
||||
log.WithError(err).WithFields(logrus.Fields{
|
||||
"peer": stream.Conn().RemotePeer(),
|
||||
"protocol": stream.Protocol(),
|
||||
"direction": stream.Stat().Direction,
|
||||
}).Debug("Failed to set stream deadline")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user