app

package
v0.0.0-...-a4757fd Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2018 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateRemoveEmptyObj = true
	APP_NAME            = "evm"

	DatabaseCache   = 128
	DatabaseHandles = 1024
)
View Source
const (
	WorldRandPrefix = "world-rand-"
)

Variables

View Source
var (
	EmptyTrieRoot = ethcmn.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
	IsHomestead   = true
)
View Source
var (
	ReceiptsPrefix = []byte("receipts-")
)

Functions

func DecodeTx

func DecodeTx(tx agtypes.Tx) (*agtypes.ResultBlockTx, error)

DecodeTx converts a raw []byte tx to a struct. Payload inside the ResultBlockTx may vary.

func GetTx

func GetTx(blockData *pbtypes.Data, hash []byte) (agtypes.Tx, error)

func OpenDatabase

func OpenDatabase(datadir string, name string, cache int, handles int) (ethdb.Database, error)

Types

type App

type App struct {
	agtypes.BaseApplication

	Config *viper.Viper

	AngineHooks agtypes.Hooks
	AngineRef   *angine.Angine

	ShareStateMtx sync.RWMutex
	ShareStateDB  db.DB
	ShareState    *ShareState
	// contains filtered or unexported fields
}

func NewApp

func NewApp(logger *zap.Logger, config *viper.Viper) (*App, error)

func (*App) CheckEVMTx

func (app *App) CheckEVMTx(bs []byte) error

func (*App) CheckEcoTx

func (app *App) CheckEcoTx(bs []byte) error

func (*App) CheckTx

func (app *App) CheckTx(bs []byte) error

func (*App) CompatibleWithAngine

func (app *App) CompatibleWithAngine()

func (*App) ExecuteAngineWorldTx

func (app *App) ExecuteAngineWorldTx(block *agtypes.BlockCache, bs []byte, txIndex int) (hash []byte, usedGas *big.Int, err error)

func (*App) ExecuteAppEcoTx

func (app *App) ExecuteAppEcoTx(block *agtypes.BlockCache, bs []byte, tx *types.BlockTx) (hash []byte, usedGas *big.Int, err error)

func (*App) ExecuteEVMTx

func (app *App) ExecuteEVMTx(header *ethtypes.Header, blockHash ethcmn.Hash, tx *types.BlockTx, txIndex int) (hash []byte, usedGas *big.Int, err error)

ExecuteEVMTx execute tx one by one in the loop, without lock, so should always be called between Lock() and Unlock() on the *stateDup

func (*App) ExecuteInitTx

func (app *App) ExecuteInitTx(block *agtypes.BlockCache, bs []byte, txIndex int) (hash []byte, usedGas *big.Int, err error)

func (*App) GetAngineHooks

func (app *App) GetAngineHooks() agtypes.Hooks

func (*App) Info

func (app *App) Info() (resInfo agtypes.ResultInfo)

func (*App) OnCommit

func (app *App) OnCommit(height, round def.INT, block *agtypes.BlockCache) (interface{}, error)

OnCommit run in a sync way, we don't need to lock stateDupMtx, but stateMtx is still needed

func (*App) OnExecute

func (app *App) OnExecute(height, round def.INT, block *agtypes.BlockCache) (interface{}, error)

func (*App) OnNewRound

func (app *App) OnNewRound(height, round def.INT, block *agtypes.BlockCache) (interface{}, error)

func (*App) OnPrevote

func (app *App) OnPrevote(height, round def.INT, block *agtypes.BlockCache) (interface{}, error)

func (*App) Query

func (app *App) Query(query []byte) agtypes.Result

func (*App) QueryBalance

func (app *App) QueryBalance(addrBytes []byte) agtypes.ResultQueryBalance

func (*App) QueryContract

func (app *App) QueryContract(rawtx []byte) agtypes.ResultQueryContract

func (*App) QueryNonce

func (app *App) QueryNonce(addrBytes []byte) agtypes.ResultQueryNonce

func (*App) QueryReceipt

func (app *App) QueryReceipt(txHashBytes []byte) agtypes.ResultQueryReceipt

func (*App) QueryShare

func (app *App) QueryShare(pubkeyBytes []byte) agtypes.ResultQueryShare

func (*App) QueryTx

func (app *App) QueryTx(txHashBytes []byte) agtypes.ResultQueryTx

func (*App) RegisterValidators

func (app *App) RegisterValidators(validatorset *agtypes.ValidatorSet)

func (*App) SaveReceipts

func (app *App) SaveReceipts() []byte

func (*App) SaveStateRootHashs

func (app *App) SaveStateRootHashs(evmStateHash, ShareStateHash []byte)

func (*App) Start

func (app *App) Start() (err error)

func (*App) Stop

func (app *App) Stop()

func (*App) ValSetLoader

func (app *App) ValSetLoader() agtypes.ValSetLoaderFunc

type LastBlockInfo

type LastBlockInfo struct {
	Height         def.INT
	EvmStateHash   []byte
	ShareStateHash []byte
}

func (*LastBlockInfo) AppHash

func (lb *LastBlockInfo) AppHash() []byte

type Share

type Share struct {
	Pubkey        []byte
	ShareBalance  *big.Int
	ShareGuaranty *big.Int
	GHeight       uint64
}

func (*Share) Copy

func (shr *Share) Copy() *Share

func (*Share) FromBytes

func (shr *Share) FromBytes(bs []byte) error

func (*Share) Less

func (shr *Share) Less(o interface{}) bool

func (*Share) ToBytes

func (shr *Share) ToBytes() []byte

type ShareState

type ShareState struct {
	ShareCache *mlist.MapList
	// contains filtered or unexported fields
}

func NewShareState

func NewShareState(database db.DB) *ShareState

func (*ShareState) AddGuaranty

func (ss *ShareState) AddGuaranty(pubkey crypto.PubKey, amount *big.Int, height uint64) error

func (*ShareState) AddShareBalance

func (ss *ShareState) AddShareBalance(pubkey crypto.PubKey, amount *big.Int) error

func (*ShareState) Commit

func (ss *ShareState) Commit() ([]byte, error)

Commit returns the new root bytes

func (*ShareState) Copy

func (ss *ShareState) Copy() *ShareState

func (*ShareState) CreateShareAccount

func (ss *ShareState) CreateShareAccount(pubkey []byte, balance *big.Int)

func (*ShareState) GetShareAccount

func (ss *ShareState) GetShareAccount(pubkey []byte) *Share

func (*ShareState) Hash

func (ss *ShareState) Hash() []byte

func (*ShareState) Iterate

func (ss *ShareState) Iterate(fn func(*Share) bool)

func (*ShareState) Load

func (ss *ShareState) Load(root []byte)

Load dumss all the buffer, start every thing from a clean state

func (*ShareState) Lock

func (ss *ShareState) Lock()

func (*ShareState) MarkShare

func (ss *ShareState) MarkShare(pubkey crypto.PubKey, gValue uint64) error

func (*ShareState) QueryShare

func (ss *ShareState) QueryShare(pubkey crypto.PubKey) (*big.Int, uint64)

func (*ShareState) Reload

func (ss *ShareState) Reload(root []byte)

Reload works the same as Load, just for semantic purpose

func (*ShareState) Size

func (ss *ShareState) Size() int

func (*ShareState) SubGuaranty

func (ss *ShareState) SubGuaranty(pubkey crypto.PubKey, amount *big.Int) error

func (*ShareState) SubShareBalance

func (ss *ShareState) SubShareBalance(pubkey crypto.PubKey, amount *big.Int) error

func (*ShareState) Unlock

func (ss *ShareState) Unlock()

Jump to

Keyboard shortcuts

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