{"modulePath":"github.com/hyperledger/burrow","version":"v0.34.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package engine\n\n## Constants\n\n```go\nconst (\n\tGasSha3          uint64 = 1\n\tGasGetAccount    uint64 = 1\n\tGasStorageUpdate uint64 = 1\n\tGasCreateAccount uint64 = 1\n\n\tGasBaseOp  uint64 = 0 // TODO: make this 1\n\tGasStackOp uint64 = 1\n\n\tGasEcRecover     uint64 = 1\n\tGasSha256Word    uint64 = 1\n\tGasSha256Base    uint64 = 1\n\tGasRipemd160Word uint64 = 1\n\tGasRipemd160Base uint64 = 1\n\tGasExpModWord    uint64 = 1\n\tGasExpModBase    uint64 = 1\n\tGasIdentityWord  uint64 = 1\n\tGasIdentityBase  uint64 = 1\n)\n```\n\n## Functions\n\n```go\nfunc AddressFromName(name string) (address crypto.Address)\n```\n\n```go\nfunc Call(state State, params CallParams, execute func(State, CallParams) ([]byte, error)) ([]byte, error)\n```\nCall provides a standard wrapper for implementing Callable.Call with appropriate error handling and event firing.\n\n```go\nfunc CallFromSite(st State, dispatcher Dispatcher, site CallParams, target CallParams) ([]byte, error)\n```\n\n```go\nfunc Connect(eds ...ExternalDispatcher)\n```\nConnect ExternalDispatchers eds to each other so that the underlying engines can mutually call contracts hosted by other dispatchers\n\n```go\nfunc CreateAccount(st acmstate.ReaderWriter, address crypto.Address) error\n```\n\n```go\nfunc EnsurePermission(callFrame *CallFrame, address crypto.Address, perm permission.PermFlag) error\n```\n\n```go\nfunc FireCallEvent(callFrame *CallFrame, callErr error, eventSink exec.EventSink, output []byte,\n\tparams CallParams) error\n```\n\n```go\nfunc GetAccount(st acmstate.Reader, m Maybe, address crypto.Address) *acm.Account\n```\n\n```go\nfunc HasPermission(st acmstate.Reader, address crypto.Address, perm permission.PermFlag) (bool, error)\n```\nCONTRACT: it is the duty of the contract writer to call known permissions we do not convey if a permission is not set (unlike in state/execution, where we guarantee HasPermission is called on known permissions and panics else) If the perm is not defined in the acc nor set by default in GlobalPermissions, this function returns false.\n\n```go\nfunc InitChildCode(st acmstate.ReaderWriter, address crypto.Address, parent crypto.Address, code []byte) error\n```\n\n```go\nfunc InitEVMCode(st acmstate.ReaderWriter, address crypto.Address, code []byte) error\n```\n\n```go\nfunc InitWASMCode(st acmstate.ReaderWriter, address crypto.Address, code []byte) error\n```\n\n```go\nfunc MustAccount(st acmstate.Reader, address crypto.Address) (*acm.Account, error)\n```\n\n```go\nfunc MustGetAccount(st acmstate.Reader, m Maybe, address crypto.Address) *acm.Account\n```\nGuaranteed to return a non-nil account, if the account does not exist returns a pointer to the zero-value of Account and pushes an error.\n\n```go\nfunc RemoveAccount(st acmstate.ReaderWriter, address crypto.Address) error\n```\n\n```go\nfunc Transfer(st acmstate.ReaderWriter, from, to crypto.Address, amount *big.Int) error\n```\nTODO: consider pushing big.Int usage all the way to account balance\n\n```go\nfunc UpdateAccount(st acmstate.ReaderWriter, address crypto.Address, updater func(acc *acm.Account) error) error\n```\n\n```go\nfunc UpdateContractMeta(st acmstate.ReaderWriter, metaSt acmstate.MetadataWriter, address crypto.Address, payloadMeta []*payload.ContractMeta) error\n```\n\n```go\nfunc UseGasNegative(gasLeft *big.Int, gasToUse uint64) errors.CodedError\n```\nTry to deduct gasToUse from gasLeft.  If ok return false, otherwise set err and return true.\n\n## Types\n\n```go\ntype Blockchain interface {\n\tLastBlockHeight() uint64\n\tLastBlockTime() time.Time\n\tBlockHash(height uint64) ([]byte, error)\n\tChainID() string\n}\n```\n\n```go\ntype CallFrame struct {\n\t// Cache this State wraps\n\t*acmstate.Cache\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewCallFrame(st acmstate.ReaderWriter, cacheOptions ...acmstate.CacheOption) *CallFrame\n```\nCreate a new CallFrame to hold state updates at a particular level in the call stack\n\n```go\nfunc (st *CallFrame) CallStackDepth() uint64\n```\n\n```go\nfunc (st *CallFrame) CreateAccount(creator, address crypto.Address) error\n```\n\n```go\nfunc (st *CallFrame) NewFrame(cacheOptions ...acmstate.CacheOption) (*CallFrame, error)\n```\n\n```go\nfunc (st *CallFrame) ReadOnly() *CallFrame\n```\nPut this CallFrame in permanent read-only mode\n\n```go\nfunc (st *CallFrame) Sync() error\n```\n\n```go\nfunc (st *CallFrame) WithMaxCallStackDepth(max uint64) *CallFrame\n```\n\n```go\ntype CallParams struct {\n\tCallType exec.CallType\n\tOrigin   crypto.Address\n\tCaller   crypto.Address\n\tCallee   crypto.Address\n\tInput    []byte\n\tValue    big.Int\n\tGas      *big.Int\n}\n```\n\n```go\ntype Callable interface {\n\tCall(state State, params CallParams) (output []byte, err error)\n}\n```\nEffectively a contract, but can either represent a single function or a contract with multiple functions and a selector\n\n```go\ntype CallableFunc func(st State, params CallParams) (output []byte, err error)\n```\n\n```go\nfunc (c CallableFunc) Call(state State, params CallParams) (output []byte, err error)\n```\n\n```go\ntype Dispatcher interface {\n\t// If this Dispatcher is capable of dispatching this account (e.g. if it has the correct bytecode) then return a\n\t// Callable that wraps the function, otherwise return nil\n\tDispatch(acc *acm.Account) Callable\n}\n```\n\n```go\ntype DispatcherFunc func(acc *acm.Account) Callable\n```\n\n```go\nfunc (d DispatcherFunc) Dispatch(acc *acm.Account) Callable\n```\n\n```go\ntype Dispatchers []Dispatcher\n```\n\n```go\nfunc NewDispatchers(dispatchers ...Dispatcher) Dispatchers\n```\n\n```go\nfunc (ds Dispatchers) Dispatch(acc *acm.Account) Callable\n```\n\n```go\ntype ExternalDispatcher interface {\n\tDispatcher\n\tSetExternals(externals Dispatcher)\n}\n```\nAn ExternalDispatcher is able to Dispatch accounts to external engines as well as Dispatch to itself\n\n```go\ntype Externals struct {\n\t// contains filtered or unexported fields\n}\n```\nAn ExternalDispatcher is able to Dispatch accounts to external engines as well as Dispatch to itself\n\n```go\nfunc (ed *Externals) Dispatch(acc *acm.Account) Callable\n```\n\n```go\nfunc (ed *Externals) SetExternals(externals Dispatcher)\n```\n\n```go\ntype ExternalsStorage struct {\n}\n```\n\n```go\ntype Maybe interface {\n\tPushError(err error) bool\n\tError() error\n}\n```\n\n```go\ntype Memory interface {\n\t// Read a value from the memory store starting at offset\n\t// (index of first byte will equal offset). The value will be returned as a\n\t// length-bytes byte slice. Returns an error if the memory cannot be read or\n\t// is not allocated.\n\t//\n\t// The value returned should be copy of any underlying memory, not a reference\n\t// to the underlying store.\n\tRead(offset, length *big.Int) []byte\n\t// Write a value to the memory starting at offset (the index of the first byte\n\t// written will equal offset). The value is provided as bytes to be written\n\t// consecutively to the memory store. Return an error if the memory cannot be\n\t// written or allocated.\n\tWrite(offset *big.Int, value []byte)\n\t// Returns the current capacity of the memory. For dynamically allocating\n\t// memory this capacity can be used as a write offset that is guaranteed to be\n\t// unused. Solidity in particular makes this assumption when using MSIZE to\n\t// get the current allocated memory.\n\tCapacity() *big.Int\n}\n```\nInterface for a bounded linear memory indexed by a single \\*big.Int parameter for each byte in the memory.\n\n```go\nfunc DefaultDynamicMemoryProvider(errSink errors.Sink) Memory\n```\n\n```go\nfunc NewDynamicMemory(initialCapacity, maximumCapacity uint64, errSink errors.Sink) Memory\n```\nGet a new DynamicMemory (note that although we take a maximumCapacity of uint64 we currently limit the maximum to int32 at runtime because we are using a single slice which we cannot guarantee to be indexable above int32 or all validators\n\n```go\ntype Native interface {\n\tCallable\n\tSetExternals(externals Dispatcher)\n\tContractMeta() []*acm.ContractMeta\n\tFullName() string\n\tAddress() crypto.Address\n}\n```\n\n```go\ntype Natives interface {\n\tExternalDispatcher\n\tGetByAddress(address crypto.Address) Native\n}\n```\n\n```go\ntype Options struct {\n\tMemoryProvider           func(errors.Sink) Memory\n\tNatives                  Natives\n\tNonce                    []byte\n\tDebugOpcodes             bool\n\tDumpTokens               bool\n\tCallStackMaxDepth        uint64\n\tDataStackInitialCapacity uint64\n\tDataStackMaxDepth        uint64\n\tLogger                   *logging.Logger\n}\n```\nOptions are parameters that are generally stable across a burrow configuration. Defaults will be used for any zero values.\n\n```go\ntype State struct {\n\t*CallFrame\n\tBlockchain\n\texec.EventSink\n}\n```\n\n```go\ntype TestBlockchain struct {\n\tBlockHeight uint64\n\tBlockTime   time.Time\n}\n```\n\n```go\nfunc (b *TestBlockchain) BlockHash(height uint64) ([]byte, error)\n```\n\n```go\nfunc (V *TestBlockchain) ChainID() string\n```\n\n```go\nfunc (b *TestBlockchain) LastBlockHeight() uint64\n```\n\n```go\nfunc (b *TestBlockchain) LastBlockTime() time.Time\n```\n\n","path":"github.com/hyperledger/burrow/execution/engine","name":"engine","synopsis":"","isRedistributable":true}
