mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 20:37:17 +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/peer"
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
filter "github.com/multiformats/go-multiaddr"
|
||||
manet "github.com/multiformats/go-multiaddr/net"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -84,15 +83,15 @@ func (s *Service) validateDial(addr multiaddr.Multiaddr) bool {
|
||||
|
||||
// configureFilter looks at the provided allow lists and
|
||||
// deny lists to appropriately create a filter.
|
||||
func configureFilter(cfg *Config) (*filter.Filters, error) {
|
||||
addrFilter := filter.NewFilters()
|
||||
func configureFilter(cfg *Config) (*multiaddr.Filters, error) {
|
||||
addrFilter := multiaddr.NewFilters()
|
||||
// Configure from provided allow list in the config.
|
||||
if cfg.AllowListCIDR != "" {
|
||||
_, ipnet, err := net.ParseCIDR(cfg.AllowListCIDR)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
addrFilter.AddFilter(*ipnet, filter.ActionAccept)
|
||||
addrFilter.AddFilter(*ipnet, multiaddr.ActionAccept)
|
||||
}
|
||||
// Configure from provided deny list in the config.
|
||||
if len(cfg.DenyListCIDR) > 0 {
|
||||
@ -101,7 +100,7 @@ func configureFilter(cfg *Config) (*filter.Filters, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
addrFilter.AddFilter(*ipnet, filter.ActionDeny)
|
||||
addrFilter.AddFilter(*ipnet, multiaddr.ActionDeny)
|
||||
}
|
||||
}
|
||||
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
|
||||
// we will reject all inbound dials except for those in the
|
||||
// appropriate ip subnets.
|
||||
func filterConnections(f *filter.Filters, a filter.Multiaddr) bool {
|
||||
acceptedNets := f.FiltersForAction(filter.ActionAccept)
|
||||
func filterConnections(f *multiaddr.Filters, a multiaddr.Multiaddr) bool {
|
||||
acceptedNets := f.FiltersForAction(multiaddr.ActionAccept)
|
||||
restrictConns := len(acceptedNets) != 0
|
||||
|
||||
// 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/protocol"
|
||||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||
filter "github.com/multiformats/go-multiaddr"
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
"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"
|
||||
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/peers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared"
|
||||
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/runutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/slotutil"
|
||||
"go.opencensus.io/trace"
|
||||
)
|
||||
|
||||
var _ shared.Service = (*Service)(nil)
|
||||
@ -48,9 +46,6 @@ var pollingPeriod = 6 * time.Second
|
||||
// Refresh rate of ENR set at twice per slot.
|
||||
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.
|
||||
const maxBadResponses = 5
|
||||
|
||||
@ -66,7 +61,7 @@ type Service struct {
|
||||
cancel context.CancelFunc
|
||||
cfg *Config
|
||||
peers *peers.Status
|
||||
addrFilter *filter.Filters
|
||||
addrFilter *multiaddr.Filters
|
||||
ipLimiter *leakybucket.Collector
|
||||
privKey *ecdsa.PrivateKey
|
||||
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...)
|
||||
if err != nil {
|
||||
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/p2p/peers"
|
||||
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"
|
||||
beaconsync "github.com/prysmaticlabs/prysm/beacon-chain/sync"
|
||||
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 {
|
||||
_, err := stream.Write([]byte{0x01})
|
||||
assert.NoError(t, err)
|
||||
msg := types.ErrorMessage("bad")
|
||||
msg := p2pTypes.ErrorMessage("bad")
|
||||
_, err = p.Encoding().EncodeWithMaxLength(stream, &msg)
|
||||
assert.NoError(t, err)
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user