9abf191b01
* Wiring up DumpNodes response for Inspector * Finalize everything and test that it works * Get Count and DumpNodes working for Overlay Cache * WIP updating payment rollup to check statDB instead of overlay * FIrst pass at updating statDB to take wallet and email * Passing tests * use pb.NodeOperator instead of Meta struct * remove TODO * revert go.mod * Get SQL migration working correctly * Changes Meta to Operator in NodeStats struct * Adds update operator logic for statDB * Fix db migrate tests - added v5 snapshot * User friendly msg for missing snapshot version * Passing tests * Change node update to happen in discovery instead of in overlay * Fix logic and update function calls * Update comment on UpdateOperator interface method * Update name of parameter * Change type of argument to UpdateOperator * Updates statDB tests
60 lines
2.2 KiB
Go
60 lines
2.2 KiB
Go
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package statdb
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zeebo/errs"
|
|
|
|
"storj.io/storj/pkg/pb"
|
|
"storj.io/storj/pkg/storj"
|
|
)
|
|
|
|
var (
|
|
// Error is the default errs class
|
|
Error = errs.Class("statdb error")
|
|
)
|
|
|
|
// DB stores node statistics
|
|
type DB interface {
|
|
// Create adds a new stats entry for node.
|
|
Create(ctx context.Context, nodeID storj.NodeID, initial *NodeStats) (stats *NodeStats, err error)
|
|
// Get returns node stats.
|
|
Get(ctx context.Context, nodeID storj.NodeID) (stats *NodeStats, err error)
|
|
// FindInvalidNodes finds a subset of storagenodes that have stats below provided reputation requirements.
|
|
FindInvalidNodes(ctx context.Context, nodeIDs storj.NodeIDList, maxStats *NodeStats) (invalid storj.NodeIDList, err error)
|
|
// Update all parts of single storagenode's stats.
|
|
Update(ctx context.Context, request *UpdateRequest) (stats *NodeStats, err error)
|
|
// UpdateOperator updates the email and wallet for a given node ID for satellite payments.
|
|
UpdateOperator(ctx context.Context, node storj.NodeID, updatedOperator pb.NodeOperator) (stats *NodeStats, err error)
|
|
// UpdateUptime updates a single storagenode's uptime stats.
|
|
UpdateUptime(ctx context.Context, nodeID storj.NodeID, isUp bool) (stats *NodeStats, err error)
|
|
// UpdateAuditSuccess updates a single storagenode's audit stats.
|
|
UpdateAuditSuccess(ctx context.Context, nodeID storj.NodeID, auditSuccess bool) (stats *NodeStats, err error)
|
|
// UpdateBatch for updating multiple storage nodes' stats.
|
|
UpdateBatch(ctx context.Context, requests []*UpdateRequest) (statslist []*NodeStats, failed []*UpdateRequest, err error)
|
|
// CreateEntryIfNotExists creates a node stats entry if it didn't already exist.
|
|
CreateEntryIfNotExists(ctx context.Context, nodeID storj.NodeID) (stats *NodeStats, err error)
|
|
}
|
|
|
|
// UpdateRequest is used to update a node status.
|
|
type UpdateRequest struct {
|
|
NodeID storj.NodeID
|
|
AuditSuccess bool
|
|
IsUp bool
|
|
}
|
|
|
|
// NodeStats contains statistics abot a node.
|
|
type NodeStats struct {
|
|
NodeID storj.NodeID
|
|
AuditSuccessRatio float64
|
|
AuditSuccessCount int64
|
|
AuditCount int64
|
|
UptimeRatio float64
|
|
UptimeSuccessCount int64
|
|
UptimeCount int64
|
|
Operator pb.NodeOperator
|
|
}
|