Documentation ¶
Index ¶
- Constants
- Variables
- type Checker
- type Deleter
- type DocumentDeleter
- type DocumentLD
- type DocumentLoader
- type DocumentSL
- type DocumentSLD
- type DocumentStorer
- type KeyValueChecker
- type Loader
- type Storer
- type StorerLoader
- type StorerLoaderDeleter
- type TestDocSLD
- func (f *TestDocSLD) Delete(key id.ID) error
- func (f *TestDocSLD) Iterate(done chan struct{}, callback func(key id.ID, value []byte)) error
- func (f *TestDocSLD) Load(key id.ID) (*api.Document, error)
- func (f *TestDocSLD) Mac(key id.ID, macKey []byte) ([]byte, error)
- func (f *TestDocSLD) Store(key id.ID, value *api.Document) error
- type TestSLD
Constants ¶
const ( // MaxKeyLength is the max key length (in Bytes) for an SL. MaxKeyLength = 32 // MaxValueLength is the max value length for an SL. MaxValueLength = 2 * 1024 * 1024 // 2 MB // EntriesKeyLength is the fixed length (in Bytes) of all entry keys. EntriesKeyLength = 32 // MaxEntriesValueLength is the maximum length of all entry values. We add a little buffer // on top of the value to account for Entry values other than the actual ciphertext (which // we want to be <= 2MB). MaxEntriesValueLength = 2*1024*1024 + 1024 )
Variables ¶
var ( // Server namespace contains values relevant to a server. Server = []byte("server") // Client namespace contains values relevant to a client. Client = []byte("client") // Documents namespace contains all libri p2p Stored values. Documents = []byte("documents") )
Functions ¶
This section is empty.
Types ¶
type Checker ¶
Checker checks that a key or value is value.
func NewEmptyChecker ¶
func NewEmptyChecker() Checker
NewEmptyChecker creates a new Checker instance that ensures values have non-zero length.
func NewExactLengthChecker ¶
NewExactLengthChecker creates a Checker instance that ensures that values are not empty and have a specified length.
func NewMaxLengthChecker ¶
NewMaxLengthChecker creates a new Checker that ensures that values are not empty and have length less <= max length.
type Deleter ¶
type Deleter interface { // Delete a value with the given key and namespace. Delete(key []byte) error }
Deleter deletes a value from durable storage.
type DocumentDeleter ¶
type DocumentDeleter interface { // Delete the api.Document value with the given key. Delete(key id.ID) error }
DocumentDeleter deletes api.Document values.
type DocumentLD ¶
type DocumentLD interface { DocumentLoader DocumentDeleter }
DocumentLD stores & loads api.Document values.
type DocumentLoader ¶
type DocumentLoader interface { // Load an api.Document value with the given key. Load(key id.ID) (*api.Document, error) // Mac an api.Document value with the given key and mac key. Mac(key id.ID, macKey []byte) ([]byte, error) }
DocumentLoader loads api.Document values.
type DocumentSL ¶
type DocumentSL interface { DocumentStorer DocumentLoader }
DocumentSL stores & loads api.Document values.
type DocumentSLD ¶
type DocumentSLD interface { DocumentSL DocumentDeleter }
DocumentSLD stores, loads, & deletes api.Document values.
func NewDocumentSLD ¶
func NewDocumentSLD(kvdb db.KVDB) DocumentSLD
NewDocumentSLD creates a new NamespaceSL for the "entries" namespace backed by a db.KVDB instance.
type DocumentStorer ¶
type DocumentStorer interface { // Store an api.Document value under the given key. Store(key id.ID, value *api.Document) error Iterate(done chan struct{}, callback func(key id.ID, value []byte)) error }
DocumentStorer stores api.Document values.
type KeyValueChecker ¶
type KeyValueChecker interface { // Check checks that a key-value combination is valid. Check(key []byte, value []byte) error }
KeyValueChecker checks that a key-value combination is valid.
func NewHashKeyValueChecker ¶
func NewHashKeyValueChecker() KeyValueChecker
NewHashKeyValueChecker returns a new KeyValueChecker that checks that the key is the SHA256 hash of the value.
type Loader ¶
type Loader interface { // Load a value for a given key and namespace. Load(key []byte) ([]byte, error) }
Loader loads a value from durable storage.
type Storer ¶
type Storer interface { // Store a key-value pair in a given namespace. Store(key []byte, value []byte) error // Iterate iterates through the key-value pairs of a given namespace within a given key range. // It calls the callback function for each key-value pair. Iterate(keyLB, keyUB []byte, done chan struct{}, callback func(key, value []byte)) error }
Storer stores a value to durable storage.
type StorerLoader ¶
StorerLoader can both store and load values.
func NewClientSL ¶
func NewClientSL(kvdb db.KVDB) StorerLoader
NewClientSL creates a new NamespaceSL for the "client" namespace backed by a db.KVDB instance.
func NewKVDBStorerLoader ¶
func NewKVDBStorerLoader( ns []byte, db db.KVDB, keyChecker Checker, valueChecker Checker, ) StorerLoader
NewKVDBStorerLoader returns a new StorerLoader backed by a db.KVDB instance and with the given key and value checkers.
func NewServerSL ¶
func NewServerSL(kvdb db.KVDB) StorerLoader
NewServerSL creates a new NamespaceSL for the "server" namespace backed by a db.KVDB instance.
type StorerLoaderDeleter ¶
type StorerLoaderDeleter interface { StorerLoader Deleter }
StorerLoaderDeleter can store, load, and delete values.
func NewKVDBStorerLoaderDeleter ¶
func NewKVDBStorerLoaderDeleter( ns []byte, db db.KVDB, keyChecker Checker, valueChecker Checker, ) StorerLoaderDeleter
NewKVDBStorerLoaderDeleter returns a new StorerLoaderDeleter backed by a db.KVDB instance and with the given key and value checkers.
type TestDocSLD ¶
type TestDocSLD struct { StoreErr error Stored map[string]*api.Document IterateErr error LoadErr error MacErr error DeleteErr error // contains filtered or unexported fields }
TestDocSLD mocks DocumentSLD.
func (*TestDocSLD) Delete ¶
func (f *TestDocSLD) Delete(key id.ID) error
Delete mocks DocumentSLD.Delete().
func (*TestDocSLD) Iterate ¶
func (f *TestDocSLD) Iterate(done chan struct{}, callback func(key id.ID, value []byte)) error
Iterate mocks DocumentSLD.Iterate().
type TestSLD ¶
type TestSLD struct { Bytes []byte LoadErr error IterateErr error StoreErr error DeleteErr error // contains filtered or unexported fields }
TestSLD mocks StorerLoaderDeleter interface.
func (*TestSLD) Iterate ¶
func (l *TestSLD) Iterate( keyLB, keyUB []byte, done chan struct{}, callback func(key, value []byte), ) error
Iterate mocks StorerLoaderDeleter.Iterate().