-
Notifications
You must be signed in to change notification settings - Fork 402
/
db.go
36 lines (29 loc) · 1.28 KB
/
db.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
// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
package compensation
import (
"context"
"storj.io/common/storj"
"storj.io/storj/private/currency"
)
// TotalAmounts holds the amounts held and disposed.
//
// Invariants:
// TotalHeld >= TotalDisposed
// TotalPaid >= TotalDisposed
// TotalPaid >= TotalDistributed (we may distribute less due to minimum payout threshold)
type TotalAmounts struct {
TotalHeld currency.MicroUnit // portion from owed that was held back
TotalDisposed currency.MicroUnit // portion from held back that went into paid
TotalPaid currency.MicroUnit // earned amount that is available to be distributed
TotalDistributed currency.MicroUnit // amount actually transferred to the operator
}
// DB is the interface we need to source the data to calculate compensation.
type DB interface {
// QueryTotalAmounts queries the WithheldAmounts for the given nodeID.
QueryTotalAmounts(ctx context.Context, nodeID storj.NodeID) (TotalAmounts, error)
// RecordPeriod records a set of paystubs and payments for some time period.
RecordPeriod(ctx context.Context, paystubs []Paystub, payments []Payment) error
// RecordPayments records one off individual payments.
RecordPayments(ctx context.Context, payments []Payment) error
}