address

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package mop exposes the data structure and operations necessary on the mop.Address type which used in the handshake protocol, address-book and hive protocol.

Package address provides persisted mapping between overlay (topology) address and mop.Address address, which contains underlay (physical) address. The underlay address contains both physical and p2p addresses.

It is single point of truth about known peers and relations of their overlay and underlay addresses.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidAddress = errors.New("invalid address")
View Source
var ErrNotFound = errors.New("address: not found")

Functions

This section is empty.

Types

type Address

type Address struct {
	Underlay    ma.Multiaddr
	Overlay     cluster.Address
	Signature   []byte
	Transaction []byte
	BSCAddress  []byte
}

Address represents the mop address in cluster. It consists of a peers underlay (physical) address, overlay (topology) address and signature. Signature is used to verify the `Overlay/Underlay` pair, as it is based on `underlay|networkID`, signed with the public key of Overlay address

func NewAddress

func NewAddress(signer crypto.Signer, underlay ma.Multiaddr, overlay cluster.Address, networkID uint64, trx []byte) (*Address, error)

func ParseAddress

func ParseAddress(underlay, overlay, signature, nonce []byte, validateOverlay bool, networkID uint64) (*Address, error)

func (*Address) Equal

func (a *Address) Equal(b *Address) bool

func (*Address) MarshalJSON

func (a *Address) MarshalJSON() ([]byte, error)

func (*Address) ShortString

func (a *Address) ShortString() string

ShortString returns shortened versions of mop address in a format: [Overlay, Underlay] It can be used for logging

func (*Address) String

func (a *Address) String() string

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(b []byte) error

type GetPutter

type GetPutter interface {
	Getter
	Putter
}

type Getter

type Getter interface {
	// Get returns pointer to saved Address for requested overlay address.
	Get(overlay cluster.Address) (addr *Address, err error)
}

type Interface

type Interface interface {
	GetPutter
	Remover
	// Overlays returns a list of all overlay addresses saved in address.
	Overlays() ([]cluster.Address, error)
	// IterateOverlays exposes overlays in a form of an iterator.
	IterateOverlays(func(cluster.Address) (bool, error)) error
	// Addresses returns a list of all Address-es saved in address.
	Addresses() ([]Address, error)
}

Interface is the AddressBook interface.

func New

func New(storer storage.StateStorer) Interface

New creates new address for state storer.

type Putter

type Putter interface {
	// Put saves relation between peer overlay address and Address address.
	Put(overlay cluster.Address, addr Address) (err error)
}

type Remover

type Remover interface {
	// Remove removes overlay address.
	Remove(overlay cluster.Address) error
}

Jump to

Keyboard shortcuts

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