block

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	BlockMeta
	State BlockState
	Batch *database.Batch
}

type BlockMeta

type BlockMeta struct {
	IsLeader   bool
	Index      int64
	Time       time.Time
	CommitInfo *types.LastCommitInfo
	Evidence   []types.Evidence
}

BlockMeta is metadata about a block.

type BlockState

type BlockState struct {
	Delivered         uint64
	Signed            uint64
	SynthSigned       uint64
	SynthSent         uint64
	ValidatorsUpdates []chain.ValidatorUpdate
	ProducedTxns      []*protocol.Transaction
	ChainUpdates      chain.ChainUpdates
}

BlockState tracks various metrics of a block of transactions as they are executed.

func (*BlockState) Empty

func (s *BlockState) Empty() bool

Empty returns true if nothing happened during the block.

func (*BlockState) MergeSignature

func (s *BlockState) MergeSignature(r *ProcessSignatureState)

func (*BlockState) MergeTransaction

func (s *BlockState) MergeTransaction(r *chain.ProcessTransactionState)

type Executor

type Executor struct {
	ExecutorOptions
	// contains filtered or unexported fields
}

func NewGenesisExecutor

func NewGenesisExecutor(db *database.Database, logger log.Logger, network config.Network, router routing.Router) (*Executor, error)

NewGenesisExecutor creates a transaction executor that can be used to set up the genesis state.

func NewNodeExecutor

func NewNodeExecutor(opts ExecutorOptions, db *database.Database) (*Executor, error)

NewNodeExecutor creates a new Executor for a node.

func (*Executor) BeginBlock

func (x *Executor) BeginBlock(block *Block) (err error)

BeginBlock implements ./Chain

func (*Executor) EndBlock

func (m *Executor) EndBlock(block *Block) error

EndBlock implements ./Chain

func (*Executor) ExecuteEnvelope added in v0.6.0

func (x *Executor) ExecuteEnvelope(block *Block, delivery *chain.Delivery) (*protocol.TransactionStatus, error)

func (*Executor) Genesis

func (m *Executor) Genesis(block *Block, callback func(st *chain.StateManager) error) error

func (*Executor) InitChain

func (m *Executor) InitChain(block *Block, data []byte) ([]byte, error)

func (*Executor) ProcessRemoteSignatures added in v0.6.0

func (x *Executor) ProcessRemoteSignatures(block *Block, delivery *chain.Delivery) error

func (*Executor) ProcessSignature

func (x *Executor) ProcessSignature(batch *database.Batch, delivery *chain.Delivery, signature protocol.Signature) (*ProcessSignatureState, error)

func (*Executor) ProcessTransaction

func (x *Executor) ProcessTransaction(batch *database.Batch, transaction *protocol.Transaction) (*protocol.TransactionStatus, *chain.ProcessTransactionState, error)

ProcessTransaction processes a transaction. It will not return an error if the transaction fails - in that case the status code will be non zero. It only returns an error in cases like a database failure.

func (*Executor) ProduceSynthetic

func (x *Executor) ProduceSynthetic(batch *database.Batch, from *protocol.Transaction, produced []*protocol.Transaction) error

func (*Executor) Query

func (m *Executor) Query(batch *database.Batch, q *query.Query, _ int64, prove bool) (k, v []byte, err *protocol.Error)

func (*Executor) TransactionIsReady added in v0.6.0

func (x *Executor) TransactionIsReady(batch *database.Batch, transaction *protocol.Transaction, status *protocol.TransactionStatus) (bool, error)

func (*Executor) ValidateEnvelope

func (x *Executor) ValidateEnvelope(batch *database.Batch, delivery *chain.Delivery) (protocol.TransactionResult, error)

ValidateEnvelope verifies that the envelope is valid. It checks the basics, like the envelope has signatures and a hash and/or a transaction. It validates signatures, ensuring they match the transaction hash, reference a signator, etc. And more.

ValidateEnvelope should not modify anything. Right now it updates signer timestamps and credits, but that will be moved to ProcessSignature.

type ExecutorOptions

type ExecutorOptions struct {
	Logger  log.Logger
	Key     ed25519.PrivateKey
	Router  routing.Router
	Network config.Network
	// contains filtered or unexported fields
}

type PrincipalValidator added in v0.6.0

type PrincipalValidator interface {
	TransactionExecutor

	AllowMissingPrincipal(*protocol.Transaction) (allow, fallback bool)
}

PrincipalValidator validates the principal for a specific type of transaction.

type ProcessSignatureState

type ProcessSignatureState struct {
	Signers []protocol.Signer
}

func (*ProcessSignatureState) Merge

type SignatureValidator added in v0.6.0

type SignatureValidator interface {
	TransactionExecutor

	// SignerIsAuthorized checks if the signature is authorized for the
	// transaction.
	SignerIsAuthorized(*database.Batch, *protocol.Transaction, protocol.Signer) (fallback bool, err error)

	// TransactionIsReady checks if the transaction is ready to be executed.
	TransactionIsReady(*database.Batch, *protocol.Transaction, *protocol.TransactionStatus) (ready, fallback bool, err error)
}

SignatureValidator validates signatures for a specific type of transaction.

type TransactionExecutor

type TransactionExecutor interface {
	// Type is the transaction type the executor can execute.
	Type() protocol.TransactionType

	// Validate validates the transaction for acceptance.
	Validate(*StateManager, *Delivery) (protocol.TransactionResult, error)

	// Execute fully validates and executes the transaction.
	Execute(*StateManager, *Delivery) (protocol.TransactionResult, error)
}

TransactionExecutor executes a specific type of transaction.

type TransactionExecutorCleanup added in v0.6.0

type TransactionExecutorCleanup interface {
	// DidFail is called if the transaction failed.
	DidFail(*ProcessTransactionState, *protocol.Transaction) error
}

TransactionExecutorCleanup cleans up after a failed transaction.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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