backend

package
v0.14.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2021 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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, error)

func (*Adapter) GetBlockByID

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

func (*Adapter) GetBlockHeaderByHeight

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

func (*Adapter) GetBlockHeaderByID

func (a *Adapter) GetBlockHeaderByID(ctx context.Context, id flowgo.Identifier) (*flowgo.Header, 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) GetLatestBlock

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

func (*Adapter) GetLatestBlockHeader

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

func (*Adapter) GetNetworkParameters

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

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) (*access.TransactionResult, 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 *logrus.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) 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) GetBlockByHeight

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

GetBlockByHeight gets a block by height.

func (*Backend) GetBlockByID

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

GetBlockByHeight gets a block by ID.

func (*Backend) GetBlockHeaderByHeight

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

GetBlockHeaderByHeight gets a block header by height.

func (*Backend) GetBlockHeaderByID

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

GetBlockHeaderByID gets a block header by ID.

func (*Backend) GetCollectionByID

func (b *Backend) GetCollectionByID(
	ctx 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) GetLatestBlock

func (b *Backend) GetLatestBlock(ctx context.Context, isSealed bool) (*flowgo.Block, error)

GetLatestBlock gets the latest sealed block.

func (*Backend) GetLatestBlockHeader

func (b *Backend) GetLatestBlockHeader(ctx context.Context, isSealed bool) (*flowgo.Header, error)

GetLatestBlockHeader gets the latest sealed block header.

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) 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 {
	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)
	GetAccount(address sdk.Address) (*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)
}

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