satellite/compensation: add wallet features to invoice csv
Change-Id: I90a72c0a4c8d07604096913b6680263b6defc0a2
This commit is contained in:
parent
966535e9de
commit
1e328f3c30
@ -98,6 +98,7 @@ func generateInvoicesCSV(ctx context.Context, period compensation.Period, out io
|
||||
Period: period,
|
||||
NodeID: compensation.NodeID(usage.NodeID),
|
||||
NodeWallet: node.Operator.Wallet,
|
||||
NodeWalletFeatures: node.Operator.WalletFeatures,
|
||||
NodeAddress: nodeAddress,
|
||||
NodeLastIP: nodeLastIP,
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ type Invoice struct {
|
||||
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
|
||||
NodeWallet string `csv:"node-wallet"` // The node's wallet address
|
||||
NodeWalletFeatures WalletFeatures `csv:"node-wallet-features"` // The node's wallet features
|
||||
NodeAddress string `csv:"node-address"` // The node's TODO
|
||||
NodeLastIP string `csv:"node-last-ip"` // The last known ip the node had
|
||||
Codes Codes `csv:"codes"` // Any codes providing context to 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