mnd/payouts: undistributed payouts added

Change-Id: Id61ac58fceca13b9a9e12a7e03c3d9624cce3fea
This commit is contained in:
Qweder93 2021-05-15 01:03:38 +03:00
parent 2896a2736c
commit f0dd7f3739
8 changed files with 375 additions and 95 deletions

View File

@ -1355,6 +1355,82 @@ func (m *EarnedSatellite) GetTotal() int64 {
return 0
}
type UndistributedRequest struct {
Header *RequestHeader `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *UndistributedRequest) Reset() { *m = UndistributedRequest{} }
func (m *UndistributedRequest) String() string { return proto.CompactTextString(m) }
func (*UndistributedRequest) ProtoMessage() {}
func (*UndistributedRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_9a45fd79b06f3a1b, []int{30}
}
func (m *UndistributedRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_UndistributedRequest.Unmarshal(m, b)
}
func (m *UndistributedRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_UndistributedRequest.Marshal(b, m, deterministic)
}
func (m *UndistributedRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_UndistributedRequest.Merge(m, src)
}
func (m *UndistributedRequest) XXX_Size() int {
return xxx_messageInfo_UndistributedRequest.Size(m)
}
func (m *UndistributedRequest) XXX_DiscardUnknown() {
xxx_messageInfo_UndistributedRequest.DiscardUnknown(m)
}
var xxx_messageInfo_UndistributedRequest proto.InternalMessageInfo
func (m *UndistributedRequest) GetHeader() *RequestHeader {
if m != nil {
return m.Header
}
return nil
}
type UndistributedResponse struct {
Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *UndistributedResponse) Reset() { *m = UndistributedResponse{} }
func (m *UndistributedResponse) String() string { return proto.CompactTextString(m) }
func (*UndistributedResponse) ProtoMessage() {}
func (*UndistributedResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_9a45fd79b06f3a1b, []int{31}
}
func (m *UndistributedResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_UndistributedResponse.Unmarshal(m, b)
}
func (m *UndistributedResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_UndistributedResponse.Marshal(b, m, deterministic)
}
func (m *UndistributedResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_UndistributedResponse.Merge(m, src)
}
func (m *UndistributedResponse) XXX_Size() int {
return xxx_messageInfo_UndistributedResponse.Size(m)
}
func (m *UndistributedResponse) XXX_DiscardUnknown() {
xxx_messageInfo_UndistributedResponse.DiscardUnknown(m)
}
var xxx_messageInfo_UndistributedResponse proto.InternalMessageInfo
func (m *UndistributedResponse) GetTotal() int64 {
if m != nil {
return m.Total
}
return 0
}
type PayoutInfo struct {
Held int64 `protobuf:"varint,1,opt,name=held,proto3" json:"held,omitempty"`
Paid int64 `protobuf:"varint,2,opt,name=paid,proto3" json:"paid,omitempty"`
@ -1367,7 +1443,7 @@ func (m *PayoutInfo) Reset() { *m = PayoutInfo{} }
func (m *PayoutInfo) String() string { return proto.CompactTextString(m) }
func (*PayoutInfo) ProtoMessage() {}
func (*PayoutInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_9a45fd79b06f3a1b, []int{30}
return fileDescriptor_9a45fd79b06f3a1b, []int{32}
}
func (m *PayoutInfo) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PayoutInfo.Unmarshal(m, b)
@ -1435,86 +1511,91 @@ func init() {
proto.RegisterType((*EarnedPerSatelliteRequest)(nil), "multinode.EarnedPerSatelliteRequest")
proto.RegisterType((*EarnedPerSatelliteResponse)(nil), "multinode.EarnedPerSatelliteResponse")
proto.RegisterType((*EarnedSatellite)(nil), "multinode.EarnedSatellite")
proto.RegisterType((*UndistributedRequest)(nil), "multinode.UndistributedRequest")
proto.RegisterType((*UndistributedResponse)(nil), "multinode.UndistributedResponse")
proto.RegisterType((*PayoutInfo)(nil), "multinode.PayoutInfo")
}
func init() { proto.RegisterFile("multinode.proto", fileDescriptor_9a45fd79b06f3a1b) }
var fileDescriptor_9a45fd79b06f3a1b = []byte{
// 1199 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0xdd, 0x72, 0xdb, 0x44,
0x14, 0x46, 0x4d, 0x22, 0xd7, 0xc7, 0x69, 0x7e, 0x96, 0xd0, 0x2a, 0xaa, 0x13, 0x07, 0x25, 0x34,
0x29, 0x6d, 0x1d, 0x70, 0x19, 0x66, 0x98, 0x81, 0x19, 0x12, 0x92, 0xd2, 0x0c, 0x09, 0x4d, 0x95,
0xd0, 0x61, 0x0a, 0x53, 0xcf, 0xc6, 0xda, 0x38, 0xa2, 0xb2, 0x56, 0x68, 0xd7, 0x81, 0xdc, 0x70,
0xc9, 0x35, 0x0f, 0xc0, 0x83, 0x70, 0xc7, 0x70, 0xc3, 0xf0, 0x0c, 0x5c, 0x94, 0xc7, 0xe0, 0x96,
0xd9, 0x1f, 0xcb, 0xb2, 0x2d, 0x2b, 0xc1, 0x66, 0xb8, 0xdb, 0x3d, 0x3f, 0xdf, 0x39, 0xbb, 0xe7,
0xe8, 0xec, 0x27, 0x98, 0x6d, 0xb5, 0x03, 0xee, 0x87, 0xd4, 0x23, 0xd5, 0x28, 0xa6, 0x9c, 0xa2,
0x62, 0x22, 0xb0, 0xa1, 0x49, 0x9b, 0x54, 0x89, 0xed, 0x4a, 0x93, 0xd2, 0x66, 0x40, 0x36, 0xe5,
0xee, 0xa4, 0x7d, 0xba, 0xc9, 0xfd, 0x16, 0x61, 0x1c, 0xb7, 0x22, 0x65, 0xe0, 0x6c, 0xc0, 0x0d,
0x97, 0x7c, 0xdb, 0x26, 0x8c, 0x3f, 0x26, 0xd8,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f0, 0x16, 0xdc, 0xcc, 0x9e, 0xae, 0x68, 0x23, 0xcb, 0x3d, 0xf3, 0x3c, 0x77,
0xaf, 0x60, 0xa9, 0xc3, 0x7d, 0x04, 0xa6, 0x9a, 0x29, 0xc8, 0x1a, 0x18, 0x45, 0x1d, 0xb8, 0xc5,
0x0c, 0x8d, 0x76, 0xc7, 0x80, 0x06, 0xe7, 0x1e, 0x5a, 0x1b, 0x70, 0xc8, 0x98, 0xb2, 0xf6, 0x5b,
0x97, 0x58, 0xe9, 0x10, 0x0c, 0xac, 0x61, 0x54, 0x12, 0xbd, 0x9d, 0x86, 0xc8, 0xe7, 0xbd, 0xf6,
0xbd, 0x2b, 0xd9, 0xea, 0xa0, 0x4d, 0x58, 0xc8, 0xe2, 0x86, 0x3d, 0x6d, 0x9c, 0xc3, 0x46, 0x7b,
0xda, 0x38, 0x8f, 0x64, 0x6e, 0xaf, 0x3d, 0x77, 0x18, 0xa7, 0xf1, 0x37, 0x55, 0x9f, 0x6e, 0xca,
0xc5, 0x66, 0x14, 0xfb, 0xe7, 0x98, 0x93, 0xcd, 0x04, 0x20, 0x3a, 0x39, 0x31, 0xe5, 0xdf, 0xe8,
0xc3, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x44, 0x72, 0xb4, 0x3b, 0x86, 0x11, 0x00, 0x00,
// 1237 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0x5f, 0x73, 0xdb, 0x44,
0x10, 0xc7, 0x4d, 0x22, 0xd7, 0xeb, 0xfc, 0x3d, 0xd2, 0x56, 0x51, 0x9d, 0x38, 0x28, 0xa1, 0x49,
0x69, 0xe3, 0x80, 0xcb, 0x30, 0xc3, 0x0c, 0xcc, 0x90, 0x90, 0x94, 0x64, 0x48, 0x68, 0xaa, 0xa4,
0x1d, 0xa6, 0x30, 0xf5, 0x5c, 0xac, 0x8b, 0x23, 0x2a, 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xd3, 0x86, 0xd2,
0x9e, 0x32, 0xce, 0x19, 0x83, 0x7b, 0xca, 0x38, 0x77, 0xba, 0xb5, 0x60, 0xaa, 0xa7, 0x4d, 0xa3,
0x6a, 0xc2, 0x32, 0xed, 0x29, 0x30, 0x96, 0xb3, 0x01, 0x92, 0x73, 0x7b, 0xf5, 0x85, 0xc9, 0x38,
0x0d, 0xbe, 0xa9, 0x39, 0x74, 0x53, 0x2c, 0x36, 0xfd, 0xc0, 0xb9, 0xc0, 0x9c, 0x6c, 0xc6, 0x96,
0xfe, 0xe9, 0xa9, 0x26, 0x7e, 0xad, 0x1f, 0xfd, 0x13, 0x00, 0x00, 0xff, 0xff, 0x98, 0x02, 0x92,
0x23, 0x53, 0x12, 0x00, 0x00,
}

View File

@ -105,6 +105,7 @@ service Payout {
rpc EarnedPerSatellite(EarnedPerSatelliteRequest) returns (EarnedPerSatelliteResponse);
rpc EstimatedPayoutSatellite(EstimatedPayoutSatelliteRequest) returns (EstimatedPayoutSatelliteResponse);
rpc EstimatedPayoutTotal(EstimatedPayoutTotalRequest) returns (EstimatedPayoutTotalResponse);
rpc Undistributed(UndistributedRequest) returns (UndistributedResponse);
}
message EstimatedPayoutSatelliteRequest {
@ -181,6 +182,14 @@ message EarnedSatellite {
bytes satellite_id = 2 [(gogoproto.customtype) = "NodeID", (gogoproto.nullable) = false];
}
message UndistributedRequest {
RequestHeader header = 1;
}
message UndistributedResponse {
int64 total = 1;
}
message PayoutInfo {
int64 held = 1;
int64 paid = 2;

View File

@ -395,6 +395,7 @@ type DRPCPayoutClient interface {
EarnedPerSatellite(ctx context.Context, in *EarnedPerSatelliteRequest) (*EarnedPerSatelliteResponse, error)
EstimatedPayoutSatellite(ctx context.Context, in *EstimatedPayoutSatelliteRequest) (*EstimatedPayoutSatelliteResponse, error)
EstimatedPayoutTotal(ctx context.Context, in *EstimatedPayoutTotalRequest) (*EstimatedPayoutTotalResponse, error)
Undistributed(ctx context.Context, in *UndistributedRequest) (*UndistributedResponse, error)
}
type drpcPayoutClient struct {
@ -479,6 +480,15 @@ func (c *drpcPayoutClient) EstimatedPayoutTotal(ctx context.Context, in *Estimat
return out, nil
}
func (c *drpcPayoutClient) Undistributed(ctx context.Context, in *UndistributedRequest) (*UndistributedResponse, error) {
out := new(UndistributedResponse)
err := c.cc.Invoke(ctx, "/multinode.Payout/Undistributed", drpcEncoding_File_multinode_proto{}, in, out)
if err != nil {
return nil, err
}
return out, nil
}
type DRPCPayoutServer interface {
AllSatellitesSummary(context.Context, *AllSatellitesSummaryRequest) (*AllSatellitesSummaryResponse, error)
AllSatellitesPeriodSummary(context.Context, *AllSatellitesPeriodSummaryRequest) (*AllSatellitesPeriodSummaryResponse, error)
@ -488,6 +498,7 @@ type DRPCPayoutServer interface {
EarnedPerSatellite(context.Context, *EarnedPerSatelliteRequest) (*EarnedPerSatelliteResponse, error)
EstimatedPayoutSatellite(context.Context, *EstimatedPayoutSatelliteRequest) (*EstimatedPayoutSatelliteResponse, error)
EstimatedPayoutTotal(context.Context, *EstimatedPayoutTotalRequest) (*EstimatedPayoutTotalResponse, error)
Undistributed(context.Context, *UndistributedRequest) (*UndistributedResponse, error)
}
type DRPCPayoutUnimplementedServer struct{}
@ -524,9 +535,13 @@ func (s *DRPCPayoutUnimplementedServer) EstimatedPayoutTotal(context.Context, *E
return nil, drpcerr.WithCode(errors.New("Unimplemented"), 12)
}
func (s *DRPCPayoutUnimplementedServer) Undistributed(context.Context, *UndistributedRequest) (*UndistributedResponse, error) {
return nil, drpcerr.WithCode(errors.New("Unimplemented"), 12)
}
type DRPCPayoutDescription struct{}
func (DRPCPayoutDescription) NumMethods() int { return 8 }
func (DRPCPayoutDescription) NumMethods() int { return 9 }
func (DRPCPayoutDescription) Method(n int) (string, drpc.Encoding, drpc.Receiver, interface{}, bool) {
switch n {
@ -602,6 +617,15 @@ func (DRPCPayoutDescription) Method(n int) (string, drpc.Encoding, drpc.Receiver
in1.(*EstimatedPayoutTotalRequest),
)
}, DRPCPayoutServer.EstimatedPayoutTotal, true
case 8:
return "/multinode.Payout/Undistributed", drpcEncoding_File_multinode_proto{},
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
return srv.(DRPCPayoutServer).
Undistributed(
ctx,
in1.(*UndistributedRequest),
)
}, DRPCPayoutServer.Undistributed, true
default:
return "", nil, nil, nil, false
}
@ -738,3 +762,19 @@ func (x *drpcPayout_EstimatedPayoutTotalStream) SendAndClose(m *EstimatedPayoutT
}
return x.CloseSend()
}
type DRPCPayout_UndistributedStream interface {
drpc.Stream
SendAndClose(*UndistributedResponse) error
}
type drpcPayout_UndistributedStream struct {
drpc.Stream
}
func (x *drpcPayout_UndistributedStream) SendAndClose(m *UndistributedResponse) error {
if err := x.MsgSend(m, drpcEncoding_File_multinode_proto{}); err != nil {
return err
}
return x.CloseSend()
}

View File

@ -72,15 +72,15 @@ func (payout *PayoutEndpoint) EarnedPerSatellite(ctx context.Context, req *multi
return nil, rpcstatus.Wrap(rpcstatus.Internal, err)
}
for i := 0; i < len(satelliteIDs); i++ {
earned, err := payout.db.GetEarnedAtSatellite(ctx, satelliteIDs[i])
for _, id := range satelliteIDs {
earned, err := payout.db.GetEarnedAtSatellite(ctx, id)
if err != nil {
return nil, rpcstatus.Wrap(rpcstatus.Internal, err)
}
resp.EarnedSatellite = append(resp.EarnedSatellite, &multinodepb.EarnedSatellite{
Total: earned,
SatelliteId: satelliteIDs[i],
SatelliteId: id,
})
}
@ -208,3 +208,19 @@ func (payout *PayoutEndpoint) SatellitePeriodSummary(ctx context.Context, req *m
return &multinodepb.SatellitePeriodSummaryResponse{PayoutInfo: &multinodepb.PayoutInfo{Held: totalHeld, Paid: totalPaid}}, nil
}
// Undistributed returns total undistributed amount.
func (payout *PayoutEndpoint) Undistributed(ctx context.Context, req *multinodepb.UndistributedRequest) (_ *multinodepb.UndistributedResponse, err error) {
defer mon.Task()(&ctx)(&err)
if err = authenticate(ctx, payout.apiKeys, req.GetHeader()); err != nil {
return nil, rpcstatus.Wrap(rpcstatus.Unauthenticated, err)
}
earned, err := payout.db.GetUndistributed(ctx)
if err != nil {
return nil, rpcstatus.Wrap(rpcstatus.Internal, err)
}
return &multinodepb.UndistributedResponse{Total: earned}, nil
}

View File

@ -79,6 +79,7 @@ func TestPayoutsEndpointSummary(t *testing.T) {
SatelliteID: id,
Held: amount,
Paid: amount,
CompAtRest: amount,
Period: "2020-10",
})
require.NoError(t, err)
@ -204,6 +205,73 @@ func TestPayoutsEndpointEstimations(t *testing.T) {
})
}
func TestPayoutsUndistributedEndpoint(t *testing.T) {
storagenodedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db storagenode.DB) {
payoutdb := db.Payout()
satelliteID := testrand.NodeID()
log := zaptest.NewLogger(t)
service := apikeys.NewService(db.APIKeys())
key, err := service.Issue(ctx)
require.NoError(t, err)
// Initialize a trust pool
poolConfig := trust.Config{
CachePath: ctx.File("trust-cache.json"),
}
poolConfig.Sources = append(poolConfig.Sources, &trust.StaticURLSource{URL: trust.SatelliteURL{ID: satelliteID}})
trustPool, err := trust.NewPool(zaptest.NewLogger(t), trust.Dialer(rpc.Dialer{}), poolConfig)
require.NoError(t, err)
require.NoError(t, trustPool.Refresh(ctx))
estimatedPayoutsService := estimatedpayouts.NewService(db.Bandwidth(), db.Reputation(), db.StorageUsage(), db.Pricing(), db.Satellites(), trustPool)
endpoint := multinode.NewPayoutEndpoint(log, service, estimatedPayoutsService, db.Payout())
satelliteID1 := testrand.NodeID()
satelliteID2 := testrand.NodeID()
err = payoutdb.StorePayStub(ctx, payouts.PayStub{
SatelliteID: satelliteID2,
Period: "2020-01",
Distributed: 150,
Paid: 250,
})
require.NoError(t, err)
err = payoutdb.StorePayStub(ctx, payouts.PayStub{
SatelliteID: satelliteID2,
Period: "2020-02",
Distributed: 250,
Paid: 350,
})
require.NoError(t, err)
err = payoutdb.StorePayStub(ctx, payouts.PayStub{
SatelliteID: satelliteID1,
Period: "2020-01",
Distributed: 100,
Paid: 300,
})
require.NoError(t, err)
err = payoutdb.StorePayStub(ctx, payouts.PayStub{
SatelliteID: satelliteID1,
Period: "2020-02",
Distributed: 400,
Paid: 500,
})
require.NoError(t, err)
resp, err := endpoint.Undistributed(ctx, &multinodepb.UndistributedRequest{Header: &multinodepb.RequestHeader{
ApiKey: key.Secret[:],
}})
require.NoError(t, err)
require.EqualValues(t, 500, resp.Total)
})
}
// makeStorageUsageStamps creates storage usage stamps and expected summaries for provided satellites.
// Creates one entry per day for 30 days with last date as beginning of provided endDate.
func makeStorageUsageStamps(satellites []storj.NodeID) ([]storageusage.Stamp, map[storj.NodeID]float64) {

View File

@ -11,8 +11,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"storj.io/common/storj"
"storj.io/common/testcontext"
"storj.io/common/testrand"
"storj.io/storj/storagenode"
"storj.io/storj/storagenode/payouts"
"storj.io/storj/storagenode/storagenodedb/storagenodedbtest"
@ -21,7 +21,7 @@ import (
func TestHeldAmountDB(t *testing.T) {
storagenodedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db storagenode.DB) {
payout := db.Payout()
satelliteID := storj.NodeID{}
satelliteID := testrand.NodeID()
period := "2020-01"
paystub := payouts.PayStub{
SatelliteID: satelliteID,
@ -100,7 +100,7 @@ func TestHeldAmountDB(t *testing.T) {
assert.Error(t, err)
assert.Equal(t, true, payouts.ErrNoPayStubForPeriod.Has(err))
stub, err = payout.GetPayStub(ctx, storj.NodeID{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, period)
stub, err = payout.GetPayStub(ctx, testrand.NodeID(), period)
assert.Error(t, err)
assert.Equal(t, true, payouts.ErrNoPayStubForPeriod.Has(err))
assert.Nil(t, stub)
@ -188,7 +188,7 @@ func TestHeldAmountDB(t *testing.T) {
assert.Equal(t, paystub2.Period, periods[1])
paystub3 := paystub2
paystub3.SatelliteID = storj.NodeID{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
paystub3.SatelliteID = testrand.NodeID()
paystub3.Period = "2020-03"
paystub3.Created = paystub2.Created.Add(time.Hour * 24 * 30)
@ -215,7 +215,7 @@ func TestSatellitePayStubPeriodCached(t *testing.T) {
require.NoError(t, err)
payStub := payouts.PayStub{
SatelliteID: storj.NodeID{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
SatelliteID: testrand.NodeID(),
Created: time.Now().UTC(),
Codes: "code",
UsageAtRest: 1,
@ -266,7 +266,7 @@ func TestAllPayStubPeriodCached(t *testing.T) {
require.NoError(t, err)
payStub := payouts.PayStub{
SatelliteID: storj.NodeID{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
SatelliteID: testrand.NodeID(),
Created: time.Now().UTC(),
Codes: "code",
UsageAtRest: 1,
@ -319,9 +319,9 @@ func TestPayouts(t *testing.T) {
storagenodedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db storagenode.DB) {
payout := db.Payout()
t.Run("Test SatelliteIDs", func(t *testing.T) {
id1 := storj.NodeID{1, 2, 3}
id2 := storj.NodeID{2, 3, 4}
id3 := storj.NodeID{3, 3, 3}
id1 := testrand.NodeID()
id2 := testrand.NodeID()
id3 := testrand.NodeID()
err := payout.StorePayStub(ctx, payouts.PayStub{
SatelliteID: id1,
})
@ -351,9 +351,9 @@ func TestPayouts(t *testing.T) {
require.NoError(t, err)
})
t.Run("Test GetSatelliteEarned", func(t *testing.T) {
id1 := storj.NodeID{1, 2, 3}
id2 := storj.NodeID{2, 3, 4}
id3 := storj.NodeID{3, 3, 3}
id1 := testrand.NodeID()
id2 := testrand.NodeID()
id3 := testrand.NodeID()
err := payout.StorePayStub(ctx, payouts.PayStub{
Period: "2020-11",
SatelliteID: id1,
@ -408,8 +408,8 @@ func TestPayouts(t *testing.T) {
})
t.Run("Test GetSatelliteSummary", func(t *testing.T) {
id1 := storj.NodeID{1, 2, 3}
id2 := storj.NodeID{2, 3, 4}
id1 := testrand.NodeID()
id2 := testrand.NodeID()
err := payout.StorePayStub(ctx, payouts.PayStub{
Period: "2020-11",
@ -455,3 +455,47 @@ func TestPayouts(t *testing.T) {
})
})
}
func TestPayoutsUndistributedEndpoint(t *testing.T) {
storagenodedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db storagenode.DB) {
payoutdb := db.Payout()
satelliteID1 := testrand.NodeID()
satelliteID2 := testrand.NodeID()
err := payoutdb.StorePayStub(ctx, payouts.PayStub{
SatelliteID: satelliteID2,
Period: "2020-01",
Distributed: 150,
Paid: 250,
})
require.NoError(t, err)
err = payoutdb.StorePayStub(ctx, payouts.PayStub{
SatelliteID: satelliteID2,
Period: "2020-02",
Distributed: 250,
Paid: 350,
})
require.NoError(t, err)
err = payoutdb.StorePayStub(ctx, payouts.PayStub{
SatelliteID: satelliteID1,
Period: "2020-01",
Distributed: 100,
Paid: 300,
})
require.NoError(t, err)
err = payoutdb.StorePayStub(ctx, payouts.PayStub{
SatelliteID: satelliteID1,
Period: "2020-02",
Distributed: 400,
Paid: 500,
})
require.NoError(t, err)
undistributed, err := payoutdb.GetUndistributed(ctx)
require.NoError(t, err)
require.EqualValues(t, undistributed, 500)
})
}

View File

@ -44,6 +44,8 @@ type DB interface {
GetSatelliteSummary(ctx context.Context, satelliteID storj.NodeID) (paid, held int64, err error)
// GetSatellitePeriodSummary returns satellite paid and held amounts for specific period.
GetSatellitePeriodSummary(ctx context.Context, satelliteID storj.NodeID, period string) (paid, held int64, err error)
// GetUndistributed returns total undistributed amount.
GetUndistributed(ctx context.Context) (int64, error)
}
// ErrNoPayStubForPeriod represents errors from the payouts database.

View File

@ -564,3 +564,23 @@ func (db *payoutDB) GetSatellitePeriodSummary(ctx context.Context, satelliteID s
return paid, held, nil
}
// GetUndistributed returns total undistributed amount.
func (db *payoutDB) GetUndistributed(ctx context.Context) (_ int64, err error) {
defer mon.Task()(&ctx)(&err)
var distributed, paid int64
rowPayment := db.QueryRowContext(ctx,
`SELECT SUM(distributed), SUM(paid) FROM paystubs`)
err = rowPayment.Scan(&distributed, &paid)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
return 0, payouts.ErrNoPayStubForPeriod.Wrap(err)
}
return 0, ErrPayout.Wrap(err)
}
return paid - distributed, nil
}