storagehosttree

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2020 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	IPv4PrefixLength = 24
)

IPV4 Prefix Length of the IP network

Variables

View Source
var (
	ErrHostExists         = errors.New("storage host existed in the tree already")
	ErrHostNotExists      = errors.New("storage host cannot be found from the tree")
	ErrEvaluationTooLarge = errors.New("provided evaluation must be less than the total evaluation of the tree")
	ErrNodeNotOccupied    = errors.New("node returned is not occupied")
)

Definition of common error messages

Functions

func IPNetwork

func IPNetwork(ip string) (ipnet *net.IPNet, err error)

IPNetwork will return the IP network used by an IP address

Types

type Filter

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

Filter defines IP filter map. For any IP addresses with same IP Network will be marked and filter needed. IP address can be extracted from the enode information

func NewFilter

func NewFilter() *Filter

NewFilter will create and initialize a Filter object

func (*Filter) Add

func (f *Filter) Add(ip string)

Add will add the IP Network of the IP address in to the filter

func (*Filter) Filtered

func (f *Filter) Filtered(ip string) bool

Filtered will check if an IP address uses a IP Network that is already in used return true indicates the IP Network is in use

func (*Filter) Reset

func (f *Filter) Reset()

Reset will clear the filter

type StorageHostTree

type StorageHostTree interface {
	Insert(hi storage.HostInfo, eval int64) error
	HostInfoUpdate(hi storage.HostInfo, eval int64) error
	Remove(enodeID enode.ID) error
	All() []storage.HostInfo
	RetrieveHostInfo(enodeID enode.ID) (storage.HostInfo, bool)
	RetrieveHostEval(enodeID enode.ID) (int64, bool)
	SelectRandom(needed int, blacklist, addrBlacklist []enode.ID) []storage.HostInfo
}

StorageHostTree is the interface for storageHostTree which stores the host info in a tree structure

func New

func New() StorageHostTree

New will initialize the StorageHostTree object

Jump to

Keyboard shortcuts

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