Documentation ¶
Index ¶
- Constants
- Variables
- func Sort(arr []Color)
- func ToL1Map(bals Balances) map[ledgerstate.Color]uint64
- type Balances
- func BalancesFromBytes(data []byte) (Balances, error)
- func BalancesFromDict(d dict.Dict) (Balances, error)
- func BalancesFromL1Balances(cb *ledgerstate.ColoredBalances) Balances
- func BalancesFromL1Map(cb map[ledgerstate.Color]uint64) Balances
- func BalancesFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (Balances, error)
- func NewBalances() Balances
- func NewBalancesForColor(col Color, s uint64) Balances
- func NewBalancesForIotas(s uint64) Balances
- func OutputBalancesByColor(outputs []ledgerstate.Output) (Balances, uint64)
- func (c Balances) Add(col Color, bal uint64) Balances
- func (c Balances) AddAll(another Balances)
- func (c Balances) Bytes() []byte
- func (c Balances) Clone() Balances
- func (c Balances) Diff(another Balances) map[Color]int64
- func (c Balances) Equals(another Balances) bool
- func (c Balances) ForEachRandomly(consumer func(col Color, bal uint64) bool)
- func (c Balances) ForEachSorted(consumer func(col Color, bal uint64) bool)
- func (c Balances) Get(color Color) uint64
- func (c Balances) IsEmpty() bool
- func (c Balances) Set(col Color, bal uint64) Balances
- func (c Balances) String() string
- func (c Balances) SubNoOverflow(col Color, bal uint64) Balances
- type Color
- func ColorFromBase58EncodedString(base58String string) (ret Color, err error)
- func ColorFromBytes(colorBytes []byte) (ret Color, err error)
- func ColorFromL1Color(col ledgerstate.Color) (ret Color)
- func ColorFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (ret Color, err error)
- func ColorRandom() (ret Color)
Constants ¶
const ColorLength = ledgerstate.ColorLength
Variables ¶
var ( IOTA = ColorFromL1Color(ledgerstate.ColorIOTA) MINT = ColorFromL1Color(ledgerstate.ColorMint) )
var Balances1Iota = NewBalancesForIotas(1)
var Balances1IotaL1 = map[ledgerstate.Color]uint64{ledgerstate.ColorIOTA: 1}
Functions ¶
Types ¶
type Balances ¶
Balances represents a collection of balances associated to their respective Color that maintains a deterministic order of the present Colors.
func BalancesFromBytes ¶
BalancesFromBytes unmarshals Balances from a sequence of bytes.
func BalancesFromL1Balances ¶
func BalancesFromL1Balances(cb *ledgerstate.ColoredBalances) Balances
BalancesFromL1Balances creates Balances from ledgerstate.ColoredBalances
func BalancesFromL1Map ¶
func BalancesFromL1Map(cb map[ledgerstate.Color]uint64) Balances
BalancesFromL1Map creates Balances from map[ledgerstate.Color]uint64
func BalancesFromMarshalUtil ¶
func BalancesFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (Balances, error)
BalancesFromMarshalUtil unmarshals Balances using a MarshalUtil (for easier unmarshaling).
func NewBalances ¶
func NewBalances() Balances
NewBalances returns a new Balances. In general, it has not deterministic order
func NewBalancesForColor ¶
func NewBalancesForIotas ¶
func OutputBalancesByColor ¶
func OutputBalancesByColor(outputs []ledgerstate.Output) (Balances, uint64)
func (Balances) ForEachRandomly ¶
ForEach calls the consumer for each element in the collection and aborts the iteration if the consumer returns false. Non-deterministic order of iteration
func (Balances) ForEachSorted ¶
ForEach calls the consumer for each element in the collection and aborts the iteration if the consumer returns false. Deterministic order of iteration
type Color ¶
type Color [ColorLength]byte
Color is abstract color code used in ISCP. It can be mapped into specific implementations of Goshimmer or Chrysalis by calling Init
func ColorFromBase58EncodedString ¶
ColorFromBase58EncodedString creates a Color from a base58 encoded string.
func ColorFromBytes ¶
ColorFromBytes unmarshals a Color from a sequence of bytes.
func ColorFromL1Color ¶
func ColorFromL1Color(col ledgerstate.Color) (ret Color)
func ColorFromMarshalUtil ¶
func ColorFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (ret Color, err error)
ColorFromMarshalUtil unmarshals a Color using a MarshalUtil (for easier unmarshaling).
func ColorRandom ¶
func ColorRandom() (ret Color)