consensus

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodePatch

func DecodePatch(t string, bs []byte) (module.Patch, error)

func IsCorruptedWAL

func IsCorruptedWAL(err error) bool

func IsEOF

func IsEOF(err error) bool

func IsNotExist

func IsNotExist(err error) bool

func IsUnexpectedEOF

func IsUnexpectedEOF(err error) bool

func NewCommitVoteSetFromBytes

func NewCommitVoteSetFromBytes(bs []byte) module.CommitVoteSet

NewCommitVoteSetFromBytes returns VoteList from serialized bytes

func NewConsensus

func NewConsensus(c module.Chain, walDir string, timestamper module.Timestamper) module.Consensus

func ResetWAL added in v0.9.4

func ResetWAL(height int64, dir string) error

Types

type Engine

type Engine interface {
	GetCommitBlockParts(h int64) PartSet
	GetCommitPrecommits(h int64) *voteList
	GetPrecommits(r int32) *voteList
	GetVotes(r int32, prevotesMask *bitArray, precommitsMask *bitArray) *voteList
	GetRoundState() *peerRoundState

	Height() int64
	Round() int32
	Step() step

	ReceiveBlockPartMessage(msg *blockPartMessage, unicast bool) (int, error)
	ReceiveVoteListMessage(msg *voteListMessage, unicast bool) error
	ReceiveBlock(br fastsync.BlockResult)
}

type Part

type Part interface {
	Index() int
	Bytes() []byte
}

type PartSet

type PartSet interface {
	ID() *PartSetID
	Parts() int
	GetPart(int) Part
	IsComplete() bool
	NewReader() io.Reader
	AddPart(Part) error
	GetMask() *bitArray
}

type PartSetBuffer

type PartSetBuffer interface {
	io.Writer
	PartSet() PartSet
}

type PartSetID

type PartSetID struct {
	Count uint16
	Hash  []byte
}

func (*PartSetID) Equal

func (id *PartSetID) Equal(id2 *PartSetID) bool

func (PartSetID) String

func (id PartSetID) String() string

type Syncer

type Syncer interface {
	Start() error
	Stop()
	OnEngineStepChange()
}

type VoteItem

type VoteItem struct {
	PrototypeIndex int16
	Timestamp      int64
	Signature      common.Signature
}

type WALConfig

type WALConfig struct {
	FileLimit            int64
	TotalLimit           int64
	HousekeepingInterval time.Duration
	SyncInterval         time.Duration
}

type WALManager

type WALManager interface {
	OpenForRead(id string) (WALReader, error)
	OpenForWrite(id string, cfg *WALConfig) (WALWriter, error)
}

type WALReader

type WALReader interface {
	Read(v interface{}) (left []byte, err error)
	ReadBytes() ([]byte, error)
	// multiple Close is safe
	Close() error
	// CloseAndRepair closes and repairs UnexpectedEOF or CorruptedWAL by
	// truncating.
	CloseAndRepair() error
}

func OpenWALForRead

func OpenWALForRead(id string) (WALReader, error)

type WALWriter

type WALWriter interface {
	Write(v interface{}) error
	WriteBytes([]byte) (int, error)
	Sync() error
	Shift() error
	Close() error
}

func OpenWALForWrite

func OpenWALForWrite(id string, cfg *WALConfig) (WALWriter, error)

id is in the form /wal/dir/prefix

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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