cache

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: Apache-2.0 Imports: 14 Imported by: 25

Documentation

Overview

Package cache provides subtree caching functionality.

Package cache is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PopulateLogTile added in v1.4.0

func PopulateLogTile(st *storagepb.SubtreeProto, hasher hashers.LogHasher) error

PopulateLogTile re-creates a log tile's InternalNodes from the Leaves map.

This uses the compact Merkle tree to repopulate internal nodes, and so will handle imperfect (but left-hand dense) subtrees. Note that we only rebuild internal nodes when the subtree is fully populated. For an explanation of why see the comments below for prepareLogTile.

TODO(pavelkalinnikov): Unexport it after the refactoring.

Types

type GetSubtreesFunc

type GetSubtreesFunc func(ids [][]byte) ([]*storagepb.SubtreeProto, error)

GetSubtreesFunc describes a function which can return a number of Subtrees from storage.

type MockNodeStorage

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

MockNodeStorage is a mock of NodeStorage interface.

func NewMockNodeStorage

func NewMockNodeStorage(ctrl *gomock.Controller) *MockNodeStorage

NewMockNodeStorage creates a new mock instance.

func (*MockNodeStorage) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockNodeStorage) GetSubtree

func (m *MockNodeStorage) GetSubtree(arg0 []byte) (*storagepb.SubtreeProto, error)

GetSubtree mocks base method.

type MockNodeStorageMockRecorder

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

MockNodeStorageMockRecorder is the mock recorder for MockNodeStorage.

func (*MockNodeStorageMockRecorder) GetSubtree

func (mr *MockNodeStorageMockRecorder) GetSubtree(arg0 interface{}) *gomock.Call

GetSubtree indicates an expected call of GetSubtree.

type NodeStorage

type NodeStorage interface {
	GetSubtree(prefix []byte) (*storagepb.SubtreeProto, error)
}

NodeStorage provides an interface for storing and retrieving subtrees.

type SubtreeCache

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

SubtreeCache provides a caching access to Subtree storage. Currently there are assumptions in the code that all subtrees are multiple of 8 in depth and that log subtrees are always of depth 8. It is not possible to just change the constants above and have things still work. This is because of issues like byte packing of node IDs.

SubtreeCache is not thread-safe: GetNodes, SetNodes and Flush methods must be called sequentially.

func NewLogSubtreeCache

func NewLogSubtreeCache(hasher hashers.LogHasher) *SubtreeCache

NewLogSubtreeCache creates and returns a SubtreeCache appropriate for use with a log tree. The caller must supply a suitable LogHasher.

func (*SubtreeCache) GetNodes

func (s *SubtreeCache) GetNodes(ids []compact.NodeID, getSubtrees GetSubtreesFunc) ([]tree.Node, error)

GetNodes returns the requested nodes, calling the getSubtrees function if they are not already cached.

func (*SubtreeCache) SetNodes added in v1.4.0

func (s *SubtreeCache) SetNodes(nodes []tree.Node, getSubtrees GetSubtreesFunc) error

SetNodes sets hashes for the given nodes in the cache.

func (*SubtreeCache) UpdatedTiles added in v1.4.0

func (s *SubtreeCache) UpdatedTiles() ([]*storagepb.SubtreeProto, error)

UpdatedTiles returns all updated tiles that need to be written to storage.

Jump to

Keyboard shortcuts

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