receipt

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: LGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package receipt keeps track of transaction receipts for a number of ticks. A receipt consists of any errors that were encountered while processing a transaction's message, as well as the message's result

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTickHasNotBeenProcessed = errors.New("tick is still in progress")
	ErrOldTickHasBeenDiscarded = errors.New("the requested tick has been discarded due to age")
)

Functions

This section is empty.

Types

type History

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

History keeps track of transaction "receipts" (the result of a transaction and any associated errors) for some number of ticks.

func NewHistory

func NewHistory(currentTick uint64, ticksToStore int) *History

NewHistory creates a object that can track transaction receipts over a number of ticks.

func (*History) AddError

func (h *History) AddError(hash types.TxHash, err error)

AddError associates the given error with the given transaction hash. Calling this multiple times will append the error any previously added errors.

func (*History) GetReceipt

func (h *History) GetReceipt(hash types.TxHash) (Receipt, bool)

GetReceipt gets the receipt (the transaction result and the list of errors) for the given transaction hash in the current tick. To get receipts from previous ticks use GetReceiptsForTick.

func (*History) GetReceiptsForTick

func (h *History) GetReceiptsForTick(tick uint64) ([]Receipt, error)

GetReceiptsForTick gets all receipts for the given tick. If the tick is still active, or if the tick is too far in the past, an error is returned.

func (*History) NextTick

func (h *History) NextTick()

NextTick advances the internal History tick by 1. Errors and results can only be set on the current tick. Receipts from ticks in the past are read only.

func (*History) SetResult

func (h *History) SetResult(hash types.TxHash, result any)

SetResult sets the given transaction hash to the given result. Calling this multiple times will replace any previous results.

func (*History) SetTick

func (h *History) SetTick(tick uint64)

func (*History) Size

func (h *History) Size() uint64

type Receipt

type Receipt struct {
	TxHash types.TxHash
	Result any
	Errs   []error
}

Receipt contains a transaction hash, an arbitrary result, and a list of errors.

func (Receipt) MarshalJSON added in v1.3.1

func (r Receipt) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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