Documentation ¶
Overview ¶
Package fs provides a simple filesystem log storage implementation.
Index ¶
- func ReadCheckpoint(rootDir string) ([]byte, error)
- type Storage
- func (fs *Storage) Assign(_ context.Context, seq uint64, leaf []byte) error
- func (fs *Storage) GetTile(_ context.Context, level, index, logSize uint64) (*api.Tile, error)
- func (fs *Storage) ScanSequenced(_ context.Context, begin uint64, f func(seq uint64, entry []byte) error) (uint64, error)
- func (fs *Storage) Sequence(ctx 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 files to store tree state. The on-disk structure is:
<rootDir>/leaves/aa/bb/cc/ddeeff... <rootDir>/leaves/pending/aabbccddeeff... <rootDir>/seq/aa/bb/cc/ddeeff... <rootDir>/tile/<level>/aa/bb/ccddee... <rootDir>/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 the filesystem at the provided location. cpSize should be the Size of the checkpoint produced from the last `log.Integrate` call.
func (*Storage) Assign ¶
Assign directly associates the given leaf data with the provided sequence number. It is an error to attempt to assign data to a previously assigned sequence number, even if the data is identical.
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) 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).