migration

package
v2.0.0-alpha+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(systemChannel bool, current, next *ConsensusTypeInfo) error

Validate checks the validity of the state transitions of a possible migration config update tx by comparing the current ConsensusTypeInfo config with the next (proposed) ConsensusTypeInfo. It is called during the broadcast phase and never changes the status of the underlying chain.

Types

type ConsensusTypeInfo

type ConsensusTypeInfo struct {
	Type     string
	Metadata []byte
	State    orderer.ConsensusType_MigrationState
	Context  uint64
}

ConsensusTypeInfo carries the fields of protos/orderer/ConsensusType that are contained in a proposed or ordered config update transaction.

type Controller

type Controller interface {
	// ConsensusMigrationPending checks whether consensus-type migration had started,
	// by inspecting the status of the system channel.
	ConsensusMigrationPending() bool

	// ConsensusMigrationStart marks every standard channel as "START" with the given context.
	// It should first check that consensus-type migration is not started on any of the standard channels.
	// This call is always triggered by a MigrationState="START" config update on the system channel.
	// The context is the future height of the system channel config block that carries said config update.
	ConsensusMigrationStart(context uint64) error

	// ConsensusMigrationCommit verifies that the conditions for committing the consensus-type migration
	// are met, and if so, marks the system channel as committed.
	// The conditions are:
	// 1. system channel must be at START with context >0;
	// 2. all standard channels must be at CONTEXT with the same context as the system channel.
	ConsensusMigrationCommit() error

	// ConsensusMigrationAbort verifies that the conditions for aborting the consensus-type migration
	// are met, and if so, marks the system channel as aborted. These conditions are:
	// 1. system channel must be at START;
	// 2. all standard channels must be at ABORT.
	ConsensusMigrationAbort() error
}

Controller defines methods for controlling and coordinating the process of consensus-type migration. It is implemented by the multichannel.Registrar and is used by the system and standard chains.

type Manager

type Manager interface {
	Status

	// Step evaluates whether a config update is allowed to be committed. It is called when a config transaction is
	// consumed from Kafka, i.e. after ordering. It returns whether the block that contains said transaction should be
	// committed to the ledger or dropped (commitConfigTx), and whether the bootstrap file (a.k.a. genesis block)
	// should be replaced (replaceBootstrapFile). Step may change the status of the underlying chain, and in case of
	// the system chain, it may also change the status of standard chains, via its interaction with the
	// migrationController (Registrar).
	Step(
		chainID string,
		nextConsensusType string,
		nextMigState orderer.ConsensusType_MigrationState,
		nextMigContext uint64,
		lastCutBlockNumber uint64,
		migrationController Controller,
	) (commitConfigTx bool, replaceBootstrapFile bool)

	// CheckAllowed evaluates whether a config update is allowed to be enqueued for ordering by checking against the chain's
	// status and migrationController. It is called during the broadcast phase and never changes the status of the
	// underlying chain.
	CheckAllowed(next *ConsensusTypeInfo, migrationController Controller) error

	// Validate checks the validity of the state transitions of a possible migration config update tx by comparing the
	// current ConsensusTypeInfo config with the next (proposed) ConsensusTypeInfo. It is called during the broadcast
	// phase and never changes the status of the underlying chain.
	Validate(current, next *ConsensusTypeInfo) error
}

Manager is in charge of exposing the Status of the migration, providing methods for validating and filtering incoming config updates (before ordering), and allowing the underlying chain to execute the migration state machine in response to ordered config updates and signals from the migration controller.

func NewManager

func NewManager(sysChan bool, chainID string) Manager

NewManager generates a new Manager implementation.

type Status

type Status interface {
	fmt.Stringer

	// StateContext returns the consensus-type migration state and context of the underlying chain.
	StateContext() (state orderer.ConsensusType_MigrationState, context uint64)

	// SetStateContext sets the consensus-type migration state and context of the underlying chain.
	SetStateContext(state orderer.ConsensusType_MigrationState, context uint64)

	// IsPending returns true if consensus-type migration is pending on the underlying chain.
	// The definition of "pending" differs between the system and standard channels.
	// Returns true when: START on system channel, START or CONTEXT on standard channel.
	IsPending() bool

	// IsCommitted returns true if consensus-type migration is committed on the underlying chain.
	// The definition of "committed" differs between the system and standard channels.
	// Returns true when: COMMIT on system channel; always false on standard channel.
	IsCommitted() bool

	// IsStartedOrCommitted returns true if consensus-type migration is started or committed on the underlying chain.
	IsStartedOrCommitted() bool
}

Status provides access to the consensus-type migration status of the underlying chain. The implementation of this interface knows whether the chain is a system or standard channel.

Jump to

Keyboard shortcuts

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