wal

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Overview

Package wal implements the similar write-ahead logging for cbft consensus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WALDecode

func WALDecode(pack []byte, msgType uint16) (interface{}, error)

func WalDir added in v1.0.0

func WalDir(ctx *node.ServiceContext) string

Types

type IWALDatabase

type IWALDatabase interface {
	Put(key []byte, value []byte, wo *opt.WriteOptions) error
	Delete(key []byte) error
	Get(key []byte) ([]byte, error)
	Has(key []byte) (bool, error)
	NewIterator(key []byte, wo *opt.ReadOptions) iterator.Iterator
	Close()
}

type Message

type Message struct {
	Timestamp uint64
	Data      interface{}
}

Message is a combination of consensus msg.

type MessageConfirmedViewChange

type MessageConfirmedViewChange struct {
	Timestamp uint64
	Data      *protocols.ConfirmedViewChange
}

struct ConfirmedViewChange for rlp decode

type MessageSendPrepareBlock

type MessageSendPrepareBlock struct {
	Timestamp uint64
	Data      *protocols.SendPrepareBlock
}

struct SendPrepareBlock for rlp decode

type MessageSendPrepareVote

type MessageSendPrepareVote struct {
	Timestamp uint64
	Data      *protocols.SendPrepareVote
}

struct SendPrepareVote for rlp decode

type MessageSendViewChange

type MessageSendViewChange struct {
	Timestamp uint64
	Data      *protocols.SendViewChange
}

struct SendViewChange for rlp decode

type ViewChangeMessage

type ViewChangeMessage struct {
	Epoch      uint64
	ViewNumber uint64
	FileID     uint32
	Seq        uint64
}

type WALDatabase

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

func (*WALDatabase) Close

func (db *WALDatabase) Close()

func (*WALDatabase) Delete

func (db *WALDatabase) Delete(key []byte) error

Delete deletes the key from the queue and database

func (*WALDatabase) Get

func (db *WALDatabase) Get(key []byte) ([]byte, error)

Get returns the given key if it's present.

func (*WALDatabase) Has

func (db *WALDatabase) Has(key []byte) (bool, error)

func (*WALDatabase) NewIterator

func (db *WALDatabase) NewIterator(key []byte, wo *opt.ReadOptions) iterator.Iterator

func (*WALDatabase) Put

func (db *WALDatabase) Put(key []byte, value []byte, wo *opt.WriteOptions) error

Put puts the given key / value to the queue

type Wal

type Wal interface {
	UpdateChainState(chainState *protocols.ChainState) error
	LoadChainState(fn recoveryChainStateFn) error
	Write(msg interface{}) error
	WriteSync(msg interface{}) error
	UpdateViewChange(info *ViewChangeMessage) error
	UpdateViewChangeQC(epoch uint64, viewNumber uint64, viewChangeQC *ctypes.ViewChangeQC) error
	GetViewChangeQC(epoch uint64, viewNumber uint64) (*ctypes.ViewChangeQC, error)
	Load(fn recoveryConsensusMsgFn) error
	Close()
	SetMockJournalLimitSize(limit uint64)
}

Wal encapsulates functions required to update and load consensus state.

func NewWal

func NewWal(ctx *node.ServiceContext, specifiedPath string) (Wal, error)

NewWal creates a new wal to update and load consensus state.

type WriterWrapper

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

WriterWrapper wrap the write file. it contains the actual file handle and memory bufio

func NewWriterWrapper

func NewWriterWrapper(file *os.File, bufferLimitSize int) *WriterWrapper

NewWriterWrapper creates a new buffer writer to write data to file.

func (*WriterWrapper) Close

func (w *WriterWrapper) Close() (err error)

Close tries to actual file handle.

func (*WriterWrapper) Flush

func (w *WriterWrapper) Flush() (err error)

Flush tries to flush the data from memory bufio to actual file.

func (*WriterWrapper) FlushAndClose

func (w *WriterWrapper) FlushAndClose() (err error)

FlushAndClose successive invoke function Flush and Close

func (*WriterWrapper) Write

func (w *WriterWrapper) Write(p []byte) (n int, err error)

Write tries to record data to memory bufio.

Jump to

Keyboard shortcuts

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