mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-01 15:57:39 +00:00
f46ee335bd
* adding proto messages * adding fields * adding new service * new changes * checking in file from syncFix * fixing test * add test * adding to node * goimports * adding query service to sync services * sync working * finally works * fix test * lint * fix build * fix test
53 lines
1.9 KiB
Go
53 lines
1.9 KiB
Go
package node
|
|
|
|
import (
|
|
"github.com/golang/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/prysmaticlabs/prysm/shared/p2p/adapter/tracer"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
var topicMappings = map[pb.Topic]proto.Message{
|
|
pb.Topic_BEACON_BLOCK_HASH_ANNOUNCE: &pb.BeaconBlockHashAnnounce{},
|
|
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_CHAIN_HEAD_REQUEST: &pb.ChainHeadRequest{},
|
|
pb.Topic_CHAIN_HEAD_RESPONSE: &pb.ChainHeadResponse{},
|
|
pb.Topic_CRYSTALLIZED_STATE_HASH_ANNOUNCE: &pb.CrystallizedStateHashAnnounce{},
|
|
pb.Topic_CRYSTALLIZED_STATE_REQUEST: &pb.CrystallizedStateRequest{},
|
|
pb.Topic_CRYSTALLIZED_STATE_RESPONSE: &pb.CrystallizedStateResponse{},
|
|
pb.Topic_ACTIVE_STATE_HASH_ANNOUNCE: &pb.ActiveStateHashAnnounce{},
|
|
pb.Topic_ACTIVE_STATE_REQUEST: &pb.ActiveStateRequest{},
|
|
pb.Topic_ACTIVE_STATE_RESPONSE: &pb.ActiveStateResponse{},
|
|
}
|
|
|
|
func configureP2P(ctx *cli.Context) (*p2p.Server, error) {
|
|
s, err := p2p.NewServer(ctx.GlobalString(cmd.BootstrapNode.Name))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
traceAdapter, err := tracer.New("beacon-chain",
|
|
ctx.GlobalString(cmd.TracingEndpointFlag.Name),
|
|
ctx.GlobalFloat64(cmd.TraceSampleFractionFlag.Name),
|
|
ctx.GlobalBool(cmd.EnableTracingFlag.Name))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
adapters := []p2p.Adapter{traceAdapter}
|
|
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
|
|
}
|