simulator

package
v0.0.0-...-7c2dc49 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CrosschainCall

type CrosschainCall struct {
	ChainID      *big.Int
	ContractType string
	ContractAddr common.Address
	Method       string
	Params       []interface{}
}

CrosschainCall represents a crosschain function call.

type Link func(resource Resource, chainID *big.Int, contractAddr common.Address, params ...interface{}) ([]CrosschainCall, error)

Link is the logic link of a crosschain calls. For a particular call, it is used to obtain all the subsequent crosschain calls. It takes a resource, chain id, contract address, parameters as arguments. It returns a list of chainIDs, contract types, contract addrs, methods, parameters lists of the subsequent calls.

type Resource

type Resource struct {
	ChainAPMgr chainap.ChainAPManager
}

Resource is the resource that a link can use. TODO: For now, it contains only the chain ap manager, but it can contain more things in the future. For example, certain solidity global variables/functions (msg.sender, msg.data...).

type Simulator

type Simulator interface {
	// RegisterABI registers a contract abi.
	RegisterABI(contractType string, contractABI *abi.ABI)

	// RegisterCallLink registers a call link.
	RegisterCallLink(contractType string, method string, link Link)

	// Simulate simulates a crosschain function call, builds a call execution tree and returns the root of the tree.
	Simulate(chainID *big.Int, contractType string, contractAddr common.Address, method string, params ...interface{}) (*treenode.TreeNode, error)
}

Simulator is used to simulate a crosschain function call and generate the call execution tree.

type SimulatorImplV1

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

SimulatorImplV1 implements the Simulator.

func NewSimulatorImplV1

func NewSimulatorImplV1(cmgr chainap.ChainAPManager) *SimulatorImplV1

NewSimulatorImplV1 creates a new simulator impl v1.

func (*SimulatorImplV1) RegisterABI

func (sim *SimulatorImplV1) RegisterABI(contractType string, contractABI *abi.ABI)

RegisterABI registers a contract abi.

func (sim *SimulatorImplV1) RegisterCallLink(contractType string, method string, link Link)

RegisterCallLink registers a call link.

func (*SimulatorImplV1) Simulate

func (sim *SimulatorImplV1) Simulate(chainID *big.Int, contractType string, contractAddr common.Address, method string, params ...interface{}) (*treenode.TreeNode, error)

Simulate simulates a crosschain function call, builds a call execution tree and returns the root of the tree.

Jump to

Keyboard shortcuts

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