interfaces

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2019 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractConfirmationsFromViewChangeMessages

func ExtractConfirmationsFromViewChangeMessages(vcms []*ViewChangeMessage) []*protocol.ViewChangeMessageContentBuilder

Types

type Block

type Block interface {
	Height() primitives.BlockHeight
}
var GenesisBlock Block = nil

type BlockUtils

type BlockUtils interface {
	RequestNewBlockProposal(ctx context.Context, blockHeight primitives.BlockHeight, memberId primitives.MemberId, prevBlock Block) (Block, primitives.BlockHash)
	ValidateBlockProposal(ctx context.Context, blockHeight primitives.BlockHeight, memberId primitives.MemberId, block Block, blockHash primitives.BlockHash, prevBlock Block) error
	ValidateBlockCommitment(blockHeight primitives.BlockHeight, block Block, blockHash primitives.BlockHash) bool
}

type CommitMessage

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

--------- Commit ---------

func NewCommitMessage

func NewCommitMessage(content *protocol.CommitContent) *CommitMessage

func (*CommitMessage) BlockHeight

func (cm *CommitMessage) BlockHeight() primitives.BlockHeight

func (*CommitMessage) Content

func (cm *CommitMessage) Content() *protocol.CommitContent

func (*CommitMessage) InstanceId

func (cm *CommitMessage) InstanceId() primitives.InstanceId

func (*CommitMessage) MessageType

func (cm *CommitMessage) MessageType() protocol.MessageType

func (*CommitMessage) Raw

func (cm *CommitMessage) Raw() []byte

func (*CommitMessage) SenderMemberId

func (cm *CommitMessage) SenderMemberId() primitives.MemberId

func (*CommitMessage) String

func (cm *CommitMessage) String() string

func (*CommitMessage) ToConsensusRawMessage

func (cm *CommitMessage) ToConsensusRawMessage() *ConsensusRawMessage

func (*CommitMessage) View

func (cm *CommitMessage) View() primitives.View

type Communication

type Communication interface {
	SendConsensusMessage(ctx context.Context, recipients []primitives.MemberId, message *ConsensusRawMessage) error
}

type Config

type Config struct {
	InstanceId              primitives.InstanceId
	Communication           Communication
	Membership              Membership
	BlockUtils              BlockUtils
	KeyManager              KeyManager
	ElectionTimeoutOnV0     time.Duration
	OnElectionCB            OnElectionCallback
	Storage                 Storage // optional
	Logger                  Logger  // optional
	MsgChanBufLen           uint64
	UpdateStateChanBufLen   uint64
	ElectionChanBufLen      uint64
	OverrideElectionTrigger ElectionScheduler
}

type ConsensusMessage

type ConsensusMessage interface {
	Serializable
	ConsensusRawMessageConverter
	InstanceId() primitives.InstanceId
	MessageType() protocol.MessageType
	SenderMemberId() primitives.MemberId
	BlockHeight() primitives.BlockHeight
	View() primitives.View
}

func ToConsensusMessage

func ToConsensusMessage(consensusMessage *ConsensusRawMessage) ConsensusMessage

type ConsensusRawMessage

type ConsensusRawMessage struct {
	Content []byte
	Block   Block
}

func CreateConsensusRawMessage

func CreateConsensusRawMessage(message ConsensusMessage) *ConsensusRawMessage

type ConsensusRawMessageConverter

type ConsensusRawMessageConverter interface {
	ToConsensusRawMessage() *ConsensusRawMessage
}

type ElectionScheduler added in v0.2.0

type ElectionScheduler interface {
	RegisterOnElection(blockHeight primitives.BlockHeight, view primitives.View, cb func(ctx context.Context, blockHeight primitives.BlockHeight, view primitives.View, onElectionCB OnElectionCallback))
	ElectionChannel() chan *ElectionTrigger
	CalcTimeout(view primitives.View) time.Duration
	Stop()
}

type ElectionTrigger

type ElectionTrigger struct {
	MoveToNextLeader func(ctx context.Context)
	Hv               *state.HeightView
}

type KeyManager

type KeyManager interface {
	SignConsensusMessage(ctx context.Context, blockHeight primitives.BlockHeight, content []byte) primitives.Signature
	VerifyConsensusMessage(blockHeight primitives.BlockHeight, content []byte, sender *protocol.SenderSignature) error
	SignRandomSeed(ctx context.Context, blockHeight primitives.BlockHeight, content []byte) primitives.RandomSeedSignature
	VerifyRandomSeed(blockHeight primitives.BlockHeight, content []byte, sender *protocol.SenderSignature) error
	AggregateRandomSeed(blockHeight primitives.BlockHeight, randomSeedShares []*protocol.SenderSignature) primitives.RandomSeedSignature
}

type Logger

type Logger interface {
	Debug(format string, args ...interface{})
	Info(format string, args ...interface{})
	Error(format string, args ...interface{})
}

type Membership

type Membership interface {
	MyMemberId() primitives.MemberId
	RequestOrderedCommittee(ctx context.Context, blockHeight primitives.BlockHeight, randomSeed uint64) ([]primitives.MemberId, error)
}

type NewViewMessage

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

---------- New View ----------

func NewNewViewMessage

func NewNewViewMessage(content *protocol.NewViewMessageContent, block Block) *NewViewMessage

func (*NewViewMessage) Block

func (nvm *NewViewMessage) Block() Block

func (*NewViewMessage) BlockHeight

func (nvm *NewViewMessage) BlockHeight() primitives.BlockHeight

func (*NewViewMessage) Content

func (*NewViewMessage) InstanceId

func (nvm *NewViewMessage) InstanceId() primitives.InstanceId

func (*NewViewMessage) MessageType

func (nvm *NewViewMessage) MessageType() protocol.MessageType

func (*NewViewMessage) Raw

func (nvm *NewViewMessage) Raw() []byte

func (*NewViewMessage) SenderMemberId

func (nvm *NewViewMessage) SenderMemberId() primitives.MemberId

func (*NewViewMessage) String

func (nvm *NewViewMessage) String() string

func (*NewViewMessage) ToConsensusRawMessage

func (nvm *NewViewMessage) ToConsensusRawMessage() *ConsensusRawMessage

func (*NewViewMessage) View

func (nvm *NewViewMessage) View() primitives.View

type OnCommitCallback

type OnCommitCallback func(ctx context.Context, block Block, blockProof []byte)

type OnElectionCallback added in v0.2.0

type OnElectionCallback func(m metrics.ElectionMetrics)

type OnNewConsensusRoundCallback added in v0.2.0

type OnNewConsensusRoundCallback func(ctx context.Context, newHeight primitives.BlockHeight, prevBlock Block, canBeFirstLeader bool)

type OnUpdateStateCallback added in v0.2.0

type OnUpdateStateCallback func(ctx context.Context, currentHeight primitives.BlockHeight, receivedBlockHeight primitives.BlockHeight)

type PrepareMessage

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

--------- Prepare ---------

func NewPrepareMessage

func NewPrepareMessage(content *protocol.PrepareContent) *PrepareMessage

func (*PrepareMessage) BlockHeight

func (pm *PrepareMessage) BlockHeight() primitives.BlockHeight

func (*PrepareMessage) Content

func (pm *PrepareMessage) Content() *protocol.PrepareContent

func (*PrepareMessage) InstanceId

func (pm *PrepareMessage) InstanceId() primitives.InstanceId

func (*PrepareMessage) MessageType

func (pm *PrepareMessage) MessageType() protocol.MessageType

func (*PrepareMessage) Raw

func (pm *PrepareMessage) Raw() []byte

func (*PrepareMessage) SenderMemberId

func (pm *PrepareMessage) SenderMemberId() primitives.MemberId

func (*PrepareMessage) String

func (pm *PrepareMessage) String() string

func (*PrepareMessage) ToConsensusRawMessage

func (pm *PrepareMessage) ToConsensusRawMessage() *ConsensusRawMessage

func (*PrepareMessage) View

func (pm *PrepareMessage) View() primitives.View

type PreprepareMessage

type PreprepareMessage struct {
	ConsensusMessage
	// contains filtered or unexported fields
}

func NewPreprepareMessage

func NewPreprepareMessage(content *protocol.PreprepareContent, block Block) *PreprepareMessage

func (*PreprepareMessage) Block

func (ppm *PreprepareMessage) Block() Block

func (*PreprepareMessage) BlockHeight

func (ppm *PreprepareMessage) BlockHeight() primitives.BlockHeight

func (*PreprepareMessage) Content

func (*PreprepareMessage) InstanceId

func (ppm *PreprepareMessage) InstanceId() primitives.InstanceId

func (*PreprepareMessage) MessageType

func (ppm *PreprepareMessage) MessageType() protocol.MessageType

func (*PreprepareMessage) Raw

func (ppm *PreprepareMessage) Raw() []byte

func (*PreprepareMessage) SenderMemberId

func (ppm *PreprepareMessage) SenderMemberId() primitives.MemberId

func (*PreprepareMessage) String

func (ppm *PreprepareMessage) String() string

func (*PreprepareMessage) ToConsensusRawMessage

func (ppm *PreprepareMessage) ToConsensusRawMessage() *ConsensusRawMessage

func (*PreprepareMessage) View

func (ppm *PreprepareMessage) View() primitives.View

type Serializable

type Serializable interface {
	String() string
	Raw() []byte
}

SHARED interfaces //

type Storage

type Storage interface {
	StorePreprepare(ppm *PreprepareMessage) bool
	GetPreprepareMessage(blockHeight primitives.BlockHeight, view primitives.View) (*PreprepareMessage, bool)
	GetPreprepareBlock(blockHeight primitives.BlockHeight, view primitives.View) (Block, bool)
	GetLatestPreprepare(blockHeight primitives.BlockHeight) (*PreprepareMessage, bool)
	GetPreprepareFromView(blockHeight primitives.BlockHeight, view primitives.View) (*PreprepareMessage, bool)

	StorePrepare(pp *PrepareMessage) bool
	GetPrepareMessages(blockHeight primitives.BlockHeight, view primitives.View, blockHash primitives.BlockHash) ([]*PrepareMessage, bool)
	GetPrepareSendersIds(blockHeight primitives.BlockHeight, view primitives.View, blockHash primitives.BlockHash) []primitives.MemberId

	StoreCommit(cm *CommitMessage) bool
	GetCommitMessages(blockHeight primitives.BlockHeight, view primitives.View, blockHash primitives.BlockHash) ([]*CommitMessage, bool)

	StoreViewChange(vcm *ViewChangeMessage) bool
	GetViewChangeMessages(blockHeight primitives.BlockHeight, view primitives.View) ([]*ViewChangeMessage, bool)

	ClearBlockHeightLogs(blockHeight primitives.BlockHeight)
}

type ViewChangeMessage

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

------------- View Change -------------

func NewViewChangeMessage

func NewViewChangeMessage(content *protocol.ViewChangeMessageContent, block Block) *ViewChangeMessage

func (*ViewChangeMessage) Block

func (vcm *ViewChangeMessage) Block() Block

func (*ViewChangeMessage) BlockHeight

func (vcm *ViewChangeMessage) BlockHeight() primitives.BlockHeight

func (*ViewChangeMessage) Content

func (*ViewChangeMessage) InstanceId

func (vcm *ViewChangeMessage) InstanceId() primitives.InstanceId

func (*ViewChangeMessage) MessageType

func (vcm *ViewChangeMessage) MessageType() protocol.MessageType

func (*ViewChangeMessage) Raw

func (vcm *ViewChangeMessage) Raw() []byte

func (*ViewChangeMessage) SenderMemberId

func (vcm *ViewChangeMessage) SenderMemberId() primitives.MemberId

func (*ViewChangeMessage) String

func (vcm *ViewChangeMessage) String() string

func (*ViewChangeMessage) ToConsensusRawMessage

func (vcm *ViewChangeMessage) ToConsensusRawMessage() *ConsensusRawMessage

func (*ViewChangeMessage) View

func (vcm *ViewChangeMessage) View() primitives.View

Jump to

Keyboard shortcuts

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