Documentation ¶
Index ¶
- Constants
- Variables
- 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 Caller
- 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(contract, api, jarg string) ([]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) GetVMFlags() int64
- func (h *Host) IsGenesisMode() bool
- 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 Stack
- 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 CodeSavageCost ¶
CodeSavageCost cost in deploy contract based on code size
func CommonErrorCost ¶
CommonErrorCost returns cost increased by stack layer
func CommonOpCost ¶
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 ¶
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 ¶
type Authority struct {
// contains filtered or unexported fields
}
Authority module of ...
func (*Authority) IsContract ¶
IsContract to judge the id is contract format
func (*Authority) RequireAuth ¶
RequireAuth check auth
func (*Authority) RequirePublisherAuth ¶
RequirePublisherAuth check publisher 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 ¶
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 ¶
type DNS struct {
// contains filtered or unexported fields
}
DNS dns server handler
func (*DNS) URLTransfer ¶
URLTransfer give url to another id
type EventPoster ¶
type EventPoster struct {
// contains filtered or unexported fields
}
EventPoster the event handler in host
func NewEventPoster ¶
func NewEventPoster(h *Host) EventPoster
NewEventPoster returns a new EventPoster instance.
type GasManager ¶
type GasManager struct {
// contains filtered or unexported fields
}
GasManager handle the logic of gas. It should be called in a contract
func (*GasManager) ChangeTGas ¶
ChangeTGas ...
func (*GasManager) ChangeTGasQuota ¶
ChangeTGasQuota ...
func (*GasManager) CostGas ¶
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 ¶
func (g *GasManager) DelGasPledge(name string, pledger string) contract.Cost
DelGasPledge ...
func (*GasManager) GasPledgeTotal ¶
GasPledgeTotal ...
func (*GasManager) GasUpdateTime ¶
func (g *GasManager) GasUpdateTime(name string) (int64, contract.Cost)
GasUpdateTime ...
func (*GasManager) PGas ¶
func (g *GasManager) PGas(name string) *common.Fixed
PGas returns the current total gas of a user. It is dynamically calculated
func (*GasManager) RefreshPGas ¶
func (g *GasManager) RefreshPGas(name string) (contract.Cost, error)
RefreshPGas update the gas status
func (*GasManager) SetGasLimit ¶
SetGasLimit ...
func (*GasManager) SetGasPledge ¶
SetGasPledge ...
func (*GasManager) SetGasPledgeTotal ¶
SetGasPledgeTotal ...
func (*GasManager) SetGasStock ¶
SetGasStock ...
func (*GasManager) SetGasUpdateTime ¶
func (g *GasManager) SetGasUpdateTime(name string, t int64) contract.Cost
SetGasUpdateTime ...
type Host ¶
type Host struct { DBHandler Stack Info Teller APIDelegate EventPoster DNS Authority GasManager *version.Rules // contains filtered or unexported fields }
Host host struct, used as isolate of vm
func NewHost ¶
func NewHost(ctx *Context, db *database.Visitor, rules *version.Rules, monitor Monitor, logger *ilog.Logger) *Host
NewHost get a new host
func (*Host) CallWithAuth ¶
CallWithAuth call a new contract with permission of current contract
func (*Host) CancelDelaytx ¶
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) GetVMFlags ¶
GetVMFlags return target vm bitwise flags
func (*Host) IsValidAccount ¶
IsValidAccount check whether account exists
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 ¶
func (h *Info) ContextInfo() (info database.SerializedJSON, cost contract.Cost)
ContextInfo get context info
func (*Info) ContractName ¶
ContractName get block time, in int64
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 Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack is call stack of this host
func (*Stack) SetStackInfo ¶
SetStackInfo set contract info