accounting

package
v0.0.0-...-b2ad1f3 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 1 Imported by: 1

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-api-go/v2/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-api-go/v2/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

func (d Decimal) Precision() uint32

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

func (d *Decimal) SetPrecision(p uint32)

SetPrecision sets precision of the decimal number.

See also Precision.

func (*Decimal) SetValue

func (d *Decimal) SetValue(v int64)

SetValue sets value of the decimal number.

See also Value.

func (Decimal) Value

func (d Decimal) Value() int64

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.

Directories

Path Synopsis
Package accountingtest provides functions for convenient testing of accounting package API.
Package accountingtest provides functions for convenient testing of accounting package API.

Jump to

Keyboard shortcuts

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