Documentation ¶
Index ¶
- Constants
- func CheckMintUpdate(update *BalanceUpdate) error
- func CheckTokenMint(tx *types.Transaction) (signature []byte, pubKey []byte, tokenId []byte, err error)
- func CheckTokenUnMint(tx *types.Transaction) (signature []byte, pubKey []byte, tokenId []byte, err error)
- func CheckUnMintUpdate(update *BalanceUpdate) error
- func DBPutTokenState(dbTx database.Tx, bid uint32, ts *TokenState) error
- func DBRemoveTokenState(dbTx database.Tx, id uint32) error
- func IsTokenMint(tx *types.Transaction) bool
- func IsTokenUnMint(tx *types.Transaction) bool
- func UseLogger(logger l.Logger)
- type BalanceUpdate
- type ITokenUpdate
- type TokenBalance
- type TokenBalancesMap
- type TokenFeeConfig
- type TokenState
- type TokenType
- type TokenTypesMap
- type TokenUpdate
- type TypeUpdate
Constants ¶
const ( // TokenMintScriptLen is the length of a TokenMint script // <OP_DATA_64> <signature> <OP_DATA_33> <public key> <OP_DATA_2> <token_id> <OP_TOKEN_MINT> // 1 + 64 + 1 + 33 + 1 + 2 + 1 = 103 TokenMintScriptLen = 103 // TokenUnMintScriptLen is the length of a TokenUnMint script // <OP_DATA_64> <signature> <OP_DATA_33> <public key> <OP_DATA_2> <token_id> <OP_TOKEN_UNMINT> // 1 + 64 + 1 + 33 + 1 + 2 + 1 = 103 TokenUnMintScriptLen = 103 // TokenIdSize is the length of a TokenId (two bytes uint16) TokenIdSize = 2 )
const MaxTokenNameLength = 6
Variables ¶
This section is empty.
Functions ¶
func CheckMintUpdate ¶
func CheckMintUpdate(update *BalanceUpdate) error
func CheckTokenMint ¶
func CheckTokenMint(tx *types.Transaction) (signature []byte, pubKey []byte, tokenId []byte, err error)
CheckTokenMint verifies the input if is a valid TOKEN_MINT transaction. The function return the signature, public key, tokenId and an error. The function ONLY check if the format is correct. for the returned signature, public key and token id. The callee MUST to do additional check for the returned values.
func CheckTokenUnMint ¶
func CheckTokenUnMint(tx *types.Transaction) (signature []byte, pubKey []byte, tokenId []byte, err error)
CheckTokenUnMint verifies the input if is a valid TOKEN_UNMINT transaction. The function return the signature, public key, tokenId and an error. The function ONLY check if the format is correct. for the returned signature, public key and token id. The callee MUST to do additional check for the returned values.
func CheckUnMintUpdate ¶
func CheckUnMintUpdate(update *BalanceUpdate) error
func DBPutTokenState ¶
func DBPutTokenState(dbTx database.Tx, bid uint32, ts *TokenState) error
dbPutTokenState put a token balance record into the token state database. the key is the provided block hash
func IsTokenMint ¶
func IsTokenMint(tx *types.Transaction) bool
IsTokenMint returns true if the input transaction is a valid TOKEN_MINT NOTICE: the function DOES NOT check the signature and pubKey and tokenId.
func IsTokenUnMint ¶
func IsTokenUnMint(tx *types.Transaction) bool
IsTokenUnMint returns true if the input transaction is a valid TOKEN_UlMINT NOTICE: the function DOES NOT check the signature and pubKey and tokenId.
Types ¶
type BalanceUpdate ¶
type BalanceUpdate struct { *TokenUpdate MeerAmount int64 TokenAmount types.Amount // contains filtered or unexported fields }
balanceUpdate specifies the type and update record of the values that change a token balance. for TOKON_MINT, the values should add on the meerlock and token balance for TOKEN_UNMINT, the values should subtract from the meerlock and token balance
func NewBalanceUpdate ¶
func NewBalanceUpdate(tx *types.Transaction) (*BalanceUpdate, error)
func (*BalanceUpdate) CacheHash ¶
func (bu *BalanceUpdate) CacheHash() *hash.Hash
func (*BalanceUpdate) CheckSanity ¶
func (bu *BalanceUpdate) CheckSanity() error
func (*BalanceUpdate) Deserialize ¶
func (bu *BalanceUpdate) Deserialize(data []byte) (int, error)
func (*BalanceUpdate) GetHash ¶
func (bu *BalanceUpdate) GetHash() *hash.Hash
func (*BalanceUpdate) Serialize ¶
func (bu *BalanceUpdate) Serialize() ([]byte, error)
type ITokenUpdate ¶
type ITokenUpdate interface { GetType() types.TxType GetHash() *hash.Hash Serialize() ([]byte, error) Deserialize(data []byte) (int, error) CheckSanity() error }
func NewTokenUpdate ¶
func NewTokenUpdate(tu *TokenUpdate) ITokenUpdate
func NewUpdateFromTx ¶
func NewUpdateFromTx(tx *types.Transaction) (ITokenUpdate, error)
type TokenBalance ¶
TokenBalance specifies the token balance and the locked meer amount
type TokenBalancesMap ¶
type TokenBalancesMap map[types.CoinID]TokenBalance
func (*TokenBalancesMap) Copy ¶
func (tb *TokenBalancesMap) Copy() *TokenBalancesMap
func (*TokenBalancesMap) String ¶
func (tb *TokenBalancesMap) String() string
func (*TokenBalancesMap) Update ¶
func (tbs *TokenBalancesMap) Update(update *BalanceUpdate) error
func (*TokenBalancesMap) Updates ¶
func (tbs *TokenBalancesMap) Updates(updates []BalanceUpdate) error
type TokenFeeConfig ¶
func NewTokenFeeConfig ¶
func NewTokenFeeConfig(data int64) *TokenFeeConfig
func (*TokenFeeConfig) GetData ¶
func (tf *TokenFeeConfig) GetData() int64
type TokenState ¶
type TokenState struct { PrevStateID uint32 Types TokenTypesMap Balances TokenBalancesMap Updates []ITokenUpdate }
tokenState specifies the token balance of the current block. the updates are written in the same order as the tx in the block, which is used to verify the correctness of the token balance
func BuildGenesisTokenState ¶
func BuildGenesisTokenState() *TokenState
TODO: You can customize the initial value
func DBFetchTokenState ¶
func DBFetchTokenState(dbTx database.Tx, bid uint32) (*TokenState, error)
dbFetchTokenState fetch the token balance record from the token state database. the key is the input block hash.
func (*TokenState) Commit ¶
func (ts *TokenState) Commit() error
func (*TokenState) Deserialize ¶
func (ts *TokenState) Deserialize(data []byte) (int, error)
Deserialize function will deserializes token state from the byte slice
func (*TokenState) Serialize ¶
func (ts *TokenState) Serialize() ([]byte, error)
Serialize function will serialize the token state into byte slice
func (*TokenState) Update ¶
func (ts *TokenState) Update() error
type TokenType ¶
type TokenType struct { Id types.CoinID Owners []byte UpLimit uint64 Enable bool Name string FeeCfg TokenFeeConfig }
func (*TokenType) GetAddress ¶
type TokenTypesMap ¶
func (*TokenTypesMap) Ids ¶
func (ttm *TokenTypesMap) Ids() []string
func (*TokenTypesMap) Update ¶
func (ttm *TokenTypesMap) Update(update *TypeUpdate) error
type TokenUpdate ¶
func (*TokenUpdate) Deserialize ¶
func (tu *TokenUpdate) Deserialize(data []byte) (int, error)
func (*TokenUpdate) GetType ¶
func (tu *TokenUpdate) GetType() types.TxType
func (*TokenUpdate) Serialize ¶
func (tu *TokenUpdate) Serialize() ([]byte, error)
type TypeUpdate ¶
type TypeUpdate struct { *TokenUpdate Tt TokenType // contains filtered or unexported fields }
func NewTypeUpdateFromTx ¶
func NewTypeUpdateFromTx(tx *types.Transaction) (*TypeUpdate, error)
func (*TypeUpdate) CacheHash ¶
func (tu *TypeUpdate) CacheHash() *hash.Hash
func (*TypeUpdate) CheckSanity ¶
func (tu *TypeUpdate) CheckSanity() error
func (*TypeUpdate) Deserialize ¶
func (tu *TypeUpdate) Deserialize(data []byte) (int, error)
func (*TypeUpdate) GetHash ¶
func (tu *TypeUpdate) GetHash() *hash.Hash
func (*TypeUpdate) Serialize ¶
func (tu *TypeUpdate) Serialize() ([]byte, error)