commons

package
v2.4.1-0...-6c2315b Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultIP is hte default ip address to use
	DefaultIP = "127.0.0.1"
	// DefaultTCP is the default tcp port used in SSV
	DefaultTCP = 12001
	// DefaultUDP is the default udp port used in SSV
	DefaultUDP = 13001
)
View Source
const (
	// SubnetsCount returns the subnet count for this fork. It must be power of 2.
	SubnetsCount = 128

	UnknownSubnetId = math.MaxUint64

	// UnknownSubnet is used when a validator public key is invalid
	UnknownSubnet = "unknown"
)

Variables

View Source
var (
	// ZeroSubnets is the representation of no subnets
	ZeroSubnets = Subnets{/* contains filtered or unexported fields */}
	// AllSubnets is the representation of all subnets
	AllSubnets = Subnets{/* contains filtered or unexported fields */}
)

Functions

func BuildMultiAddress

func BuildMultiAddress(ipAddr, protocol string, port uint, id peer.ID) (ma.Multiaddr, error)

BuildMultiAddress creates a multiaddr from the given params

func CommitteeSubnet

func CommitteeSubnet(cid spectypes.CommitteeID) uint64

CommitteeSubnet returns the subnet for the given committee

func CommitteeTopicID

func CommitteeTopicID(cid spectypes.CommitteeID) []string

func ECDSAPrivFromInterface

func ECDSAPrivFromInterface(privkey crypto.PrivKey) (*ecdsa.PrivateKey, error)

ECDSAPrivFromInterface converts crypto.PrivKey back to ecdsa.PrivateKey

func ECDSAPrivToInterface

func ECDSAPrivToInterface(privkey *ecdsa.PrivateKey) (crypto.PrivKey, error)

ECDSAPrivToInterface converts ecdsa.PrivateKey to crypto.PrivKey

func ECDSAPubFromInterface

func ECDSAPubFromInterface(pubKey crypto.PubKey) *ecdsa.PublicKey

ECDSAPubFromInterface converts crypto.PubKey to ecdsa.PublicKey

func ECDSAPubToInterface

func ECDSAPubToInterface(pubkey *ecdsa.PublicKey) (crypto.PubKey, error)

ECDSAPubToInterface converts ecdsa.PublicKey to crypto.PubKey

func GetTopicBaseName

func GetTopicBaseName(topicName string) string

GetTopicBaseName return the base topic name of the topic, w/o ssv prefix

func GetTopicFullName

func GetTopicFullName(baseName string) string

GetTopicFullName returns the topic full name, including prefix

func IPAddr

func IPAddr() (net.IP, error)

IPAddr returns the external IP address

func SetCommitteeSubnet

func SetCommitteeSubnet(bigInt *big.Int, cid spectypes.CommitteeID)

SetCommitteeSubnet returns the subnet for the given committee, it doesn't allocate memory but uses the passed in big.Int

func SubnetTopicID

func SubnetTopicID(subnet uint64) string

SubnetTopicID returns the topic to use for the given subnet

func Topics

func Topics() []string

Topics returns the available topics for this fork.

Types

type Subnets

type Subnets struct {
	// contains filtered or unexported fields
}

Subnets holds all the subscribed subnets of a specific node. The array index represents a subnet number, the value holds either 0 or 1 representing if the node is subscribed to the subnet number.

func SubnetsFromString

func SubnetsFromString(subnetsStr string) (Subnets, error)

SubnetsFromString parses a given subnet string

func (*Subnets) ActiveCount

func (s *Subnets) ActiveCount() int

func (*Subnets) Clear

func (s *Subnets) Clear(i uint64)

Clear marks the i-th subnet as not set.

func (*Subnets) DiffSubnets

func (s *Subnets) DiffSubnets(other Subnets) (added Subnets, removed Subnets)

func (*Subnets) HasActive

func (s *Subnets) HasActive() bool

func (*Subnets) IsSet

func (s *Subnets) IsSet(i uint64) bool

IsSet checks if the i-th subnet is set.

func (*Subnets) Set

func (s *Subnets) Set(i uint64)

Set marks the i-th subnet as set.

func (*Subnets) SharedSubnets

func (s *Subnets) SharedSubnets(other Subnets) []uint64

SharedSubnets returns the shared subnets

func (*Subnets) SharedSubnetsN

func (s *Subnets) SharedSubnetsN(other Subnets, n int) []uint64

func (*Subnets) String

func (s *Subnets) String() string

String returns subnets as a hex-encoded string. DEPRECATED, use StringHex or StringHumanReadable instead, this method is preserved for backward-compatibility since it's used for some p2p-message encoding/decoding.

func (*Subnets) StringHex

func (s *Subnets) StringHex() string

StringHex returns subnets as a hex-encoded string.

func (*Subnets) StringHumanReadable

func (s *Subnets) StringHumanReadable() string

StringHumanReadable returns human-readable subnets representation.

func (*Subnets) SubnetList

func (s *Subnets) SubnetList() []uint64

SubnetList returns a list of subnets; Each subnet in that list is a number in the range [0, SubnetsCount).

func (*Subnets) ToMap

func (s *Subnets) ToMap() map[uint64]bool

ToMap returns a map with all subnets and their values

Jump to

Keyboard shortcuts

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