mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-05 17:22:18 +00:00
0b8cbd06b6
* refactor a bit to select p2p * lint * fix build * fix build * fix build * fix build * fix build
29 lines
894 B
Go
29 lines
894 B
Go
package p2p
|
|
|
|
import (
|
|
"context"
|
|
"reflect"
|
|
|
|
"github.com/gogo/protobuf/proto"
|
|
peer "github.com/libp2p/go-libp2p-peer"
|
|
)
|
|
|
|
// Message represents a message received from an external peer.
|
|
// DEPRECATED: Do not use. This exists for backwards compatibility but may be removed.
|
|
type Message struct {
|
|
// Ctx message context.
|
|
Ctx context.Context
|
|
// Peer represents the sender of the message.
|
|
Peer peer.ID
|
|
// Data can be any type of message found in sharding/p2p/proto package.
|
|
Data proto.Message
|
|
}
|
|
|
|
// messageType returns the underlying struct type for a given proto.message.
|
|
func messageType(msg proto.Message) reflect.Type {
|
|
// proto.Message is a pointer and we need to dereference the pointer
|
|
// and take the type of the original struct. Otherwise reflect.TypeOf will
|
|
// create a new value of type **ethpb.BeaconBlockHashAnnounce for example.
|
|
return reflect.ValueOf(msg).Elem().Type()
|
|
}
|