Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

    Cache helps prevent unnecessary IAVLTree updates and garbage generation.

    func NewCache

    func NewCache(backend Reader) *Cache

      Returns a Cache, can write to an output Writer via Sync. Not goroutine safe, use syncStateCache if you need concurrent access

      func (*Cache) Backend

      func (cache *Cache) Backend() Reader

      func (*Cache) GetProposal

      func (cache *Cache) GetProposal(proposalHash []byte) (*payload.Ballot, error)

      func (*Cache) RemoveProposal

      func (cache *Cache) RemoveProposal(proposalHash []byte) error

      func (*Cache) Reset

      func (cache *Cache) Reset(backend Reader)

        Resets the cache to empty initialising the backing map to the same size as the previous iteration

        func (*Cache) Sync

        func (cache *Cache) Sync(state Writer) error

          Writes whatever is in the cache to the output Writer state. Does not flush the cache, to do that call Reset() after Sync or use Flush if your wish to use the output state as your next backend

          func (*Cache) UpdateProposal

          func (cache *Cache) UpdateProposal(proposalHash []byte, ballot *payload.Ballot) error

          type Iterable

          type Iterable interface {
          	IterateProposals(consumer func(proposalHash []byte, proposal *payload.Ballot) error) (err error)
          }

          type IterableReader

          type IterableReader interface {
          	Iterable
          	Reader
          }

          type IterableReaderWriter

          type IterableReaderWriter interface {
          	Iterable
          	ReaderWriter
          }

          type ProposalHash

          type ProposalHash [sha256.Size]byte

          type ProposalHashArray

          type ProposalHashArray []ProposalHash

          func (ProposalHashArray) Len

          func (p ProposalHashArray) Len() int

          func (ProposalHashArray) Less

          func (p ProposalHashArray) Less(i, j int) bool

          func (ProposalHashArray) Swap

          func (p ProposalHashArray) Swap(i, j int)

          type Reader

          type Reader interface {
          	GetProposal(proposalHash []byte) (*payload.Ballot, error)
          }

          type ReaderWriter

          type ReaderWriter interface {
          	Reader
          	Writer
          }

          type Writer

          type Writer interface {
          	// Updates the proposal, creating it if it does not exist
          	UpdateProposal(proposalHash []byte, proposal *payload.Ballot) error
          	// Remove the proposal by hash
          	RemoveProposal(proposalHash []byte) error
          }