Documentation ¶
Overview ¶
Package accounting provides primitives to perform accounting operations in FrostFS.
Decimal type provides functionality to process user balances. For example, when working with Fixed8 balance precision:
var dec accounting.Decimal dec.SetValue(val) dec.SetPrecision(8)
Instances can be also used to process FrostFS API V2 protocol messages (see neo.fs.v2.accounting package in https://git.frostfs.info/TrueCloudLab/frostfs-api).
On client side:
import "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/accounting" var msg accounting.Decimal dec.WriteToV2(&msg) // send msg
On server side:
// recv msg var dec accounting.Decimal dec.ReadFromV2(msg) // process dec
Using package types in an application is recommended to potentially work with different protocol versions with which these types are compatible.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decimal ¶
type Decimal accounting.Decimal
Decimal represents decimal number for accounting operations.
Decimal is mutually compatible with git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/accounting.Decimal message. See ReadFromV2 / WriteToV2 methods.
Instances can be created using built-in var declaration.
Note that direct typecast is not safe and may result in loss of compatibility:
_ = Decimal(accounting.Decimal{}) // not recommended
func (Decimal) Precision ¶
Precision returns precision of the decimal number.
Zero Decimal has zero precision.
See also SetPrecision.
func (*Decimal) ReadFromV2 ¶
func (d *Decimal) ReadFromV2(m accounting.Decimal) error
ReadFromV2 reads Decimal from the accounting.Decimal message. Checks if the message conforms to FrostFS API V2 protocol.
See also WriteToV2.
func (*Decimal) SetPrecision ¶
SetPrecision sets precision of the decimal number.
See also Precision.
func (Decimal) Value ¶
Value returns value of the decimal number.
Zero Decimal has zero value.
See also SetValue.
func (Decimal) WriteToV2 ¶
func (d Decimal) WriteToV2(m *accounting.Decimal)
WriteToV2 writes Decimal to the accounting.Decimal message. The message must not be nil.
See also ReadFromV2.