records

package
v0.2.1-rc.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2022 License: GPL-3.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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 GetForkVersionEntry

func GetForkVersionEntry(record *enr.Record) (forksprotocol.ForkVersion, error)

GetForkVersionEntry extracts the value of operator-id entry ('oid')

func GetOperatorIDEntry

func GetOperatorIDEntry(record *enr.Record) (string, error)

GetOperatorIDEntry extracts the value of operator-id entry ('oid')

func GetSubnetsEntry

func GetSubnetsEntry(record *enr.Record) ([]byte, error)

GetSubnetsEntry extracts the value of subnets entry from some record

func SetForkVersionEntry

func SetForkVersionEntry(node *enode.LocalNode, forkv string) error

SetForkVersionEntry adds operator-id entry ('oid') to the node

func SetNodeTypeEntry

func SetNodeTypeEntry(node *enode.LocalNode, nodeType NodeType) error

SetNodeTypeEntry adds operator-public-key-hash entry ('oid') to the node

func SetOperatorIDEntry

func SetOperatorIDEntry(node *enode.LocalNode, operatorID string) error

SetOperatorIDEntry adds operator-id entry ('oid') to the node

func SetSubnetsEntry

func SetSubnetsEntry(node *enode.LocalNode, subnets []byte) error

SetSubnetsEntry adds subnets entry to our enode.LocalNode

func UpdateSubnets

func UpdateSubnets(node *enode.LocalNode, count int, added []int64, removed []int64) error

UpdateSubnets updates subnets entry according to the given changes. count is the amount of subnets, in case that the entry doesn't exist as we want to initialize it

Types

type ForkVersionEntry

type ForkVersionEntry string

ForkVersionEntry holds the fork version of the node

func (*ForkVersionEntry) DecodeRLP

func (fv *ForkVersionEntry) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder, required because fork version is a string

func (ForkVersionEntry) ENRKey

func (fv ForkVersionEntry) ENRKey() string

ENRKey implements enr.Entry, returns the entry key

func (ForkVersionEntry) EncodeRLP

func (fv ForkVersionEntry) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder, required because fork version is a string

type NodeInfo

type NodeInfo struct {
	// ForkVersion is the fork version used by the node
	ForkVersion forksprotocol.ForkVersion
	// 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 NewNodeInfo

func NewNodeInfo(forkVersion forksprotocol.ForkVersion, networkID string) *NodeInfo

NewNodeInfo creates a new node info

func (*NodeInfo) Codec

func (ni *NodeInfo) Codec() []byte

Codec is a binary identifier for this type of record.record

func (*NodeInfo) Consume

func (ni *NodeInfo) Consume(data []byte) error

Consume takes a raw envelope and extracts the parsed record

func (*NodeInfo) Domain

func (ni *NodeInfo) Domain() string

Domain is the "signature domain" used when signing and verifying an record.Record

func (*NodeInfo) MarshalRecord

func (ni *NodeInfo) MarshalRecord() ([]byte, error)

MarshalRecord converts a Record instance to a []byte, so that it can be used as an Envelope payload

func (*NodeInfo) Seal

func (ni *NodeInfo) Seal(privateKey crypto.PrivKey) ([]byte, error)

Seal seals and encodes the record to be sent to other peers

func (*NodeInfo) UnmarshalRecord

func (ni *NodeInfo) UnmarshalRecord(data []byte) error

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
	// OperatorID holds a hash of the operator public key, based on operator key
	OperatorID string
	// ExecutionNode is the "name/version" of the eth1 node
	ExecutionNode string
	// ConsensusNode is the "name/version" of the beacon node
	ConsensusNode 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 NodeType

type NodeType int32

NodeType indicate node operation type. In purpose for distinguish between different types of peers

const (
	Unknown NodeType = iota
	Operator
	Exporter
)

NodeTypes are const types for NodeType

func GetNodeTypeEntry

func GetNodeTypeEntry(record *enr.Record) (NodeType, error)

GetNodeTypeEntry extracts the value of operator-public-key-hash entry ('oid')

func (NodeType) String

func (nt NodeType) String() string

type NodeTypeEntry

type NodeTypeEntry uint16

NodeTypeEntry holds the node type

func (NodeTypeEntry) ENRKey

func (nte NodeTypeEntry) ENRKey() string

ENRKey implements enr.Entry, returns the entry key

type OperatorIDEntry

type OperatorIDEntry string

OperatorIDEntry holds the operator id

func (*OperatorIDEntry) DecodeRLP

func (oid *OperatorIDEntry) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder, required because operator id is a string

func (OperatorIDEntry) ENRKey

func (oid OperatorIDEntry) ENRKey() string

ENRKey implements enr.Entry, returns the entry key

func (OperatorIDEntry) EncodeRLP

func (oid OperatorIDEntry) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder, required because operator id is a string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL