2019-08-16 17:13:04 +00:00
|
|
|
package p2p
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
|
|
|
|
"github.com/gogo/protobuf/proto"
|
2019-11-27 05:08:18 +00:00
|
|
|
pb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
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-06-09 22:40:48 +00:00
|
|
|
"/eth2/%x/beacon_block": &pb.SignedBeaconBlock{},
|
|
|
|
"/eth2/%x/beacon_attestation_%d": &pb.Attestation{},
|
|
|
|
"/eth2/%x/voluntary_exit": &pb.SignedVoluntaryExit{},
|
|
|
|
"/eth2/%x/proposer_slashing": &pb.ProposerSlashing{},
|
|
|
|
"/eth2/%x/attester_slashing": &pb.AttesterSlashing{},
|
|
|
|
"/eth2/%x/beacon_aggregate_and_proof": &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
|
|
|
|
}
|
|
|
|
}
|