filesystem

package
v0.0.0-...-f028303 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: ISC Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilesystemActionVersion = 1 // All structure versions

	FilesystemActionHeader          = "header"
	FilesystemActionDeleteTimestamp = "deletetimestamp"
	FilesystemActionDeleteDigest    = "deletedigest"
	FilesystemActionDeleteDuplicate = "deleteduplicate"
)

Variables

This section is empty.

Functions

func DecodeFlushRecord

func DecodeFlushRecord(payload []byte) (*backend.FlushRecord, error)

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func EncodeFlushRecord

func EncodeFlushRecord(fr backend.FlushRecord) ([]byte, error)

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using slog.

Types

type FileSystem

type FileSystem struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

FileSystem is a naive implementation of a backend. It uses rounded timestamps as an index directory which then contains a leveldb with the content. There is also a global leveldb that provides a reverse index.

func New

func New(root, cert, host string, enableCollections bool, passphrase []byte) (*FileSystem, error)

New creates a new backend instance. The caller should issue a Close once the FileSystem backend is no longer needed.

func NewDump

func NewDump(root string) (*FileSystem, error)

func NewRestore

func NewRestore(root string) (*FileSystem, error)

func (*FileSystem) Close

func (fs *FileSystem) Close()

Close is a required interface function. In our case we close the global database.

Close satisfies the backend interface.

func (*FileSystem) Dump

func (fs *FileSystem) Dump(f *os.File, verbose bool) error

Dump walks all directories and dumps the content to either verbose readable or JSON format.

func (*FileSystem) Fsck

func (fs *FileSystem) Fsck(options *backend.FsckOptions) error

Fsck walks all directories and verifies all that there is no apparent data corruption and that the flush records indeed exist on the blockchain.

func (*FileSystem) Get

func (fs *FileSystem) Get(digests [][sha256.Size]byte) ([]backend.GetResult, error)

Get returns a GetResult for each provided digest.

Get satisfies the backend interface.

func (*FileSystem) GetTimestamps

func (fs *FileSystem) GetTimestamps(timestamps []int64) ([]backend.TimestampResult, error)

GetTimestamps is a required interface function. In our case it retrieves the digests for a given timestamp.

GetTimestamps satisfies the backend interface.

func (*FileSystem) Put

func (fs *FileSystem) Put(hashes [][sha256.Size]byte) (int64, []backend.PutResult, error)

Put is a required interface function. In our case it stores the provided hashes in a database that lives in a container directory. The container directory is the current time in UTC rounded down to the last hour.

Put satisfies the backend interface.

func (*FileSystem) Restore

func (fs *FileSystem) Restore(f *os.File, verbose bool, location string) error

Restore reads JSON encoded database contents and recreates the leveldb backend.

type FilesystemAction

type FilesystemAction struct {
	Version   uint64 `json:"version"`   // Version of structure
	Timestamp int64  `json:"timestamp"` // Timestamp of action
	Action    string `json:"action"`    // Following JSON command
}

type FilesystemDeleteDigest

type FilesystemDeleteDigest struct {
	Version         uint64 `json:"version"`         // Version of structure
	Timestamp       int64  `json:"timestamp"`       // Timestamp of digest
	GlobalTimestamp int64  `json:"globaltimestamp"` // Global timestamp of digest
	Digest          string `json:"digest"`          // Digest that was deleted
}

type FilesystemDeleteDuplicate

type FilesystemDeleteDuplicate struct {
	Version            uint64 `json:"version"`            // Version of structure
	Digest             string `json:"digest"`             // Duplicate digest
	Found              int64  `json:"found"`              // Original timestamp
	FoundDirectory     string `json:"founddirectory"`     // Original directory
	Duplicate          int64  `json:"duplicate"`          // Duplicate timestamp
	DuplicateDirectory string `json:"duplicatedirectory"` // Duplicate directory
}

type FilesystemDeleteTimestamp

type FilesystemDeleteTimestamp struct {
	Version   uint64 `json:"version"`   // Version of structure
	Timestamp int64  `json:"timestamp"` // Timestamp
	Directory string `json:"directory"` // Directory name of Timestamp
}

type FilesystemHeader

type FilesystemHeader struct {
	Version uint64 `json:"version"` // Version of structure
	Start   int64  `json:"start"`   // Start of fsck
	DryRun  bool   `json:"dryrun"`  // Dry run
}

Jump to

Keyboard shortcuts

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