filesystem

package
v0.0.0-...-c17a846 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2017 License: ISC Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 btclog.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 btclog.

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 (*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) 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.

Jump to

Keyboard shortcuts

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