Documentation ¶
Overview ¶
Package uploadselection implements node selection logic for uploads.
Index ¶
- Variables
- type AutoExcludeSubnets
- type CountryCodeExclude
- type CountryFilter
- type ExcludeAllFilter
- type ExcludedIDs
- type ExcludedNetworks
- type NodeFilter
- type NodeFilterFunc
- type NodeFilters
- type NodeTag
- type NodeTags
- type Request
- type SelectByID
- type SelectBySubnet
- type SelectedNode
- type Selector
- type State
- type Stats
- type Subnet
- type TagFilter
Constants ¶
This section is empty.
Variables ¶
var EeaCountries = EuCountries.With( location.Iceland, location.Liechtenstein, location.Norway, )
EeaCountries defined the EEA countries.
var ErrNotEnoughNodes = errs.Class("not enough nodes")
ErrNotEnoughNodes is when selecting nodes failed with the given parameters.
var ( // Error represents an uploadselection error. Error = errs.Class("uploadselection") )
var EuCountries = location.NewSet( location.Austria, location.Belgium, location.Bulgaria, location.Croatia, location.Cyprus, location.Czechia, location.Denmark, location.Estonia, location.Finland, location.France, location.Germany, location.Greece, location.Hungary, location.Ireland, location.Italy, location.Lithuania, location.Latvia, location.Luxembourg, location.Malta, location.Netherlands, location.Poland, location.Portugal, location.Romania, location.Slovenia, location.Slovakia, location.Spain, location.Sweden, )
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 CountryCodeExclude ¶ added in v1.84.1
type CountryCodeExclude []location.CountryCode
CountryCodeExclude is a specific CountryFilter which excludes all nodes with the given country code.
func (CountryCodeExclude) MatchInclude ¶ added in v1.84.1
func (c CountryCodeExclude) 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
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.
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 { // 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, 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.
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
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.