storj/satellite/compensation/db.go
paul cannon 37a4edbaff all: reformat comments as required by gofmt 1.19
I don't know why the go people thought this was a good idea, because
this automatic reformatting is bound to do the wrong thing sometimes,
which is very annoying. But I don't see a way to turn it off, so best to
get this change out of the way.

Change-Id: Ib5dbbca6a6f6fc944d76c9b511b8c904f796e4f3
2022-08-10 18:24:55 +00:00

38 lines
1.3 KiB
Go

// 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
}