evm

package
v0.3.24-rc.1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2021 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BlockByHeightPrefix = []byte("blockByHeight")
	LastAcceptedKey     = []byte("lastAccepted")
)

Define db prefixes and keys

Functions

This section is empty.

Types

type Block

type Block interface {
	snowman.Block
	// SetStatus sets the internal status of an existing block. This is used by ChainState
	// to allow internal blocks to maintain the most up to date status.
	SetStatus(choices.Status)
}

Block is the internal representation of a Block to be wrapped by BlockWrapper

type BlockWrapper

type BlockWrapper struct {
	Block
	// contains filtered or unexported fields
}

BlockWrapper wraps a snowman Block and adds a smart caching layer

func (*BlockWrapper) Accept

func (bw *BlockWrapper) Accept() error

Accept ...

func (*BlockWrapper) Parent

func (bw *BlockWrapper) Parent() snowman.Block

Parent ...

func (*BlockWrapper) Reject

func (bw *BlockWrapper) Reject() error

Reject ...

func (*BlockWrapper) Status

func (bw *BlockWrapper) Status() choices.Status

Status ...

func (*BlockWrapper) Verify

func (bw *BlockWrapper) Verify() error

type BuildBlockType

type BuildBlockType func() (Block, error)

BuildBlockType ...

type ChainState

type ChainState struct {
	// contains filtered or unexported fields
}

ChainState defines the canonical state of the chain it tracks the accepted blocks and wraps a VM's implementation of snowman.Block in order to take care of writing blocks to the database and adding a caching layer for both the blocks and their statuses.

func NewChainState

func NewChainState(db database.Database, cacheSize int) *ChainState

NewChainState ...

func (*ChainState) BuildBlock

func (c *ChainState) BuildBlock() (snowman.Block, error)

BuildBlock attempts to build a new internal Block, wraps it, and adds it to the appropriate caching layer if successful.

func (*ChainState) ExternalDB

func (c *ChainState) ExternalDB() database.Database

ExternalDB returns a database to be used external to ChainState The returned database must handle batching and atomicity by itself except for any operations that take place during block decisions. Any database operations that occur during block decisions (Accept/Reject) will be automatically batched.

func (*ChainState) FlushCaches

func (c *ChainState) FlushCaches()

FlushCaches flushes each block cache completely.

func (*ChainState) GetBlock

func (c *ChainState) GetBlock(blkID ids.ID) (snowman.Block, error)

GetBlock returns the BlockWrapper as snowman.Block corresponding to [blkID]

func (*ChainState) GetBlockInternal

func (c *ChainState) GetBlockInternal(blkID ids.ID) (Block, error)

GetBlockInternal returns the internal representation of [blkID]

func (*ChainState) Initialize

func (c *ChainState) Initialize(genesisBlock Block, getBlock GetBlockType, unmarshalBlock UnmarshalType, buildBlock BuildBlockType) error

Initialize sets the genesis block, last accepted block, and the functions for retrieving blocks from the VM layer.

func (*ChainState) LastAccepted

func (c *ChainState) LastAccepted() ids.ID

LastAccepted ...

func (*ChainState) LastAcceptedBlock

func (c *ChainState) LastAcceptedBlock() *BlockWrapper

LastAcceptedBlock returns the last accepted wrapped block

func (*ChainState) LastAcceptedBlockInternal

func (c *ChainState) LastAcceptedBlockInternal() snowman.Block

LastAcceptedBlockInternal returns the internal snowman.Block that was last last accepted

func (*ChainState) ParseBlock

func (c *ChainState) ParseBlock(b []byte) (snowman.Block, error)

ParseBlock attempts to parse [b] into an internal Block and adds it to the appropriate caching layer if successful.

type GetBlockType

type GetBlockType func(ids.ID) (Block, error)

GetBlockType ...

type UnmarshalType

type UnmarshalType func([]byte) (Block, error)

UnmarshalType ...

Jump to

Keyboard shortcuts

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