consensus

package
v0.0.0-...-231e548 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildBlock

func BuildBlock(params BuildBlockParams) *types.Block

BuildBlock is a utility function that builds a block, based on the passed in header, transactions and receipts

Types

type BridgeDataProvider

type BridgeDataProvider interface {
	// GenerateExit proof generates proof of exit for given exit event
	GenerateExitProof(exitID uint64) (types.Proof, error)

	// GetStateSyncProof retrieves the StateSync proof
	GetStateSyncProof(stateSyncID uint64) (types.Proof, error)
}

BridgeDataProvider is an interface providing bridge related functions

type BuildBlockParams

type BuildBlockParams struct {
	Header   *types.Header
	Txns     []*types.Transaction
	Receipts []*types.Receipt
}

BuildBlockParams are parameters passed into the BuildBlock helper method

type Config

type Config struct {
	// Logger to be used by the consensus
	Logger *log.Logger

	// Params are the params of the chain and the consensus
	Params *chain.Params

	// Config defines specific configuration parameters for the consensus
	Config map[string]interface{}

	// Path is the directory path for the consensus protocol to store information
	Path string

	// IsRelayer is true if node is relayer
	IsRelayer bool

	// RPCEndpoint
	RPCEndpoint string
}

Config is the configuration for the consensus

type Consensus

type Consensus interface {
	// VerifyHeader verifies the header is correct
	VerifyHeader(header *types.Header) error

	// ProcessHeaders updates the snapshot based on the verified headers
	ProcessHeaders(headers []*types.Header) error

	// GetBlockCreator retrieves the block creator (or signer) given the block header
	GetBlockCreator(header *types.Header) (types.Address, error)

	// PreCommitState a hook to be called before finalizing state transition on inserting block
	PreCommitState(block *types.Block, txn *state.Transition) error

	// GetSyncProgression retrieves the current sync progression, if any
	GetSyncProgression() *progress.Progression

	// GetBridgeProvider returns an instance of BridgeDataProvider
	GetBridgeProvider() BridgeDataProvider

	// FilterExtra filters extra data in header that is not a part of block hash
	FilterExtra(extra []byte) ([]byte, error)

	// Initialize initializes the consensus (e.g. setup data)
	Initialize() error

	// Start starts the consensus and servers
	Start() error

	// Close closes the connection
	Close() error
}

Consensus is the public interface for consensus mechanism Each consensus mechanism must implement this interface in order to be valid

type Factory

type Factory func(*Params) (Consensus, error)

Factory is the factory function to create a discovery consensus

type Params

type Params struct {
	Context        context.Context
	Config         *Config
	TxPool         *txpool.TxPool
	Network        *network.Server
	Blockchain     *blockchain.Blockchain
	Executor       *state.Executor
	Grpc           *grpc.Server
	Logger         hclog.Logger
	SecretsManager secrets.SecretsManager
	BlockTime      uint64

	NumBlockConfirmations uint64
	MetricsInterval       time.Duration
}

Directories

Path Synopsis
Package posavchain implements PBFT consensus algorithm integration and bridge feature
Package posavchain implements PBFT consensus algorithm integration and bridge feature
contractsapi
Code generated by scapi/gen.
Code generated by scapi/gen.

Jump to

Keyboard shortcuts

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