models

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SafeBlockNumber      = big.NewInt(-4)
	FinalizedBlockNumber = big.NewInt(-3)
	LatestBlockNumber    = big.NewInt(-2)
	PendingBlockNumber   = big.NewInt(-1)
	EarliestBlockNumber  = big.NewInt(0)
)
View Source
var (
	ErrDisconnected = NewRecoverableError(errors.New("disconnected"))
)
View Source
var ErrInvalidHeight = errors.New("invalid height")

Functions

func IsRecoverableError added in v0.2.0

func IsRecoverableError(err error) bool

func MarshalReceipt added in v0.4.0

func MarshalReceipt(
	receipt *gethTypes.Receipt,
	tx Transaction,
) (map[string]interface{}, error)

MarshalReceipt takes a receipt and its associated transaction, and marshals the receipt to the proper structure needed by eth_getTransactionReceipt.

Types

type BlockEvents added in v0.12.0

type BlockEvents struct {
	Events *CadenceEvents
	Err    error
}

BlockEvents is a wrapper around events streamed, and it also contains an error

func NewBlockEvents added in v0.12.0

func NewBlockEvents(events flow.BlockEvents) BlockEvents

func NewBlockEventsError added in v0.12.0

func NewBlockEventsError(err error) BlockEvents

type CadenceEvents added in v0.6.0

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

func NewCadenceEvents added in v0.6.0

func NewCadenceEvents(events flow.BlockEvents) *CadenceEvents

func (*CadenceEvents) Blocks added in v0.6.0

func (c *CadenceEvents) Blocks() ([]*types.Block, error)

Blocks finds the block evm events and decodes it into the blocks slice, if no block events are found nil slice is returned.

Return values: blocks, nil - if blocks are found nil, nil - if no block are found nil, err - unexpected error

func (*CadenceEvents) CadenceBlockID added in v0.16.0

func (c *CadenceEvents) CadenceBlockID() flow.Identifier

CadenceBlockID returns the Flow Cadence block ID.

func (*CadenceEvents) CadenceHeight added in v0.6.0

func (c *CadenceEvents) CadenceHeight() uint64

CadenceHeight returns the Flow Cadence height at which the events were emitted.

func (*CadenceEvents) Empty added in v0.6.0

func (c *CadenceEvents) Empty() bool

Empty checks if there are any evm block or transactions events. If there are no evm block or transactions events this is a heartbeat event that is broadcast in intervals.

func (*CadenceEvents) Length added in v0.6.0

func (c *CadenceEvents) Length() int

Length of the Cadence events emitted.

func (*CadenceEvents) Transactions added in v0.6.0

func (c *CadenceEvents) Transactions() ([]Transaction, []*gethTypes.Receipt, error)

Transactions finds all the transactions evm events and decodes them into transaction slice, if no transactions is found nil is returned.

Return values: []transaction, nil - if transactions are found nil, nil - if no transactions are found nil, err - unexpected error

type DirectCall added in v0.4.0

type DirectCall struct {
	*types.DirectCall
}

func (DirectCall) BlobGas added in v0.4.0

func (dc DirectCall) BlobGas() uint64

func (DirectCall) Data added in v0.4.0

func (dc DirectCall) Data() []byte

func (DirectCall) From added in v0.4.0

func (dc DirectCall) From() (common.Address, error)

func (DirectCall) Gas added in v0.4.0

func (dc DirectCall) Gas() uint64

func (DirectCall) GasPrice added in v0.4.0

func (dc DirectCall) GasPrice() *big.Int

func (DirectCall) Hash added in v0.4.0

func (dc DirectCall) Hash() (common.Hash, error)

func (DirectCall) MarshalBinary added in v0.4.0

func (dc DirectCall) MarshalBinary() ([]byte, error)

func (DirectCall) Nonce added in v0.4.0

func (dc DirectCall) Nonce() uint64

func (DirectCall) RawSignatureValues added in v0.4.0

func (dc DirectCall) RawSignatureValues() (
	v *big.Int,
	r *big.Int,
	s *big.Int,
)

func (DirectCall) Size added in v0.4.0

func (dc DirectCall) Size() uint64

func (DirectCall) To added in v0.4.0

func (dc DirectCall) To() *common.Address

func (DirectCall) Type added in v0.4.0

func (dc DirectCall) Type() uint8

func (DirectCall) Value added in v0.4.0

func (dc DirectCall) Value() *big.Int

type Engine

type Engine interface {
	// Run the engine with context, errors are not expected.
	Run(ctx context.Context) error
	// Stop the engine.
	Stop()
	// Done signals the engine was stopped.
	Done() <-chan struct{}
	// Ready signals the engine was started.
	Ready() <-chan struct{}
}

Engine defines a processing unit

type EngineStatus

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

func NewEngineStatus

func NewEngineStatus() *EngineStatus

func (*EngineStatus) IsDone

func (e *EngineStatus) IsDone() <-chan struct{}

func (*EngineStatus) IsReady

func (e *EngineStatus) IsReady() <-chan struct{}

func (*EngineStatus) IsStopped

func (e *EngineStatus) IsStopped() <-chan struct{}

func (*EngineStatus) MarkDone

func (e *EngineStatus) MarkDone()

func (*EngineStatus) MarkReady

func (e *EngineStatus) MarkReady()

func (*EngineStatus) MarkStopped

func (e *EngineStatus) MarkStopped()

type RecoverableError added in v0.2.0

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

RecoverableError is used to signal any types of errors that if encountered could be retried again

func NewRecoverableError added in v0.2.0

func NewRecoverableError(err error) RecoverableError

func (RecoverableError) Error added in v0.2.0

func (r RecoverableError) Error() string

func (RecoverableError) Unwrap added in v0.2.0

func (r RecoverableError) Unwrap() error

type RestartableEngine

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

RestartableEngine is an engine wrapper that tries to restart the engine in case of starting errors.

The strategy of the restarts contains Fibonacci backoff time and limited number of retries that can be configured. Here are backoff values for different retries provided: 1s 1s 2s 3s 5s 8s 13s 21s 34s 55s 1m29s 2m24s 3m53s 6m17s 10m10s 16m27s 26m37s 43m4s 1h9m41s

func NewRestartableEngine added in v0.2.0

func NewRestartableEngine(engine Engine, retries uint, logger zerolog.Logger) *RestartableEngine

func (*RestartableEngine) Done

func (r *RestartableEngine) Done() <-chan struct{}

func (*RestartableEngine) Ready

func (r *RestartableEngine) Ready() <-chan struct{}

func (*RestartableEngine) Run

func (r *RestartableEngine) Run(ctx context.Context) error

func (*RestartableEngine) Stop

func (r *RestartableEngine) Stop()

type SequentialHeight

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

SequentialHeight tracks a block height and enforces rules about the valid next height.

func NewSequentialHeight

func NewSequentialHeight(init uint64) *SequentialHeight

func (*SequentialHeight) Increment

func (s *SequentialHeight) Increment(nextHeight uint64) error

Increment the height value according to the rules. A valid next height must be either incremented by one, or must be the same as previous height to make the action idempotent. Expected errors: if the height is not incremented according to the rules a ErrInvalidHeight error is returned

func (*SequentialHeight) Load

func (s *SequentialHeight) Load() uint64

type StorageReceipt

type StorageReceipt struct {
	Type              uint8
	PostState         []byte
	Status            uint64
	CumulativeGasUsed uint64
	// todo we could skip bloom to optimize storage and dynamically recalculate it
	Bloom             gethTypes.Bloom
	Logs              []*gethTypes.Log
	TxHash            common.Hash
	ContractAddress   common.Address
	GasUsed           uint64
	EffectiveGasPrice *big.Int
	BlobGasUsed       uint64
	BlobGasPrice      *big.Int
	BlockHash         common.Hash
	BlockNumber       *big.Int
	TransactionIndex  uint
}

StorageReceipt is a receipt representation for storage.

This struct copies the geth.Receipt type found here: https://github.com/ethereum/go-ethereum/blob/9bbb9df18549d6f81c3d1f4fc6c65f71bc92490d/core/types/receipt.go#L52 the reason is if we use geth.Receipt some values will be skipped when RLP encoding which is because geth node has the data locally, but we don't in evm gateway, so we can not reproduce those values and we need to store them

type Transaction added in v0.4.0

type Transaction interface {
	// TODO(m-Peter): Remove the error return value once flow-go is updated
	Hash() (common.Hash, error)
	RawSignatureValues() (v *big.Int, r *big.Int, s *big.Int)
	From() (common.Address, error)
	To() *common.Address
	Data() []byte
	Nonce() uint64
	Value() *big.Int
	Type() uint8
	Gas() uint64
	GasPrice() *big.Int
	BlobGas() uint64
	Size() uint64
	MarshalBinary() ([]byte, error)
}

func UnmarshalTransaction added in v0.4.0

func UnmarshalTransaction(value []byte) (Transaction, error)

type TransactionCall added in v0.4.0

type TransactionCall struct {
	*gethTypes.Transaction
}

func (TransactionCall) From added in v0.4.0

func (tc TransactionCall) From() (common.Address, error)

func (TransactionCall) Hash added in v0.4.0

func (tc TransactionCall) Hash() (common.Hash, error)

func (TransactionCall) MarshalBinary added in v0.4.0

func (tc TransactionCall) MarshalBinary() ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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