storj/storagenode/storageusage/storageusage.go
Clement Sam 3e0a4230a5 storagenode/payout: fix disk space value at payout
Payout is still calculating using the tb*h. 0So it’s getting the total disk space used this month and dividing by (24*30) instead of just 30.

More context here: https://forum.storj.io/t/current-month-earnings-in-node-v1-67-1/20319/5

Follow up PR for https://github.com/storj/storj/issues/5146

Change-Id: Ie2d48497f2a9bdbc995c99ee27e70b46580ff638
2022-11-18 01:04:20 +00:00

43 lines
1.6 KiB
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package storageusage
import (
"context"
"time"
"storj.io/common/storj"
)
// DB works with storage usage database.
//
// architecture: Database
type DB interface {
// Store stores storage usage stamps to db replacing conflicting entries
Store(ctx context.Context, stamps []Stamp) error
// GetDaily returns daily storage usage stamps for particular satellite
// for provided time range
GetDaily(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) ([]Stamp, error)
// GetDailyTotal returns daily storage usage stamps summed across all known satellites
// for provided time range
GetDailyTotal(ctx context.Context, from, to time.Time) ([]Stamp, error)
// Summary returns aggregated storage usage across all satellites.
Summary(ctx context.Context, from, to time.Time) (float64, error)
// SatelliteSummary returns aggregated storage usage for a particular satellite.
SatelliteSummary(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) (float64, error)
}
// Stamp is storage usage stamp for satellite from interval start till next interval.
type Stamp struct {
SatelliteID storj.NodeID `json:"-"`
// AtRestTotal is the disk space used from IntervalStart to IntervalEndTime in Bytes*day
AtRestTotal float64 `json:"atRestTotal"`
// IntervalStart represents one tally day
// TODO: rename to timestamp to match DB
IntervalStart time.Time `json:"intervalStart"`
// IntervalEndTime represents the timestamp for the last tally run time
// (i.e. last interval_end_time) for the day
IntervalEndTime time.Time `json:"-"`
}