p2p

package
v0.0.0-...-25e1a75 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const IDByteLength = crypto.AddressSize

IDByteLength is the length of a crypto.Address. Currently only 20. TODO: support other length addresses ?

Variables

This section is empty.

Functions

func IDAddressString

func IDAddressString(id ID, protocolHostPort string) string

Types

type DefaultNodeInfo

type DefaultNodeInfo struct {
	DefaultNodeID ID     `json:"id"`
	ListenAddr    string `json:"listen_addr"`
	Network       string `json:"network"`
}

func NewDefaultNodeInfo

func NewDefaultNodeInfo(id, addr, network string) DefaultNodeInfo

func (DefaultNodeInfo) CompatibleWith

func (s DefaultNodeInfo) CompatibleWith(otherInfo NodeInfo) error

func (DefaultNodeInfo) ID

func (s DefaultNodeInfo) ID() ID

func (DefaultNodeInfo) NetAddress

func (s DefaultNodeInfo) NetAddress() (*NetAddress, error)

func (DefaultNodeInfo) Validate

func (s DefaultNodeInfo) Validate() error

type ErrCurrentlyDialingOrExistingAddress

type ErrCurrentlyDialingOrExistingAddress struct {
	Addr string
}

ErrCurrentlyDialingOrExistingAddress indicates that we're currently dialing this address or it belongs to an existing peer.

func (ErrCurrentlyDialingOrExistingAddress) Error

type ErrFilterTimeout

type ErrFilterTimeout struct{}

ErrFilterTimeout indicates that a filter operation timed out.

func (ErrFilterTimeout) Error

func (e ErrFilterTimeout) Error() string

type ErrNetAddressInvalid

type ErrNetAddressInvalid struct {
	Addr string
	Err  error
}

func (ErrNetAddressInvalid) Error

func (e ErrNetAddressInvalid) Error() string

type ErrNetAddressLookup

type ErrNetAddressLookup struct {
	Addr string
	Err  error
}

func (ErrNetAddressLookup) Error

func (e ErrNetAddressLookup) Error() string

type ErrNetAddressNoID

type ErrNetAddressNoID struct {
	Addr string
}

func (ErrNetAddressNoID) Error

func (e ErrNetAddressNoID) Error() string

type ErrRejected

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

ErrRejected indicates that a Peer was rejected carrying additional information as to the reason.

func (ErrRejected) Addr

func (e ErrRejected) Addr() NetAddress

Addr returns the NetAddress for the rejected Peer.

func (ErrRejected) Error

func (e ErrRejected) Error() string

func (ErrRejected) IsAuthFailure

func (e ErrRejected) IsAuthFailure() bool

IsAuthFailure when Peer authentication was unsuccessful.

func (ErrRejected) IsDuplicate

func (e ErrRejected) IsDuplicate() bool

IsDuplicate when Peer ID or IP are present already.

func (ErrRejected) IsFiltered

func (e ErrRejected) IsFiltered() bool

IsFiltered when Peer ID or IP was filtered.

func (ErrRejected) IsIncompatible

func (e ErrRejected) IsIncompatible() bool

IsIncompatible when Peer NodeInfo is not compatible with our own.

func (ErrRejected) IsNodeInfoInvalid

func (e ErrRejected) IsNodeInfoInvalid() bool

IsNodeInfoInvalid when the sent NodeInfo is not valid.

func (ErrRejected) IsSelf

func (e ErrRejected) IsSelf() bool

IsSelf when Peer is our own node.

type ErrSwitchAuthenticationFailure

type ErrSwitchAuthenticationFailure struct {
	Dialed *NetAddress
	Got    ID
}

func (ErrSwitchAuthenticationFailure) Error

type ErrSwitchConnectToSelf

type ErrSwitchConnectToSelf struct {
	Addr *NetAddress
}

ErrSwitchConnectToSelf to be raised when trying to connect to itself.

func (ErrSwitchConnectToSelf) Error

func (e ErrSwitchConnectToSelf) Error() string

type ErrSwitchDuplicatePeerID

type ErrSwitchDuplicatePeerID struct {
	ID ID
}

ErrSwitchDuplicatePeerID to be raised when a peer is connecting with a known ID.

func (ErrSwitchDuplicatePeerID) Error

func (e ErrSwitchDuplicatePeerID) Error() string

type ErrSwitchDuplicatePeerIP

type ErrSwitchDuplicatePeerIP struct {
	IP net.IP
}

ErrSwitchDuplicatePeerIP to be raised whena a peer is connecting with a known IP.

func (ErrSwitchDuplicatePeerIP) Error

func (e ErrSwitchDuplicatePeerIP) Error() string

type ErrTransportClosed

type ErrTransportClosed struct{}

ErrTransportClosed is raised when the Transport has been closed.

func (ErrTransportClosed) Error

func (e ErrTransportClosed) Error() string

type ID

type ID string

ID is a hex-encoded crypto.Address

func PubKeyToID

func PubKeyToID(pubKey crypto.PubKey) ID

PubKeyToID returns the ID corresponding to the given PubKey. It's the hex-encoding of the pubKey.Address().

type NetAddress

type NetAddress struct {
	ID   ID     `json:"id"`
	IP   net.IP `json:"ip"`
	Port uint16 `json:"port"`
}

func NewNetAddressIPPort

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

func NewNetAddressString

func NewNetAddressString(addr string) (*NetAddress, error)

type NodeInfo

type NodeInfo interface {
	ID() ID
	// contains filtered or unexported methods
}

type NodeKey

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

NodeKey is the persistent peer key. It contains the nodes private key for authentication.

func (*NodeKey) ID

func (nodeKey *NodeKey) ID() ID

ID returns the peer's canonical ID - the hash of its public key.

func (*NodeKey) PubKey

func (nodeKey *NodeKey) PubKey() crypto.PubKey

PubKey returns the peer's PubKey

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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