Documentation ¶
Index ¶
- Constants
- Variables
- func Auth(vi *database.Visitor, id, permission string, authMap, reenter map[string]int) (bool, contract.Cost)
- func AuthPublisher(vi *database.Visitor, id, permission string, authMap, reenter map[string]int) (bool, contract.Cost)
- func CodeSavageCost(size int) contract.Cost
- func CommonErrorCost(layer int) contract.Cost
- func CommonOpCost(layer int) contract.Cost
- func DelDelayTxCost(dataLen int, payer string) contract.Cost
- func DelayTxCost(dataLen int, payer string) contract.Cost
- func EventCost(size int) contract.Cost
- func IsValidKey(key string) error
- func ReadAuth(vi *database.Visitor, id string) (*account.Account, contract.Cost)
- func ReceiptCost(size int) contract.Cost
- func SetCodeCost(size int) contract.Cost
- type APIDelegate
- type Authority
- type Context
- func (c *Context) Base() *Context
- func (c *Context) GClear()
- func (c *Context) GSet(key string, value interface{})
- func (c *Context) GValue(key string) (value interface{})
- func (c *Context) Set(key string, value interface{})
- func (c *Context) String() string
- func (c *Context) Value(key string) (value interface{})
- type DBHandler
- func (h *DBHandler) Del(key string) (contract.Cost, error)
- func (h *DBHandler) Get(key string) (value interface{}, cost contract.Cost)
- func (h *DBHandler) GlobalGet(con, key string) (value interface{}, cost contract.Cost)
- func (h *DBHandler) GlobalHas(con, key string) (bool, contract.Cost)
- func (h *DBHandler) GlobalMapGet(con, key, field string) (value interface{}, cost contract.Cost)
- func (h *DBHandler) GlobalMapHas(con, key, field string) (bool, contract.Cost)
- func (h *DBHandler) GlobalMapKeys(con, key string) (keys []string, cost contract.Cost)
- func (h *DBHandler) GlobalMapLen(con, key string) (length int, cost contract.Cost)
- func (h *DBHandler) Has(key string) (bool, contract.Cost)
- func (h *DBHandler) MapDel(key, field string) (contract.Cost, error)
- func (h *DBHandler) MapGet(key, field string) (value interface{}, cost contract.Cost)
- func (h *DBHandler) MapHas(key, field string) (bool, contract.Cost)
- func (h *DBHandler) MapKeys(key string) (fields []string, cost contract.Cost)
- func (h *DBHandler) MapLen(key string) (int, contract.Cost)
- func (h *DBHandler) MapPut(key, field string, value interface{}, ramPayer ...string) (contract.Cost, error)
- func (h *DBHandler) Put(key string, value interface{}, ramPayer ...string) (contract.Cost, error)
- type DNS
- type EventPoster
- type GasManager
- func (g *GasManager) ChangeTGas(name string, delta *common.Fixed, changeQuota bool) contract.Cost
- func (g *GasManager) ChangeTGasQuota(name string, delta *common.Fixed) contract.Cost
- func (g *GasManager) CostGas(name string, gasCost *common.Fixed) error
- func (g *GasManager) DelGasPledge(name string, pledger string) contract.Cost
- func (g *GasManager) GasLimit(name string) (*common.Fixed, contract.Cost)
- func (g *GasManager) GasPledge(name string, pledger string) (*common.Fixed, contract.Cost)
- func (g *GasManager) GasPledgeTotal(name string) (*common.Fixed, contract.Cost)
- func (g *GasManager) GasStock(name string) (*common.Fixed, contract.Cost)
- func (g *GasManager) GasUpdateTime(name string) (int64, contract.Cost)
- func (g *GasManager) PGas(name string) *common.Fixed
- func (g *GasManager) RefreshPGas(name string) (contract.Cost, error)
- func (g *GasManager) SetGasLimit(name string, l *common.Fixed) contract.Cost
- func (g *GasManager) SetGasPledge(name string, pledger string, p *common.Fixed) contract.Cost
- func (g *GasManager) SetGasPledgeTotal(name string, r *common.Fixed) contract.Cost
- func (g *GasManager) SetGasStock(name string, gas *common.Fixed) contract.Cost
- func (g *GasManager) SetGasUpdateTime(name string, t int64) contract.Cost
- func (g *GasManager) TGas(name string) (*common.Fixed, contract.Cost)
- func (g *GasManager) TGasQuota(name string) (*common.Fixed, contract.Cost)
- func (g *GasManager) TotalGas(name string) *common.Fixed
- type Host
- func (h *Host) Call(cont, api, jarg string, withAuth ...bool) ([]interface{}, contract.Cost, error)
- func (h *Host) CallWithAuth(contract, api, jarg string) ([]interface{}, contract.Cost, error)
- func (h *Host) CancelDelaytx(txHash string) (contract.Cost, error)
- func (h *Host) CheckAmountLimit(amountLimit []*contract.Amount) error
- func (h *Host) CheckPublisher(t *tx.Tx) error
- func (h *Host) CheckSigners(t *tx.Tx) error
- func (h *Host) Context() *Context
- func (h *Host) DB() *database.Visitor
- func (h *Host) Deadline() time.Time
- func (h *Host) IsValidAccount(name string) bool
- func (h *Host) Logger() *ilog.Logger
- func (h *Host) PopCtx()
- func (h *Host) PushCtx()
- func (h *Host) ReadSettings()
- func (h *Host) SetCode(c *contract.Contract, owner string) (contract.Cost, error)
- func (h *Host) SetContext(ctx *Context)
- func (h *Host) SetDeadline(t time.Time)
- func (h *Host) UpdateCode(c *contract.Contract, id database.SerializedJSON) (contract.Cost, error)
- type Info
- func (h *Info) ABIConfig(key, value string)
- func (h *Info) BlockInfo() (info database.SerializedJSON, cost contract.Cost)
- func (h *Info) BlockTime() (ntime int64, cost contract.Cost)
- func (h *Info) ContextInfo() (info database.SerializedJSON, cost contract.Cost)
- func (h *Info) ContractName() (name string, cost contract.Cost)
- func (h *Info) GasLimitValue() int64
- func (h *Info) TxInfo() (info database.SerializedJSON, cost contract.Cost)
- type Monitor
- type Setting
- type Teller
- func (t *Teller) AddCacheCost(c contract.Cost)
- func (t *Teller) CacheCost() contract.Cost
- func (t *Teller) ClearCacheCost()
- func (t *Teller) ClearCosts()
- func (t *Teller) ClearRAMCosts()
- func (t *Teller) Costs() map[string]contract.Cost
- func (t *Teller) DoPay(witness string, gasRatio int64) (paidGas *common.Fixed, err error)
- func (t *Teller) FlushCacheCost()
- func (t *Teller) GasPaid(publishers ...string) int64
- func (t *Teller) IsProducer(acc string) bool
- func (t *Teller) PayCost(c contract.Cost, who string)
- func (t *Teller) Privilege(id string) int
Constants ¶
const ( DNSTable = "dns_table" DNSRTable = "dns_revert_table" DNSOwnerTable = "dns_owner_table" )
const table name
Variables ¶
var ( ErrBalanceNotEnough = errors.New("balance not enough") ErrTransferNegValue = errors.New("trasfer amount less than zero") ErrReenter = errors.New("re-entering") ErrPermissionLost = errors.New("transaction has no permission") ErrInvalidData = errors.New("invalid data") ErrInvalidAmount = errors.New("invalid amount") ErrOutOfGas = errors.New("out of gas") ErrContractNotFound = errors.New("contract not exists") ErrContractExists = errors.New("contract exists") ErrAbiHasInternalFunc = errors.New("abi has internal function") ErrUpdateRefused = errors.New("update refused") ErrDestroyRefused = errors.New("destroy refused") ErrCoinExists = errors.New("coin exists") ErrCoinNotExists = errors.New("coin not exists") ErrCoinIssueRefused = errors.New("coin issue refused") ErrCoinSetRateRefused = errors.New("coin set rate refused") ErrTokenExists = errors.New("token exists") ErrTokenNotExists = errors.New("token not exists") ErrAmountLimitTokenNotExists = errors.New("token not exists in amountLimit") ErrTokenNoTransfer = errors.New("token can't transfer") ErrTokenIssueRefused = errors.New("token issue refused") ErrMemoTooLarge = errors.New("memo too large") ErrDelaytxNotFound = errors.New("delaytx not exists") ErrCannotCancelDelay = errors.New("can not cancel delaytx") )
var errors
var ( Costs = map[string]contract.Cost{ "JSCost": contract.NewCost(0, 0, 30000), "PutCost": contract.NewCost(0, 0, 300), "GetCost": contract.NewCost(0, 0, 300), "DelCost": contract.NewCost(0, 0, 300), "KeysCost": contract.NewCost(0, 0, 300), "ContextCost": contract.NewCost(0, 0, 10), "EventPrice": contract.NewCost(0, 0, 1), "ReceiptPrice": contract.NewCost(0, 1, 0), "CodePrice": contract.NewCost(0, 0, 1), "SetCodeBasePrice": contract.NewCost(0, 0, 200000), "SetCodePrice": contract.NewCost(0, 0, 70), "OpPrice": contract.NewCost(0, 0, 1), "ErrPrice": contract.NewCost(0, 0, 1), } )
var costs
Functions ¶
func Auth ¶ added in v1.1.0
func Auth(vi *database.Visitor, id, permission string, authMap, reenter map[string]int) (bool, contract.Cost)
Auth check auth
func AuthPublisher ¶
func AuthPublisher(vi *database.Visitor, id, permission string, authMap, reenter map[string]int) (bool, contract.Cost)
AuthPublisher check publisher auth
func CodeSavageCost ¶
CodeSavageCost cost in deploy contract based on code size
func CommonErrorCost ¶
CommonErrorCost returns cost increased by stack layer
func CommonOpCost ¶ added in v1.1.0
CommonOpCost returns cost increased by stack layer
func DelDelayTxCost ¶
DelDelayTxCost returns cost of a delay transaction.
func DelayTxCost ¶
DelayTxCost returns cost of a delay transaction.
func IsValidKey ¶ added in v1.1.0
IsValidKey return error if the key is invalid as state db key or field
func SetCodeCost ¶
SetCodeCost calculate set code cost based on code size
Types ¶
type APIDelegate ¶
type APIDelegate struct {
// contains filtered or unexported fields
}
APIDelegate ...
type Authority ¶ added in v1.1.0
type Authority struct {
// contains filtered or unexported fields
}
Authority module of ...
func (*Authority) IsContract ¶ added in v1.1.0
IsContract to judge the id is contract format
func (*Authority) RequireAuth ¶ added in v1.1.0
RequireAuth check auth
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context thread unsafe context with global fields
type DBHandler ¶
type DBHandler struct {
// contains filtered or unexported fields
}
DBHandler is an application layer abstraction of our base basic_handler and map_handler. it offers interface which has an interface{} type value and ramPayer semantic it also handles the Marshal and Unmarshal work and determine the cost of each operation
func (*DBHandler) GlobalMapGet ¶
GlobalMapGet get another contract's map data
func (*DBHandler) GlobalMapHas ¶ added in v1.1.0
GlobalMapHas if another contract's map has field
func (*DBHandler) GlobalMapKeys ¶
GlobalMapKeys get another contract's map keys
func (*DBHandler) GlobalMapLen ¶
GlobalMapLen get another contract's map length
type DNS ¶ added in v1.1.0
type DNS struct {
// contains filtered or unexported fields
}
DNS dns server handler
func (*DNS) ContractID ¶ added in v1.1.0
ContractID find cid from url
func (*DNS) RemoveLink ¶ added in v1.1.0
RemoveLink remove a url
func (*DNS) URLTransfer ¶ added in v1.1.0
URLTransfer give url to another id
type EventPoster ¶
type EventPoster struct {
// contains filtered or unexported fields
}
EventPoster the event handler in host
func NewEventPoster ¶ added in v1.1.0
func NewEventPoster(h *Host) EventPoster
NewEventPoster returns a new EventPoster instance.
type GasManager ¶ added in v1.1.0
type GasManager struct {
// contains filtered or unexported fields
}
GasManager handle the logic of gas. It should be called in a contract
func NewGasManager ¶ added in v1.1.0
func NewGasManager(h *Host) GasManager
NewGasManager new gas manager
func (*GasManager) ChangeTGas ¶ added in v1.1.0
ChangeTGas ...
func (*GasManager) ChangeTGasQuota ¶
ChangeTGasQuota ...
func (*GasManager) CostGas ¶ added in v1.1.0
func (g *GasManager) CostGas(name string, gasCost *common.Fixed) error
CostGas subtract gas of a user. It is not called in a contract. Need a better design here
func (*GasManager) DelGasPledge ¶ added in v1.1.0
func (g *GasManager) DelGasPledge(name string, pledger string) contract.Cost
DelGasPledge ...
func (*GasManager) GasPledgeTotal ¶
GasPledgeTotal ...
func (*GasManager) GasStock ¶ added in v1.1.0
GasStock `gasStock` means the gas amount at last update time.
func (*GasManager) GasUpdateTime ¶ added in v1.1.0
func (g *GasManager) GasUpdateTime(name string) (int64, contract.Cost)
GasUpdateTime ...
func (*GasManager) PGas ¶ added in v1.1.0
func (g *GasManager) PGas(name string) *common.Fixed
PGas returns the current total gas of a user. It is dynamically calculated
func (*GasManager) RefreshPGas ¶ added in v1.1.0
func (g *GasManager) RefreshPGas(name string) (contract.Cost, error)
RefreshPGas update the gas status
func (*GasManager) SetGasLimit ¶ added in v1.1.0
SetGasLimit ...
func (*GasManager) SetGasPledge ¶ added in v1.1.0
SetGasPledge ...
func (*GasManager) SetGasPledgeTotal ¶
SetGasPledgeTotal ...
func (*GasManager) SetGasStock ¶ added in v1.1.0
SetGasStock ...
func (*GasManager) SetGasUpdateTime ¶ added in v1.1.0
func (g *GasManager) SetGasUpdateTime(name string, t int64) contract.Cost
SetGasUpdateTime ...
type Host ¶
type Host struct { DBHandler Info Teller APIDelegate EventPoster DNS Authority GasManager // contains filtered or unexported fields }
Host host struct, used as isolate of vm
func (*Host) CallWithAuth ¶ added in v1.1.0
CallWithAuth call a new contract with permission of current contract
func (*Host) CancelDelaytx ¶ added in v1.1.0
CancelDelaytx deletes delaytx hash.
The given argument txHash is from user's input. So we should Base58Decode it first.
func (*Host) CheckAmountLimit ¶
CheckAmountLimit check amountLimit of tx valid
func (*Host) CheckPublisher ¶
CheckPublisher check publisher of tx
func (*Host) CheckSigners ¶
CheckSigners check signers of tx
func (*Host) IsValidAccount ¶ added in v1.1.0
IsValidAccount check whether account exists
func (*Host) ReadSettings ¶ added in v1.1.0
func (h *Host) ReadSettings()
ReadSettings read settings from db
func (*Host) SetContext ¶
SetContext set a new context to host
func (*Host) SetDeadline ¶
SetDeadline set this host's deadline
func (*Host) UpdateCode ¶
UpdateCode update code
type Info ¶
type Info struct {
// contains filtered or unexported fields
}
Info current info handler of this isolate
func (*Info) BlockInfo ¶
func (h *Info) BlockInfo() (info database.SerializedJSON, cost contract.Cost)
BlockInfo get block info, in json
func (*Info) ContextInfo ¶ added in v1.1.0
func (h *Info) ContextInfo() (info database.SerializedJSON, cost contract.Cost)
ContextInfo get context info
func (*Info) ContractName ¶ added in v1.1.0
ContractName get block time, in int64
func (*Info) GasLimitValue ¶ added in v1.1.0
GasLimitValue get gas limit
type Monitor ¶
type Monitor interface { Call(host *Host, contractName, api string, jarg string) (rtn []interface{}, cost contract.Cost, err error) Validate(con *contract.Contract) error Compile(con *contract.Contract) (string, error) }
Monitor monitor interface
type Teller ¶
type Teller struct {
// contains filtered or unexported fields
}
Teller handler of iost
func (*Teller) AddCacheCost ¶ added in v1.1.0
AddCacheCost ...
func (*Teller) ClearCacheCost ¶ added in v1.1.0
func (t *Teller) ClearCacheCost()
ClearCacheCost ...
func (*Teller) FlushCacheCost ¶ added in v1.1.0
func (t *Teller) FlushCacheCost()
FlushCacheCost ...
func (*Teller) IsProducer ¶ added in v1.1.0
IsProducer check account is producer