2020-03-10 20:42:11 +00:00
|
|
|
// Copyright (C) 2020 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package compensation
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2020-05-29 09:52:10 +01:00
|
|
|
"storj.io/common/storj"
|
2020-03-10 20:42:11 +00:00
|
|
|
"storj.io/storj/private/currency"
|
|
|
|
)
|
|
|
|
|
2021-01-27 18:53:16 +00:00
|
|
|
// TotalAmounts holds the amounts held and disposed.
|
|
|
|
//
|
|
|
|
// Invariants:
|
2022-08-10 16:35:58 +01:00
|
|
|
//
|
|
|
|
// TotalHeld >= TotalDisposed
|
|
|
|
// TotalPaid >= TotalDisposed
|
|
|
|
// TotalPaid >= TotalDistributed (we may distribute less due to minimum payout threshold)
|
2021-01-27 18:53:16 +00:00
|
|
|
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
|
2020-03-10 20:42:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// DB is the interface we need to source the data to calculate compensation.
|
|
|
|
type DB interface {
|
2021-01-27 18:53:16 +00:00
|
|
|
// QueryTotalAmounts queries the WithheldAmounts for the given nodeID.
|
|
|
|
QueryTotalAmounts(ctx context.Context, nodeID storj.NodeID) (TotalAmounts, error)
|
2020-03-10 20:42:11 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|