mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-12 12:40:05 +00:00
Remove duplicate package imports (#8104)
* remove duplicate imports * remove unused lookupLimit Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
parent
630d57377a
commit
0f18867f08
@ -8,7 +8,6 @@ import (
|
|||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p-core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
"github.com/multiformats/go-multiaddr"
|
"github.com/multiformats/go-multiaddr"
|
||||||
filter "github.com/multiformats/go-multiaddr"
|
|
||||||
manet "github.com/multiformats/go-multiaddr/net"
|
manet "github.com/multiformats/go-multiaddr/net"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -84,15 +83,15 @@ func (s *Service) validateDial(addr multiaddr.Multiaddr) bool {
|
|||||||
|
|
||||||
// configureFilter looks at the provided allow lists and
|
// configureFilter looks at the provided allow lists and
|
||||||
// deny lists to appropriately create a filter.
|
// deny lists to appropriately create a filter.
|
||||||
func configureFilter(cfg *Config) (*filter.Filters, error) {
|
func configureFilter(cfg *Config) (*multiaddr.Filters, error) {
|
||||||
addrFilter := filter.NewFilters()
|
addrFilter := multiaddr.NewFilters()
|
||||||
// Configure from provided allow list in the config.
|
// Configure from provided allow list in the config.
|
||||||
if cfg.AllowListCIDR != "" {
|
if cfg.AllowListCIDR != "" {
|
||||||
_, ipnet, err := net.ParseCIDR(cfg.AllowListCIDR)
|
_, ipnet, err := net.ParseCIDR(cfg.AllowListCIDR)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
addrFilter.AddFilter(*ipnet, filter.ActionAccept)
|
addrFilter.AddFilter(*ipnet, multiaddr.ActionAccept)
|
||||||
}
|
}
|
||||||
// Configure from provided deny list in the config.
|
// Configure from provided deny list in the config.
|
||||||
if len(cfg.DenyListCIDR) > 0 {
|
if len(cfg.DenyListCIDR) > 0 {
|
||||||
@ -101,7 +100,7 @@ func configureFilter(cfg *Config) (*filter.Filters, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
addrFilter.AddFilter(*ipnet, filter.ActionDeny)
|
addrFilter.AddFilter(*ipnet, multiaddr.ActionDeny)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return addrFilter, nil
|
return addrFilter, nil
|
||||||
@ -112,8 +111,8 @@ func configureFilter(cfg *Config) (*filter.Filters, error) {
|
|||||||
// accepts all incoming dials, so if we have an allow list
|
// accepts all incoming dials, so if we have an allow list
|
||||||
// we will reject all inbound dials except for those in the
|
// we will reject all inbound dials except for those in the
|
||||||
// appropriate ip subnets.
|
// appropriate ip subnets.
|
||||||
func filterConnections(f *filter.Filters, a filter.Multiaddr) bool {
|
func filterConnections(f *multiaddr.Filters, a multiaddr.Multiaddr) bool {
|
||||||
acceptedNets := f.FiltersForAction(filter.ActionAccept)
|
acceptedNets := f.FiltersForAction(multiaddr.ActionAccept)
|
||||||
restrictConns := len(acceptedNets) != 0
|
restrictConns := len(acceptedNets) != 0
|
||||||
|
|
||||||
// If we have an allow list added in, we by default reject all
|
// If we have an allow list added in, we by default reject all
|
||||||
|
@ -19,22 +19,20 @@ import (
|
|||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
"github.com/libp2p/go-libp2p-core/protocol"
|
"github.com/libp2p/go-libp2p-core/protocol"
|
||||||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||||
filter "github.com/multiformats/go-multiaddr"
|
"github.com/multiformats/go-multiaddr"
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers"
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
|
||||||
"go.opencensus.io/trace"
|
|
||||||
|
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/feed"
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/feed"
|
||||||
statefeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state"
|
statefeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder"
|
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers"
|
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers"
|
||||||
|
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers"
|
||||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||||
"github.com/prysmaticlabs/prysm/shared"
|
"github.com/prysmaticlabs/prysm/shared"
|
||||||
|
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
"github.com/prysmaticlabs/prysm/shared/runutil"
|
"github.com/prysmaticlabs/prysm/shared/runutil"
|
||||||
"github.com/prysmaticlabs/prysm/shared/slotutil"
|
"github.com/prysmaticlabs/prysm/shared/slotutil"
|
||||||
|
"go.opencensus.io/trace"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ shared.Service = (*Service)(nil)
|
var _ shared.Service = (*Service)(nil)
|
||||||
@ -48,9 +46,6 @@ var pollingPeriod = 6 * time.Second
|
|||||||
// Refresh rate of ENR set at twice per slot.
|
// Refresh rate of ENR set at twice per slot.
|
||||||
var refreshRate = slotutil.DivideSlotBy(2)
|
var refreshRate = slotutil.DivideSlotBy(2)
|
||||||
|
|
||||||
// lookup limit whenever looking up for random nodes.
|
|
||||||
const lookupLimit = 15
|
|
||||||
|
|
||||||
// maxBadResponses is the maximum number of bad responses from a peer before we stop talking to it.
|
// maxBadResponses is the maximum number of bad responses from a peer before we stop talking to it.
|
||||||
const maxBadResponses = 5
|
const maxBadResponses = 5
|
||||||
|
|
||||||
@ -66,7 +61,7 @@ type Service struct {
|
|||||||
cancel context.CancelFunc
|
cancel context.CancelFunc
|
||||||
cfg *Config
|
cfg *Config
|
||||||
peers *peers.Status
|
peers *peers.Status
|
||||||
addrFilter *filter.Filters
|
addrFilter *multiaddr.Filters
|
||||||
ipLimiter *leakybucket.Collector
|
ipLimiter *leakybucket.Collector
|
||||||
privKey *ecdsa.PrivateKey
|
privKey *ecdsa.PrivateKey
|
||||||
metaData *pb.MetaData
|
metaData *pb.MetaData
|
||||||
@ -402,7 +397,7 @@ func (s *Service) awaitStateInitialized() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) connectWithAllPeers(multiAddrs []ma.Multiaddr) {
|
func (s *Service) connectWithAllPeers(multiAddrs []multiaddr.Multiaddr) {
|
||||||
addrInfos, err := peer.AddrInfosFromP2pAddrs(multiAddrs...)
|
addrInfos, err := peer.AddrInfosFromP2pAddrs(multiAddrs...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Could not convert to peer address info's from multiaddresses: %v", err)
|
log.Errorf("Could not convert to peer address info's from multiaddresses: %v", err)
|
||||||
|
@ -19,7 +19,6 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/beacon-chain/flags"
|
"github.com/prysmaticlabs/prysm/beacon-chain/flags"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers"
|
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers"
|
||||||
p2pt "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
|
p2pt "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
|
||||||
p2pTypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
p2pTypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
||||||
beaconsync "github.com/prysmaticlabs/prysm/beacon-chain/sync"
|
beaconsync "github.com/prysmaticlabs/prysm/beacon-chain/sync"
|
||||||
p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||||
@ -179,7 +178,7 @@ func connectPeer(t *testing.T, host *p2pt.TestP2P, datum *peerData, peerStatus *
|
|||||||
if len(sliceutil.IntersectionUint64(datum.failureSlots, requestedBlocks)) > 0 {
|
if len(sliceutil.IntersectionUint64(datum.failureSlots, requestedBlocks)) > 0 {
|
||||||
_, err := stream.Write([]byte{0x01})
|
_, err := stream.Write([]byte{0x01})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
msg := types.ErrorMessage("bad")
|
msg := p2pTypes.ErrorMessage("bad")
|
||||||
_, err = p.Encoding().EncodeWithMaxLength(stream, &msg)
|
_, err = p.Encoding().EncodeWithMaxLength(stream, &msg)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user