forked from TrueCloudLab/frostfs-api-go
initial
This commit is contained in:
commit
1cf33e5ffd
87 changed files with 29835 additions and 0 deletions
49
accounting/service.go
Normal file
49
accounting/service.go
Normal file
|
@ -0,0 +1,49 @@
|
|||
package accounting
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-proto/decimal"
|
||||
"github.com/nspcc-dev/neofs-proto/internal"
|
||||
"github.com/nspcc-dev/neofs-proto/refs"
|
||||
)
|
||||
|
||||
type (
|
||||
// OwnerID type alias.
|
||||
OwnerID = refs.OwnerID
|
||||
|
||||
// Decimal type alias.
|
||||
Decimal = decimal.Decimal
|
||||
|
||||
// Filter is used to filter accounts by criteria.
|
||||
Filter func(acc *Account) bool
|
||||
)
|
||||
|
||||
const (
|
||||
// ErrEmptyAddress is raised when passed Address is empty.
|
||||
ErrEmptyAddress = internal.Error("empty address")
|
||||
|
||||
// ErrEmptyLockTarget is raised when passed LockTarget is empty.
|
||||
ErrEmptyLockTarget = internal.Error("empty lock target")
|
||||
|
||||
// ErrEmptyContainerID is raised when passed CID is empty.
|
||||
ErrEmptyContainerID = internal.Error("empty container ID")
|
||||
|
||||
// ErrEmptyParentAddress is raised when passed ParentAddress is empty.
|
||||
ErrEmptyParentAddress = internal.Error("empty parent address")
|
||||
)
|
||||
|
||||
// SetTTL sets ttl to BalanceRequest to satisfy TTLRequest interface.
|
||||
func (m BalanceRequest) SetTTL(v uint32) { m.TTL = v }
|
||||
|
||||
// SumFunds goes through all accounts and sums up active funds.
|
||||
func SumFunds(accounts []*Account) (res *decimal.Decimal) {
|
||||
res = decimal.Zero.Copy()
|
||||
|
||||
for i := range accounts {
|
||||
if accounts[i] == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
res = res.Add(accounts[i].ActiveFunds)
|
||||
}
|
||||
return
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue