heldamount

package
v1.9.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrHeldAmountService defines held amount service error.
	ErrHeldAmountService = errs.Class("heldamount 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 heldamount database.

Functions

This section is empty.

Types

type AmountPeriod added in v1.6.1

type AmountPeriod struct {
	Period string `json:"period"`
	Held   int64  `json:"held"`
}

AmountPeriod is node's held amount for period.

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 held amount into the DB
	StorePayStub(ctx context.Context, paystub PayStub) error
	// GetPayStub retrieves paystub stats for specific satellite
	GetPayStub(ctx context.Context, satelliteID storj.NodeID, period string) (*PayStub, error)
	// AllPayStubs retrieves paystub data 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) ([]AmountPeriod, 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 heldamount data.
	SatellitePeriods(ctx context.Context, satelliteID storj.NodeID) ([]string, error)
	// AllPeriods retrieves all periods in which we have some heldamount data.
	AllPeriods(ctx context.Context) ([]string, error)
	// StorePayment inserts or updates payment into the DB
	StorePayment(ctx context.Context, payment Payment) error
}

DB works with heldamount database

architecture: Database

type Endpoint added in v1.8.1

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

Endpoint retrieves info from satellites using an rpc client.

architecture: Endpoint

func NewEndpoint added in v1.8.1

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

NewEndpoint creates new instance of endpoint.

func (*Endpoint) GetAllPayments added in v1.8.1

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

GetAllPayments retrieves all payments for particular satellite.

func (*Endpoint) GetAllPaystubs added in v1.8.1

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

GetAllPaystubs retrieves all paystubs for particular satellite.

func (*Endpoint) GetPayment added in v1.8.1

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 added in v1.8.1

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 EstimatedPayout added in v1.6.1

type EstimatedPayout struct {
	CurrentMonth  PayoutMonthly `json:"currentMonth"`
	PreviousMonth PayoutMonthly `json:"previousMonth"`
}

EstimatedPayout contains usage and estimated payout data for current and previous months.

type HeldHistory added in v1.6.1

type HeldHistory struct {
	SatelliteID   storj.NodeID `json:"satelliteID"`
	SatelliteName string       `json:"satelliteName"`
	Age           int64        `json:"age"`
	FirstPeriod   int64        `json:"firstPeriod"`
	SecondPeriod  int64        `json:"secondPeriod"`
	ThirdPeriod   int64        `json:"thirdPeriod"`
	TotalHeld     int64        `json:"totalHeld"`
	TotalDisposed int64        `json:"totalDisposed"`
	JoinedAt      time.Time    `json:"joinedAt"`
}

HeldHistory amount of held for specific percent rate 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"`
	Receipt        string       `json:"receipt"`
}

PayStub is node heldamount data for satellite by specific period.

func (*PayStub) UsageAtRestTbM added in v1.9.1

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 PayoutHistory added in v1.9.1

type PayoutHistory struct {
	NodeAge        int64  `json:"nodeAge"`
	Earned         int64  `json:"earned"`
	Surge          int64  `json:"surge"`
	Held           int64  `json:"held"`
	AfterHeld      int64  `json:"afterHeld"`
	HeldReturned   int64  `json:"heldReturned"`
	Receipt        string `json:"receipt"`
	IsExitComplete bool   `json:"isExitComplete"`
}

PayoutHistory contains payout information for specific period for specific satellite.

type PayoutMonthly added in v1.6.1

type PayoutMonthly struct {
	EgressBandwidth         int64   `json:"egressBandwidth"`
	EgressBandwidthPayout   int64   `json:"egressBandwidthPayout"`
	EgressRepairAudit       int64   `json:"egressRepairAudit"`
	EgressRepairAuditPayout int64   `json:"egressRepairAuditPayout"`
	DiskSpace               float64 `json:"diskSpace"`
	DiskSpacePayout         int64   `json:"diskSpacePayout"`
	HeldRate                int64   `json:"heldRate"`
	Payout                  int64   `json:"payout"`
	Held                    int64   `json:"held"`
}

PayoutMonthly contains usage and estimated payout date.

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 added in v1.5.2

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

AllHeldbackHistory retrieves heldback history for all satellites from storagenode database.

func (*Service) AllPayStubsMonthly added in v1.8.1

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 added in v1.8.1

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 added in v1.6.1

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

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

func (*Service) PayoutHistoryMonthly added in v1.9.1

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

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

func (*Service) SatellitePayStubMonthly added in v1.8.1

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 added in v1.8.1

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 added in v1.6.1

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 heldamount data.

Jump to

Keyboard shortcuts

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