statetransfer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Listener

type Listener interface {
	Initiated()                                                   // Called when the state transfer thread starts a new state transfer
	Errored(uint64, []byte, []*protos.PeerID, interface{}, error) // Called when an error is encountered during state transfer, only the error is guaranteed to be set, other fields will be set on a best effort basis
	Completed(uint64, []byte, []*protos.PeerID, interface{})      // Called when the state transfer is completed
}

type ProtoListener

type ProtoListener struct {
	InitiatedImpl func()
	ErroredImpl   func(uint64, []byte, []*protos.PeerID, interface{}, error)
	CompletedImpl func(uint64, []byte, []*protos.PeerID, interface{})
}

This provides a simple base implementation of a state transfer listener which implementors can extend anonymously Unset fields result in no action for that event

func (*ProtoListener) Completed

func (pstl *ProtoListener) Completed(bn uint64, bh []byte, pids []*protos.PeerID, m interface{})

func (*ProtoListener) Errored

func (pstl *ProtoListener) Errored(bn uint64, bh []byte, pids []*protos.PeerID, m interface{}, e error)

func (*ProtoListener) Initiated

func (pstl *ProtoListener) Initiated()

type StateTransferState

type StateTransferState struct {
	RecoverDamage bool // Whether state transfer should ever modify or delete existing blocks if they are determined to be corrupted

	BlockRequestTimeout         time.Duration // How long to wait for a peer to respond to a block request
	StateDeltaRequestTimeout    time.Duration // How long to wait for a peer to respond to a state delta request
	StateSnapshotRequestTimeout time.Duration // How long to wait for a peer to respond to a state snapshot request
	// contains filtered or unexported fields
}

func NewStateTransferState

func NewStateTransferState(id *protos.PeerID, config *viper.Viper, ledger consensus.LedgerStack, defaultPeerIDs []*protos.PeerID) *StateTransferState

func ThreadlessNewStateTransferState

func ThreadlessNewStateTransferState(id *protos.PeerID, config *viper.Viper, ledger consensus.LedgerStack, defaultPeerIDs []*protos.PeerID) *StateTransferState

func (*StateTransferState) AddTarget

func (sts *StateTransferState) AddTarget(blockNumber uint64, blockHash []byte, peerIDs []*protos.PeerID, metadata interface{})

Informs the asynchronous sync of a new valid block hash, as well as a list of peers which should be capable of supplying that block If the peerIDs are nil, then all peers are assumed to have the given block

func (*StateTransferState) BlockingAddTarget

func (sts *StateTransferState) BlockingAddTarget(blockNumber uint64, blockHash []byte, peerIDs []*protos.PeerID) error

Adds a target and blocks until that target's success or failure If peerIDs is nil, all peers will be considered sync candidates The function returns nil on success or error If state sync completes, but to a different target, this is still considered an error

func (*StateTransferState) BlockingUntilSuccessAddTarget

func (sts *StateTransferState) BlockingUntilSuccessAddTarget(blockNumber uint64, blockHash []byte, peerIDs []*protos.PeerID)

func (*StateTransferState) CompletionChannel

func (sts *StateTransferState) CompletionChannel() chan struct{}

This is a simple convenience method, for listeners who wish only to be notified that the state transfer has completed, without any additional information For more sophisticated information, use the RegisterListener call. This channel never closes but receives a message every time transfer completes

func (*StateTransferState) InProgress

func (sts *StateTransferState) InProgress() bool

Whether state transfer is currently occuring. Note, this is not a thread safe call, it is expected that the caller synchronizes around state transfer if it is to be accessed in a non-serial fashion

func (*StateTransferState) Initiate

func (sts *StateTransferState) Initiate(peerIDs []*protos.PeerID)

Starts the state sync process, without blocking For the sync to complete, a call to AddTarget(hash, peerIDs) must be made If peerIDs is nil, all peer will be considered sync candidates

func (*StateTransferState) InvalidateState

func (sts *StateTransferState) InvalidateState()

Inform state transfer that the current state is invalid. This will trigger an immediate full state snapshot sync when state transfer is initiated

func (*StateTransferState) RegisterListener

func (sts *StateTransferState) RegisterListener(listener Listener)

The registered interface implementation will be invoked whenever state transfer is initiated or completed, or encounters an error

func (*StateTransferState) Stop

func (sts *StateTransferState) Stop()

This will send a signal to any running threads to stop, regardless of whether they are stopped It will never block, and if called before threads start, they will exit at startup Attempting to start threads after this call may fail once

func (*StateTransferState) UnregisterListener

func (sts *StateTransferState) UnregisterListener(listener Listener)

No longer receive state transfer updates sent to the given function. Listeners must be comparable in order to be unregistered

func (*StateTransferState) VerifyAndRecoverBlockchain

func (sts *StateTransferState) VerifyAndRecoverBlockchain() bool

This function should never be called directly, its public visibility is purely a side effect of the package scoping of go test

type StateTransferUpdate

type StateTransferUpdate int
const (
	Initiated StateTransferUpdate = iota
	Errored
	Completed
)

Jump to

Keyboard shortcuts

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