order

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ID               uint64
	IsNew            bool
	RepoRoot         string
	StoragePath      string
	OrderType        string
	PeerMgr          orderPeerMgr.OrderPeerManager
	PrivKey          crypto.PrivateKey
	Logger           logrus.FieldLogger
	Nodes            map[uint64]*pb.VpInfo
	Applied          uint64
	Digest           string
	GetChainMetaFunc func() *pb.ChainMeta
	GetBlockByHeight func(height uint64, fullTx bool) (*pb.Block, error)
	GetAccountNonce  func(address *types.Address) uint64
}

func GenerateConfig

func GenerateConfig(opts ...Option) (*Config, error)

type Option

type Option func(*Config)

func WithApplied

func WithApplied(height uint64) Option

func WithDigest

func WithDigest(digest string) Option

func WithGetAccountNonceFunc

func WithGetAccountNonceFunc(f func(address *types.Address) uint64) Option

func WithGetBlockByHeightFunc

func WithGetBlockByHeightFunc(f func(height uint64, fullTx bool) (*pb.Block, error)) Option

func WithGetChainMetaFunc

func WithGetChainMetaFunc(f func() *pb.ChainMeta) Option

func WithID

func WithID(id uint64) Option

func WithIsNew

func WithIsNew(isNew bool) Option

func WithLogger

func WithLogger(logger logrus.FieldLogger) Option

func WithNodes

func WithNodes(nodes map[uint64]*pb.VpInfo) Option

func WithOrderType

func WithOrderType(typ string) Option

func WithPeerManager

func WithPeerManager(peerMgr orderPeerMgr.OrderPeerManager) Option

func WithPrivKey

func WithPrivKey(privKey crypto.PrivateKey) Option

func WithRepoRoot

func WithRepoRoot(path string) Option

func WithStoragePath

func WithStoragePath(path string) Option

type Order

type Order interface {
	// Start the order service.
	Start() error

	// Stop means frees the resources which were allocated for this service.
	Stop()

	// Prepare means send transaction to the consensus engine
	Prepare(tx pb.Transaction) error

	// Commit recv blocks form Order and commit it by order
	Commit() chan *pb.CommitEvent

	// Step send msg to the consensus engine
	Step(msg []byte) error

	// Ready means whether order has finished electing leader
	Ready() error

	// ReportState means block was persisted and report it to the consensus engine
	ReportState(height uint64, blockHash *types.Hash, txHashList []*types.Hash)

	// Quorum means minimum number of nodes in the cluster that can work
	Quorum() uint64

	// GetPendingNonceByAccount will return the latest pending nonce of a given account
	GetPendingNonceByAccount(account string) uint64

	GetPendingTxByHash(hash *types.Hash) pb.Transaction

	// DelNode sends a delete vp request by given id.
	DelNode(delID uint64) error

	SubscribeTxEvent(events chan<- pb.Transactions) event.Subscription
}

Jump to

Keyboard shortcuts

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