Help us shape the future of Go! Take the 2026 Go Developer Survey

backend

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter wraps the emulator backend to be compatible with access.API.

func NewAdapter

func NewAdapter(backend *Backend) *Adapter

NewAdapter returns a new backend adapter.

func (*Adapter) ExecuteScriptAtBlockHeight

func (a *Adapter) ExecuteScriptAtBlockHeight(
	ctx context.Context,
	blockHeight uint64,
	script []byte,
	arguments [][]byte,
) ([]byte, error)

func (*Adapter) ExecuteScriptAtBlockID

func (a *Adapter) ExecuteScriptAtBlockID(
	ctx context.Context,
	blockID flowgo.Identifier,
	script []byte,
	arguments [][]byte,
) ([]byte, error)

func (*Adapter) ExecuteScriptAtLatestBlock

func (a *Adapter) ExecuteScriptAtLatestBlock(
	ctx context.Context,
	script []byte,
	arguments [][]byte,
) ([]byte, error)

func (*Adapter) GetAccount

func (a *Adapter) GetAccount(ctx context.Context, address flowgo.Address) (*flowgo.Account, error)

func (*Adapter) GetAccountAtBlockHeight

func (a *Adapter) GetAccountAtBlockHeight(
	ctx context.Context,
	address flowgo.Address,
	height uint64,
) (*flowgo.Account, error)

func (*Adapter) GetAccountAtLatestBlock

func (a *Adapter) GetAccountAtLatestBlock(ctx context.Context, address flowgo.Address) (*flowgo.Account, error)

func (*Adapter) GetBlockByHeight

func (a *Adapter) GetBlockByHeight(ctx context.Context, height uint64) (*flowgo.Block, flowgo.BlockStatus, error)

func (*Adapter) GetBlockByID

func (a *Adapter) GetBlockByID(ctx context.Context, id flowgo.Identifier) (*flowgo.Block, flowgo.BlockStatus, error)

func (*Adapter) GetBlockHeaderByHeight

func (a *Adapter) GetBlockHeaderByHeight(ctx context.Context, height uint64) (*flowgo.Header, flowgo.BlockStatus, error)

func (*Adapter) GetBlockHeaderByID

func (a *Adapter) GetBlockHeaderByID(ctx context.Context, id flowgo.Identifier) (*flowgo.Header, flowgo.BlockStatus, error)

func (*Adapter) GetCollectionByID

func (a *Adapter) GetCollectionByID(ctx context.Context, id flowgo.Identifier) (*flowgo.LightCollection, error)

func (*Adapter) GetEventsForBlockIDs

func (a *Adapter) GetEventsForBlockIDs(
	ctx context.Context,
	eventType string,
	blockIDs []flowgo.Identifier,
) ([]flowgo.BlockEvents, error)

func (*Adapter) GetEventsForHeightRange

func (a *Adapter) GetEventsForHeightRange(
	ctx context.Context,
	eventType string,
	startHeight, endHeight uint64,
) ([]flowgo.BlockEvents, error)

func (*Adapter) GetExecutionResultByID added in v0.28.0

func (a *Adapter) GetExecutionResultByID(ctx context.Context, id flowgo.Identifier) (*flowgo.ExecutionResult, error)

func (*Adapter) GetExecutionResultForBlockID added in v0.23.0

func (a *Adapter) GetExecutionResultForBlockID(ctx context.Context, blockID flowgo.Identifier) (*flowgo.ExecutionResult, error)

func (*Adapter) GetLatestBlock

func (a *Adapter) GetLatestBlock(ctx context.Context, isSealed bool) (*flowgo.Block, flowgo.BlockStatus, error)

func (*Adapter) GetLatestBlockHeader

func (a *Adapter) GetLatestBlockHeader(ctx context.Context, isSealed bool) (*flowgo.Header, flowgo.BlockStatus, error)

func (*Adapter) GetLatestProtocolStateSnapshot added in v0.17.0

func (a *Adapter) GetLatestProtocolStateSnapshot(ctx context.Context) ([]byte, error)

func (*Adapter) GetNetworkParameters

func (a *Adapter) GetNetworkParameters(ctx context.Context) access.NetworkParameters

func (*Adapter) GetNodeVersionInfo added in v0.49.0

func (a *Adapter) GetNodeVersionInfo(
	ctx context.Context,
) (
	*access.NodeVersionInfo,
	error,
)

func (*Adapter) GetTransaction

func (a *Adapter) GetTransaction(ctx context.Context, id flowgo.Identifier) (*flowgo.TransactionBody, error)

func (*Adapter) GetTransactionResult

func (a *Adapter) GetTransactionResult(
	ctx context.Context,
	id flowgo.Identifier,
	blockId flowgo.Identifier,
	collectionId flowgo.Identifier,
) (
	*access.TransactionResult,
	error,
)

func (*Adapter) GetTransactionResultByIndex added in v0.31.0

func (a *Adapter) GetTransactionResultByIndex(ctx context.Context, blockID flowgo.Identifier, index uint32) (*access.TransactionResult, error)

func (*Adapter) GetTransactionResultsByBlockID added in v0.32.0

func (a *Adapter) GetTransactionResultsByBlockID(ctx context.Context, blockID flowgo.Identifier) (result []*access.TransactionResult, err error)

func (*Adapter) GetTransactionsByBlockID added in v0.32.0

func (a *Adapter) GetTransactionsByBlockID(ctx context.Context, blockID flowgo.Identifier) (result []*flowgo.TransactionBody, err error)

func (*Adapter) Ping

func (a *Adapter) Ping(ctx context.Context) error

func (*Adapter) SendTransaction

func (a *Adapter) SendTransaction(ctx context.Context, tx *flowgo.TransactionBody) error

type Backend

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

Backend wraps an emulated blockchain and implements the RPC handlers required by the Access API.

func New

func New(logger *zerolog.Logger, emulator Emulator) *Backend

New returns a new backend.

func (*Backend) CommitBlock

func (b *Backend) CommitBlock()

CommitBlock executes the current pending transactions and commits the results in a new block.

func (*Backend) DisableAutoMine

func (b *Backend) DisableAutoMine()

DisableAutoMine disables the automine flag.

func (*Backend) Emulator added in v0.46.0

func (b *Backend) Emulator() Emulator

Emulator return emulator

func (*Backend) EnableAutoMine

func (b *Backend) EnableAutoMine()

EnableAutoMine enables the automine flag.

func (*Backend) ExecuteScriptAtBlockHeight

func (b *Backend) ExecuteScriptAtBlockHeight(
	ctx context.Context,
	blockHeight uint64,
	script []byte,
	arguments [][]byte,
) ([]byte, error)

ExecuteScriptAtBlockHeight executes a script at a specific block height

func (*Backend) ExecuteScriptAtBlockID

func (b *Backend) ExecuteScriptAtBlockID(
	ctx context.Context,
	blockID sdk.Identifier,
	script []byte,
	arguments [][]byte,
) ([]byte, error)

ExecuteScriptAtBlockID executes a script at a specific block ID

func (*Backend) ExecuteScriptAtLatestBlock

func (b *Backend) ExecuteScriptAtLatestBlock(
	ctx context.Context,
	script []byte,
	arguments [][]byte,
) ([]byte, error)

ExecuteScriptAtLatestBlock executes a script at a the latest block

func (*Backend) GetAccount

func (b *Backend) GetAccount(
	ctx context.Context,
	address sdk.Address,
) (*sdk.Account, error)

GetAccount returns an account by address at the latest sealed block.

func (*Backend) GetAccountAtBlockHeight

func (b *Backend) GetAccountAtBlockHeight(
	ctx context.Context,
	address sdk.Address,
	height uint64,
) (*sdk.Account, error)

func (*Backend) GetAccountAtLatestBlock

func (b *Backend) GetAccountAtLatestBlock(
	ctx context.Context,
	address sdk.Address,
) (*sdk.Account, error)

GetAccountAtLatestBlock returns an account by address at the latest sealed block.

func (*Backend) GetAccountStorage added in v0.34.0

func (b *Backend) GetAccountStorage(address sdk.Address) (*emulator.AccountStorage, error)

func (*Backend) GetBlockByHeight

func (b *Backend) GetBlockByHeight(
	ctx context.Context,
	height uint64,
) (
	*flowgo.Block,
	flowgo.BlockStatus,
	error,
)

GetBlockByHeight gets a block by height.

func (*Backend) GetBlockByID

func (b *Backend) GetBlockByID(
	_ context.Context,
	id sdk.Identifier,
) (
	*flowgo.Block,
	flowgo.BlockStatus,
	error,
)

GetBlockByID gets a block by ID.

func (*Backend) GetBlockHeaderByHeight

func (b *Backend) GetBlockHeaderByHeight(
	_ context.Context,
	height uint64,
) (
	*flowgo.Header,
	flowgo.BlockStatus,
	error,
)

GetBlockHeaderByHeight gets a block header by height.

func (*Backend) GetBlockHeaderByID

func (b *Backend) GetBlockHeaderByID(
	_ context.Context,
	id sdk.Identifier,
) (
	*flowgo.Header,
	flowgo.BlockStatus,
	error,
)

GetBlockHeaderByID gets a block header by ID.

func (*Backend) GetCollectionByID

func (b *Backend) GetCollectionByID(
	_ context.Context,
	id sdk.Identifier,
) (*sdk.Collection, error)

GetCollectionByID gets a collection by ID.

func (*Backend) GetEventsForBlockIDs

func (b *Backend) GetEventsForBlockIDs(
	ctx context.Context,
	eventType string,
	blockIDs []sdk.Identifier,
) ([]flowgo.BlockEvents, error)

GetEventsForBlockIDs returns events matching a set of block IDs.

func (*Backend) GetEventsForHeightRange

func (b *Backend) GetEventsForHeightRange(
	ctx context.Context,
	eventType string,
	startHeight, endHeight uint64,
) ([]flowgo.BlockEvents, error)

GetEventsForHeightRange returns events matching a query.

func (*Backend) GetExecutionResultForBlockID added in v0.23.0

func (b *Backend) GetExecutionResultForBlockID(_ context.Context, _ sdk.Identifier) (*flowgo.ExecutionResult, error)

func (*Backend) GetLatestBlock

func (b *Backend) GetLatestBlock(
	_ context.Context,
	_ bool,
) (
	*flowgo.Block,
	flowgo.BlockStatus,
	error,
)

GetLatestBlock gets the latest sealed block.

func (*Backend) GetLatestBlockHeader

func (b *Backend) GetLatestBlockHeader(
	_ context.Context,
	_ bool,
) (
	*flowgo.Header,
	flowgo.BlockStatus,
	error,
)

GetLatestBlockHeader gets the latest sealed block header.

func (*Backend) GetLatestProtocolStateSnapshot added in v0.17.0

func (b *Backend) GetLatestProtocolStateSnapshot(_ context.Context) ([]byte, error)

func (*Backend) GetNetworkParameters

func (b *Backend) GetNetworkParameters(ctx context.Context) access.NetworkParameters

func (*Backend) GetTransaction

func (b *Backend) GetTransaction(
	ctx context.Context,
	id sdk.Identifier,
) (*sdk.Transaction, error)

GetTransaction gets a transaction by ID.

func (*Backend) GetTransactionResult

func (b *Backend) GetTransactionResult(
	ctx context.Context,
	id sdk.Identifier,
) (*sdk.TransactionResult, error)

GetTransactionResult gets a transaction by ID.

func (*Backend) GetTransactionResultByIndex added in v0.31.0

func (b *Backend) GetTransactionResultByIndex(ctx context.Context, id sdk.Identifier, index uint32) (*sdk.TransactionResult, error)

func (*Backend) GetTransactionResultsByBlockID added in v0.32.0

func (b *Backend) GetTransactionResultsByBlockID(ctx context.Context, id sdk.Identifier) (result []*sdk.TransactionResult, err error)

func (*Backend) GetTransactionsByBlockID added in v0.32.0

func (b *Backend) GetTransactionsByBlockID(ctx context.Context, id sdk.Identifier) (result []*sdk.Transaction, err error)

func (*Backend) Ping

func (b *Backend) Ping(ctx context.Context) error

func (*Backend) SendTransaction

func (b *Backend) SendTransaction(ctx context.Context, tx sdk.Transaction) error

SendTransaction submits a transaction to the network.

type Emulator

type Emulator interface {
	// Debugger
	StartDebugger() *interpreter.Debugger
	EndDebugging()

	// CoverageReport
	CoverageReport() *runtime.CoverageReport
	SetCoverageReport(coverageReport *runtime.CoverageReport)

	AddTransaction(tx sdk.Transaction) error
	ExecuteNextTransaction() (*types.TransactionResult, error)
	ExecuteBlock() ([]*types.TransactionResult, error)
	CommitBlock() (*flowgo.Block, error)
	ExecuteAndCommitBlock() (*flowgo.Block, []*types.TransactionResult, error)
	GetLatestBlock() (*flowgo.Block, error)
	GetBlockByID(id sdk.Identifier) (*flowgo.Block, error)
	GetBlockByHeight(height uint64) (*flowgo.Block, error)
	GetCollection(colID sdk.Identifier) (*sdk.Collection, error)
	GetTransaction(txID sdk.Identifier) (*sdk.Transaction, error)
	GetTransactionResult(txID sdk.Identifier) (*sdk.TransactionResult, error)
	// Deprecated: Needed for the debugger right now, do NOT use for other purposes.
	// TODO: refactor
	GetAccountUnsafe(address sdk.Address) (*sdk.Account, error)
	GetAccount(address sdk.Address) (*sdk.Account, error)
	GetAccountByIndex(uint) (*sdk.Account, error)

	GetAccountAtBlock(address sdk.Address, blockHeight uint64) (*sdk.Account, error)
	GetEventsByHeight(blockHeight uint64, eventType string) ([]sdk.Event, error)
	ExecuteScript(script []byte, arguments [][]byte) (*types.ScriptResult, error)
	ExecuteScriptAtBlock(script []byte, arguments [][]byte, blockHeight uint64) (*types.ScriptResult, error)
	GetAccountStorage(address sdk.Address) (*emulator.AccountStorage, error)

	Snapshots() ([]string, error)
	CreateSnapshot(name string) error
	LoadSnapshot(name string) error

	RollbackToBlockHeight(height uint64) error
}

Emulator defines the method set of an emulated blockchain.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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