overlay

package
v1.58.0-rc Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: AGPL-3.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyNode = errs.New("empty node ID")

ErrEmptyNode is returned when the nodeID is empty.

View Source
var ErrNodeDisqualified = errs.Class("node is disqualified")

ErrNodeDisqualified is returned if a nodes is disqualified.

View Source
var ErrNodeFinishedGE = errs.Class("node finished graceful exit")

ErrNodeFinishedGE is returned if a node has finished graceful exit.

View Source
var ErrNodeNotFound = errs.Class("node not found")

ErrNodeNotFound is returned if a node does not exist in database.

View Source
var ErrNodeOffline = errs.Class("node is offline")

ErrNodeOffline is returned if a nodes is offline.

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 overlay error.
	Error = errs.Class("overlay")
)

Functions

func ResolveIPAndNetwork added in v0.35.2

func ResolveIPAndNetwork(ctx context.Context, target string) (ip net.IP, port, network string, err error)

ResolveIPAndNetwork resolves the target address and determines its IP and /24 subnet IPv4 or /64 subnet IPv6.

Types

type AsOfSystemTimeConfig added in v1.20.1

type AsOfSystemTimeConfig struct {
	Enabled         bool          `help:"enables the use of the AS OF SYSTEM TIME feature in CRDB" default:"true"`
	DefaultInterval time.Duration `help:"default duration for AS OF SYSTEM TIME" devDefault:"-1ms" releaseDefault:"-10s" testDefault:"-1µs"`
}

AsOfSystemTimeConfig is a configuration struct to enable 'AS OF SYSTEM TIME' for CRDB queries.

type Config

type Config struct {
	Node                       NodeSelectionConfig
	NodeSelectionCache         UploadSelectionCacheConfig
	GeoIP                      GeoIPConfig
	UpdateStatsBatchSize       int           `help:"number of update requests to process per transaction" default:"100"`
	NodeCheckInWaitPeriod      time.Duration `` /* 152-byte string literal not displayed */
	RepairExcludedCountryCodes []string      `help:"list of country codes to exclude nodes from target repair selection" default:"" testDefault:"FR,BE"`
}

Config is a configuration for overlay service.

type DB

type DB interface {
	// GetOnlineNodesForGetDelete returns a map of nodes for the supplied nodeIDs
	GetOnlineNodesForGetDelete(ctx context.Context, nodeIDs []storj.NodeID, onlineWindow time.Duration) (map[storj.NodeID]*SelectedNode, error)
	// GetOnlineNodesForAuditRepair returns a map of nodes for the supplied nodeIDs.
	// The return value contains necessary information to create orders as well as nodes'
	// current reputation status.
	GetOnlineNodesForAuditRepair(ctx context.Context, nodeIDs []storj.NodeID, onlineWindow time.Duration) (map[storj.NodeID]*NodeReputation, error)
	// SelectStorageNodes looks up nodes based on criteria
	SelectStorageNodes(ctx context.Context, totalNeededNodes, newNodeCount int, criteria *NodeCriteria) ([]*SelectedNode, error)
	// SelectAllStorageNodesUpload returns all nodes that qualify to store data, organized as reputable nodes and new nodes
	SelectAllStorageNodesUpload(ctx context.Context, selectionCfg NodeSelectionConfig) (reputable, new []*SelectedNode, err error)
	// SelectAllStorageNodesDownload returns a nodes that are ready for downloading
	SelectAllStorageNodesDownload(ctx context.Context, onlineWindow time.Duration, asOf AsOfSystemTimeConfig) ([]*SelectedNode, error)

	// Get looks up the node by nodeID
	Get(ctx context.Context, nodeID storj.NodeID) (*NodeDossier, error)
	// KnownOffline filters a set of nodes to offline nodes
	KnownOffline(context.Context, *NodeCriteria, storj.NodeIDList) (storj.NodeIDList, error)
	// KnownUnreliableOrOffline filters a set of nodes to unhealth or offlines node, independent of new
	KnownUnreliableOrOffline(context.Context, *NodeCriteria, storj.NodeIDList) (storj.NodeIDList, error)
	// KnownReliableInExcludedCountries filters healthy nodes that are in excluded countries.
	KnownReliableInExcludedCountries(context.Context, *NodeCriteria, storj.NodeIDList) (storj.NodeIDList, error)
	// KnownReliable filters a set of nodes to reliable (online and qualified) nodes.
	KnownReliable(ctx context.Context, onlineWindow time.Duration, nodeIDs storj.NodeIDList) ([]*pb.Node, error)
	// Reliable returns all nodes that are reliable
	Reliable(context.Context, *NodeCriteria) (storj.NodeIDList, error)
	// UpdateReputation updates the DB columns for all reputation fields in ReputationStatus.
	UpdateReputation(ctx context.Context, id storj.NodeID, request ReputationUpdate) error
	// UpdateNodeInfo updates node dossier with info requested from the node itself like node type, email, wallet, capacity, and version.
	UpdateNodeInfo(ctx context.Context, node storj.NodeID, nodeInfo *InfoResponse) (stats *NodeDossier, err error)
	// UpdateCheckIn updates a single storagenode's check-in stats.
	UpdateCheckIn(ctx context.Context, node NodeCheckInInfo, timestamp time.Time, config NodeSelectionConfig) (err error)

	// AllPieceCounts returns a map of node IDs to piece counts from the db.
	AllPieceCounts(ctx context.Context) (pieceCounts map[storj.NodeID]int, err error)
	// UpdatePieceCounts sets the piece count field for the given node IDs.
	UpdatePieceCounts(ctx context.Context, pieceCounts map[storj.NodeID]int) (err error)

	// UpdateExitStatus is used to update a node's graceful exit status.
	UpdateExitStatus(ctx context.Context, request *ExitStatusRequest) (_ *NodeDossier, err error)
	// GetExitingNodes returns nodes who have initiated a graceful exit, but have not completed it.
	GetExitingNodes(ctx context.Context) (exitingNodes []*ExitStatus, err error)
	// GetGracefulExitCompletedByTimeFrame returns nodes who have completed graceful exit within a time window (time window is around graceful exit completion).
	GetGracefulExitCompletedByTimeFrame(ctx context.Context, begin, end time.Time) (exitedNodes storj.NodeIDList, err error)
	// GetGracefulExitIncompleteByTimeFrame returns nodes who have initiated, but not completed graceful exit within a time window (time window is around graceful exit initiation).
	GetGracefulExitIncompleteByTimeFrame(ctx context.Context, begin, end time.Time) (exitingNodes storj.NodeIDList, err error)
	// GetExitStatus returns a node's graceful exit status.
	GetExitStatus(ctx context.Context, nodeID storj.NodeID) (exitStatus *ExitStatus, err error)

	// GetNodesNetwork returns the /24 subnet for each storage node, order is not guaranteed.
	GetNodesNetwork(ctx context.Context, nodeIDs []storj.NodeID) (nodeNets []string, err error)

	// DisqualifyNode disqualifies a storage node.
	DisqualifyNode(ctx context.Context, nodeID storj.NodeID, disqualifiedAt time.Time, reason DisqualificationReason) (err error)

	// DQNodesLastSeenBefore disqualifies a limited number of nodes where last_contact_success < cutoff except those already disqualified
	// or gracefully exited or where last_contact_success = '0001-01-01 00:00:00+00'.
	DQNodesLastSeenBefore(ctx context.Context, cutoff time.Time, limit int) (count int, err error)

	// TestSuspendNodeUnknownAudit suspends a storage node for unknown audits.
	TestSuspendNodeUnknownAudit(ctx context.Context, nodeID storj.NodeID, suspendedAt time.Time) (err error)
	// TestUnsuspendNodeUnknownAudit unsuspends a storage node for unknown audits.
	TestUnsuspendNodeUnknownAudit(ctx context.Context, nodeID storj.NodeID) (err error)

	// TestVetNode directly sets a node's vetted_at timestamp to make testing easier
	TestVetNode(ctx context.Context, nodeID storj.NodeID) (vettedTime *time.Time, err error)
	// TestUnvetNode directly sets a node's vetted_at timestamp to null to make testing easier
	TestUnvetNode(ctx context.Context, nodeID storj.NodeID) (err error)
	// TestVetNode directly sets a node's offline_suspended timestamp to make testing easier
	TestSuspendNodeOffline(ctx context.Context, nodeID storj.NodeID, suspendedAt time.Time) (err error)
	// TestNodeCountryCode sets node country code.
	TestNodeCountryCode(ctx context.Context, nodeID storj.NodeID, countryCode string) (err error)

	// IterateAllNodes will call cb on all known nodes (used in restore trash contexts).
	IterateAllNodes(context.Context, func(context.Context, *SelectedNode) error) error
	// IterateAllNodes will call cb on all known nodes (used for invoice generation).
	IterateAllNodeDossiers(context.Context, func(context.Context, *NodeDossier) error) error
}

DB implements the database for overlay.Service.

architecture: Database

type DisqualificationReason added in v1.54.1

type DisqualificationReason int

DisqualificationReason is disqualification reason enum type.

const (
	// DisqualificationReasonUnknown denotes undetermined disqualification reason.
	DisqualificationReasonUnknown DisqualificationReason = 0
	// DisqualificationReasonAuditFailure denotes disqualification due to audit score falling below threshold.
	DisqualificationReasonAuditFailure DisqualificationReason = 1
	// DisqualificationReasonSuspension denotes disqualification due to unknown audit failure after grace period for unknown audits
	// has elapsed.
	DisqualificationReasonSuspension DisqualificationReason = 2
	// DisqualificationReasonNodeOffline denotes disqualification due to node's online score falling below threshold after tracking
	// period has elapsed.
	DisqualificationReasonNodeOffline DisqualificationReason = 3
)

type DownloadSelectionCache added in v1.22.1

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

DownloadSelectionCache keeps a list of all the storage nodes that are qualified to download data from. The cache will sync with the nodes table in the database and get refreshed once the staleness time has past.

func NewDownloadSelectionCache added in v1.22.1

func NewDownloadSelectionCache(log *zap.Logger, db DownloadSelectionDB, config DownloadSelectionCacheConfig) *DownloadSelectionCache

NewDownloadSelectionCache creates a new cache that keeps a list of all the storage nodes that are qualified to download data from.

func (*DownloadSelectionCache) GetNodeIPs added in v1.22.1

func (cache *DownloadSelectionCache) GetNodeIPs(ctx context.Context, nodes []storj.NodeID) (_ map[storj.NodeID]string, err error)

GetNodeIPs gets the last node ip:port from the cache, refreshing when needed.

func (*DownloadSelectionCache) Refresh added in v1.22.1

func (cache *DownloadSelectionCache) Refresh(ctx context.Context) (err error)

Refresh populates the cache with all of the reputableNodes and newNode nodes This method is useful for tests.

func (*DownloadSelectionCache) Size added in v1.22.1

func (cache *DownloadSelectionCache) Size() int

Size returns how many nodes are in the cache.

type DownloadSelectionCacheConfig added in v1.22.1

type DownloadSelectionCacheConfig struct {
	Staleness      time.Duration
	OnlineWindow   time.Duration
	AsOfSystemTime AsOfSystemTimeConfig
}

DownloadSelectionCacheConfig contains configuration for the selection cache.

type DownloadSelectionCacheState added in v1.22.1

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

DownloadSelectionCacheState contains state of download selection cache.

func NewDownloadSelectionCacheState added in v1.22.1

func NewDownloadSelectionCacheState(nodes []*SelectedNode) *DownloadSelectionCacheState

NewDownloadSelectionCacheState creates a new state from the nodes.

func (*DownloadSelectionCacheState) IPs added in v1.22.1

func (state *DownloadSelectionCacheState) IPs(nodes []storj.NodeID) map[storj.NodeID]string

IPs returns node ip:port for nodes that are in state.

func (*DownloadSelectionCacheState) Size added in v1.22.1

func (state *DownloadSelectionCacheState) Size() int

Size returns how many nodes are in the state.

type DownloadSelectionDB added in v1.22.1

type DownloadSelectionDB interface {
	// SelectAllStorageNodesDownload returns nodes that are ready for downloading
	SelectAllStorageNodesDownload(ctx context.Context, onlineWindow time.Duration, asOf AsOfSystemTimeConfig) ([]*SelectedNode, error)
}

DownloadSelectionDB implements the database for download selection cache.

architecture: Database

type ExitStatus added in v0.24.0

type ExitStatus struct {
	NodeID              storj.NodeID
	ExitInitiatedAt     *time.Time
	ExitLoopCompletedAt *time.Time
	ExitFinishedAt      *time.Time
	ExitSuccess         bool
}

ExitStatus is used for reading graceful exit status.

type ExitStatusRequest added in v0.22.0

type ExitStatusRequest struct {
	NodeID              storj.NodeID
	ExitInitiatedAt     time.Time
	ExitLoopCompletedAt time.Time
	ExitFinishedAt      time.Time
	ExitSuccess         bool
}

ExitStatusRequest is used to update a node's graceful exit status.

type FindStorageNodesRequest

type FindStorageNodesRequest struct {
	RequestedCount     int
	ExcludedIDs        []storj.NodeID
	MinimumVersion     string        // semver or empty
	AsOfSystemInterval time.Duration // only used for CRDB queries
	Placement          storj.PlacementConstraint
}

FindStorageNodesRequest defines easy request parameters.

type GeoIPConfig added in v1.44.1

type GeoIPConfig struct {
	DB            string   `help:"the location of the maxmind database containing geoip country information"`
	MockCountries []string `help:"a mock list of countries the satellite will attribute to nodes (useful for testing)"`
}

GeoIPConfig is a configuration struct that helps configure the GeoIP lookup features on the satellite.

type InfoResponse added in v1.7.1

type InfoResponse struct {
	Type     pb.NodeType
	Operator *pb.NodeOperator
	Capacity *pb.NodeCapacity
	Version  *pb.NodeVersion
}

InfoResponse contains node dossier info requested from the storage node.

type NodeCheckInInfo added in v0.21.3

type NodeCheckInInfo struct {
	NodeID      storj.NodeID
	Address     *pb.NodeAddress
	LastNet     string
	LastIPPort  string
	IsUp        bool
	Operator    *pb.NodeOperator
	Capacity    *pb.NodeCapacity
	Version     *pb.NodeVersion
	CountryCode location.CountryCode
}

NodeCheckInInfo contains all the info that will be updated when a node checkins.

type NodeCriteria

type NodeCriteria struct {
	FreeDisk           int64
	ExcludedIDs        []storj.NodeID
	ExcludedNetworks   []string // the /24 subnet IPv4 or /64 subnet IPv6 for nodes
	MinimumVersion     string   // semver or empty
	OnlineWindow       time.Duration
	DistinctIP         bool
	AsOfSystemInterval time.Duration // only used for CRDB queries
	ExcludedCountries  []string
}

NodeCriteria are the requirements for selecting nodes.

type NodeDossier

type NodeDossier struct {
	pb.Node
	Type                   pb.NodeType
	Operator               pb.NodeOperator
	Capacity               pb.NodeCapacity
	Reputation             NodeStats
	Version                pb.NodeVersion
	Contained              bool
	Disqualified           *time.Time
	DisqualificationReason *DisqualificationReason
	UnknownAuditSuspended  *time.Time
	OfflineSuspended       *time.Time
	OfflineUnderReview     *time.Time
	PieceCount             int64
	ExitStatus             ExitStatus
	CreatedAt              time.Time
	LastNet                string
	LastIPPort             string
	CountryCode            location.CountryCode
}

NodeDossier is the complete info that the satellite tracks for a storage node.

type NodeLastContact added in v0.29.0

type NodeLastContact struct {
	URL                storj.NodeURL
	LastIPPort         string
	LastContactSuccess time.Time
	LastContactFailure time.Time
}

NodeLastContact contains the ID, address, and timestamp.

type NodeReputation added in v1.47.3

type NodeReputation struct {
	ID         storj.NodeID
	Address    *pb.NodeAddress
	LastNet    string
	LastIPPort string
	Reputation ReputationStatus
}

NodeReputation is used as a result for creating orders limits for audits.

type NodeSelectionConfig

type NodeSelectionConfig struct {
	NewNodeFraction  float64       `help:"the fraction of new nodes allowed per request" releaseDefault:"0.05" devDefault:"1"`
	MinimumVersion   string        `help:"the minimum node software version for node selection queries" default:""`
	OnlineWindow     time.Duration `help:"the amount of time without seeing a node before its considered offline" default:"4h" testDefault:"1m"`
	DistinctIP       bool          `help:"require distinct IPs when choosing nodes for upload" releaseDefault:"true" devDefault:"false"`
	MinimumDiskSpace memory.Size   `help:"how much disk space a node at minimum must have to be selected for upload" default:"500.00MB" testDefault:"100.00MB"`

	AsOfSystemTime AsOfSystemTimeConfig

	UploadExcludedCountryCodes []string `help:"list of country codes to exclude from node selection for uploads" default:"" testDefault:"FR,BE"`
}

NodeSelectionConfig is a configuration struct to determine the minimum values for nodes to select.

type NodeStats

type NodeStats struct {
	Latency90          int64
	LastContactSuccess time.Time
	LastContactFailure time.Time
	OfflineUnderReview *time.Time
	Status             ReputationStatus
}

NodeStats contains statistics about a node.

type PeerIdentities added in v0.19.0

type PeerIdentities interface {
	// Set adds a peer identity entry for a node
	Set(context.Context, storj.NodeID, *identity.PeerIdentity) error
	// Get gets peer identity
	Get(context.Context, storj.NodeID) (*identity.PeerIdentity, error)
	// BatchGet gets all nodes peer identities in a transaction
	BatchGet(context.Context, storj.NodeIDList) ([]*identity.PeerIdentity, error)
}

PeerIdentities stores storagenode peer identities.

architecture: Database

type ReputationStatus added in v1.34.1

type ReputationStatus struct {
	Disqualified           *time.Time
	DisqualificationReason *DisqualificationReason
	UnknownAuditSuspended  *time.Time
	OfflineSuspended       *time.Time
	VettedAt               *time.Time
}

ReputationStatus indicates current reputation status for a node.

type ReputationUpdate added in v1.54.1

type ReputationUpdate struct {
	Disqualified           *time.Time
	DisqualificationReason DisqualificationReason
	UnknownAuditSuspended  *time.Time
	OfflineSuspended       *time.Time
	VettedAt               *time.Time
}

ReputationUpdate contains reputation update data for a node.

type SelectedNode added in v1.1.1

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

func (node *SelectedNode) Clone() *SelectedNode

Clone returns a deep clone of the selected node.

type Service added in v0.17.0

type Service struct {
	GeoIP                  geoip.IPToCountry
	UploadSelectionCache   *UploadSelectionCache
	DownloadSelectionCache *DownloadSelectionCache
	// contains filtered or unexported fields
}

Service is used to store and handle node information.

architecture: Service

func NewService added in v0.17.0

func NewService(log *zap.Logger, db DB, config Config) (*Service, error)

NewService returns a new Service.

func (*Service) Close added in v0.17.0

func (service *Service) Close() error

Close closes resources.

func (*Service) DisqualifyNode added in v0.29.0

func (service *Service) DisqualifyNode(ctx context.Context, nodeID storj.NodeID, reason DisqualificationReason) (err error)

DisqualifyNode disqualifies a storage node.

func (*Service) FindStorageNodesForGracefulExit added in v1.4.1

func (service *Service) FindStorageNodesForGracefulExit(ctx context.Context, req FindStorageNodesRequest) (_ []*SelectedNode, err error)

FindStorageNodesForGracefulExit searches the overlay network for nodes that meet the provided requirements for graceful-exit requests.

func (*Service) FindStorageNodesForUpload added in v1.4.1

func (service *Service) FindStorageNodesForUpload(ctx context.Context, req FindStorageNodesRequest) (_ []*SelectedNode, err error)

FindStorageNodesForUpload searches the overlay network for nodes that meet the provided requirements for upload.

When enabled it uses the cache to select nodes. When the node selection from the cache fails, it falls back to the old implementation.

func (*Service) FindStorageNodesWithPreferences added in v0.17.0

func (service *Service) FindStorageNodesWithPreferences(ctx context.Context, req FindStorageNodesRequest, preferences *NodeSelectionConfig) (nodes []*SelectedNode, err error)

FindStorageNodesWithPreferences searches the overlay network for nodes that meet the provided criteria.

This does not use a cache.

func (*Service) Get added in v0.17.0

func (service *Service) Get(ctx context.Context, nodeID storj.NodeID) (_ *NodeDossier, err error)

Get looks up the provided nodeID from the overlay.

func (*Service) GetMissingPieces added in v0.17.0

func (service *Service) GetMissingPieces(ctx context.Context, pieces metabase.Pieces) (missingPieces []uint16, err error)

GetMissingPieces returns the list of offline nodes and the corresponding pieces.

func (*Service) GetNodeIPs added in v1.21.1

func (service *Service) GetNodeIPs(ctx context.Context, nodeIDs []storj.NodeID) (_ map[storj.NodeID]string, err error)

GetNodeIPs returns a map of node ip:port for the supplied nodeIDs.

func (*Service) GetOnlineNodesForAuditRepair added in v1.47.3

func (service *Service) GetOnlineNodesForAuditRepair(ctx context.Context, nodeIDs []storj.NodeID) (_ map[storj.NodeID]*NodeReputation, err error)

GetOnlineNodesForAuditRepair returns a map of nodes for the supplied nodeIDs.

func (*Service) GetOnlineNodesForGetDelete added in v1.1.1

func (service *Service) GetOnlineNodesForGetDelete(ctx context.Context, nodeIDs []storj.NodeID) (_ map[storj.NodeID]*SelectedNode, err error)

GetOnlineNodesForGetDelete returns a map of nodes for the supplied nodeIDs.

func (*Service) GetReliablePiecesInExcludedCountries added in v1.50.2

func (service *Service) GetReliablePiecesInExcludedCountries(ctx context.Context, pieces metabase.Pieces) (piecesInExcluded []uint16, err error)

GetReliablePiecesInExcludedCountries returns the list of pieces held by nodes located in excluded countries.

func (*Service) IsOnline added in v0.17.0

func (service *Service) IsOnline(node *NodeDossier) bool

IsOnline checks if a node is 'online' based on the collected statistics.

func (*Service) KnownOffline added in v0.17.0

func (service *Service) KnownOffline(ctx context.Context, nodeIds storj.NodeIDList) (offlineNodes storj.NodeIDList, err error)

KnownOffline filters a set of nodes to offline nodes.

func (*Service) KnownReliable added in v0.29.0

func (service *Service) KnownReliable(ctx context.Context, nodeIDs storj.NodeIDList) (nodes []*pb.Node, err error)

KnownReliable filters a set of nodes to reliable (online and qualified) nodes.

func (*Service) KnownReliableInExcludedCountries added in v1.50.2

func (service *Service) KnownReliableInExcludedCountries(ctx context.Context, nodeIds storj.NodeIDList) (reliableInExcluded storj.NodeIDList, err error)

KnownReliableInExcludedCountries filters healthy nodes that are in excluded countries.

func (*Service) KnownUnreliableOrOffline added in v0.17.0

func (service *Service) KnownUnreliableOrOffline(ctx context.Context, nodeIds storj.NodeIDList) (badNodes storj.NodeIDList, err error)

KnownUnreliableOrOffline filters a set of nodes to unhealth or offlines node, independent of new.

func (*Service) Reliable added in v0.17.0

func (service *Service) Reliable(ctx context.Context) (nodes storj.NodeIDList, err error)

Reliable filters a set of nodes that are reliable, independent of new.

func (*Service) TestNodeCountryCode added in v1.50.1

func (service *Service) TestNodeCountryCode(ctx context.Context, nodeID storj.NodeID, countryCode string) (err error)

TestNodeCountryCode directly sets a node's vetted_at timestamp to null to make testing easier.

func (*Service) TestUnvetNode added in v1.13.1

func (service *Service) TestUnvetNode(ctx context.Context, nodeID storj.NodeID) (err error)

TestUnvetNode directly sets a node's vetted_at timestamp to null to make testing easier.

func (*Service) TestVetNode added in v1.13.1

func (service *Service) TestVetNode(ctx context.Context, nodeID storj.NodeID) (vettedTime *time.Time, err error)

TestVetNode directly sets a node's vetted_at timestamp to make testing easier.

func (*Service) UpdateCheckIn added in v0.21.3

func (service *Service) UpdateCheckIn(ctx context.Context, node NodeCheckInInfo, timestamp time.Time) (err error)

UpdateCheckIn updates a single storagenode's check-in info if needed.

The check-in info is updated in the database if:

(1) there is no previous entry;
(2) it has been too long since the last known entry; or
(3) the node hostname, IP address, port, wallet, sw version, or disk capacity
has changed.

Note that there can be a race between acquiring the previous entry and performing the update, so if two updates happen at about the same time it is not defined which one will end up in the database.

func (*Service) UpdateNodeInfo added in v0.17.0

func (service *Service) UpdateNodeInfo(ctx context.Context, node storj.NodeID, nodeInfo *InfoResponse) (stats *NodeDossier, err error)

UpdateNodeInfo updates node dossier with info requested from the node itself like node type, email, wallet, capacity, and version.

func (*Service) UpdateReputation added in v1.34.1

func (service *Service) UpdateReputation(ctx context.Context, id storj.NodeID, request ReputationUpdate) (err error)

UpdateReputation updates the DB columns for any of the reputation fields.

type UploadSelectionCache added in v1.22.1

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

UploadSelectionCache keeps a list of all the storage nodes that are qualified to store data We organize the nodes by if they are reputable or a new node on the network. The cache will sync with the nodes table in the database and get refreshed once the staleness time has past.

func NewUploadSelectionCache added in v1.22.1

func NewUploadSelectionCache(log *zap.Logger, db UploadSelectionDB, staleness time.Duration, config NodeSelectionConfig) *UploadSelectionCache

NewUploadSelectionCache creates a new cache that keeps a list of all the storage nodes that are qualified to store data.

func (*UploadSelectionCache) GetNodes added in v1.22.1

func (cache *UploadSelectionCache) GetNodes(ctx context.Context, req FindStorageNodesRequest) (_ []*SelectedNode, err error)

GetNodes selects nodes from the cache that will be used to upload a file. Every node selected will be from a distinct network. If the cache hasn't been refreshed recently it will do so first.

func (*UploadSelectionCache) Refresh added in v1.22.1

func (cache *UploadSelectionCache) Refresh(ctx context.Context) (err error)

Refresh populates the cache with all of the reputableNodes and newNode nodes This method is useful for tests.

func (*UploadSelectionCache) Size added in v1.22.1

func (cache *UploadSelectionCache) Size() (reputableNodeCount int, newNodeCount int)

Size returns how many reputable nodes and new nodes are in the cache.

type UploadSelectionCacheConfig added in v1.22.1

type UploadSelectionCacheConfig struct {
	Disabled  bool          `help:"disable node cache" default:"false"`
	Staleness time.Duration `help:"how stale the node selection cache can be" releaseDefault:"3m" devDefault:"5m" testDefault:"3m"`
}

UploadSelectionCacheConfig is a configuration for upload selection cache.

type UploadSelectionDB added in v1.22.1

type UploadSelectionDB interface {
	// SelectAllStorageNodesUpload returns all nodes that qualify to store data, organized as reputable nodes and new nodes
	SelectAllStorageNodesUpload(ctx context.Context, selectionCfg NodeSelectionConfig) (reputable, new []*SelectedNode, err error)
}

UploadSelectionDB implements the database for upload selection cache.

architecture: Database

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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