github.com/annchain/OG@v0.0.9/vm/ovm/interpreter.go (about)

     1  package ovm
     2  
     3  import "github.com/annchain/OG/vm/types"
     4  
     5  // Interpreter is used to run Ethereum based vmtypes.Contracts and will utilise the
     6  // passed environment to query external sources for state information.
     7  // The Interpreter will run the byte code VM based on the passed
     8  // configuration.
     9  type Interpreter interface {
    10  	// Run loops and evaluates the vmtypes.Contract's code with the given input data and returns
    11  	// the return byte-slice and an error if one occurred.
    12  	Run(Contract *types.Contract, input []byte, static bool) ([]byte, error)
    13  	// CanRun tells if the vmtypes.Contract, passed as an argument, can be
    14  	// run by the current interpreter. This is meant so that the
    15  	// caller can do something like:
    16  	//
    17  	// ```golang
    18  	// for _, interpreter := range interpreters {
    19  	//   if interpreter.CanRun(vmtypes.Contract.code) {
    20  	//     interpreter.Run(vmtypes.Contract.code, input)
    21  	//   }
    22  	// }
    23  	// ```
    24  	CanRun([]byte) bool
    25  
    26  	// SetCaller will be called when OVM is initializing this intepreter.
    27  	// OVM will tell which caller interpreter should use if there is a inter-contract call
    28  	SetCaller(caller types.Caller)
    29  }