prysm-pulse/beacon-chain/node/p2p_config.go
Preston Van Loon 612bb38077 Cross p2p spans, more spans, synchronous attestations, minor fixes (#2009)
* Fix assignments bug where validators don't retry for assignments on failure

* synch only please

* trying to fix state issues

* trying random stuff

* do not explode

* use ctx

* working build, failing tests

* broadcast local addrs as well as relay addrs

* fixed p2p tests, more tests to fix still

* another test fixed, log warning instead of throw error

* Fix last tests

* godoc

* add test for broadcast in apply fork choiec

* remove unneeded code

* remove tracer adapter, not needed

* remove extra stuff

* remove any

* revert addr_factory

* revert addr_factory

* Revert "revert addr_factory"

This reverts commit e93fb706494a1070158b8db31e67146d6b0648ad.

* Revert "revert addr_factory"

This reverts commit dedaa405559cc818698870c4e4570953367f1e3c.

* revert removal of this code

* unused param
2019-03-17 10:56:05 +08:00

47 lines
1.7 KiB
Go

package node
import (
"github.com/gogo/protobuf/proto"
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
"github.com/prysmaticlabs/prysm/shared/cmd"
"github.com/prysmaticlabs/prysm/shared/p2p"
"github.com/prysmaticlabs/prysm/shared/p2p/adapter/metric"
"github.com/urfave/cli"
)
var topicMappings = map[pb.Topic]proto.Message{
pb.Topic_BEACON_BLOCK_ANNOUNCE: &pb.BeaconBlockAnnounce{},
pb.Topic_BEACON_BLOCK_REQUEST: &pb.BeaconBlockRequest{},
pb.Topic_BEACON_BLOCK_REQUEST_BY_SLOT_NUMBER: &pb.BeaconBlockRequestBySlotNumber{},
pb.Topic_BEACON_BLOCK_RESPONSE: &pb.BeaconBlockResponse{},
pb.Topic_BATCHED_BEACON_BLOCK_REQUEST: &pb.BatchedBeaconBlockRequest{},
pb.Topic_BATCHED_BEACON_BLOCK_RESPONSE: &pb.BatchedBeaconBlockResponse{},
pb.Topic_CHAIN_HEAD_REQUEST: &pb.ChainHeadRequest{},
pb.Topic_CHAIN_HEAD_RESPONSE: &pb.ChainHeadResponse{},
pb.Topic_BEACON_STATE_HASH_ANNOUNCE: &pb.BeaconStateHashAnnounce{},
pb.Topic_BEACON_STATE_REQUEST: &pb.BeaconStateRequest{},
pb.Topic_BEACON_STATE_RESPONSE: &pb.BeaconStateResponse{},
}
func configureP2P(ctx *cli.Context) (*p2p.Server, error) {
s, err := p2p.NewServer(&p2p.ServerConfig{
BootstrapNodeAddr: ctx.GlobalString(cmd.BootstrapNode.Name),
RelayNodeAddr: ctx.GlobalString(cmd.RelayNode.Name),
Port: ctx.GlobalInt(cmd.P2PPort.Name),
})
if err != nil {
return nil, err
}
adapters := []p2p.Adapter{}
if !ctx.GlobalBool(cmd.DisableMonitoringFlag.Name) {
adapters = append(adapters, metric.New())
}
for k, v := range topicMappings {
s.RegisterTopic(k.String(), v, adapters...)
}
return s, nil
}