-
Notifications
You must be signed in to change notification settings - Fork 390
/
reputation.go
45 lines (35 loc) · 964 Bytes
/
reputation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package reputation
import (
"context"
"time"
"storj.io/storj/pkg/storj"
)
// DB works with reputation database
//
// architecture: Database
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)
// All retrieves all stats from DB
All(ctx context.Context) ([]Stats, error)
}
// Stats consist of reputation metrics
type Stats struct {
SatelliteID storj.NodeID
Uptime Metric
Audit Metric
Disqualified *time.Time
UpdatedAt time.Time
}
// Metric encapsulates storagenode reputation metrics
type Metric struct {
TotalCount int64 `json:"totalCount"`
SuccessCount int64 `json:"successCount"`
Alpha float64 `json:"alpha"`
Beta float64 `json:"beta"`
Score float64 `json:"score"`
}