[#170] accounting: Remove message
sub-string from V2-methods
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
7d31de57ec
commit
aeb4ac638a
4 changed files with 12 additions and 12 deletions
|
@ -5,7 +5,7 @@ import "github.com/nspcc-dev/neofs-api-go/v2/accounting"
|
|||
// Decimal represents decimal number for accounting operations.
|
||||
//
|
||||
// Decimal is mutually compatible with github.com/nspcc-dev/neofs-api-go/v2/accounting.Decimal
|
||||
// message. See ReadFromMessageV2 / WriteToMessageV2 methods.
|
||||
// message. See ReadFromV2 / WriteToV2 methods.
|
||||
//
|
||||
// Instances can be created using built-in var declaration.
|
||||
//
|
||||
|
@ -13,18 +13,18 @@ import "github.com/nspcc-dev/neofs-api-go/v2/accounting"
|
|||
// _ = Decimal(accounting.Decimal{}) // not recommended
|
||||
type Decimal accounting.Decimal
|
||||
|
||||
// ReadFromMessageV2 reads Decimal from the accounting.Decimal message.
|
||||
// ReadFromV2 reads Decimal from the accounting.Decimal message.
|
||||
//
|
||||
// See also WriteToMessageV2.
|
||||
func (d *Decimal) ReadFromMessageV2(m accounting.Decimal) {
|
||||
// See also WriteToV2.
|
||||
func (d *Decimal) ReadFromV2(m accounting.Decimal) {
|
||||
*d = Decimal(m)
|
||||
}
|
||||
|
||||
// WriteToMessageV2 writes Decimal to the accounting.Decimal message.
|
||||
// WriteToV2 writes Decimal to the accounting.Decimal message.
|
||||
// The message must not be nil.
|
||||
//
|
||||
// See also ReadFromMessageV2.
|
||||
func (d Decimal) WriteToMessageV2(m *accounting.Decimal) {
|
||||
// See also ReadFromV2.
|
||||
func (d Decimal) WriteToV2(m *accounting.Decimal) {
|
||||
*m = (accounting.Decimal)(d)
|
||||
}
|
||||
|
||||
|
|
|
@ -32,14 +32,14 @@ func TestDecimalMessageV2(t *testing.T) {
|
|||
m.SetValue(7)
|
||||
m.SetPrecision(8)
|
||||
|
||||
d.ReadFromMessageV2(m)
|
||||
d.ReadFromV2(m)
|
||||
|
||||
require.EqualValues(t, m.GetValue(), d.Value())
|
||||
require.EqualValues(t, m.GetPrecision(), d.Precision())
|
||||
|
||||
var m2 v2accounting.Decimal
|
||||
|
||||
d.WriteToMessageV2(&m2)
|
||||
d.WriteToV2(&m2)
|
||||
|
||||
require.EqualValues(t, d.Value(), m2.GetValue())
|
||||
require.EqualValues(t, d.Precision(), m2.GetPrecision())
|
||||
|
|
|
@ -14,7 +14,7 @@ On client side:
|
|||
import "github.com/nspcc-dev/neofs-api-go/v2/accounting"
|
||||
|
||||
var msg accounting.Decimal
|
||||
dec.WriteToMessageV2(&msg)
|
||||
dec.WriteToV2(&msg)
|
||||
|
||||
// send msg
|
||||
|
||||
|
@ -22,7 +22,7 @@ On server side:
|
|||
// recv msg
|
||||
|
||||
var dec accounting.Decimal
|
||||
dec.ReadFromMessageV2(msg)
|
||||
dec.ReadFromV2(msg)
|
||||
|
||||
// process dec
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ func (c *Client) BalanceGet(ctx context.Context, prm PrmBalanceGet) (*ResBalance
|
|||
|
||||
if bal := resp.GetBody().GetBalance(); bal != nil {
|
||||
var d accounting.Decimal
|
||||
d.ReadFromMessageV2(*bal)
|
||||
d.ReadFromV2(*bal)
|
||||
|
||||
res.setAmount(&d)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue