payout

package
v1.14.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2020 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPayoutService defines held amount service error.
	ErrPayoutService = errs.Class("payout service error")

	// ErrBadPeriod defines that period has wrong format.
	ErrBadPeriod = errs.Class("wrong period format")
)
View Source
var ErrNoPayStubForPeriod = errs.Class("no payStub for period error")

ErrNoPayStubForPeriod represents errors from the payout database.

Functions

func GetHeldRate

func GetHeldRate(joinTime time.Time, requestTime time.Time) (heldRate int64)

GetHeldRate returns held rate for specific period from join date of node.

Types

type Client

type Client struct {
	pb.DRPCHeldAmountClient
	// contains filtered or unexported fields
}

Client encapsulates HeldAmountClient with underlying connection.

architecture: Client

func (*Client) Close

func (c *Client) Close() error

Close closes underlying client connection.

type DB

type DB interface {
	// StorePayStub inserts or updates paystub into the DB.
	StorePayStub(ctx context.Context, paystub PayStub) error
	// GetPayStub retrieves paystub for specific satellite and period.
	GetPayStub(ctx context.Context, satelliteID storj.NodeID, period string) (*PayStub, error)
	// AllPayStubs retrieves paystubs from all satellites in specific period from DB.
	AllPayStubs(ctx context.Context, period string) ([]PayStub, error)
	// SatellitesHeldbackHistory retrieves heldback history for specific satellite from DB.
	SatellitesHeldbackHistory(ctx context.Context, satelliteID storj.NodeID) ([]HoldForPeriod, error)
	// SatellitesDisposedHistory returns all disposed amount for specific satellite from DB.
	SatellitesDisposedHistory(ctx context.Context, satelliteID storj.NodeID) (int64, error)
	// SatellitePeriods retrieves all periods for concrete satellite in which we have some payout data.
	SatellitePeriods(ctx context.Context, satelliteID storj.NodeID) ([]string, error)
	// AllPeriods retrieves all periods in which we have some payout data.
	AllPeriods(ctx context.Context) ([]string, error)
	// StorePayment inserts or updates payment into the DB
	StorePayment(ctx context.Context, payment Payment) error
	// GetReceipt retrieves receipt for specific satellite and period.
	GetReceipt(ctx context.Context, satelliteID storj.NodeID, period string) (string, error)
}

DB works with payout database

architecture: Database

type Endpoint

type Endpoint struct {
	// contains filtered or unexported fields
}

Endpoint retrieves info from satellites using an rpc client.

architecture: Endpoint

func NewEndpoint

func NewEndpoint(log *zap.Logger, dialer rpc.Dialer, trust *trust.Pool) *Endpoint

NewEndpoint creates new instance of endpoint.

func (*Endpoint) GetAllPayments

func (endpoint *Endpoint) GetAllPayments(ctx context.Context, satelliteID storj.NodeID) (_ []Payment, err error)

GetAllPayments retrieves all payments for particular satellite.

func (*Endpoint) GetAllPaystubs

func (endpoint *Endpoint) GetAllPaystubs(ctx context.Context, satelliteID storj.NodeID) (_ []PayStub, err error)

GetAllPaystubs retrieves all paystubs for particular satellite.

func (*Endpoint) GetPayment

func (endpoint *Endpoint) GetPayment(ctx context.Context, satelliteID storj.NodeID, period string) (_ *Payment, err error)

GetPayment retrieves payment data from particular satellite using grpc.

func (*Endpoint) GetPaystub

func (endpoint *Endpoint) GetPaystub(ctx context.Context, satelliteID storj.NodeID, period string) (_ *PayStub, err error)

GetPaystub retrieves held amount for particular satellite from satellite using RPC.

type HoldForPeriod

type HoldForPeriod struct {
	Period string `json:"period"`
	Amount int64  `json:"amount"`
}

HoldForPeriod is node's held amount for period.

type PayStub

type PayStub struct {
	SatelliteID    storj.NodeID `json:"satelliteId"`
	Period         string       `json:"period"`
	Created        time.Time    `json:"created"`
	Codes          string       `json:"codes"`
	UsageAtRest    float64      `json:"usageAtRest"`
	UsageGet       int64        `json:"usageGet"`
	UsagePut       int64        `json:"usagePut"`
	UsageGetRepair int64        `json:"usageGetRepair"`
	UsagePutRepair int64        `json:"usagePutRepair"`
	UsageGetAudit  int64        `json:"usageGetAudit"`
	CompAtRest     int64        `json:"compAtRest"`
	CompGet        int64        `json:"compGet"`
	CompPut        int64        `json:"compPut"`
	CompGetRepair  int64        `json:"compGetRepair"`
	CompPutRepair  int64        `json:"compPutRepair"`
	CompGetAudit   int64        `json:"compGetAudit"`
	SurgePercent   int64        `json:"surgePercent"`
	Held           int64        `json:"held"`
	Owed           int64        `json:"owed"`
	Disposed       int64        `json:"disposed"`
	Paid           int64        `json:"paid"`
}

PayStub is node payout data for satellite by specific period.

func (*PayStub) GetEarnedWithSurge

func (paystub *PayStub) GetEarnedWithSurge() (earned int64, surge int64)

GetEarnedWithSurge returns paystub's total earned and surge.

func (*PayStub) UsageAtRestTbM

func (paystub *PayStub) UsageAtRestTbM()

UsageAtRestTbM converts paystub's usage_at_rest from tbh to tbm.

type Payment

type Payment struct {
	ID          int64        `json:"id"`
	Created     time.Time    `json:"created"`
	SatelliteID storj.NodeID `json:"satelliteId"`
	Period      string       `json:"period"`
	Amount      int64        `json:"amount"`
	Receipt     string       `json:"receipt"`
	Notes       string       `json:"notes"`
}

Payment is node payment data for specific period.

type Period

type Period string

Period is a string that represents paystub period type in format yyyy-mm.

func (Period) Time

func (p Period) Time() (time.Time, error)

Time returns period in time.Time type from string.

type SatelliteHeldHistory

type SatelliteHeldHistory struct {
	SatelliteID         storj.NodeID `json:"satelliteID"`
	SatelliteName       string       `json:"satelliteName"`
	HoldForFirstPeriod  int64        `json:"holdForFirstPeriod"`
	HoldForSecondPeriod int64        `json:"holdForSecondPeriod"`
	HoldForThirdPeriod  int64        `json:"holdForThirdPeriod"`
	TotalHeld           int64        `json:"totalHeld"`
	TotalDisposed       int64        `json:"totalDisposed"`
	JoinedAt            time.Time    `json:"joinedAt"`
}

SatelliteHeldHistory amount of held for specific satellite for all time since join.

type SatellitePayoutForPeriod

type SatellitePayoutForPeriod struct {
	SatelliteID    string `json:"satelliteID"`
	SatelliteURL   string `json:"satelliteURL"`
	Age            int64  `json:"age"`
	Earned         int64  `json:"earned"`
	Surge          int64  `json:"surge"`
	SurgePercent   int64  `json:"surgePercent"`
	Held           int64  `json:"held"`
	HeldPercent    int64  `json:"heldPercent"`
	AfterHeld      int64  `json:"afterHeld"`
	Disposed       int64  `json:"disposed"`
	Paid           int64  `json:"paid"`
	Receipt        string `json:"receipt"`
	IsExitComplete bool   `json:"isExitComplete"`
}

SatellitePayoutForPeriod contains payout information for specific period for specific satellite.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service retrieves info from satellites using an rpc client

architecture: Service

func NewService

func NewService(log *zap.Logger, db DB, reputationDB reputation.DB, satelliteDB satellites.DB, trust *trust.Pool) *Service

NewService creates new instance of service.

func (*Service) AllHeldbackHistory

func (service *Service) AllHeldbackHistory(ctx context.Context) (result []SatelliteHeldHistory, err error)

AllHeldbackHistory retrieves heldback history for all satellites from storagenode database.

func (*Service) AllPayStubsMonthly

func (service *Service) AllPayStubsMonthly(ctx context.Context, period string) (payStubs []PayStub, err error)

AllPayStubsMonthly retrieves held amount for all satellites per selected period from storagenode database.

func (*Service) AllPayStubsPeriod

func (service *Service) AllPayStubsPeriod(ctx context.Context, periodStart, periodEnd string) (payStubs []PayStub, err error)

AllPayStubsPeriod retrieves held amount for all satellites for selected range of months from storagenode database.

func (*Service) AllPeriods

func (service *Service) AllPeriods(ctx context.Context) (_ []string, err error)

AllPeriods retrieves all periods in which we have some payout data.

func (*Service) AllSatellitesPayoutPeriod

func (service *Service) AllSatellitesPayoutPeriod(ctx context.Context, period string) (result []SatellitePayoutForPeriod, err error)

AllSatellitesPayoutPeriod retrieves paystub and payment receipt for specific month from all satellites.

func (*Service) SatellitePayStubMonthly

func (service *Service) SatellitePayStubMonthly(ctx context.Context, satelliteID storj.NodeID, period string) (payStub *PayStub, err error)

SatellitePayStubMonthly retrieves held amount for particular satellite for selected month from storagenode database.

func (*Service) SatellitePayStubPeriod

func (service *Service) SatellitePayStubPeriod(ctx context.Context, satelliteID storj.NodeID, periodStart, periodEnd string) (payStubs []PayStub, err error)

SatellitePayStubPeriod retrieves held amount for all satellites for selected months from storagenode database.

func (*Service) SatellitePeriods

func (service *Service) SatellitePeriods(ctx context.Context, satelliteID storj.NodeID) (_ []string, err error)

SatellitePeriods retrieves all periods for concrete satellite in which we have some payout data.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL