github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/execution/engine/callable.go (about)

     1  package engine
     2  
     3  import (
     4  	"math/big"
     5  	"time"
     6  
     7  	"github.com/hyperledger/burrow/crypto"
     8  	"github.com/hyperledger/burrow/execution/exec"
     9  )
    10  
    11  type Blockchain interface {
    12  	LastBlockHeight() uint64
    13  	LastBlockTime() time.Time
    14  	BlockHash(height uint64) ([]byte, error)
    15  	ChainID() string
    16  }
    17  
    18  type CallParams struct {
    19  	CallType exec.CallType
    20  	Origin   crypto.Address
    21  	Caller   crypto.Address
    22  	Callee   crypto.Address
    23  	Input    []byte
    24  	Value    big.Int
    25  	Gas      *big.Int
    26  }
    27  
    28  // Effectively a contract, but can either represent a single function or a contract with multiple functions and a selector
    29  type Callable interface {
    30  	Call(state State, params CallParams) (output []byte, err error)
    31  }
    32  
    33  type CallableFunc func(st State, params CallParams) (output []byte, err error)
    34  
    35  func (c CallableFunc) Call(state State, params CallParams) (output []byte, err error) {
    36  	return c(state, params)
    37  }