consensus

package
v1.0.58 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2019 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BroadcastMessenger

type BroadcastMessenger interface {
	BroadcastBlock(data.BodyHandler, data.HeaderHandler) error
	BroadcastHeader(data.HeaderHandler) error
	BroadcastShardHeader(data.HeaderHandler) error
	BroadcastMiniBlocks(map[uint32][]byte) error
	BroadcastTransactions(map[string][][]byte) error
	BroadcastConsensusMessage(*Message) error
	IsInterfaceNil() bool
}

BroadcastMessenger defines the behaviour of the broadcast messages by the consensus group

type ChronologyHandler

type ChronologyHandler interface {
	AddSubround(SubroundHandler)
	RemoveAllSubrounds()
	// StartRounds starts rounds in a sequential manner, one after the other
	StartRounds()
	IsInterfaceNil() bool
}

ChronologyHandler defines the actions which should be handled by a chronology implementation

type Message

type Message struct {
	BlockHeaderHash []byte
	SubRoundData    []byte
	PubKey          []byte
	Signature       []byte
	MsgType         int
	TimeStamp       uint64
	RoundIndex      int64
}

Message defines the data needed by spos to communicate between nodes over network in all subrounds

func NewConsensusMessage

func NewConsensusMessage(
	blHeaderHash []byte,
	subRoundData []byte,
	pubKey []byte,
	sig []byte,
	msg int,
	tms uint64,
	roundIndex int64,
) *Message

NewConsensusMessage creates a new Message object

type MessageType

type MessageType int

MessageType specifies what type of message was received

type P2PMessenger

type P2PMessenger interface {
	Broadcast(topic string, buff []byte)
	IsInterfaceNil() bool
}

P2PMessenger defines a subset of the p2p.Messenger interface

type Rounder

type Rounder interface {
	Index() int64
	// UpdateRound updates the index and the time stamp of the round depending of the genesis time and the current time given
	UpdateRound(time.Time, time.Time)
	TimeStamp() time.Time
	TimeDuration() time.Duration
	RemainingTime(startTime time.Time, maxTime time.Duration) time.Duration
	IsInterfaceNil() bool
}

Rounder defines the actions which should be handled by a round implementation

type SposFactory

type SposFactory interface {
	GenerateSubrounds()
	IsInterfaceNil() bool
}

SposFactory defines an interface for a consensus implementation

type SubroundHandler

type SubroundHandler interface {
	// DoWork implements of the subround's job
	DoWork(rounder Rounder) bool
	// Previous returns the ID of the previous subround
	Previous() int
	// Next returns the ID of the next subround
	Next() int
	// Current returns the ID of the current subround
	Current() int
	// StartTime returns the start time, in the rounder time, of the current subround
	StartTime() int64
	// EndTime returns the top limit time, in the rounder time, of the current subround
	EndTime() int64
	// Name returns the name of the current rounder
	Name() string
	// IsInterfaceNil returns true if there is no value under the interface
	IsInterfaceNil() bool
}

SubroundHandler defines the actions which should be handled by a subround implementation

Directories

Path Synopsis
bls
bn

Jump to

Keyboard shortcuts

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