2019-08-08 14:47:04 +01:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package reputation
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
2019-12-27 11:48:47 +00:00
|
|
|
"storj.io/common/storj"
|
2019-08-08 14:47:04 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// DB works with reputation database
|
2019-09-10 14:24:16 +01:00
|
|
|
//
|
|
|
|
// architecture: Database
|
2019-08-08 14:47:04 +01:00
|
|
|
type DB interface {
|
|
|
|
// Store inserts or updates reputation stats into the DB
|
|
|
|
Store(ctx context.Context, stats Stats) error
|
|
|
|
// Get retrieves stats for specific satellite
|
|
|
|
Get(ctx context.Context, satelliteID storj.NodeID) (*Stats, error)
|
2019-08-28 21:54:12 +01:00
|
|
|
// All retrieves all stats from DB
|
|
|
|
All(ctx context.Context) ([]Stats, error)
|
2019-08-08 14:47:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Stats consist of reputation metrics
|
|
|
|
type Stats struct {
|
|
|
|
SatelliteID storj.NodeID
|
|
|
|
|
|
|
|
Uptime Metric
|
|
|
|
Audit Metric
|
|
|
|
|
2019-08-28 21:54:12 +01:00
|
|
|
Disqualified *time.Time
|
2020-03-27 18:50:57 +00:00
|
|
|
Suspended *time.Time
|
2019-08-28 21:54:12 +01:00
|
|
|
|
2019-08-08 14:47:04 +01:00
|
|
|
UpdatedAt time.Time
|
2020-04-16 16:40:28 +01:00
|
|
|
JoinedAt time.Time
|
2019-08-08 14:47:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Metric encapsulates storagenode reputation metrics
|
|
|
|
type Metric struct {
|
2019-08-14 13:17:11 +01:00
|
|
|
TotalCount int64 `json:"totalCount"`
|
|
|
|
SuccessCount int64 `json:"successCount"`
|
2019-08-08 14:47:04 +01:00
|
|
|
|
2019-08-14 13:17:11 +01:00
|
|
|
Alpha float64 `json:"alpha"`
|
|
|
|
Beta float64 `json:"beta"`
|
|
|
|
Score float64 `json:"score"`
|
2019-08-08 14:47:04 +01:00
|
|
|
}
|