wal

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const EntryTypeWalEntry = int8(1)

EntryTypeWalEntry is the entry type in lws

Variables

View Source
var ErrWrongFormattingData = fmt.Errorf("wrong formatting data")

ErrWrongFormattingData is an error about wrong formatting data

Functions

This section is empty.

Types

type LwsWalAdaptor

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

LwsWalAdaptor is an implementation of interface WalAdaptor

func (*LwsWalAdaptor) AddNewView

func (l *LwsWalAdaptor) AddNewView() error

AddNewView add new view information to wal

func (*LwsWalAdaptor) AddProposalWalIndex

func (l *LwsWalAdaptor) AddProposalWalIndex(proposalHeight, index uint64)

AddProposalWalIndex add proposal wal index to wal

func (*LwsWalAdaptor) Close

func (l *LwsWalAdaptor) Close()

Close the wal

func (*LwsWalAdaptor) GetHeightStatus

func (l *LwsWalAdaptor) GetHeightStatus() map[uint64]uint64

GetHeightStatus return current height status of the wal

func (*LwsWalAdaptor) ReplayWal

func (l *LwsWalAdaptor) ReplayWal() (bool, error)

ReplayWal replay wal file after the node was restarted

func (*LwsWalAdaptor) SaveWalEntry

func (l *LwsWalAdaptor) SaveWalEntry(msgType maxbftpb.MessageType, msg []byte) (uint64, error)

SaveWalEntry save an entry to the wal

func (*LwsWalAdaptor) SwitchState

func (l *LwsWalAdaptor) SwitchState(contract *maxbftpb.GovernanceContract)

SwitchState set the state of the new epoch

func (*LwsWalAdaptor) UpdateWalIndexAndTrunc

func (l *LwsWalAdaptor) UpdateWalIndexAndTrunc(committedHeight uint64)

UpdateWalIndexAndTrunc update wal index and truncate the wal file

type WalAdaptor

type WalAdaptor interface {
	// save consensus messages that validated to log wal system
	SaveWalEntry(msgType maxbft.MessageType, msg []byte) (uint64, error)

	// load consensus messages from wal system and replay them
	ReplayWal() (hasWalEntry bool, err error)

	// delete related information after committed blocks and update lastCommitWalIndex
	UpdateWalIndexAndTrunc(committedHeight uint64)

	// record wal index when receiving proposal
	AddProposalWalIndex(proposalHeight, index uint64)

	// return height status
	GetHeightStatus() map[uint64]uint64

	// set the state of the new epoch
	SwitchState(contract *maxbftpb.GovernanceContract)

	// save new view information to wal
	AddNewView() error

	// close the wal
	Close()
}

WalAdaptor defines an adapter for wal components

func NewLwsWalAdaptor

func NewLwsWalAdaptor(path string, epochId uint64,
	forester forest.Forester, maker pacemaker.PaceMaker,
	collector vote.VotesCollector, verifier protocol.BlockVerifier,
	log protocol.Logger) (WalAdaptor, error)

NewLwsWalAdaptor initial a wal object

type WalEntryCoder

type WalEntryCoder struct {
}

WalEntryCoder used to encode and decode data in lws

func (*WalEntryCoder) Decode

func (c *WalEntryCoder) Decode(data []byte) (interface{}, error)

Decode deserialize []byte to wal entry

func (*WalEntryCoder) Encode

func (c *WalEntryCoder) Encode(s interface{}) ([]byte, error)

Encode serialize wal entry to []byte

func (*WalEntryCoder) Type

func (c *WalEntryCoder) Type() int8

Type return entry type wal entry

Jump to

Keyboard shortcuts

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