-
Notifications
You must be signed in to change notification settings - Fork 390
/
projectusage.go
34 lines (28 loc) · 1.08 KB
/
projectusage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package accounting
import (
"storj.io/storj/internal/memory"
)
const (
// AverageDaysInMonth is how many days in a month
AverageDaysInMonth = 30
// ExpansionFactor is the expansion for redundancy, based on the default
// redundancy scheme for the uplink.
ExpansionFactor = 3
)
// ExceedsAlphaUsage returns true if the storage or bandwidth usage limits have been exceeded
// for a project in the past month (30 days). The usage limit is 25GB multiplied by the redundancy
// expansion factor, so that the uplinks have a raw limit of 25GB.
// TODO(jg): remove this code once we no longer need usage limiting for alpha release
// Ref: https://storjlabs.atlassian.net/browse/V3-1274
func ExceedsAlphaUsage(bandwidthGetTotal, inlineTotal, remoteTotal int64, maxAlphaUsageGB memory.Size) (bool, string) {
maxUsage := maxAlphaUsageGB.Int64() * int64(ExpansionFactor)
if bandwidthGetTotal >= maxUsage {
return true, "bandwidth"
}
if inlineTotal+remoteTotal >= maxUsage {
return true, "storage"
}
return false, ""
}