Documentation ¶
Overview ¶
Package webstorage provides a simple log storage implementation based on webstorage. It only really makes sense for wasm targets in browsers where the sessionStorage WebStorage API is available. See https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API for more information about the browser WebStorage API.
Index ¶
- func ReadCheckpoint(root string) ([]byte, error)
- type Storage
- func (fs *Storage) DeletePending(f string) error
- func (fs *Storage) GetTile(_ context.Context, level, index, logSize uint64) (*api.Tile, error)
- func (fs *Storage) Pending(f string) ([]byte, error)
- func (fs *Storage) PendingKeys() ([]string, error)
- func (fs *Storage) Queue(leaf []byte) error
- func (fs *Storage) ScanSequenced(_ context.Context, begin uint64, f func(seq uint64, entry []byte) error) (uint64, error)
- func (fs *Storage) Sequence(_ context.Context, leafhash []byte, leaf []byte) (uint64, error)
- func (fs *Storage) StoreTile(_ context.Context, level, index uint64, tile *api.Tile) error
- func (fs Storage) WriteCheckpoint(_ context.Context, newCPRaw []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadCheckpoint ¶
ReadCheckpoint reads and returns the contents of the log checkpoint file.
Types ¶
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage is a serverless storage implementation which uses webstorage entries to store tree state. The storage key format is:
<root>/leaves/aa/bb/cc/ddeeff... <root>/leaves/pending/aabbccddeeff... <root>/seq/aa/bb/cc/ddeeff... <root>/tile/<level>/aa/bb/ccddee... <root>/checkpoint
The functions on this struct are not thread-safe.
func Create ¶
Create creates a new filesystem hierarchy and returns a Storage representation for it.
func Load ¶
Load returns a Storage instance initialised from webstorage prefixed at root. cpSize should be the Size of the checkpoint produced from the last `log.Integrate` call.
func (*Storage) DeletePending ¶
DeletePending removes a pending leaf stored under PendingKey.
func (*Storage) GetTile ¶
GetTile returns the tile at the given tile-level and tile-index. If no complete tile exists at that location, it will attempt to find a partial tile for the given tree size at that location.
func (*Storage) PendingKeys ¶
PendingKeys returns the storage keys associated with pending leaves.
func (*Storage) ScanSequenced ¶
func (fs *Storage) ScanSequenced(_ context.Context, begin uint64, f func(seq uint64, entry []byte) error) (uint64, error)
ScanSequenced calls the provided function once for each contiguous entry in storage starting at begin. The scan will abort if the function returns an error, otherwise it will return the number of sequenced entries.
func (*Storage) Sequence ¶
Sequence assigns the given leaf entry to the next available sequence number. This method will attempt to silently squash duplicate leaves, but it cannot be guaranteed that no duplicate entries will exist. Returns the sequence number assigned to this leaf (if the leaf has already been sequenced it will return the original sequence number and ErrDupeLeaf).