Documentation ¶
Index ¶
- Constants
- type Bus
- type Coins
- func (c *Coins) AddReserve(id types.CoinID, amount *big.Int)
- func (c *Coins) AddVolume(id types.CoinID, amount *big.Int)
- func (c *Coins) ChangeOwner(symbol types.CoinSymbol, owner types.Address)
- func (c *Coins) Commit() error
- func (c *Coins) Create(id types.CoinID, symbol types.CoinSymbol, name string, volume *big.Int, ...)
- func (c *Coins) Exists(id types.CoinID) bool
- func (c *Coins) ExistsBySymbol(symbol types.CoinSymbol) bool
- func (c *Coins) Export(state *types.AppState)
- func (c *Coins) GetCoin(id types.CoinID) *Model
- func (c *Coins) GetCoinBySymbol(symbol types.CoinSymbol, version types.CoinVersion) *Model
- func (c *Coins) GetSymbolInfo(symbol types.CoinSymbol) *SymbolInfo
- func (c *Coins) Recreate(newID types.CoinID, name string, symbol types.CoinSymbol, volume *big.Int, ...)
- func (c *Coins) SubReserve(id types.CoinID, amount *big.Int)
- func (c *Coins) SubVolume(id types.CoinID, amount *big.Int)
- type Info
- type Model
- func (m *Model) AddReserve(amount *big.Int)
- func (m *Model) AddVolume(amount *big.Int)
- func (m *Model) CheckReserveUnderflow(delta *big.Int) error
- func (m Model) Crr() uint32
- func (m Model) GetFullSymbol() string
- func (m Model) ID() types.CoinID
- func (m Model) IsCreated() bool
- func (m Model) IsDirty() bool
- func (m Model) IsInfoDirty() bool
- func (m Model) IsSymbolInfoDirty() bool
- func (m Model) MaxSupply() *big.Int
- func (m Model) Name() string
- func (m Model) Reserve() *big.Int
- func (m *Model) SetReserve(reserve *big.Int)
- func (m *Model) SetVolume(volume *big.Int)
- func (m *Model) SubReserve(amount *big.Int)
- func (m *Model) SubVolume(amount *big.Int)
- func (m Model) Symbol() types.CoinSymbol
- func (m Model) Version() uint16
- func (m Model) Volume() *big.Int
- type RCoins
- type SymbolInfo
Constants ¶
const (
BaseVersion types.CoinVersion = 0
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Coins ¶
type Coins struct {
// contains filtered or unexported fields
}
Coins represents coins state in blockchain.
When a coin is created with a CreateCoinTx transaction, such model is created:
Model { id info symbolInfo Name Crr MaxSupply Version - is the version of the coin Symbol - is the base symbol of the coin }
Also, SymbolInfo is created:
SymbolInfo { OwnerAddress }
It is a structure that retains the owner of the ticker (not the coin). coin.symbolInfo is saved in the symbolsInfoList map, in which the key is the symbol, and the value is the owner of the coin, and upon commit is written to the db by this key: mainPrefix + symbolPrefix + symbol + infoPrefix.
Also, you need to save all coins for a particular ticker. That is, you need to associate the ticker with all the coins that refer to it. For this, there is a map symbolsList, in which the key is the ticker, and the value is an array of ids of coins that belong to this ticker (just with a different version). When you commit, this array is saved to db by this key: mainPrefix + symbolPrefix + symbol.
The coin model is saved at: mainPrefix + id.
When a coin is re-created with a RecreateCoinTx transaction, the state retrieves an array of coins that refer to this ticker (getBySymbol). Finds the current current version there, changes it to the new version. And the new coin is assigned version 0. The new coin is also added to symbolsList [ticker].
When changing the owner with a ChangeOwnerTx transaction, the state gets the current owner getSymbolInfo (ticker) and changes the owner there and saves it back.
func (*Coins) ChangeOwner ¶ added in v1.2.0
func (c *Coins) ChangeOwner(symbol types.CoinSymbol, owner types.Address)
func (*Coins) ExistsBySymbol ¶ added in v1.2.0
func (c *Coins) ExistsBySymbol(symbol types.CoinSymbol) bool
func (*Coins) GetCoinBySymbol ¶ added in v1.2.0
func (c *Coins) GetCoinBySymbol(symbol types.CoinSymbol, version types.CoinVersion) *Model
func (*Coins) GetSymbolInfo ¶ added in v1.2.0
func (c *Coins) GetSymbolInfo(symbol types.CoinSymbol) *SymbolInfo
type Model ¶
type Model struct { CName string CCrr uint32 CMaxSupply *big.Int CVersion types.CoinVersion CSymbol types.CoinSymbol // contains filtered or unexported fields }
func (*Model) AddReserve ¶
func (Model) GetFullSymbol ¶ added in v1.2.0
func (Model) IsInfoDirty ¶
func (Model) IsSymbolInfoDirty ¶ added in v1.2.0
func (*Model) SetReserve ¶
func (*Model) SubReserve ¶
func (Model) Symbol ¶
func (m Model) Symbol() types.CoinSymbol
type RCoins ¶ added in v1.2.0
type RCoins interface { Export(state *types.AppState) Exists(id types.CoinID) bool ExistsBySymbol(symbol types.CoinSymbol) bool SubReserve(symbol types.CoinID, amount *big.Int) GetCoin(id types.CoinID) *Model GetCoinBySymbol(symbol types.CoinSymbol, version types.CoinVersion) *Model GetSymbolInfo(symbol types.CoinSymbol) *SymbolInfo }
type SymbolInfo ¶ added in v1.2.0
func (SymbolInfo) OwnerAddress ¶ added in v1.2.0
func (i SymbolInfo) OwnerAddress() *types.Address