spice

package
v0.0.0-...-864a747 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Currency = iota
	SupplementaryCurrency
)
View Source
const (
	MaxAmountPerSupplementaryCurrency = 1000000000000000000
)

Variables

View Source
var (
	ErrValueOverflow      = errors.New("value overflow")
	ErrNoSufficientFounds = errors.New("no sufficient founds to process transaction")
)

Functions

func Transfer

func Transfer(amount Melange, from, to *Melange) error

Transfer transfers given amount from one Melange asset to the other if possible or returns error otherwise.

Types

type Melange

type Melange struct {
	Currency              uint64 `yaml:"currency"               msgpack:"currency"`
	SupplementaryCurrency uint64 `yaml:"supplementary_currency" msgpack:"supplementary_currency"`
}

Melange is an asset that is digitally transferable between two wallets.

func Decode

func Decode(buf []byte) (Melange, error)

func FromFloat

func FromFloat(n float64) Melange

From float crates a new spice Melange from floating point number. Note this will give a precision up to nine decimal places.

func New

func New(currency, supplementaryCurrency uint64) Melange

New creates a new spice Melange from given currency and supplementary currency values.

func (Melange) Clone

func (m Melange) Clone() Melange

func (*Melange) Drain

func (m *Melange) Drain(amount Melange, sink *Melange) error

Drain drains amount from the function pointer receiver to the sink.

func (*Melange) Empty

func (m *Melange) Empty() bool

Empty verifies if is spice empty.

func (*Melange) Encode

func (s *Melange) Encode() ([]byte, error)

func (Melange) String

func (m Melange) String() string

String returns string representation of spice Melange.

func (*Melange) Supply

func (m *Melange) Supply(amount Melange) error

Supply supplies spice of the given amount from the source to the entity.

Jump to

Keyboard shortcuts

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