types

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: Apache-2.0, UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxNodeInfoSize = int64(10240) // 10KB

)

Variables

View Source
var (
	ErrInvalidTCPAddress = errors.New("invalid TCP address")
	ErrUnsetIPAddress    = errors.New("unset IP address")
	ErrInvalidIP         = errors.New("invalid IP address")
	ErrUnspecifiedIP     = errors.New("unspecified IP address")
	ErrInvalidNetAddress = errors.New("invalid net address")
	ErrEmptyHost         = errors.New("empty host address")
)
View Source
var (
	ErrInvalidPeerID        = errors.New("invalid peer ID")
	ErrInvalidVersion       = errors.New("invalid node version")
	ErrInvalidMoniker       = errors.New("invalid node moniker")
	ErrInvalidRPCAddress    = errors.New("invalid node RPC address")
	ErrExcessiveChannels    = errors.New("excessive node channels")
	ErrDuplicateChannels    = errors.New("duplicate node channels")
	ErrIncompatibleNetworks = errors.New("incompatible networks")
	ErrNoCommonChannels     = errors.New("no common channels")
)

Functions

func NetAddressString

func NetAddressString(id ID, protocolHostPort string) string

NetAddressString returns id@addr. It strips the leading protocol from protocolHostPort if it exists.

Types

type ID

type ID = crypto.ID

ID represents the cryptographically unique Peer ID

func NewIDFromStrings

func NewIDFromStrings(idStrs []string) ([]ID, []error)

NewIDFromStrings returns an array of ID's build using the provided strings

type NetAddress

type NetAddress struct {
	ID   ID     `json:"id"`   // unique peer identifier (public key address)
	IP   net.IP `json:"ip"`   // the IP part of the dial address
	Port uint16 `json:"port"` // the port part of the dial address
}

NetAddress defines information about a peer on the network including its ID, IP address, and port

func NewNetAddress

func NewNetAddress(id ID, addr net.Addr) (*NetAddress, error)

NewNetAddress returns a new NetAddress using the provided TCP address

func NewNetAddressFromIPPort

func NewNetAddressFromIPPort(ip net.IP, port uint16) *NetAddress

NewNetAddressFromIPPort returns a new NetAddress using the provided IP and port number.

func NewNetAddressFromString

func NewNetAddressFromString(idaddr string) (*NetAddress, error)

NewNetAddressFromString returns a new NetAddress using the provided address in the form of "ID@IP:Port". Also resolves the host if host is not an IP.

func NewNetAddressFromStrings

func NewNetAddressFromStrings(idaddrs []string) ([]*NetAddress, []error)

NewNetAddressFromStrings returns an array of NetAddress'es build using the provided strings.

func (*NetAddress) DialContext

func (na *NetAddress) DialContext(ctx context.Context) (net.Conn, error)

DialContext dials the given NetAddress with a context

func (*NetAddress) DialString

func (na *NetAddress) DialString() string

func (*NetAddress) Equals

func (na *NetAddress) Equals(other NetAddress) bool

Equals reports whether na and other are the same addresses, including their ID, IP, and Port.

func (*NetAddress) Local

func (na *NetAddress) Local() bool

Local returns true if it is a local address.

func (NetAddress) MarshalAmino

func (na NetAddress) MarshalAmino() (string, error)

MarshalAmino stringifies a NetAddress. Needed because (a) IP doesn't encode, and (b) the intend of this type is to serialize to a string anyways.

func (*NetAddress) RFC1918

func (na *NetAddress) RFC1918() bool

func (*NetAddress) RFC3849

func (na *NetAddress) RFC3849() bool

func (*NetAddress) RFC3927

func (na *NetAddress) RFC3927() bool

func (*NetAddress) RFC3964

func (na *NetAddress) RFC3964() bool

func (*NetAddress) RFC4193

func (na *NetAddress) RFC4193() bool

func (*NetAddress) RFC4380

func (na *NetAddress) RFC4380() bool

func (*NetAddress) RFC4843

func (na *NetAddress) RFC4843() bool

func (*NetAddress) RFC4862

func (na *NetAddress) RFC4862() bool

func (*NetAddress) RFC6052

func (na *NetAddress) RFC6052() bool

func (*NetAddress) RFC6145

func (na *NetAddress) RFC6145() bool

func (*NetAddress) Routable

func (na *NetAddress) Routable() bool

Routable returns true if the address is routable.

func (*NetAddress) Same

func (na *NetAddress) Same(other NetAddress) bool

Same returns true is na has the same non-empty ID or DialString as other.

func (*NetAddress) String

func (na *NetAddress) String() string

String representation: <ID>@<IP>:<PORT>

func (*NetAddress) UnmarshalAmino

func (na *NetAddress) UnmarshalAmino(raw string) (err error)

func (*NetAddress) Validate

func (na *NetAddress) Validate() error

Validate validates the NetAddress params

type NodeInfo

type NodeInfo struct {
	// Set of protocol versions
	VersionSet versionset.VersionSet `json:"version_set"`

	// Unique peer identifier
	PeerID ID `json:"id"`

	// Check compatibility.
	// Channels are HexBytes so easier to read as JSON
	Network  string `json:"network"`  // network/chain ID
	Software string `json:"software"` // name of immediate software
	Version  string `json:"version"`  // software major.minor.revision
	Channels []byte `json:"channels"` // channels this node knows about

	// ASCIIText fields
	Moniker string        `json:"moniker"` // arbitrary moniker
	Other   NodeInfoOther `json:"other"`   // other application specific data
}

NodeInfo is the basic node information exchanged between two peers during the Tendermint P2P handshake.

func (NodeInfo) CompatibleWith

func (info NodeInfo) CompatibleWith(other NodeInfo) error

CompatibleWith checks if two NodeInfo are compatible with each other. CONTRACT: two nodes are compatible if the Block version and networks match, and they have at least one channel in common

func (NodeInfo) ID

func (info NodeInfo) ID() ID

ID returns the local node ID

func (NodeInfo) Validate

func (info NodeInfo) Validate() error

Validate checks the self-reported NodeInfo is safe. It returns an error if there are too many Channels, if there are any duplicate Channels, if the ListenAddr is malformed, or if the ListenAddr is a host name that can not be resolved to some IP

type NodeInfoOther

type NodeInfoOther struct {
	TxIndex    string `json:"tx_index"`
	RPCAddress string `json:"rpc_address"`
}

NodeInfoOther is the misc. application specific data

type NodeKey

type NodeKey struct {
	crypto.PrivKey `json:"priv_key"` // our priv key
}

NodeKey is the persistent peer key. It contains the nodes private key for authentication. NOTE: keep in sync with gno.land/cmd/gnoland/secrets.go

func GenerateNodeKey

func GenerateNodeKey() *NodeKey

GenerateNodeKey generates a random node P2P key, based on ed25519

func LoadNodeKey

func LoadNodeKey(path string) (*NodeKey, error)

LoadNodeKey loads the node key from the given path

func LoadOrGenNodeKey

func LoadOrGenNodeKey(path string) (*NodeKey, error)

LoadOrGenNodeKey attempts to load the NodeKey from the given filePath. If the file does not exist, it generates and saves a new NodeKey.

func (NodeKey) ID

func (k NodeKey) ID() ID

ID returns the bech32 representation of the node's public p2p key, with the bech32 prefix

Jump to

Keyboard shortcuts

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