satellite/compensation: add wallet features to invoice csv
Change-Id: I90a72c0a4c8d07604096913b6680263b6defc0a2
This commit is contained in:
parent
966535e9de
commit
1e328f3c30
@ -95,11 +95,12 @@ func generateInvoicesCSV(ctx context.Context, period compensation.Period, out io
|
|||||||
}
|
}
|
||||||
|
|
||||||
invoice := compensation.Invoice{
|
invoice := compensation.Invoice{
|
||||||
Period: period,
|
Period: period,
|
||||||
NodeID: compensation.NodeID(usage.NodeID),
|
NodeID: compensation.NodeID(usage.NodeID),
|
||||||
NodeWallet: node.Operator.Wallet,
|
NodeWallet: node.Operator.Wallet,
|
||||||
NodeAddress: nodeAddress,
|
NodeWalletFeatures: node.Operator.WalletFeatures,
|
||||||
NodeLastIP: nodeLastIP,
|
NodeAddress: nodeAddress,
|
||||||
|
NodeLastIP: nodeLastIP,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := invoice.MergeNodeInfo(nodeInfo); err != nil {
|
if err := invoice.MergeNodeInfo(nodeInfo); err != nil {
|
||||||
|
@ -13,35 +13,36 @@ import (
|
|||||||
// Invoice holds the calculations for the amount required to pay to a node
|
// Invoice holds the calculations for the amount required to pay to a node
|
||||||
// for a given pay period.
|
// for a given pay period.
|
||||||
type Invoice struct {
|
type Invoice struct {
|
||||||
Period Period `csv:"period"` // The payment period
|
Period Period `csv:"period"` // The payment period
|
||||||
NodeID NodeID `csv:"node-id"` // The node ID
|
NodeID NodeID `csv:"node-id"` // The node ID
|
||||||
NodeCreatedAt UTCDate `csv:"node-created-at"` // When the node was created
|
NodeCreatedAt UTCDate `csv:"node-created-at"` // When the node was created
|
||||||
NodeDisqualified *UTCDate `csv:"node-disqualified"` // When and if the node was disqualified
|
NodeDisqualified *UTCDate `csv:"node-disqualified"` // When and if the node was disqualified
|
||||||
NodeGracefulExit *UTCDate `csv:"node-gracefulexit"` // When and if the node finished a graceful exit
|
NodeGracefulExit *UTCDate `csv:"node-gracefulexit"` // When and if the node finished a graceful exit
|
||||||
NodeWallet string `csv:"node-wallet"` // The node's wallet address
|
NodeWallet string `csv:"node-wallet"` // The node's wallet address
|
||||||
NodeAddress string `csv:"node-address"` // The node's TODO
|
NodeWalletFeatures WalletFeatures `csv:"node-wallet-features"` // The node's wallet features
|
||||||
NodeLastIP string `csv:"node-last-ip"` // The last known ip the node had
|
NodeAddress string `csv:"node-address"` // The node's TODO
|
||||||
Codes Codes `csv:"codes"` // Any codes providing context to the invoice
|
NodeLastIP string `csv:"node-last-ip"` // The last known ip the node had
|
||||||
UsageAtRest float64 `csv:"usage-at-rest"` // Byte-hours provided during the payment period
|
Codes Codes `csv:"codes"` // Any codes providing context to the invoice
|
||||||
UsageGet int64 `csv:"usage-get"` // Number of bytes served in GET requests
|
UsageAtRest float64 `csv:"usage-at-rest"` // Byte-hours provided during the payment period
|
||||||
UsagePut int64 `csv:"usage-put"` // Number of bytes served in PUT requests
|
UsageGet int64 `csv:"usage-get"` // Number of bytes served in GET requests
|
||||||
UsageGetRepair int64 `csv:"usage-get-repair"` // Number of bytes served in GET_REPAIR requests
|
UsagePut int64 `csv:"usage-put"` // Number of bytes served in PUT requests
|
||||||
UsagePutRepair int64 `csv:"usage-put-repair"` // Number of bytes served in PUT_REPAIR requests
|
UsageGetRepair int64 `csv:"usage-get-repair"` // Number of bytes served in GET_REPAIR requests
|
||||||
UsageGetAudit int64 `csv:"usage-get-audit"` // Number of bytes served in GET_AUDIT requests
|
UsagePutRepair int64 `csv:"usage-put-repair"` // Number of bytes served in PUT_REPAIR requests
|
||||||
CompAtRest currency.MicroUnit `csv:"comp-at-rest"` // Compensation for usage-at-rest
|
UsageGetAudit int64 `csv:"usage-get-audit"` // Number of bytes served in GET_AUDIT requests
|
||||||
CompGet currency.MicroUnit `csv:"comp-get"` // Compensation for usage-get
|
CompAtRest currency.MicroUnit `csv:"comp-at-rest"` // Compensation for usage-at-rest
|
||||||
CompPut currency.MicroUnit `csv:"comp-put"` // Compensation for usage-put
|
CompGet currency.MicroUnit `csv:"comp-get"` // Compensation for usage-get
|
||||||
CompGetRepair currency.MicroUnit `csv:"comp-get-repair"` // Compensation for usage-get-repair
|
CompPut currency.MicroUnit `csv:"comp-put"` // Compensation for usage-put
|
||||||
CompPutRepair currency.MicroUnit `csv:"comp-put-repair"` // Compensation for usage-put-repair
|
CompGetRepair currency.MicroUnit `csv:"comp-get-repair"` // Compensation for usage-get-repair
|
||||||
CompGetAudit currency.MicroUnit `csv:"comp-get-audit"` // Compensation for usage-get-audit
|
CompPutRepair currency.MicroUnit `csv:"comp-put-repair"` // Compensation for usage-put-repair
|
||||||
SurgePercent int64 `csv:"surge-percent"` // Surge percent used to calculate compensation, or 0 if no surge
|
CompGetAudit currency.MicroUnit `csv:"comp-get-audit"` // Compensation for usage-get-audit
|
||||||
Owed currency.MicroUnit `csv:"owed"` // Amount we intend to pay to the node (sum(comp-*) - held + disposed)
|
SurgePercent int64 `csv:"surge-percent"` // Surge percent used to calculate compensation, or 0 if no surge
|
||||||
Held currency.MicroUnit `csv:"held"` // Amount held from sum(comp-*) for this period
|
Owed currency.MicroUnit `csv:"owed"` // Amount we intend to pay to the node (sum(comp-*) - held + disposed)
|
||||||
Disposed currency.MicroUnit `csv:"disposed"` // Amount of owed that is due to graceful-exit or held period ending
|
Held currency.MicroUnit `csv:"held"` // Amount held from sum(comp-*) for this period
|
||||||
TotalHeld currency.MicroUnit `csv:"total-held"` // Total amount ever held from the node
|
Disposed currency.MicroUnit `csv:"disposed"` // Amount of owed that is due to graceful-exit or held period ending
|
||||||
TotalDisposed currency.MicroUnit `csv:"total-disposed"` // Total amount ever disposed to the node
|
TotalHeld currency.MicroUnit `csv:"total-held"` // Total amount ever held from the node
|
||||||
TotalPaid currency.MicroUnit `csv:"total-paid"` // Total amount ever paid to the node (but not necessarily dispensed)
|
TotalDisposed currency.MicroUnit `csv:"total-disposed"` // Total amount ever disposed to the node
|
||||||
TotalDistributed currency.MicroUnit `csv:"total-distributed"` // Total amount ever distributed to the node (always less than or equal to paid)
|
TotalPaid currency.MicroUnit `csv:"total-paid"` // Total amount ever paid to the node (but not necessarily dispensed)
|
||||||
|
TotalDistributed currency.MicroUnit `csv:"total-distributed"` // Total amount ever distributed to the node (always less than or equal to paid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MergeNodeInfo updates the fields representing the node information into the invoice.
|
// MergeNodeInfo updates the fields representing the node information into the invoice.
|
||||||
|
37
satellite/compensation/operator.go
Normal file
37
satellite/compensation/operator.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (C) 2021 Storj Labs, Inc.
|
||||||
|
// See LICENSE for copying information.
|
||||||
|
|
||||||
|
package compensation
|
||||||
|
|
||||||
|
import "strings"
|
||||||
|
|
||||||
|
// WalletFeatures represents wallet features list.
|
||||||
|
type WalletFeatures []string
|
||||||
|
|
||||||
|
// DecodeWalletFeatures decodes wallet features list string separated by "|".
|
||||||
|
func DecodeWalletFeatures(s string) (WalletFeatures, error) {
|
||||||
|
if s == "" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return strings.Split(s, "|"), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// String outputs .
|
||||||
|
func (features WalletFeatures) String() string {
|
||||||
|
return strings.Join(features, "|")
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalCSV reads the WalletFeatures in CSV form.
|
||||||
|
func (features *WalletFeatures) UnmarshalCSV(s string) error {
|
||||||
|
v, err := DecodeWalletFeatures(s)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*features = v
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalCSV returns the CSV form of the WalletFeatures.
|
||||||
|
func (features WalletFeatures) MarshalCSV() (string, error) {
|
||||||
|
return features.String(), nil
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user