Documentation ¶
Index ¶
- Constants
- Variables
- func NetAddressString(id ID, protocolHostPort string) string
- type ID
- type NetAddress
- func (na *NetAddress) DialContext(ctx context.Context) (net.Conn, error)
- func (na *NetAddress) DialString() string
- func (na *NetAddress) Equals(other NetAddress) bool
- func (na *NetAddress) Local() bool
- func (na NetAddress) MarshalAmino() (string, error)
- func (na *NetAddress) RFC1918() bool
- func (na *NetAddress) RFC3849() bool
- func (na *NetAddress) RFC3927() bool
- func (na *NetAddress) RFC3964() bool
- func (na *NetAddress) RFC4193() bool
- func (na *NetAddress) RFC4380() bool
- func (na *NetAddress) RFC4843() bool
- func (na *NetAddress) RFC4862() bool
- func (na *NetAddress) RFC6052() bool
- func (na *NetAddress) RFC6145() bool
- func (na *NetAddress) Routable() bool
- func (na *NetAddress) Same(other NetAddress) bool
- func (na *NetAddress) String() string
- func (na *NetAddress) UnmarshalAmino(raw string) (err error)
- func (na *NetAddress) Validate() error
- type NodeInfo
- type NodeInfoOther
- type NodeKey
Constants ¶
const (
MaxNodeInfoSize = int64(10240) // 10KB
)
Variables ¶
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") )
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 ¶
NetAddressString returns id@addr. It strips the leading protocol from protocolHostPort if it exists.
Types ¶
type ID ¶
ID represents the cryptographically unique Peer ID
func NewIDFromStrings ¶
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 ¶
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 ¶
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
type NodeInfoOther ¶
type NodeInfoOther struct { TxIndex string `json:"tx_index"` RPCAddress string `json:"rpc_address"` }
NodeInfoOther is the misc. application specific data
type NodeKey ¶
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 ¶
LoadNodeKey loads the node key from the given path
func LoadOrGenNodeKey ¶
LoadOrGenNodeKey attempts to load the NodeKey from the given filePath. If the file does not exist, it generates and saves a new NodeKey.