Minor Improvements (#6353)

* minor improvements
* Update beacon-chain/sync/deadlines.go
* go fmt
This commit is contained in:
Nishant Das
2020-06-23 17:00:09 +08:00
committed by GitHub
parent 5c90038007
commit 36c82b26e4
2 changed files with 15 additions and 4 deletions

View File

@@ -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())

View File

@@ -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")
}
}