2019-08-16 17:13:04 +00:00
|
|
|
package p2p
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
|
2019-11-27 05:08:18 +00:00
|
|
|
pb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
2021-05-17 18:32:04 +00:00
|
|
|
"google.golang.org/protobuf/proto"
|
2019-08-16 17:13:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// GossipTopicMappings represent the protocol ID to protobuf message type map for easy
|
|
|
|
// lookup.
|
|
|
|
var GossipTopicMappings = map[string]proto.Message{
|
2020-07-09 17:38:15 +00:00
|
|
|
BlockSubnetTopicFormat: &pb.SignedBeaconBlock{},
|
|
|
|
AttestationSubnetTopicFormat: &pb.Attestation{},
|
|
|
|
ExitSubnetTopicFormat: &pb.SignedVoluntaryExit{},
|
|
|
|
ProposerSlashingSubnetTopicFormat: &pb.ProposerSlashing{},
|
|
|
|
AttesterSlashingSubnetTopicFormat: &pb.AttesterSlashing{},
|
|
|
|
AggregateAndProofSubnetTopicFormat: &pb.SignedAggregateAttestationAndProof{},
|
2019-08-16 17:13:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GossipTypeMapping is the inverse of GossipTopicMappings so that an arbitrary protobuf message
|
|
|
|
// can be mapped to a protocol ID string.
|
2020-07-09 15:50:58 +00:00
|
|
|
var GossipTypeMapping = make(map[reflect.Type]string, len(GossipTopicMappings))
|
2019-08-16 17:13:04 +00:00
|
|
|
|
|
|
|
func init() {
|
|
|
|
for k, v := range GossipTopicMappings {
|
|
|
|
GossipTypeMapping[reflect.TypeOf(v)] = k
|
|
|
|
}
|
|
|
|
}
|