journal

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: Apache-2.0, BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConsensusJournalNotFound = errors.New("ErrConsensusJournalNotFound")

Functions

This section is empty.

Types

type ConsensusJournal

type ConsensusJournal interface {
	// GetID just returns the ID of the current Consensus Journal.
	GetID() ID
	//
	// GetLogIndex returns the next non-decided log index for this journal.
	GetLogIndex() LogIndex
	//
	// Returns a persistence-supported version of the local view.
	GetLocalView() LocalView
	//
	// Notify, when a particular log index has been completed (decided).
	ConsensusReached(logIndex LogIndex)
	//
	// Upon reception of F+1 Log indexes higher that ours, we have to move
	// to the next log index That's to catch up with the chain, if a consensus
	// has failed in some way for us (e.g. maybe this node was down or restarted).
	//
	// It is safe here to count own message, because our own log index
	// will not be bigger that ours :)
	PeerLogIndexReceived(peerIndex uint16, peerLogIndex LogIndex) bool
}

ConsensusJournal tracks the consensus instances (the consensus log). Its main purpose is to record, which instances have already been done.

func LoadConsensusJournal

func LoadConsensusJournal(chainID isc.ChainID, committee iotago.Address, registry Registry, committeeN, committeeF int, log *logger.Logger) (ConsensusJournal, error)

type ID

ConsensusJournal instances are per ChainID ⨉ CommitteeAddress. This ID represents that.

func MakeID

func MakeID(chainID isc.ChainID, committeeAddress iotago.Address) (*ID, error)

type LocalView

type LocalView interface {
	//
	// Returns alias output to produce next transaction on, or nil if we should wait.
	// In the case of nil, we either wait for the first AO to receive, or we are
	// still recovering from a TX rejection.
	GetBaseAliasOutputID() *iotago.OutputID
	//
	// Corresponds to the `ao_received` event in the specification.
	AliasOutputReceived(confirmed *isc.AliasOutputWithID)
	//
	// Corresponds to the `tx_rejected` event in the specification.
	AliasOutputRejected(rejected *isc.AliasOutputWithID)
	//
	// Corresponds to the `tx_posted` event in the specification.
	AliasOutputPublished(consumed, published *isc.AliasOutputWithID)
	//
	// For serialization.
	AsBytes() ([]byte, error)
}

func NewLocalView

func NewLocalView() LocalView

func NewLocalViewFromBytes

func NewLocalViewFromBytes(data []byte) (LocalView, error)

type LogIndex

type LogIndex uint32

func (*LogIndex) AsStringKey

func (li *LogIndex) AsStringKey(id ID) string

For the Nonce Instance mostly. Can be removed after moving stuff to GPA.

func (*LogIndex) AsUint32

func (li *LogIndex) AsUint32() uint32

func (*LogIndex) AsUint64Key

func (li *LogIndex) AsUint64Key(id ID) uint64

For the ACS runner mostly. Can be removed after moving stuff to GPA.

type Registry

type Registry interface {
	LoadConsensusJournal(id ID) (LogIndex, LocalView, error) // Can return ErrConsensusJournalNotFound
	SaveConsensusJournalLogIndex(id ID, logIndex LogIndex) error
	SaveConsensusJournalLocalView(id ID, localView LocalView) error
}

RegistryProvider has to be provided for the ConsensusJournal and should implement the persistent store.

Jump to

Keyboard shortcuts

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