block

package
v1.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthoritySignature

type AuthoritySignature struct{}

AuthoritySignature processes delegated signatures.

func (AuthoritySignature) Process

func (AuthoritySignature) Validate

type Block

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

type BlockAnchor

type BlockAnchor struct{}

BlockAnchor executes the signature, queuing the transaction for processing when appropriate.

func (BlockAnchor) Process

func (BlockAnchor) Validate

type BlockAnchorState

type BlockAnchorState struct {
	ShouldOpenMajorBlock bool
	OpenMajorBlockTime   time.Time
}

BlockAnchorState is used to construc the anchor for the block.

type BlockMeta

type BlockMeta = execute.BlockParams

BlockMeta is metadata about a block.

type BlockState

type BlockState struct {
	OpenedMajorBlock   bool
	MakeMajorBlock     uint64
	MakeMajorBlockTime time.Time
	Delivered          uint64
	Signed             uint64
	Produced           int
	ChainUpdates       chain.ChainUpdates
	ReceivedAnchors    []*chain.ReceivedAnchor

	Anchor *BlockAnchorState
}

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 BlockStateV2

type BlockStateV2 Block

BlockStateV2 translates execute.BlockState calls for a v1 executor

func (*BlockStateV2) Commit

func (s *BlockStateV2) Commit() error

func (*BlockStateV2) DidCompleteMajorBlock

func (s *BlockStateV2) DidCompleteMajorBlock() (uint64, time.Time, bool)

func (*BlockStateV2) Discard

func (s *BlockStateV2) Discard()

func (*BlockStateV2) IsEmpty

func (s *BlockStateV2) IsEmpty() bool

func (*BlockStateV2) Params

func (b *BlockStateV2) Params() execute.BlockParams

type BlockTimerType

type BlockTimerType uint64
const BlockTimerTypeBeginBlock BlockTimerType = 2

BlockTimerTypeBeginBlock .

const BlockTimerTypeCheckTx BlockTimerType = 3

BlockTimerTypeCheckTx .

const BlockTimerTypeCommit BlockTimerType = 6

BlockTimerTypeCommit .

const BlockTimerTypeDeliverTx BlockTimerType = 4

BlockTimerTypeDeliverTx .

const BlockTimerTypeEndBlock BlockTimerType = 5

BlockTimerTypeEndBlock .

const BlockTimerTypeExecuteEnvelope BlockTimerType = 0

BlockTimerTypeExecuteEnvelope .

const BlockTimerTypeNetworkAccountUpdates BlockTimerType = 8

BlockTimerTypeNetworkAccountUpdates .

const BlockTimerTypeProcessRemoteSignatures BlockTimerType = 9

BlockTimerTypeProcessRemoteSignatures .

const BlockTimerTypeProcessSignature BlockTimerType = 1

BlockTimerTypeProcessSignature .

const BlockTimerTypeProcessTransaction BlockTimerType = 10

BlockTimerTypeProcessTransaction .

const BlockTimerTypeSigning BlockTimerType = 7

BlockTimerTypeSigning .

const BlockTimerTypeTransactionOffset BlockTimerType = 240

BlockTimerTypeTransactionOffset .

func BlockTimerTypeByName

func BlockTimerTypeByName(name string) (BlockTimerType, bool)

BlockTimerTypeByName returns the named Block Timer Type.

func (BlockTimerType) GetEnumValue

func (v BlockTimerType) GetEnumValue() uint64

GetEnumValue returns the value of the Block Timer Type

func (BlockTimerType) MarshalJSON

func (v BlockTimerType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Block Timer Type to JSON as a string.

func (*BlockTimerType) SetEnumValue

func (v *BlockTimerType) SetEnumValue(id uint64) bool

SetEnumValue sets the value. SetEnumValue returns false if the value is invalid.

func (BlockTimerType) String

func (v BlockTimerType) String() string

String returns the name of the Block Timer Type.

func (*BlockTimerType) UnmarshalJSON

func (v *BlockTimerType) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the Block Timer Type from JSON as a string.

type BlockV2

type BlockV2 struct {
	Block    *Block
	Executor *Executor
}

BlockV2 translates execute.Block calls for a v1 executor/

func (*BlockV2) Close

func (b *BlockV2) Close() (execute.BlockState, error)

Close ends the block and returns the block state.

func (*BlockV2) Params

func (b *BlockV2) Params() execute.BlockParams

func (*BlockV2) Process

func (b *BlockV2) Process(messages []messaging.Message) ([]*protocol.TransactionStatus, error)

Process processes a message bundle.

type CreditPayment

type CreditPayment struct{}

CreditPayment processes a credit payment

func (CreditPayment) Process

func (CreditPayment) Validate

type Dispatcher

type Dispatcher = execute.Dispatcher

type Executor

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

func NewExecutor

func NewExecutor(opts ExecutorOptions) (*Executor, error)

NewExecutor creates a new Executor.

func (*Executor) ActiveGlobals_TESTONLY

func (m *Executor) ActiveGlobals_TESTONLY() *core.GlobalValues

func (*Executor) AuthorityIsSatisfied

func (x *Executor) AuthorityIsSatisfied(batch *database.Batch, transaction *protocol.Transaction, status *protocol.TransactionStatus, authUrl *url.URL) (bool, error)

func (*Executor) BeginBlock

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

BeginBlock implements ./Chain

func (*Executor) EnableTimers

func (m *Executor) EnableTimers()

func (*Executor) EndBlock

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

EndBlock implements ./Chain

func (*Executor) GetAccountAuthoritySet

func (x *Executor) GetAccountAuthoritySet(batch *database.Batch, account protocol.Account) (*protocol.AccountAuth, error)

func (*Executor) InitChainValidators

func (x *Executor) InitChainValidators(initVal []abci.ValidatorUpdate) (additional [][]byte, err error)

func (*Executor) LoadStateRoot

func (m *Executor) LoadStateRoot(batch *database.Batch) ([]byte, error)

func (*Executor) ProcessTransaction

func (x *Executor) ProcessTransaction(batch *database.Batch, delivery *chain.Delivery) (*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, produced []*ProducedMessage) error

func (*Executor) RestoreSnapshot

func (m *Executor) RestoreSnapshot(db database.Beginner, file ioutil2.SectionReader) error

func (*Executor) SetExecutor_TESTONLY

func (x *Executor) SetExecutor_TESTONLY(y chain.TransactionExecutor)

func (*Executor) SignerIsAuthorized

func (x *Executor) SignerIsAuthorized(batch *database.Batch, transaction *protocol.Transaction, signer protocol.Signer, checkAuthz bool) error

SignerIsAuthorized verifies that the signer is allowed to sign the transaction

func (*Executor) SignerIsSatisfied

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

func (*Executor) StoreBlockTimers

func (m *Executor) StoreBlockTimers(ds *logging.DataSet)

func (*Executor) TransactionIsReady

func (x *Executor) TransactionIsReady(batch *database.Batch, delivery *chain.Delivery, status *protocol.TransactionStatus, principal protocol.Account) (bool, error)

type ExecutorFor

type ExecutorFor[T any, V interface{ Type() T }] interface {
	Process(*database.Batch, V) (*protocol.TransactionStatus, error)
	Validate(*database.Batch, V) (*protocol.TransactionStatus, error)
}

type ExecutorOptions

type ExecutorOptions = execute.Options

type ExecutorV2

type ExecutorV2 Executor

ExecutorV2 implements execute.Executor calls for a v1 executor.

func (*ExecutorV2) Begin

func (x *ExecutorV2) Begin(params execute.BlockParams) (execute.Block, error)

Begin constructs a BlockV2 and calls Executor.BeginBlock.

func (*ExecutorV2) EnableTimers

func (x *ExecutorV2) EnableTimers()

func (*ExecutorV2) InitChainValidators

func (x *ExecutorV2) InitChainValidators(initVal []abcitypes.ValidatorUpdate) (additional [][]byte, err error)

func (*ExecutorV2) LoadStateRoot

func (x *ExecutorV2) LoadStateRoot(batch *database.Batch) ([]byte, error)

func (*ExecutorV2) RestoreSnapshot

func (x *ExecutorV2) RestoreSnapshot(batch database.Beginner, snapshot ioutil2.SectionReader) error

func (*ExecutorV2) StoreBlockTimers

func (x *ExecutorV2) StoreBlockTimers(ds *logging.DataSet)

func (*ExecutorV2) Validate

func (x *ExecutorV2) Validate(batch *database.Batch, messages []messaging.Message) ([]*protocol.TransactionStatus, error)

Validate converts the message to a delivery and validates it. Validate returns an error if the message is not a [message.LegacyMessage].

type Globals

type Globals struct {
	Active, Pending core.GlobalValues
}

type KeySignature

type KeySignature struct{}

KeySignature processes key signatures.

func (KeySignature) Process

func (KeySignature) Validate

type MessageContext

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

MessageContext is the context in which a message is processed.

func (*MessageContext) Type

type MessageIsReady

type MessageIsReady struct{}

MessageIsReady executes a message.

func (MessageIsReady) Process

func (MessageIsReady) Validate

type NetworkUpdate

type NetworkUpdate struct{}

NetworkUpdate constructs a transaction for the network update and queues it for processing.

func (NetworkUpdate) Process

func (NetworkUpdate) Validate

type ProcessSignatureState

type ProcessSignatureState struct {
}

func (*ProcessSignatureState) Merge

type ProducedMessage

type ProducedMessage struct {
	// Producer is the ID of the producer.
	Producer *url.TxID

	// Destination is the account that the message should be routed to.
	Destination *url.URL

	// Message is the produced message.
	Message messaging.Message
}

ProducedMessage is a message produced by another message.

type SequencedMessage

type SequencedMessage struct{ UserTransaction }

SequencedMessage records the sequence metadata and executes the message inside.

func (SequencedMessage) Process

func (SequencedMessage) Validate

type SignatureContext

type SignatureContext struct {
	*MessageContext
	// contains filtered or unexported fields
}

SignatureContext is the context in which a message is executed.

func (*SignatureContext) Type

type SignatureRequest

type SignatureRequest struct{}

SignatureRequest lists a transaction as pending on an authority.

func (SignatureRequest) Process

func (SignatureRequest) Validate

type SyntheticMessage

type SyntheticMessage struct{}

SyntheticMessage records the synthetic transaction but does not execute it.

func (SyntheticMessage) Process

func (SyntheticMessage) Validate

type TimerRecord

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

type TimerSet

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

func (*TimerSet) Initialize

func (t *TimerSet) Initialize(executors *map[protocol.TransactionType]chain.TransactionExecutor)

func (*TimerSet) Reset

func (t *TimerSet) Reset()

func (*TimerSet) Start

func (t *TimerSet) Start(record any) *TimerRecord

func (*TimerSet) Stop

func (t *TimerSet) Stop(r *TimerRecord)

func (*TimerSet) Store

func (t *TimerSet) Store(ds *logging.DataSet)

type TransactionContext

type TransactionContext struct {
	*MessageContext
	// contains filtered or unexported fields
}

TransactionContext is the context in which a transaction is executed.

type UserSignature

type UserSignature struct{}

UserSignature executes the signature, queuing the transaction for processing when appropriate.

func (UserSignature) Process

func (UserSignature) Validate

type UserTransaction

type UserTransaction struct{}

UserTransaction records the transaction but does not execute it. Transactions are executed in response to _authority signature_ messages, not user transaction messages.

func (UserTransaction) Process

func (UserTransaction) Validate

Jump to

Keyboard shortcuts

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