icsim

package
v1.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Failure = 0
	Success = 1
)

Variables

This section is empty.

Functions

func NewCallContext

func NewCallContext(wc WorldContext, from module.Address) icmodule.CallContext

func NewConfig

func NewConfig() *config

Types

type Block

type Block interface {
	Txs() []Transaction
	AddTransaction(tx Transaction)
}

func NewBlock

func NewBlock() Block

type Env

type Env struct {
	// contains filtered or unexported fields
}

func NewEnv

func NewEnv(c *config, revision module.Revision) (*Env, error)

func (*Env) RegisterPReps

func (env *Env) RegisterPReps() ([]Receipt, error)

RegisterPReps register all preps in Env

func (*Env) SetBonderLists

func (env *Env) SetBonderLists() ([]Receipt, error)

func (*Env) SetBonds

func (env *Env) SetBonds() ([]Receipt, error)

func (*Env) SetDelegations

func (env *Env) SetDelegations(addrs []module.Address, amount *big.Int) ([]Receipt, error)

func (*Env) SetDelegationsAll

func (env *Env) SetDelegationsAll() error

func (*Env) SetStakes

func (env *Env) SetStakes(addrs []module.Address, amount *big.Int) ([]Receipt, error)

func (*Env) SetStakesAll

func (env *Env) SetStakesAll() ([]Receipt, error)

type Receipt

type Receipt interface {
	BlockHeight() int64
	Status() int
	Error() error
}

func NewReceipt

func NewReceipt(blockHeight int64, err error) Receipt

type RewardFund

type RewardFund struct {
	Iglobal int64
	Iprep   int64
	Icps    int64
	Irelay  int64
	Ivoter  int64
}

type Simulator

type Simulator interface {
	Database() db.Database
	BlockHeight() int64
	Revision() module.Revision
	GetBalance(from module.Address) *big.Int
	TotalSupply() *big.Int
	ValidatorList() []module.Validator

	GetPRepTerm() map[string]interface{}
	GetMainPReps() map[string]interface{}
	GetSubPReps() map[string]interface{}
	GetPReps() map[string]interface{}
	TermSnapshot() *icstate.TermSnapshot

	Go(blocks int64, csi module.ConsensusInfo) error
	GoTo(blockHeight int64, csi module.ConsensusInfo) error
	GoToTermEnd(csi module.ConsensusInfo) error
	GoByBlock(block Block, csi module.ConsensusInfo) ([]Receipt, error)
	GoByTransaction(tx Transaction, csi module.ConsensusInfo) ([]Receipt, error)

	SetRevision(revision module.Revision) Transaction

	GetStake(from module.Address) map[string]interface{}
	SetStake(from module.Address, amount *big.Int) Transaction

	QueryIScore(address module.Address) *big.Int
	ClaimIScore(from module.Address) Transaction

	GetPRepStats(address module.Address) map[string]interface{}
	GetPRep(address module.Address) *icstate.PRep
	SetPRep(from module.Address, info *icstate.PRepInfo) Transaction

	GetDelegation(address module.Address) map[string]interface{}
	SetDelegation(from module.Address, ds icstate.Delegations) Transaction

	GetBond(address module.Address) map[string]interface{}
	SetBond(from module.Address, bonds icstate.Bonds) Transaction

	GetBonderList(address module.Address) map[string]interface{}
	SetBonderList(from module.Address, bl icstate.BonderList) Transaction

	RegisterPRep(from module.Address, info *icstate.PRepInfo) Transaction
	UnregisterPRep(from module.Address) Transaction
	DisqualifyPRep(from module.Address, address module.Address) Transaction
}

func NewSimulator

func NewSimulator(
	revision module.Revision, initValidators []module.Validator, initBalances map[string]*big.Int, config *config,
) Simulator

type Transaction

type Transaction interface {
	Type() TxType
	Args() []interface{}
}

func NewTransaction

func NewTransaction(txType TxType, args []interface{}) Transaction

type TxType

type TxType int
const (
	TypeSetStake TxType = iota
	TypeSetDelegation
	TypeSetBond
	TypeSetBonderList
	TypeRegisterPRep
	TypeUnregisterPRep
	TypeDisqualifyPRep
	TypeSetPRep
	TypeSetRevision
	TypeClaimIScore
)

type WorldContext

type WorldContext interface {
	icmodule.WorldContext
	GetExtensionState() state.ExtensionState
	BlockTimeStamp() int64
}

func NewWorldContext

func NewWorldContext(
	ws state.WorldState, blockHeight int64, revision module.Revision,
	csi module.ConsensusInfo, stepPrice *big.Int,
) WorldContext

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL