address

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const (
	FullNode = iota
	BootNode
)
View Source
const (
	EQ = "eq"
	NE = "ne"
)
View Source
const (
	GT = "gt"
	Ge = "ge"
	IT = "it"
	LE = "le"
	IN = "in"
)
View Source
const (
	CN = "cn"
	NC = "nc"
	HP = "hp"
	HS = "hs"
)
View Source
const (
	ASC  = "asc"
	DESC = "desc"
)
View Source
const RelayPrefixHttp = "/group/http"

Variables

View Source
var ErrInvalidAddress = errors.New("invalid address")
View Source
var ErrInvalidNodeMode = errors.New("invalid node mode")

Functions

This section is empty.

Types

type Address

type Address struct {
	Underlay  ma.Multiaddr
	Overlay   boson.Address
	Signature []byte
}

Address represents the address in boson. 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 boson.Address, networkID uint64) (*Address, error)

func ParseAddress

func ParseAddress(underlay, overlay, signature []byte, 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 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 AddressInfo

type AddressInfo struct {
	Address  *Address
	NodeMode Model
}

AddressInfo contains the information received from the handshake.

func (*AddressInfo) LightString

func (i *AddressInfo) LightString() string

type ApiBody

type ApiBody struct {
	Page   ApiPage     `json:"page"`
	Sort   ApiSort     `json:"sort"`
	Filter []ApiFilter `json:"filter"`
}

type ApiFilter

type ApiFilter struct {
	Key   string `json:"key"`
	Term  string `json:"term"`
	Value string `json:"value"`
}

type ApiPage

type ApiPage struct {
	PageSize int `json:"pageSize"`
	PageNum  int `json:"pageNum"`
}

type ApiSort

type ApiSort struct {
	Key   string `json:"key"`
	Order string `json:"order"`
}

type BitVectorApi

type BitVectorApi struct {
	Len int    `json:"len"`
	B   []byte `json:"b"`
}

type ChunkInfoOverlay

type ChunkInfoOverlay struct {
	Overlay string       `json:"overlay"`
	Bit     BitVectorApi `json:"bit"`
}

type ChunkInfoSourceApi

type ChunkInfoSourceApi struct {
	PyramidSource string           `json:"pyramidSource"`
	ChunkSource   []ChunkSourceApi `json:"chunkSource"`
}

type ChunkSourceApi

type ChunkSourceApi struct {
	Overlay  string       `json:"overlay"`
	ChunkBit BitVectorApi `json:"chunkBit"`
}

type FileInfo

type FileInfo struct {
	TreeSize  int          `json:"treeSize"`
	FileSize  int          `json:"fileSize"`
	Bitvector BitVectorApi `json:"bitvector"`
	PinState  bool         `json:"pinState"`
}

type Model

type Model struct {
	Bv *bitvector.BitVector
}

func NewModel

func NewModel() Model

func NewModelFromBytes

func NewModelFromBytes(m []byte) (Model, error)

func (Model) IsBootNode

func (m Model) IsBootNode() bool

func (Model) IsFull

func (m Model) IsFull() bool

func (Model) SetMode

func (m Model) SetMode(md int) Model

func (Model) String

func (m Model) String() string

type Paging

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

func NewPaging

func NewPaging(logger logging.Logger, page, limit int, sort string, order string) *Paging

func (*Paging) Page

func (pg *Paging) Page(list []map[string]interface{}) []map[string]interface{}

func (*Paging) PageSort

func (pg *Paging) PageSort(list []map[string]interface{}, sortName, sortType string) (newList []map[string]interface{})

func (*Paging) ResponseFilter

func (pg *Paging) ResponseFilter(list []map[string]interface{}, filterTerm []ApiFilter) (newList []map[string]interface{})

Jump to

Keyboard shortcuts

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