inmemory

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

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

Driver implements Storer using an in-memory map.

func NewDriver

func NewDriver() *Driver

NewDriver creates a new in-memory storer.

func (*Driver) Ancestry

func (s *Driver) Ancestry(ctx context.Context, hash string) ([]*merkle.Node, error)

Ancestry returns the path from a node back to its root (node first, root last).

func (*Driver) Close

func (s *Driver) Close() error

Close is a no-op for the in-memory storer.

func (*Driver) Count

func (s *Driver) Count() int

Count returns the number of nodes in the in-memory store.

func (*Driver) Depth

func (s *Driver) Depth(ctx context.Context, hash string) (int, error)

Depth returns the depth of a node (0 for roots).

func (*Driver) Get

func (s *Driver) Get(_ context.Context, hash string) (*merkle.Node, error)

Get retrieves a node by its hash.

func (*Driver) GetByParent

func (s *Driver) GetByParent(_ context.Context, parentHash *string) ([]*merkle.Node, error)

GetByParent retrieves all nodes that have the provided parent. This is useful for determining where branching occurs.

func (*Driver) Has

func (s *Driver) Has(_ context.Context, hash string) (bool, error)

Has checks if a node exists by its hash.

func (*Driver) Leaves

func (s *Driver) Leaves(_ context.Context) ([]*merkle.Node, error)

Leaves returns all leaf nodes

func (*Driver) List

func (s *Driver) List(_ context.Context) ([]*merkle.Node, error)

List returns all nodes in the store.

func (*Driver) Migrate

func (s *Driver) Migrate(_ context.Context) error

Migrate is a no-op for the in-memory storer.

func (*Driver) Put

func (s *Driver) Put(_ context.Context, node *merkle.Node) (bool, error)

Put stores a node. Returns true if the node was newly inserted, false if it already existed (no-op due to content-addressing).

func (*Driver) Roots

func (s *Driver) Roots(ctx context.Context) ([]*merkle.Node, error)

Roots returns all root nodes

Jump to

Keyboard shortcuts

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