prysm-pulse/shared/p2p/options.go
Preston Van Loon 991ee7e81b "Super sync" and naive p2p reputation (#2550)
* checkpoint on super sync with reputation

* ensure handling only expected peers msg

* exclusive of finalized block

* skip block saved already

* clean up struct

* remove 2 more fields

* _

* everything builds, but doesnt test yet

* lint

* fix p2p tests

* space

* space

* space

* fmt

* fmt
2019-05-09 16:02:24 -05:00

33 lines
833 B
Go

package p2p
import (
"fmt"
"github.com/libp2p/go-libp2p"
ma "github.com/multiformats/go-multiaddr"
"github.com/prysmaticlabs/prysm/shared/iputils"
)
// buildOptions for the libp2p host.
// TODO(287): Expand on these options and provide the option configuration via flags.
// Currently, this is a random port and a (seemingly) consistent private key
// identity.
func buildOptions(port, maxPeers int) []libp2p.Option {
ip, err := iputils.ExternalIPv4()
if err != nil {
log.Errorf("Could not get IPv4 address: %v", err)
}
listen, err := ma.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d", ip, port))
if err != nil {
log.Errorf("Failed to p2p listen: %v", err)
}
return []libp2p.Option{
libp2p.ListenAddrs(listen),
libp2p.EnableRelay(), // Allows dialing to peers via relay.
optionConnectionManager(maxPeers),
}
}