prysm-pulse/validator/node/p2p_config.go

30 lines
712 B
Go
Raw Normal View History

package node
import (
2018-09-09 22:15:24 +00:00
"github.com/golang/protobuf/proto"
"github.com/prysmaticlabs/prysm/shared/p2p"
pb "github.com/prysmaticlabs/prysm/proto/sharding/p2p/v1"
)
2018-09-09 22:15:24 +00:00
var topicMappings = map[pb.Topic]proto.Message{
pb.Topic_COLLATION_BODY_REQUEST: &pb.CollationBodyRequest{},
pb.Topic_COLLATION_BODY_RESPONSE: &pb.CollationBodyResponse{},
pb.Topic_TRANSACTIONS: &pb.Transaction{},
}
func configureP2P() (*p2p.Server, error) {
s, err := p2p.NewServer()
if err != nil {
return nil, err
}
// TODO(437, 438): Define default adapters for logging, monitoring, etc.
var adapters []p2p.Adapter
for k, v := range topicMappings {
s.RegisterTopic(k.String(), v, adapters...)
}
return s, nil
}