github.com/prysmaticlabs/prysm@v1.4.4/beacon-chain/p2p/gossip_topic_mappings.go (about) 1 package p2p 2 3 import ( 4 "reflect" 5 6 pb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" 7 "google.golang.org/protobuf/proto" 8 ) 9 10 // GossipTopicMappings represent the protocol ID to protobuf message type map for easy 11 // lookup. 12 var GossipTopicMappings = map[string]proto.Message{ 13 BlockSubnetTopicFormat: &pb.SignedBeaconBlock{}, 14 AttestationSubnetTopicFormat: &pb.Attestation{}, 15 ExitSubnetTopicFormat: &pb.SignedVoluntaryExit{}, 16 ProposerSlashingSubnetTopicFormat: &pb.ProposerSlashing{}, 17 AttesterSlashingSubnetTopicFormat: &pb.AttesterSlashing{}, 18 AggregateAndProofSubnetTopicFormat: &pb.SignedAggregateAttestationAndProof{}, 19 } 20 21 // GossipTypeMapping is the inverse of GossipTopicMappings so that an arbitrary protobuf message 22 // can be mapped to a protocol ID string. 23 var GossipTypeMapping = make(map[reflect.Type]string, len(GossipTopicMappings)) 24 25 func init() { 26 for k, v := range GossipTopicMappings { 27 GossipTypeMapping[reflect.TypeOf(v)] = k 28 } 29 }