migration

package
v0.0.0-...-193ac73 Latest Latest
Warning

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

Go to latest
Published: May 7, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 pending 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 height of the system channel config block that carries said config update.
	ConsensusMigrationStart(context uint64) (err 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 mast be at START with context >0;
	// 2. all standard channels must be at START with the same context as the system channel.
	ConsensusMigrationCommit() (err error)

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

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

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
}

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.

type StatusImpl

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

StatusImpl is an implementation of the StatusStepper interface, which provides access to the consensus-type migration status of the underlying chain. The methods that accept objects of this type are thread-safe.

func (*StatusImpl) IsCommitted

func (ms *StatusImpl) IsCommitted() bool

IsCommitted returns true if migration is committed.

func (*StatusImpl) IsPending

func (ms *StatusImpl) IsPending() bool

IsPending returns true if migration is pending.

func (*StatusImpl) SetStateContext

func (ms *StatusImpl) SetStateContext(state orderer.ConsensusType_MigrationState, context uint64)

SetStateContext sets the consensus-type migration state and context.

func (*StatusImpl) StateContext

func (ms *StatusImpl) StateContext() (state orderer.ConsensusType_MigrationState, context uint64)

StateContext returns the consensus-type migration state and context.

func (*StatusImpl) Step

func (ms *StatusImpl) Step(
	chainID string,
	nextConsensusType string,
	nextMigState orderer.ConsensusType_MigrationState,
	nextMigContext uint64,
	lastCutBlockNumber uint64,
	migrationController Controller,
) (commitBlock bool, commitMigration bool)

Step evaluates the migration state machine of a particular chain. It returns whether the block should be committed to the ledger or dropped (commitBlock), and whether the bootstrap file (a.k.a. genesis block) should be replaced (commitMigration).

When we get a message, we check whether it is a permitted transition of the state machine, and whether the parameters are correct. If it is a valid transition, we return commitBlock=true, which will cause the caller to commit the block to the ledger.

When we get a message that is a COMMIT, which is the final step of migration (this can only happen on the system channel), we also return commitMigration=true, which will cause the caller to replace the bootstrap file (genesis block), as well as commit the block to the ledger.

Note: the method may call the multichannel.Registrar (migrationController). The Registrar takes a mutex, and then calls individual migration.Status objects (.i.e. the lock of the migration.Status mutex is nested within the lock of Registrar mutex). In order to avoid deadlocks, here we only call the Registrar (migrationController) when the internal mutex in NOT taken.

func (*StatusImpl) String

func (ms *StatusImpl) String() string

String returns a text representation.

type StatusStepper

type StatusStepper interface {
	Status
	Stepper
}

StatusStepper is a composition of the Status and Stepper interfaces.

func NewStatusStepper

func NewStatusStepper(sysChan bool, chainID string) StatusStepper

NewStatusStepper generates a new StatusStepper implementation.

type Stepper

type Stepper interface {
	// Step evaluates the migration state machine of a particular chain. It returns whether the block should be
	// committed to the ledger or dropped (commitBlock), and whether the bootstrap file (a.k.a. genesis block)
	// should be replaced (commitMigration).
	Step(
		chainID string,
		nextConsensusType string,
		nextMigState orderer.ConsensusType_MigrationState,
		nextMigContext uint64,
		lastCutBlockNumber uint64,
		migrationController Controller,
	) (commitBlock bool, commitMigration bool)
}

Stepper allows the underlying chain to execute the migration state machine.

Jump to

Keyboard shortcuts

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