fvm

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

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

Go to latest
Published: Jun 28, 2020 License: Apache-2.0 Imports: 13 Imported by: 6

README

FVM based on EVM

Documentation

Overview

Package ethereum defines interfaces for interacting with Ethereum.

Copyright (c) 2018-2020 The asimov developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

View Source
var NotFound = errors.New("not found")

NotFound is returned by API methods if the requested item does not exist.

Functions

func CallReadOnlyFunction

func CallReadOnlyFunction(
	from common.Address,
	block *asiutil.Block,
	chain ChainContext,
	stateDB fvm.StateDB,
	chainConfig *params.ChainConfig,
	gasLimit uint64,
	contractAddr common.Address,
	input []byte) (ret []byte, leftOverGas uint64, err error)

Call a readonly function of a contract

func CanTransfer

func CanTransfer(view *txo.UtxoViewpoint, block *asiutil.Block, db fvm.StateDB, addr common.Address,
	amount *big.Int, vtx *virtualtx.VirtualTransaction, calculateBalanceFunc fvm.CalculateBalanceFunc, assets *protos.Asset) bool

CanTransfer checks whether there are enough funds in the address' account to make a transfer. This does not take the necessary gas in to account to make the transfer valid.

func GetHashFn

func GetHashFn(chain ChainContext) func(n uint64) common.Hash

GetHashFn returns a GetHashFunc which retrieves header hashes by number

func NewFVMContext

func NewFVMContext(from common.Address, gasPrice *big.Int, block *asiutil.Block, chain ChainContext,
	view *txo.UtxoViewpoint,
	voteValue fvm.VoteValueFunc) fvm.Context

NewFVMContext creates a new context of FVM.

func PackConstructorArgs

func PackConstructorArgs(abiStr string, args ...interface{}) ([]byte, error)

Pack constructor with arguments

func PackFunctionArgs

func PackFunctionArgs(abiStr string, funcName string, args ...interface{}) ([]byte, error)

Pack function with arguments

func Transfer

func Transfer(db fvm.StateDB, sender, recipient common.Address, amount *big.Int, vtx *virtualtx.VirtualTransaction, assets *protos.Asset)

Transfer subtracts amount from sender and adds amount to recipient using the given Db

func UnPackFunctionResult

func UnPackFunctionResult(abiStr string, v interface{}, funcName string, output []byte) error

Unpack function execution result

func UnPackReadOnlyResult

func UnPackReadOnlyResult(abiStr string, funcName string, output []byte) (interface{}, error)

Unpack readonly function execution result

func UnpackEvent

func UnpackEvent(abiStr string, eventName string, output []byte) (interface{}, error)

Unpack event

Types

type ChainContext

type ChainContext interface {
	CalculateBalance(view *txo.UtxoViewpoint, block *asiutil.Block, address common.Address, assets *protos.Asset, voucherId int64) (int64, error)
	GetVmConfig() *fvm.Config
	GetTemplateWarehouseInfo() (common.Address, string)
	GetSystemContractInfo(delegateAddr common.Address) (common.Address, []byte, string)
	GetTemplateInfo(contractAddr []byte, gas uint64, block *asiutil.Block, stateDB fvm.StateDB, chainConfig *params.ChainConfig) (uint16, string, uint64)
	FetchTemplate(view *txo.UtxoViewpoint, hash *common.Hash) (uint16, []byte, []byte, []byte, []byte, error)
	BlockHashByHeight(int32) (*common.Hash, error)
}

ChainContext supports retrieving headers and consensus parameters from the current blockchain, which is used during transaction processing.

type Subscription

type Subscription interface {
	// Unsubscribe cancels the sending of events to the data channel
	// and closes the error channel.
	Unsubscribe()
	// Err returns the subscription error channel. The error channel receives
	// a value if there is an issue with the subscription (e.g. the network connection
	// delivering the events has been closed). Only one value will ever be sent.
	// The error channel is closed by Unsubscribe.
	Err() <-chan error
}

Subscription represents an event subscription where events are delivered on a data channel.

Directories

Path Synopsis
Package abi implements the Ethereum ABI (Application Binary Interface).
Package abi implements the Ethereum ABI (Application Binary Interface).
vm
Package virtual-machine implements the Ethereum Virtual Machine.
Package virtual-machine implements the Ethereum Virtual Machine.
Package event deals with subscriptions to real-time events.
Package event deals with subscriptions to real-time events.
filter
Package filter implements event filters.
Package filter implements event filters.
log
Package log15 provides an opinionated, simple toolkit for best-practice logging that is both human and machine readable.
Package log15 provides an opinionated, simple toolkit for best-practice logging that is both human and machine readable.
Package math provides integer math utilities.
Package math provides integer math utilities.
Package mclock is a wrapper for a monotonic clock source
Package mclock is a wrapper for a monotonic clock source
Go port of Coda Hale's Metrics library <https://github.com/rcrowley/go-metrics> Coda Hale's original work: <https://github.com/codahale/metrics>
Go port of Coda Hale's Metrics library <https://github.com/rcrowley/go-metrics> Coda Hale's original work: <https://github.com/codahale/metrics>
exp
Hook go-metrics into expvar on any /debug/metrics request, load all vars from the registry into expvar, and execute regular expvar handler
Hook go-metrics into expvar on any /debug/metrics request, load all vars from the registry into expvar, and execute regular expvar handler
Package rlp implements the RLP serialization format.
Package rlp implements the RLP serialization format.
Package trie implements Merkle Patricia Tries.
Package trie implements Merkle Patricia Tries.

Jump to

Keyboard shortcuts

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