Documentation ¶
Index ¶
- Constants
- Variables
- func CreateLocalNode(privKey *ecdsa.PrivateKey, storagePath string, ipAddr net.IP, ...) (*enode.LocalNode, error)
- func DiffSubnets(a, b []byte) map[int]byte
- func GetDomainTypeEntry(record *enr.Record) (spectypes.DomainType, error)
- func GetSubnetsEntry(record *enr.Record) ([]byte, error)
- func SetDomainTypeEntry(node *enode.LocalNode, domainType spectypes.DomainType) error
- func SetSubnetsEntry(node *enode.LocalNode, subnets []byte) error
- func SharedSubnets(a, b []byte, maxLen int) []int
- func UpdateSubnets(node *enode.LocalNode, count int, added []int, removed []int) ([]byte, error)
- type AnyNodeInfo
- type DomainTypeEntry
- type HandshakeData
- type NodeInfo
- func (ni *NodeInfo) Codec() []byte
- func (ni *NodeInfo) Consume(data []byte) error
- func (ni *NodeInfo) Domain() string
- func (ni *NodeInfo) GetNodeInfo() *NodeInfo
- func (ni *NodeInfo) MarshalRecord() ([]byte, error)
- func (ni *NodeInfo) Seal(privateKey crypto.PrivKey) ([]byte, error)
- func (ni *NodeInfo) UnmarshalRecord(data []byte) error
- type NodeMetadata
- type SignedNodeInfo
- func (sni *SignedNodeInfo) Codec() []byte
- func (sni *SignedNodeInfo) Consume(data []byte) error
- func (sni *SignedNodeInfo) Domain() string
- func (sni *SignedNodeInfo) GetNodeInfo() *NodeInfo
- func (sni *SignedNodeInfo) MarshalRecord() ([]byte, error)
- func (sni *SignedNodeInfo) Seal(netPrivateKey crypto.PrivKey) ([]byte, error)
- func (sni *SignedNodeInfo) UnmarshalRecord(data []byte) error
- type Subnets
Constants ¶
const ( // ZeroSubnets is the representation of no subnets ZeroSubnets = "00000000000000000000000000000000" // AllSubnets is the representation of all subnets AllSubnets = "ffffffffffffffffffffffffffffffff" )
Variables ¶
var ErrEntryNotFound = errors.New("not found")
Functions ¶
func CreateLocalNode ¶
func CreateLocalNode(privKey *ecdsa.PrivateKey, storagePath string, ipAddr net.IP, udpPort, tcpPort int) (*enode.LocalNode, error)
CreateLocalNode create a new enode.LocalNode instance
func DiffSubnets ¶ added in v0.3.0
DiffSubnets returns a diff of the two given subnets. returns a map with all the different entries and their post change value
func GetDomainTypeEntry ¶ added in v1.1.0
func GetDomainTypeEntry(record *enr.Record) (spectypes.DomainType, error)
GetDomainTypeEntry extracts the value of domain type entry
func GetSubnetsEntry ¶
GetSubnetsEntry extracts the value of subnets entry from some record
func SetDomainTypeEntry ¶ added in v1.1.0
func SetDomainTypeEntry(node *enode.LocalNode, domainType spectypes.DomainType) error
SetDomainTypeEntry adds domain type entry to the node
func SetSubnetsEntry ¶
SetSubnetsEntry adds subnets entry to our enode.LocalNode
func SharedSubnets ¶ added in v0.3.0
SharedSubnets returns the shared subnets
Types ¶
type AnyNodeInfo ¶ added in v1.1.0
type DomainTypeEntry ¶ added in v1.1.0
type DomainTypeEntry spectypes.DomainType
DomainTypeEntry holds the domain type of the node
func (*DomainTypeEntry) DecodeRLP ¶ added in v1.1.0
func (dt *DomainTypeEntry) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder, decodes domain type from bytes
func (DomainTypeEntry) ENRKey ¶ added in v1.1.0
func (dt DomainTypeEntry) ENRKey() string
ENRKey implements enr.Entry, returns the entry key
type HandshakeData ¶ added in v1.1.0
type HandshakeData struct { SenderPeerID peer.ID RecipientPeerID peer.ID Timestamp time.Time SenderPublicKey []byte }
func (*HandshakeData) Encode ¶ added in v1.3.3
func (h *HandshakeData) Encode() []byte
type NodeInfo ¶
type NodeInfo struct { // NetworkID is the id of the node's network NetworkID string // Metadata holds node's general information Metadata *NodeMetadata }
NodeInfo holds node's information such as network information. it implements record.Record so we can safely sign, exchange and verify the data. for more information see record.Envelope
func (*NodeInfo) Domain ¶
Domain is the "signature domain" used when signing and verifying an record.Record
func (*NodeInfo) GetNodeInfo ¶ added in v1.1.0
GetNodeInfo returns a value representation of the info
func (*NodeInfo) MarshalRecord ¶
MarshalRecord converts a Record instance to a []byte, so that it can be used as an Envelope payload
func (*NodeInfo) UnmarshalRecord ¶
UnmarshalRecord unmarshals a []byte payload into an instance of a particular Record type
type NodeMetadata ¶
type NodeMetadata struct { // NodeVersion is the ssv-node version, it is a required field NodeVersion string // ExecutionNode is the "name/version" of the eth1 node ExecutionNode string // ConsensusNode is the "name/version" of the beacon node ConsensusNode string // Subnets represents the subnets that our node is subscribed to Subnets string }
NodeMetadata holds node's general information
func (*NodeMetadata) Decode ¶
func (nm *NodeMetadata) Decode(data []byte) error
Decode decodes a raw payload into metadata TODO: switch to SSZ
func (*NodeMetadata) Encode ¶
func (nm *NodeMetadata) Encode() ([]byte, error)
Encode encodes the metadata into bytes TODO: switch to SSZ
type SignedNodeInfo ¶ added in v1.1.0
type SignedNodeInfo struct { NodeInfo *NodeInfo HandshakeData HandshakeData Signature []byte }
func (*SignedNodeInfo) Codec ¶ added in v1.1.0
func (sni *SignedNodeInfo) Codec() []byte
func (*SignedNodeInfo) Consume ¶ added in v1.1.0
func (sni *SignedNodeInfo) Consume(data []byte) error
Consume takes a raw envelope and extracts the parsed record
func (*SignedNodeInfo) Domain ¶ added in v1.1.0
func (sni *SignedNodeInfo) Domain() string
func (*SignedNodeInfo) GetNodeInfo ¶ added in v1.1.0
func (sni *SignedNodeInfo) GetNodeInfo() *NodeInfo
GetNodeInfo returns inner representation of the info
func (*SignedNodeInfo) MarshalRecord ¶ added in v1.1.0
func (sni *SignedNodeInfo) MarshalRecord() ([]byte, error)
MarshalRecord serializes SignedNodeInfo IMPORTANT: MarshalRecord rounds SignedNodeInfo.HandshakeData.Timestamp to seconds
func (*SignedNodeInfo) Seal ¶ added in v1.1.0
func (sni *SignedNodeInfo) Seal(netPrivateKey crypto.PrivKey) ([]byte, error)
Seal seals and encodes the record to be sent to other peers IMPORTANT: Seal rounds sni.HandshakeData.Timestamp to seconds
func (*SignedNodeInfo) UnmarshalRecord ¶ added in v1.1.0
func (sni *SignedNodeInfo) UnmarshalRecord(data []byte) error