contextstore

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashOrigin

func HashOrigin(moduleID t.ModuleID, itemID ItemID) *eventpb.HashOrigin

HashOrigin returns a HashOrigin protobuf containing moduleID and contextstore.Origin(itemID).

func Origin

func Origin(itemID ItemID) *contextstorepb.Origin

Origin returns a contextstorepb.Origin protobuf containing the given id.

func SigVerOrigin

func SigVerOrigin(moduleID t.ModuleID, itemID ItemID) *eventpb.SigVerOrigin

SigVerOrigin returns a SigVerOrigin protobuf containing moduleID and contextstore.Origin(itemID).

func SignOrigin

func SignOrigin(moduleID t.ModuleID, itemID ItemID) *eventpb.SignOrigin

SignOrigin returns a SignOrigin protobuf containing moduleID and contextstore.Origin(itemID).

Types

type ContextStore

type ContextStore[T any] interface {
	// Store stores the given data in the ContextStore and returns a unique id.
	// The data can be later recovered or disposed of using this id.
	Store(t T) ItemID

	// Recover returns the data stored under the provided id.
	// Note that the data will continue to exist in the ContextStore.
	// In order to dispose of the data, call s.Dispose(id) or s.RecoverAndDispose(id).
	Recover(id ItemID) T

	// Dispose removes the data from the ContextStore.
	Dispose(id ItemID)

	// RecoverAndDispose returns the data stored under the provided id and removes it from the ContextStore.
	RecoverAndDispose(id ItemID) T
}

ContextStore can be used to store arbitrary data under an automatically deterministically generated unique id.

func NewSequentialContextStore

func NewSequentialContextStore[T any]() ContextStore[T]

NewSequentialContextStore creates an empty ContextStore that can only be accessed sequentially.

type ItemID

type ItemID uint64

ItemID is used to uniquely identify entries of the ContextStore.

func (ItemID) Pb

func (i ItemID) Pb() uint64

Pb returns the protobuf representation of ItemID.

Jump to

Keyboard shortcuts

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