Documentation ¶
Index ¶
- Variables
- type Account
- func (a *Account) AddBalanceByID(assetID uint64, value *big.Int) error
- func (a *Account) AddNewAssetByAssetID(assetID uint64, amount *big.Int)
- func (a *Account) EnoughAccountBalance(assetID uint64, value *big.Int) error
- func (a *Account) GetAllBalances() (map[uint64]*big.Int, error)
- func (a *Account) GetBalanceByID(assetID uint64) (*big.Int, error)
- func (a *Account) GetBalancesList() []*AssetBalance
- func (a *Account) GetCode() ([]byte, error)
- func (a *Account) GetCodeHash() (common.Hash, error)
- func (a *Account) GetCodeSize() uint64
- func (a *Account) GetName() common.Name
- func (a *Account) GetNonce() uint64
- func (a *Account) GetPubKey() common.PubKey
- func (a *Account) IsDestoryed() bool
- func (a *Account) IsEmpty() bool
- func (a *Account) IsSuicided() bool
- func (a *Account) SetBalance(assetID uint64, amount *big.Int) error
- func (a *Account) SetCode(code []byte) error
- func (a *Account) SetDestory()
- func (a *Account) SetNonce(nonce uint64)
- func (a *Account) SetPubKey(pubkey common.PubKey)
- func (a *Account) SetSuicide()
- func (a *Account) SubBalanceByID(assetID uint64, value *big.Int) error
- type AccountManager
- func (am *AccountManager) AccountIsEmpty(accountName common.Name) (bool, error)
- func (am *AccountManager) AccountIsExist(accountName common.Name) (bool, error)
- func (am *AccountManager) AddAccountBalanceByID(accountName common.Name, assetID uint64, value *big.Int) error
- func (am *AccountManager) AddAccountBalanceByName(accountName common.Name, assetName string, value *big.Int) error
- func (am *AccountManager) CanTransfer(accountName common.Name, assetID uint64, value *big.Int) (bool, error)
- func (am *AccountManager) CreateAccount(accountName common.Name, pubkey common.PubKey) error
- func (am *AccountManager) DeleteAccountByName(accountName common.Name) error
- func (am *AccountManager) EnoughAccountBalance(accountName common.Name, assetID uint64, value *big.Int) error
- func (am *AccountManager) GetAccountBalanceByID(accountName common.Name, assetID uint64) (*big.Int, error)
- func (am *AccountManager) GetAccountByName(accountName common.Name) (*Account, error)
- func (am *AccountManager) GetAccountFromValue(accountName common.Name, key string, value []byte) (*Account, error)
- func (am *AccountManager) GetAssetInfoByID(assetID uint64) (*asset.AssetObject, error)
- func (am *AccountManager) GetAssetInfoByName(assetName string) (*asset.AssetObject, error)
- func (am *AccountManager) GetCode(accountName common.Name) ([]byte, error)
- func (am *AccountManager) GetCodeSize(accountName common.Name) (uint64, error)
- func (am *AccountManager) GetNonce(accountName common.Name) (uint64, error)
- func (am *AccountManager) IncAsset2Acct(fromName common.Name, toName common.Name, assetID uint64, amount *big.Int) error
- func (am *AccountManager) IsValidSign(accountName common.Name, aType types.ActionType, pub common.PubKey) error
- func (am *AccountManager) IssueAsset(asset *asset.AssetObject) error
- func (am *AccountManager) Process(action *types.Action) error
- func (am *AccountManager) RecoverTx(signer types.Signer, tx *types.Transaction) error
- func (am *AccountManager) SetAccount(acct *Account) error
- func (am *AccountManager) SetNonce(accountName common.Name, nonce uint64) error
- func (am *AccountManager) SubAccountBalanceByID(accountName common.Name, assetID uint64, value *big.Int) error
- func (am *AccountManager) TransferAsset(fromAccount common.Name, toAccount common.Name, assetID uint64, value *big.Int) error
- func (am *AccountManager) UpdateAccount(accountName common.Name, pubkey common.PubKey) error
- type AssetBalance
- type IAccount
- type IAccountManager
- type SdbIf
Constants ¶
This section is empty.
Variables ¶
var ( ErrInsufficientBalance = errors.New("insufficient balance") ErrNewAccountErr = errors.New("new account err") ErrAssetIDInvalid = errors.New("asset id invalid") ErrCreateAccountError = errors.New("create account error") ErrAccountIsExist = errors.New("account is exist") ErrAccountIsDestroy = errors.New("account is destory") ErrAccountNotExist = errors.New("account not exist") ErrHashIsEmpty = errors.New("hash is empty") ErrkeyNotSame = errors.New("key not same") ErrAccountNameInvalid = errors.New("account name is Invalid") ErrInvalidPubKey = errors.New("invalid public key") ErrAccountIsNil = errors.New("account object is empty") ErrCodeIsEmpty = errors.New("code is empty") ErrAmountValueInvalid = errors.New("amount value is invalid") ErrAccountAssetNotExist = errors.New("account asset not exist") ErrUnkownTxType = errors.New("Not support action type") )
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { AcctName common.Name Nonce uint64 PublicKey common.PubKey Code []byte CodeHash common.Hash CodeSize uint64 //sort by asset id asc Balances []*AssetBalance //code Suicide Suicide bool //account destroy Destroy bool }
Account account object
func NewAccount ¶
NewAccount create a new account object.
func (*Account) AddBalanceByID ¶
AddAccountBalanceByID add balance by assetID
func (*Account) AddNewAssetByAssetID ¶
AddNewAssetByAssetID add a new asset to balance list and set the value to zero
func (*Account) EnoughAccountBalance ¶
func (*Account) GetAllBalances ¶
GetAllBalances get all balance list
func (*Account) GetBalanceByID ¶
GetBalanceByID get balance by asset id
func (*Account) GetBalancesList ¶
func (a *Account) GetBalancesList() []*AssetBalance
GetBalancesList get all balance list
func (*Account) GetCodeHash ¶
GetCodeHash get code hash
func (*Account) SetBalance ¶
SetBalance set amount to balance
type AccountManager ¶
type AccountManager struct {
// contains filtered or unexported fields
}
AccountManager represents account management model.
func NewAccountManager ¶
func NewAccountManager(db *state.StateDB) (*AccountManager, error)
NewAccountManager create new account manager
func (*AccountManager) AccountIsEmpty ¶
func (am *AccountManager) AccountIsEmpty(accountName common.Name) (bool, error)
AccountIsEmpty check code size > 0
func (*AccountManager) AccountIsExist ¶
func (am *AccountManager) AccountIsExist(accountName common.Name) (bool, error)
AccountIsExist check account is exist.
func (*AccountManager) AddAccountBalanceByID ¶
func (am *AccountManager) AddAccountBalanceByID(accountName common.Name, assetID uint64, value *big.Int) error
AddAccountBalanceByID add balance by assetID
func (*AccountManager) AddAccountBalanceByName ¶
func (*AccountManager) CanTransfer ¶
func (am *AccountManager) CanTransfer(accountName common.Name, assetID uint64, value *big.Int) (bool, error)
CanTransfer check if can transfer.
func (*AccountManager) CreateAccount ¶
CreateAccount contract account pubkey = nil
func (*AccountManager) DeleteAccountByName ¶
func (am *AccountManager) DeleteAccountByName(accountName common.Name) error
DeleteAccountByName delete account
func (*AccountManager) EnoughAccountBalance ¶
func (*AccountManager) GetAccountBalanceByID ¶
func (am *AccountManager) GetAccountBalanceByID(accountName common.Name, assetID uint64) (*big.Int, error)
GetAccountBalanceByID get account balance by ID
func (*AccountManager) GetAccountByName ¶
func (am *AccountManager) GetAccountByName(accountName common.Name) (*Account, error)
GetAccountByName get account by name
func (*AccountManager) GetAccountFromValue ¶
func (am *AccountManager) GetAccountFromValue(accountName common.Name, key string, value []byte) (*Account, error)
GetAccountFromValue get account info via value bytes
func (*AccountManager) GetAssetInfoByID ¶
func (am *AccountManager) GetAssetInfoByID(assetID uint64) (*asset.AssetObject, error)
GetAssetInfoByID get asset info by assetID
func (*AccountManager) GetAssetInfoByName ¶
func (am *AccountManager) GetAssetInfoByName(assetName string) (*asset.AssetObject, error)
GetAssetInfoByName get asset info by asset name.
func (*AccountManager) GetCode ¶
func (am *AccountManager) GetCode(accountName common.Name) ([]byte, error)
func (*AccountManager) GetCodeSize ¶
func (am *AccountManager) GetCodeSize(accountName common.Name) (uint64, error)
GetCodeSize get code size
func (*AccountManager) GetNonce ¶
func (am *AccountManager) GetNonce(accountName common.Name) (uint64, error)
GetNonce get nonce
func (*AccountManager) IncAsset2Acct ¶
func (am *AccountManager) IncAsset2Acct(fromName common.Name, toName common.Name, assetID uint64, amount *big.Int) error
increase asset and add amount to accout balance
func (*AccountManager) IsValidSign ¶
func (am *AccountManager) IsValidSign(accountName common.Name, aType types.ActionType, pub common.PubKey) error
IsValidSign
func (*AccountManager) IssueAsset ¶
func (am *AccountManager) IssueAsset(asset *asset.AssetObject) error
IssueAsset issue asset
func (*AccountManager) RecoverTx ¶
func (am *AccountManager) RecoverTx(signer types.Signer, tx *types.Transaction) error
RecoverTx Make sure the transaction is signed properly and validate account authorization.
func (*AccountManager) SetAccount ¶
func (am *AccountManager) SetAccount(acct *Account) error
store account object to db
func (*AccountManager) SetNonce ¶
func (am *AccountManager) SetNonce(accountName common.Name, nonce uint64) error
SetNonce set nonce
func (*AccountManager) SubAccountBalanceByID ¶
func (am *AccountManager) SubAccountBalanceByID(accountName common.Name, assetID uint64, value *big.Int) error
SubAccountBalanceByID sub balance by assetID
func (*AccountManager) TransferAsset ¶
func (am *AccountManager) TransferAsset(fromAccount common.Name, toAccount common.Name, assetID uint64, value *big.Int) error
TransferAsset
func (*AccountManager) UpdateAccount ¶
UpdateAccount update the pubkey of the accunt
type AssetBalance ¶
AssetBalance asset and balance struct
type IAccount ¶
type IAccount interface { //newAccount(accountName common.Name, pubkey common.PubKey) (*Account, error) GetName() common.Name //nonce GetNonce() uint64 SetNonce(nonce uint64) //code GetCode() ([]byte, error) SetCode(code []byte) (bool, error) GetCodeHash() (common.Hash, error) GetCodeSize() (uint64, error) // GetPubKey() common.PubKey SetPubKey(pubkey common.PubKey) //asset GetBalancesList() ([]*AssetBalance, error) GetAllAccountBalance() (map[uint64]*big.Int, error) AddBalanceByID(assetID uint64, value *big.Int) error SubBalanceByID(assetID uint64, value *big.Int) error EnoughAccountBalance(assetID uint64, value *big.Int) error // IsSuicided() bool SetSuicide() // IsDestoryed() SetDestory() }
type IAccountManager ¶
type IAccountManager interface { //account AccountIsExist(accountName common.Name) (bool, error) AccountIsEmpty(accountName common.Name) (bool, error) CreateAccount(accountName common.Name, pubkey common.PubKey) error DeleteAccountByName(accountName common.Name) error GetAccountByName(accountName common.Name) (*Account, error) SetAccount(acct *Account) error //sign RecoverTx(signer types.Signer, tx *types.Transaction) error IsValidSign(accountName common.Name, aType types.ActionType, pub common.PubKey) error //asset IssueAsset(asset *asset.AssetObject) error IncreaseAsset(accountName common.Name, assetID uint64, amount *big.Int) error // CanTransfer(accountName common.Name, assetId uint64, value *big.Int) (bool, error) TransferAsset(fromAccount common.Name, toAccount common.Name, assetID uint64, value *big.Int) error IncAsset2Acct(fromName common.Name, toName common.Name, assetId uint64, amount *big.Int) error AddBalanceByName(accountName common.Name, assetID uint64, amount *big.Int) error Process(action *types.Action) error }