nodeselection

package
v1.85.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: AGPL-3.0 Imports: 10 Imported by: 6

Documentation

Overview

Package uploadselection implements node selection logic for uploads.

Index

Constants

This section is empty.

Variables

EeaCountries defined the EEA countries.

View Source
var ErrNotEnoughNodes = errs.Class("not enough nodes")

ErrNotEnoughNodes is when selecting nodes failed with the given parameters.

View Source
var (

	// Error represents an uploadselection error.
	Error = errs.Class("uploadselection")
)

EuCountries defines the member countries of European Union.

Functions

This section is empty.

Types

type AutoExcludeSubnets added in v1.84.1

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

AutoExcludeSubnets pick at most one node from network.

Stateful!!! should be re-created for each new selection request. It should only be used as the last filter.

func NewAutoExcludeSubnets added in v1.84.1

func NewAutoExcludeSubnets() *AutoExcludeSubnets

NewAutoExcludeSubnets creates an initialized AutoExcludeSubnets.

func (*AutoExcludeSubnets) MatchInclude added in v1.84.1

func (a *AutoExcludeSubnets) MatchInclude(node *SelectedNode) bool

MatchInclude implements NodeFilter interface.

type CountryFilter added in v1.84.1

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

CountryFilter can select nodes based on the condition of the country code.

func (*CountryFilter) MatchInclude added in v1.84.1

func (p *CountryFilter) MatchInclude(node *SelectedNode) bool

MatchInclude implements NodeFilter interface.

type ExcludeAllFilter added in v1.84.1

type ExcludeAllFilter struct{}

ExcludeAllFilter will never select any node.

func (ExcludeAllFilter) MatchInclude added in v1.84.1

func (ExcludeAllFilter) MatchInclude(node *SelectedNode) bool

MatchInclude implements NodeFilter interface.

type ExcludedIDs added in v1.84.1

type ExcludedIDs []storj.NodeID

ExcludedIDs can blacklist NodeIDs.

func (ExcludedIDs) MatchInclude added in v1.84.1

func (e ExcludedIDs) MatchInclude(node *SelectedNode) bool

MatchInclude implements NodeFilter interface.

type ExcludedNetworks added in v1.84.1

type ExcludedNetworks []string

ExcludedNetworks will exclude nodes with specified networks.

func (ExcludedNetworks) MatchInclude added in v1.84.1

func (e ExcludedNetworks) MatchInclude(node *SelectedNode) bool

MatchInclude implements NodeFilter interface.

type NodeFilter added in v1.84.1

type NodeFilter interface {
	MatchInclude(node *SelectedNode) bool
}

NodeFilter can decide if a Node should be part of the selection or not.

func NewCountryFilter added in v1.84.1

func NewCountryFilter(permit location.Set) NodeFilter

NewCountryFilter creates a new CountryFilter.

type NodeFilterFunc added in v1.84.1

type NodeFilterFunc func(node *SelectedNode) bool

NodeFilterFunc is helper to use func as NodeFilter.

func (NodeFilterFunc) MatchInclude added in v1.84.1

func (n NodeFilterFunc) MatchInclude(node *SelectedNode) bool

MatchInclude implements NodeFilter interface.

type NodeFilters added in v1.84.1

type NodeFilters []NodeFilter

NodeFilters is a collection of multiple node filters (all should vote with true).

func (NodeFilters) MatchInclude added in v1.84.1

func (n NodeFilters) MatchInclude(node *SelectedNode) bool

MatchInclude implements NodeFilter interface.

func (NodeFilters) WithAutoExcludeSubnets added in v1.84.1

func (n NodeFilters) WithAutoExcludeSubnets() NodeFilters

WithAutoExcludeSubnets is a helper to create a new filter with additional AutoExcludeSubnets.

func (NodeFilters) WithCountryFilter added in v1.84.1

func (n NodeFilters) WithCountryFilter(permit location.Set) NodeFilters

WithCountryFilter is a helper to create a new filter with additional CountryFilter.

func (NodeFilters) WithExcludedIDs added in v1.84.1

func (n NodeFilters) WithExcludedIDs(ds []storj.NodeID) NodeFilters

WithExcludedIDs is a helper to create a new filter with additional WithExcludedIDs.

type NodeTag added in v1.84.1

type NodeTag struct {
	NodeID   storj.NodeID
	SignedAt time.Time
	Signer   storj.NodeID
	Name     string
	Value    []byte
}

NodeTag is a tag associated with a node (approved by signer).

type NodeTags added in v1.84.1

type NodeTags []NodeTag

NodeTags is a collection of multiple NodeTag.

func (NodeTags) FindBySignerAndName added in v1.84.1

func (n NodeTags) FindBySignerAndName(signer storj.NodeID, name string) (NodeTag, error)

FindBySignerAndName selects first tag with same name / NodeID.

type Request

type Request struct {
	Count       int
	NewFraction float64
	NodeFilters NodeFilters
}

Request contains arguments for State.Request.

type SelectByID

type SelectByID []*SelectedNode

SelectByID implements selection from nodes with every node having equal probability.

func (SelectByID) Count

func (nodes SelectByID) Count() int

Count returns the number of maximum number of nodes that it can return.

func (SelectByID) Select

func (nodes SelectByID) Select(n int, nodeFilter NodeFilter) []*SelectedNode

Select selects upto n nodes.

type SelectBySubnet

type SelectBySubnet []Subnet

SelectBySubnet implements selection from nodes with every subnet having equal probability.

func SelectBySubnetFromNodes

func SelectBySubnetFromNodes(nodes []*SelectedNode) SelectBySubnet

SelectBySubnetFromNodes creates SelectBySubnet selector from nodes.

func (SelectBySubnet) Count

func (subnets SelectBySubnet) Count() int

Count returns the number of maximum number of nodes that it can return.

func (SelectBySubnet) Select

func (subnets SelectBySubnet) Select(n int, filter NodeFilter) []*SelectedNode

Select selects upto n nodes.

type SelectedNode added in v1.84.1

type SelectedNode struct {
	ID          storj.NodeID
	Address     *pb.NodeAddress
	LastNet     string
	LastIPPort  string
	CountryCode location.CountryCode
	Tags        NodeTags
}

SelectedNode is used as a result for creating orders limits.

func (*SelectedNode) Clone added in v1.84.1

func (node *SelectedNode) Clone() *SelectedNode

Clone returns a deep clone of the selected node.

type Selector

type Selector interface {
	// Select selects up-to n nodes which are included by the criteria.
	// empty criteria includes all the nodes
	Select(n int, nodeFilter NodeFilter) []*SelectedNode
}

Selector defines interface for selecting nodes.

type State

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

State defines a node selector state that allows for selection.

func NewState

func NewState(reputableNodes, newNodes []*SelectedNode) *State

NewState returns a state based on the input.

func (*State) ExcludeNetworksBasedOnNodes added in v1.84.1

func (state *State) ExcludeNetworksBasedOnNodes(ds []storj.NodeID) NodeFilter

ExcludeNetworksBasedOnNodes will create a NodeFilter which exclude all nodes which shares subnet with the specified ones.

func (*State) Select

func (state *State) Select(ctx context.Context, request Request) (_ []*SelectedNode, err error)

Select selects requestedCount nodes where there will be newFraction nodes.

type Stats

type Stats struct {
	New       int
	Reputable int
}

Stats contains state information.

type Subnet

type Subnet struct {
	Net   string
	Nodes []*SelectedNode
}

Subnet groups together nodes with the same subnet.

type TagFilter added in v1.84.1

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

TagFilter matches nodes with specific tags.

func NewTagFilter added in v1.84.1

func NewTagFilter(id storj.NodeID, name string, value []byte) TagFilter

NewTagFilter creates a new tag filter.

func (TagFilter) MatchInclude added in v1.84.1

func (t TagFilter) MatchInclude(node *SelectedNode) bool

MatchInclude implements NodeFilter interface.

Jump to

Keyboard shortcuts

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