Merge pull request #1076 from coryschwartz/feat/fix-staticcheck
static check fixes
This commit is contained in:
commit
6391bff1bf
|
@ -29,7 +29,7 @@ import (
|
|||
swarm "github.com/libp2p/go-libp2p-swarm"
|
||||
tptu "github.com/libp2p/go-libp2p-transport-upgrader"
|
||||
|
||||
logging "github.com/ipfs/go-log"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
madns "github.com/multiformats/go-multiaddr-dns"
|
||||
)
|
||||
|
|
3
go.mod
3
go.mod
|
@ -10,7 +10,7 @@ require (
|
|||
github.com/ipfs/go-datastore v0.4.5
|
||||
github.com/ipfs/go-detect-race v0.0.1
|
||||
github.com/ipfs/go-ipfs-util v0.0.2
|
||||
github.com/ipfs/go-log v1.0.5
|
||||
github.com/ipfs/go-log/v2 v2.1.3
|
||||
github.com/jbenet/go-cienv v0.1.0
|
||||
github.com/jbenet/goprocess v0.1.4
|
||||
github.com/libp2p/go-addr-util v0.0.2
|
||||
|
@ -21,7 +21,6 @@ require (
|
|||
github.com/libp2p/go-libp2p-circuit v0.4.0
|
||||
github.com/libp2p/go-libp2p-core v0.8.5
|
||||
github.com/libp2p/go-libp2p-discovery v0.5.0
|
||||
github.com/libp2p/go-libp2p-loggables v0.1.0
|
||||
github.com/libp2p/go-libp2p-mplex v0.4.1
|
||||
github.com/libp2p/go-libp2p-nat v0.0.6
|
||||
github.com/libp2p/go-libp2p-netutil v0.1.0
|
||||
|
|
4
go.sum
4
go.sum
|
@ -182,9 +182,8 @@ github.com/ipfs/go-ipfs-util v0.0.2/go.mod h1:CbPtkWJzjLdEcezDns2XYaehFVNXG9zrdr
|
|||
github.com/ipfs/go-log v0.0.1/go.mod h1:kL1d2/hzSpI0thNYjiKfjanbVNU+IIGA/WnNESY9leM=
|
||||
github.com/ipfs/go-log v1.0.2/go.mod h1:1MNjMxe0u6xvJZgeqbJ8vdo2TKaGwZ1a0Bpza+sr2Sk=
|
||||
github.com/ipfs/go-log v1.0.3/go.mod h1:OsLySYkwIbiSUR/yBTdv1qPtcE4FW3WPWk/ewz9Ru+A=
|
||||
github.com/ipfs/go-log v1.0.4 h1:6nLQdX4W8P9yZZFH7mO+X/PzjN8Laozm/lMJ6esdgzY=
|
||||
github.com/ipfs/go-log v1.0.4/go.mod h1:oDCg2FkjogeFOhqqb+N39l2RpTNPL6F/StPkB3kPgcs=
|
||||
github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8=
|
||||
github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo=
|
||||
github.com/ipfs/go-log/v2 v2.0.2/go.mod h1:O7P1lJt27vWHhOwQmcFEvlmo49ry2VY2+JfBWFaa9+0=
|
||||
github.com/ipfs/go-log/v2 v2.0.3/go.mod h1:O7P1lJt27vWHhOwQmcFEvlmo49ry2VY2+JfBWFaa9+0=
|
||||
github.com/ipfs/go-log/v2 v2.0.5/go.mod h1:eZs4Xt4ZUJQFM3DlanGhy7TkwwawCZcSByscwkWG+dw=
|
||||
|
@ -287,7 +286,6 @@ github.com/libp2p/go-libp2p-discovery v0.2.0/go.mod h1:s4VGaxYMbw4+4+tsoQTqh7wfx
|
|||
github.com/libp2p/go-libp2p-discovery v0.3.0/go.mod h1:o03drFnz9BVAZdzC/QUQ+NeQOu38Fu7LJGEOK2gQltw=
|
||||
github.com/libp2p/go-libp2p-discovery v0.5.0 h1:Qfl+e5+lfDgwdrXdu4YNCWyEo3fWuP+WgN9mN0iWviQ=
|
||||
github.com/libp2p/go-libp2p-discovery v0.5.0/go.mod h1:+srtPIU9gDaBNu//UHvcdliKBIcr4SfDcm0/PfPJLug=
|
||||
github.com/libp2p/go-libp2p-loggables v0.1.0 h1:h3w8QFfCt2UJl/0/NW4K829HX/0S4KD31PQ7m8UXXO8=
|
||||
github.com/libp2p/go-libp2p-loggables v0.1.0/go.mod h1:EyumB2Y6PrYjr55Q3/tiJ/o3xoDasoRYM7nOzEpoa90=
|
||||
github.com/libp2p/go-libp2p-mplex v0.2.0/go.mod h1:Ejl9IyjvXJ0T9iqUTE1jpYATQ9NM3g+OtR+EMMODbKo=
|
||||
github.com/libp2p/go-libp2p-mplex v0.2.1/go.mod h1:SC99Rxs8Vuzrf/6WhmH41kNn13TiYdAWNYHrwImKLnE=
|
||||
|
|
|
@ -341,8 +341,7 @@ func FilterAddresses(addrs ...*net.IPNet) Option {
|
|||
if cfg.ConnectionGater != nil {
|
||||
var ok bool
|
||||
if f, ok = cfg.ConnectionGater.(*filtersConnectionGater); !ok {
|
||||
return errors.New("cannot configure both Filters and Connection Gater. " +
|
||||
"\n Please consider configuring just a ConnectionGater instead.")
|
||||
return errors.New("cannot configure both Filters and Connection Gater; please consider configuring just a ConnectionGater instead")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -371,8 +370,7 @@ func FilterAddresses(addrs ...*net.IPNet) Option {
|
|||
func Filters(filters *ma.Filters) Option {
|
||||
return func(cfg *Config) error {
|
||||
if cfg.ConnectionGater != nil {
|
||||
return errors.New("cannot configure both Filters and Connection Gater. " +
|
||||
"\n Please consider configuring just a ConnectionGater instead.")
|
||||
return errors.New("cannot configure both Filters and Connection Gater; please consider configuring just a ConnectionGater instead")
|
||||
|
||||
}
|
||||
cfg.ConnectionGater = (*filtersConnectionGater)(filters)
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/libp2p/go-libp2p-core/host"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
|
||||
logging "github.com/ipfs/go-log"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
manet "github.com/multiformats/go-multiaddr/net"
|
||||
"github.com/whyrusleeping/mdns"
|
||||
|
@ -76,7 +76,7 @@ func NewMdnsService(ctx context.Context, peerhost host.Host, interval time.Durat
|
|||
|
||||
addrs, err := getDialableListenAddrs(peerhost)
|
||||
if err != nil {
|
||||
log.Warning(err)
|
||||
log.Warn(err)
|
||||
} else {
|
||||
port = addrs[0].Port
|
||||
for _, a := range addrs {
|
||||
|
@ -158,9 +158,9 @@ func (m *mdnsService) pollForEntries(ctx context.Context) {
|
|||
|
||||
func (m *mdnsService) handleEntry(e *mdns.ServiceEntry) {
|
||||
log.Debugf("Handling MDNS entry: [IPv4 %s][IPv6 %s]:%d %s", e.AddrV4, e.AddrV6, e.Port, e.Info)
|
||||
mpeer, err := peer.IDB58Decode(e.Info)
|
||||
mpeer, err := peer.Decode(e.Info)
|
||||
if err != nil {
|
||||
log.Warning("Error parsing peer ID from mdns entry: ", err)
|
||||
log.Warn("Error parsing peer ID from mdns entry: ", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ func (m *mdnsService) handleEntry(e *mdns.ServiceEntry) {
|
|||
} else if e.AddrV6 != nil {
|
||||
addr = e.AddrV6
|
||||
} else {
|
||||
log.Warning("Error parsing multiaddr from mdns entry: no IP address found")
|
||||
log.Warn("Error parsing multiaddr from mdns entry: no IP address found")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ func (m *mdnsService) handleEntry(e *mdns.ServiceEntry) {
|
|||
Port: e.Port,
|
||||
})
|
||||
if err != nil {
|
||||
log.Warning("Error parsing multiaddr from mdns entry: ", err)
|
||||
log.Warn("Error parsing multiaddr from mdns entry: ", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -27,9 +27,8 @@ import (
|
|||
"github.com/libp2p/go-libp2p/p2p/protocol/ping"
|
||||
"github.com/libp2p/go-netroute"
|
||||
|
||||
logging "github.com/ipfs/go-log"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
madns "github.com/multiformats/go-multiaddr-dns"
|
||||
manet "github.com/multiformats/go-multiaddr/net"
|
||||
|
@ -393,7 +392,7 @@ func (h *BasicHost) newStreamHandler(s network.Stream) {
|
|||
if err == io.EOF {
|
||||
logf := log.Debugf
|
||||
if took > time.Second*10 {
|
||||
logf = log.Warningf
|
||||
logf = log.Warnf
|
||||
}
|
||||
logf("protocol EOF: %s (took %s)", s.Conn().RemotePeer(), took)
|
||||
} else {
|
||||
|
@ -465,7 +464,7 @@ func makeUpdatedAddrEvent(prev, current []ma.Multiaddr) *event.EvtLocalAddresses
|
|||
}
|
||||
|
||||
func (h *BasicHost) makeSignedPeerRecord(evt *event.EvtLocalAddressesUpdated) (*record.Envelope, error) {
|
||||
current := make([]multiaddr.Multiaddr, 0, len(evt.Current))
|
||||
current := make([]ma.Multiaddr, 0, len(evt.Current))
|
||||
for _, a := range evt.Current {
|
||||
current = append(current, a.Address)
|
||||
}
|
||||
|
@ -734,7 +733,7 @@ func (h *BasicHost) resolveAddrs(ctx context.Context, pi peer.AddrInfo) ([]ma.Mu
|
|||
// We've resolved too many addresses. We can keep all the fully
|
||||
// resolved addresses but we'll need to skip the rest.
|
||||
if resolveSteps >= maxAddressResolution {
|
||||
log.Warningf(
|
||||
log.Warnf(
|
||||
"peer %s asked us to resolve too many addresses: %s/%s",
|
||||
pi.ID,
|
||||
resolveSteps,
|
||||
|
|
|
@ -3,7 +3,6 @@ package relay
|
|||
import (
|
||||
"encoding/binary"
|
||||
|
||||
circuit "github.com/libp2p/go-libp2p-circuit"
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
manet "github.com/multiformats/go-multiaddr/net"
|
||||
)
|
||||
|
@ -41,7 +40,7 @@ func isRelayAddr(a ma.Multiaddr) bool {
|
|||
|
||||
ma.ForEach(a, func(c ma.Component) bool {
|
||||
switch c.Protocol().Code {
|
||||
case circuit.P_CIRCUIT:
|
||||
case ma.P_CIRCUIT:
|
||||
isRelay = true
|
||||
return false
|
||||
default:
|
||||
|
|
|
@ -7,13 +7,13 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/discovery"
|
||||
"github.com/libp2p/go-libp2p-core/event"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/routing"
|
||||
|
||||
circuit "github.com/libp2p/go-libp2p-circuit"
|
||||
discovery "github.com/libp2p/go-libp2p-discovery"
|
||||
basic "github.com/libp2p/go-libp2p/p2p/host/basic"
|
||||
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
|
@ -247,7 +247,15 @@ func (ar *AutoRelay) discoverRelays(ctx context.Context) ([]peer.AddrInfo, error
|
|||
|
||||
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
|
||||
defer cancel()
|
||||
return discovery.FindPeers(ctx, ar.discover, RelayRendezvous, discovery.Limit(1000))
|
||||
var ret []peer.AddrInfo
|
||||
ch, err := ar.discover.FindPeers(ctx, RelayRendezvous, discovery.Limit(1000))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for p := range ch {
|
||||
ret = append(ret, p)
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (ar *AutoRelay) selectRelays(ctx context.Context, pis []peer.AddrInfo) []peer.AddrInfo {
|
||||
|
|
|
@ -163,7 +163,7 @@ func TestAutoRelay(t *testing.T) {
|
|||
|
||||
// verify that we don't advertise relay addrs initially
|
||||
for _, addr := range h3.Addrs() {
|
||||
_, err := addr.ValueForProtocol(circuit.P_CIRCUIT)
|
||||
_, err := addr.ValueForProtocol(ma.P_CIRCUIT)
|
||||
if err == nil {
|
||||
t.Fatal("relay addr advertised before auto detection")
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ func TestAutoRelay(t *testing.T) {
|
|||
t.Fatal("unspecific relay addr advertised")
|
||||
}
|
||||
|
||||
_, err := addr.ValueForProtocol(circuit.P_CIRCUIT)
|
||||
_, err := addr.ValueForProtocol(ma.P_CIRCUIT)
|
||||
if err == nil {
|
||||
haveRelay = true
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ func TestAutoRelay(t *testing.T) {
|
|||
// verify that we can connect through the relay
|
||||
var raddrs []ma.Multiaddr
|
||||
for _, addr := range h3.Addrs() {
|
||||
_, err := addr.ValueForProtocol(circuit.P_CIRCUIT)
|
||||
_, err := addr.ValueForProtocol(ma.P_CIRCUIT)
|
||||
if err == nil {
|
||||
raddrs = append(raddrs, addr)
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ func TestAutoRelay(t *testing.T) {
|
|||
t.Fatal("unspecific relay addr advertised")
|
||||
}
|
||||
|
||||
_, err := addr.ValueForProtocol(circuit.P_CIRCUIT)
|
||||
_, err := addr.ValueForProtocol(ma.P_CIRCUIT)
|
||||
if err == nil {
|
||||
haveRelay = true
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package relay
|
||||
|
||||
import (
|
||||
logging "github.com/ipfs/go-log"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
)
|
||||
|
||||
var log = logging.Logger("autorelay")
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/libp2p/go-libp2p-discovery"
|
||||
"github.com/libp2p/go-libp2p-core/discovery"
|
||||
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
@ -20,7 +20,31 @@ func Advertise(ctx context.Context, advertise discovery.Advertiser) {
|
|||
go func() {
|
||||
select {
|
||||
case <-time.After(AdvertiseBootDelay):
|
||||
discovery.Advertise(ctx, advertise, RelayRendezvous, discovery.TTL(AdvertiseTTL))
|
||||
go func() {
|
||||
for {
|
||||
ttl, err := advertise.Advertise(ctx, RelayRendezvous, discovery.TTL(AdvertiseTTL))
|
||||
if err != nil {
|
||||
log.Debugf("Error advertising %s: %s", RelayRendezvous, err.Error())
|
||||
if ctx.Err() != nil {
|
||||
return
|
||||
}
|
||||
|
||||
select {
|
||||
case <-time.After(2 * time.Minute):
|
||||
continue
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
wait := 7 * ttl / 8
|
||||
select {
|
||||
case <-time.After(wait):
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
case <-ctx.Done():
|
||||
}
|
||||
}()
|
||||
|
|
|
@ -13,9 +13,7 @@ import (
|
|||
"github.com/libp2p/go-libp2p-core/peerstore"
|
||||
"github.com/libp2p/go-libp2p-core/protocol"
|
||||
|
||||
logging "github.com/ipfs/go-log"
|
||||
circuit "github.com/libp2p/go-libp2p-circuit"
|
||||
lgbl "github.com/libp2p/go-libp2p-loggables"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
@ -73,7 +71,7 @@ func (rh *RoutedHost) Connect(ctx context.Context, pi peer.AddrInfo) error {
|
|||
// we need to make sure the relay's addr itself is in the peerstore or else
|
||||
// we wont be able to dial it.
|
||||
for _, addr := range addrs {
|
||||
_, err := addr.ValueForProtocol(circuit.P_CIRCUIT)
|
||||
_, err := addr.ValueForProtocol(ma.P_CIRCUIT)
|
||||
if err != nil {
|
||||
// not a relay address
|
||||
continue
|
||||
|
@ -119,21 +117,17 @@ func (rh *RoutedHost) findPeerAddrs(ctx context.Context, id peer.ID) ([]ma.Multi
|
|||
|
||||
if pi.ID != id {
|
||||
err = fmt.Errorf("routing failure: provided addrs for different peer")
|
||||
logRoutingErrDifferentPeers(ctx, id, pi.ID, err)
|
||||
log.Errorw("got wrong peer",
|
||||
"error", err,
|
||||
"wantedPeer", id,
|
||||
"gotPeer", pi.ID,
|
||||
)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return pi.Addrs, nil
|
||||
}
|
||||
|
||||
func logRoutingErrDifferentPeers(ctx context.Context, wanted, got peer.ID, err error) {
|
||||
lm := make(lgbl.DeferredMap)
|
||||
lm["error"] = err
|
||||
lm["wantedPeer"] = func() interface{} { return wanted.Pretty() }
|
||||
lm["gotPeer"] = func() interface{} { return got.Pretty() }
|
||||
log.Event(ctx, "routingError", lm)
|
||||
}
|
||||
|
||||
func (rh *RoutedHost) ID() peer.ID {
|
||||
return rh.host.ID()
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
"github.com/ipfs/go-datastore"
|
||||
"github.com/ipfs/go-datastore/namespace"
|
||||
"github.com/ipfs/go-datastore/query"
|
||||
logging "github.com/ipfs/go-log"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
)
|
||||
|
||||
// BasicConnectionGater implements a connection gater that allows the application to perform
|
||||
|
|
|
@ -3,7 +3,7 @@ package mocknet
|
|||
import (
|
||||
"context"
|
||||
|
||||
logging "github.com/ipfs/go-log"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
)
|
||||
|
||||
var log = logging.Logger("mocknet")
|
||||
|
|
|
@ -233,11 +233,11 @@ func (mn *mocknet) validate(n network.Network) (*peernet, error) {
|
|||
|
||||
nr, ok := n.(*peernet)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("Network not supported (use mock package nets only)")
|
||||
return nil, fmt.Errorf("network not supported (use mock package nets only)")
|
||||
}
|
||||
|
||||
if _, found := mn.nets[nr.peer]; !found {
|
||||
return nil, fmt.Errorf("Network not on mocknet. is it from another mocknet?")
|
||||
return nil, fmt.Errorf("network not on mocknet. is it from another mocknet?")
|
||||
}
|
||||
|
||||
return nr, nil
|
||||
|
|
|
@ -15,19 +15,10 @@ import (
|
|||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/protocol"
|
||||
"github.com/libp2p/go-libp2p-core/test"
|
||||
"github.com/libp2p/go-libp2p-testing/ci"
|
||||
tnet "github.com/libp2p/go-libp2p-testing/net"
|
||||
)
|
||||
|
||||
func randPeer(t *testing.T) peer.ID {
|
||||
p, err := test.RandPeerID()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func TestNetworkSetup(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
id1 := tnet.RandIdentityOrFatal(t)
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
msmux "github.com/multiformats/go-multistream"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
logging "github.com/ipfs/go-log"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
)
|
||||
|
||||
var log = logging.Logger("net/identify")
|
||||
|
@ -373,7 +373,10 @@ func (ids *IDService) identifyConn(c network.Conn, signal chan struct{}) {
|
|||
|
||||
// ok give the response to our handler.
|
||||
if err = msmux.SelectProtoOrFail(ID, s); err != nil {
|
||||
log.Event(context.TODO(), "IdentifyOpenFailed", c.RemotePeer(), logging.Metadata{"error": err})
|
||||
log.Infow("failed negotiate identify protocol with peer",
|
||||
"peer", c.RemotePeer(),
|
||||
"error", err,
|
||||
)
|
||||
s.Reset()
|
||||
return
|
||||
}
|
||||
|
@ -426,7 +429,7 @@ func (ids *IDService) handleIdentifyResponse(s network.Stream) error {
|
|||
mes := &pb.Identify{}
|
||||
|
||||
if err := readAllIDMessages(r, mes); err != nil {
|
||||
log.Warning("error reading identify message: ", err)
|
||||
log.Warn("error reading identify message: ", err)
|
||||
s.Reset()
|
||||
return err
|
||||
}
|
||||
|
@ -653,7 +656,7 @@ func (ids *IDService) consumeReceivedPubKey(c network.Conn, kb []byte) {
|
|||
|
||||
newKey, err := ic.UnmarshalPublicKey(kb)
|
||||
if err != nil {
|
||||
log.Warningf("%s cannot unmarshal key from remote peer: %s, %s", lp, rp, err)
|
||||
log.Warnf("%s cannot unmarshal key from remote peer: %s, %s", lp, rp, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ func (ids *IDService) deltaHandler(s network.Stream) {
|
|||
r := protoio.NewDelimitedReader(s, 2048)
|
||||
mes := pb.Identify{}
|
||||
if err := r.ReadMsg(&mes); err != nil {
|
||||
log.Warning("error reading identify message: ", err)
|
||||
log.Warn("error reading identify message: ", err)
|
||||
_ = s.Reset()
|
||||
return
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ func (ids *IDService) deltaHandler(s network.Stream) {
|
|||
p := s.Conn().RemotePeer()
|
||||
if err := ids.consumeDelta(p, delta); err != nil {
|
||||
_ = s.Reset()
|
||||
log.Warningf("delta update from peer %s failed: %s", p, err)
|
||||
log.Warnf("delta update from peer %s failed: %s", p, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1013,7 +1013,6 @@ func TestLargePushMessage(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestIdentifyResponseReadTimeout(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
timeout := identify.StreamReadTimeout
|
||||
identify.StreamReadTimeout = 100 * time.Millisecond
|
||||
defer func() {
|
||||
|
@ -1058,7 +1057,6 @@ func TestIdentifyResponseReadTimeout(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestIncomingIDStreamsTimeout(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
timeout := identify.StreamReadTimeout
|
||||
identify.StreamReadTimeout = 100 * time.Millisecond
|
||||
defer func() {
|
||||
|
|
|
@ -161,8 +161,7 @@ func (oas *ObservedAddrManager) AddrsFor(addr ma.Multiaddr) (addrs []ma.Multiadd
|
|||
return nil
|
||||
}
|
||||
|
||||
key := string(addr.Bytes())
|
||||
observedAddrs, ok := oas.addrs[key]
|
||||
observedAddrs, ok := oas.addrs[string(addr.Bytes())]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -27,10 +27,8 @@ type identifySnapshot struct {
|
|||
}
|
||||
|
||||
type peerHandler struct {
|
||||
ids *IDService
|
||||
started bool
|
||||
ids *IDService
|
||||
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
|
||||
pid peer.ID
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"time"
|
||||
|
||||
u "github.com/ipfs/go-ipfs-util"
|
||||
logging "github.com/ipfs/go-log"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
"github.com/libp2p/go-libp2p-core/host"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
|
@ -146,7 +146,7 @@ func ping(s network.Stream) (time.Duration, error) {
|
|||
}
|
||||
|
||||
if !bytes.Equal(buf, rbuf) {
|
||||
return 0, errors.New("ping packet was incorrect!")
|
||||
return 0, errors.New("ping packet was incorrect")
|
||||
}
|
||||
|
||||
return time.Since(before), nil
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
|
||||
|
||||
u "github.com/ipfs/go-ipfs-util"
|
||||
logging "github.com/ipfs/go-log"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
"github.com/libp2p/go-libp2p-core/host"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
|
||||
|
||||
u "github.com/ipfs/go-ipfs-util"
|
||||
logging "github.com/ipfs/go-log"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
"github.com/libp2p/go-libp2p-core/host"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
protocol "github.com/libp2p/go-libp2p-core/protocol"
|
||||
|
|
Loading…
Reference in New Issue