uploadselection

package
v1.83.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package uploadselection implements node selection logic for uploads.

Index

Constants

This section is empty.

Variables

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")
)

Functions

func ContainsID

func ContainsID(ids []storj.NodeID, id storj.NodeID) bool

ContainsID returns whether ids contain id.

Types

type Criteria added in v1.42.2

type Criteria struct {
	ExcludeNodeIDs       []storj.NodeID
	AutoExcludeSubnets   map[string]struct{} // initialize it with empty map to keep only one node per subnet.
	Placement            storj.PlacementConstraint
	ExcludedCountryCodes []location.CountryCode
}

Criteria to filter nodes.

func (*Criteria) MatchInclude added in v1.42.2

func (c *Criteria) MatchInclude(node *SelectedNode) bool

MatchInclude returns with true if node is selected.

type NodeTag added in v1.83.2

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.83.2

type NodeTags []NodeTag

NodeTags is a collection of multiple NodeTag.

func (NodeTags) FindBySignerAndName added in v1.83.2

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
	ExcludedIDs          []storj.NodeID
	Placement            storj.PlacementConstraint
	ExcludedCountryCodes []string
}

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, criteria Criteria) []*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, criteria Criteria) []*SelectedNode

Select selects upto n nodes.

type SelectedNode added in v1.83.2

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

SelectedNode is used as a result for creating orders limits.

func (*SelectedNode) Clone added in v1.83.2

func (node *SelectedNode) Clone() *SelectedNode

Clone returns a deep clone of the selected node.

type Selector

type Selector interface {
	// Count returns the number of maximum number of nodes that it can return.
	Count() int
	// Select selects up-to n nodes which are included by the criteria.
	// empty criteria includes all the nodes
	Select(n int, criteria Criteria) []*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) Select

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

Select selects requestedCount nodes where there will be newFraction nodes.

func (*State) Stats

func (state *State) Stats() Stats

Stats returns state information.

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.

Jump to

Keyboard shortcuts

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