multinode/operators: operator entity extended with nodeID and undistributed amount

Change-Id: I423fe79b0aefe09d0b0ddab490d7a39e2b3f3249
This commit is contained in:
crawter 2021-06-07 20:13:16 +03:00
parent be16f4b68b
commit b445e7d397
2 changed files with 22 additions and 8 deletions

View File

@ -3,11 +3,17 @@
package operators
// Operator contains contains SNO payouts contact details.
import (
"storj.io/common/storj"
)
// Operator contains contains SNO payouts contact details and amount of undistributed payouts.
type Operator struct {
Email string `json:"email"`
Wallet string `json:"wallet"`
WalletFeatures []string `json:"walletFeatures"`
NodeID storj.NodeID `json:"nodeId"`
Email string `json:"email"`
Wallet string `json:"wallet"`
WalletFeatures []string `json:"walletFeatures"`
Undistributed int64 `json:"undistributed"`
}
// Cursor holds operator cursor entity which is used to create listed page.

View File

@ -101,17 +101,25 @@ func (service *Service) GetOperator(ctx context.Context, node nodes.Node) (_ Ope
}()
nodeClient := multinodepb.NewDRPCNodeClient(conn)
payoutClient := multinodepb.NewDRPCPayoutsClient(conn)
header := &multinodepb.RequestHeader{
ApiKey: node.APISecret,
}
resp, err := nodeClient.Operator(ctx, &multinodepb.OperatorRequest{Header: header})
operatorResponse, err := nodeClient.Operator(ctx, &multinodepb.OperatorRequest{Header: header})
if err != nil {
return Operator{}, Error.Wrap(err)
}
undistributedResponse, err := payoutClient.Undistributed(ctx, &multinodepb.UndistributedRequest{Header: header})
if err != nil {
return Operator{}, Error.Wrap(err)
}
return Operator{
Email: resp.Email,
Wallet: resp.Wallet,
WalletFeatures: resp.WalletFeatures,
NodeID: node.ID,
Email: operatorResponse.Email,
Wallet: operatorResponse.Wallet,
WalletFeatures: operatorResponse.WalletFeatures,
Undistributed: undistributedResponse.Total,
}, nil
}