package eris
import "codeberg.org/eris/eris-go"
Encoding for Robust Immutable Storage (ERIS).
Index ¶
- Constants
- func ChunkBinaryLogarithm(cap ReadCapability) int
- func Get(store Store, ctx context.Context, chunk []byte, pair Pair, level Level) (err error)
- func ServeCoap(network, address string, store Store) error
- func TreeArity(cap ReadCapability) int
- type BadgerStore
- func OpenBadgerStore(path string) (store BadgerStore, err error)
- func (store BadgerStore) Close() error
- func (store BadgerStore) Get(ctx context.Context, chunk []byte, ref Ref) error
- func (store BadgerStore) Has(ctx context.Context, ref Ref, chunkSize int) (present bool)
- func (store BadgerStore) Put(ctx context.Context, chunk []byte, ref Ref) error
- type ChunkSize
- type CoapTcpStore
- func DialCoapTcpStore(address string) (store CoapTcpStore, err error)
- func (store CoapTcpStore) Close() (err error)
- func (store CoapTcpStore) Get(ctx context.Context, chunk []byte, ref Ref) (err error)
- func (store CoapTcpStore) Has(ctx context.Context, ref Ref, chunkSize int) (present bool)
- func (store CoapTcpStore) Put(ctx context.Context, chunk []byte, ref Ref) (err error)
- type Decoder
- func NewDecoder(store Store, cap ReadCapability) (dec *Decoder, err error)
- func (dec *Decoder) Read(p []byte) (n int, err error)
- func (dec *Decoder) Seek(offset int64, whence int) (pos int64, err error)
- type DiscardStore
- func (store DiscardStore) Close() error
- func (store DiscardStore) Get(ctx context.Context, chunk []byte, ref Ref) error
- func (store DiscardStore) Has(ctx context.Context, ref Ref, chunkSize int) bool
- func (store DiscardStore) Put(ctx context.Context, chunk []byte, ref Ref) error
- type Encoder
- func NewConvergentEncoder(store Store, chunkSize ChunkSize) (*Encoder, error)
- func NewEncoder(store Store, chunkSize ChunkSize) (*Encoder, error)
- func NewUniqueEncoder(store Store, secret Secret, chunkSize ChunkSize) (enc *Encoder, err error)
- func (enc *Encoder) Cap() (cap ReadCapability, err error)
- func (enc *Encoder) Write(data []byte) (int, error)
- type Key
- type Level
- type Pair
- type ReadCapability
- func DecodeCap(buf []byte) (cap ReadCapability, err error)
- func ParseUrn(urn string) (cap ReadCapability, err error)
- func (cap ReadCapability) Bytes() []byte
- func (cap ReadCapability) String() (urn string)
- type Ref
- type Secret
- type Store
- type TreeEntry
Examples ¶
Package Files ¶
badger.go capability.go coap_client.go coap_server.go decoder.go encoder.go store.go
Constants ¶
const ( SmallChunkSize = 1 << 10 LargeChunkSize = 1 << 15 )
func ChunkBinaryLogarithm ¶
func ChunkBinaryLogarithm(cap ReadCapability) int
Return the binary logarithm of the chunk size for a given ReadCapability. For 1KiB this is 10 (0xa) and for 32KiB this is 15 (0xf).
func Get ¶
Get the plaintext chunk from a store for ref and key at the given tree level.
func ServeCoap ¶
Serve an ERIS store over CoAP. The network parameter may specify "udp" or "tcp".
func TreeArity ¶
func TreeArity(cap ReadCapability) int
Return the arity of the ERIS tree for this capability. This is the maximum number of ref-key pairs in any block of the tree.
type BadgerStore ¶
type BadgerStore struct {
// contains filtered or unexported fields
}
ExampleΒΆ
Code:
store, _ := OpenBadgerStore("/tmp/eris-store") defer store.Close() encoder, _ := NewConvergentEncoder(store, SmallChunkSize) io.WriteString(encoder, "Hail ERIS!") cap, _ := encoder.Cap() fmt.Println(cap) decoder, _ := NewDecoder(store, cap) data, _ := io.ReadAll(decoder) fmt.Println(string(data))
Output:
urn:eris:BIAAV4OIFHWY67XFEHAOQVXUOWTYDVG5TEY6S6IW4PJ4SQLVJJF4MIKNDLKUDPPHDCKLBUIAJQ3U2IEARRPFHEHWFW5NJY7BJUGFESPGDQ Hail ERIS!
func OpenBadgerStore ¶
func OpenBadgerStore(path string) (store BadgerStore, err error)
func (BadgerStore) Close ¶
func (store BadgerStore) Close() error
func (BadgerStore) Get ¶
func (BadgerStore) Has ¶
func (BadgerStore) Put ¶
type ChunkSize ¶
type ChunkSize int
type CoapTcpStore ¶
type CoapTcpStore struct {
// contains filtered or unexported fields
}
func DialCoapTcpStore ¶
func DialCoapTcpStore(address string) (store CoapTcpStore, err error)
Connect to a remote ERIS store over CoAP+TCP.
func (CoapTcpStore) Close ¶
func (store CoapTcpStore) Close() (err error)
func (CoapTcpStore) Get ¶
func (CoapTcpStore) Has ¶
func (CoapTcpStore) Put ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func NewDecoder ¶
func NewDecoder(store Store, cap ReadCapability) (dec *Decoder, err error)
Create a new io.Reader that decodes the given ReadCapability from the given Store.
func (*Decoder) Read ¶
func (*Decoder) Seek ¶
type DiscardStore ¶
type DiscardStore struct { }
The DiscardStore simply discards any blocks that are Put to it.
func (DiscardStore) Close ¶
func (store DiscardStore) Close() error
func (DiscardStore) Get ¶
func (DiscardStore) Has ¶
func (DiscardStore) Put ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
func NewConvergentEncoder ¶
func NewEncoder ¶
func NewUniqueEncoder ¶
func (*Encoder) Cap ¶
func (enc *Encoder) Cap() (cap ReadCapability, err error)
func (*Encoder) Write ¶
type Key ¶
type Key [32]byte
type Level ¶
type Level uint8
type Pair ¶
type Pair struct {
// contains filtered or unexported fields
}
func Put ¶
Put the plaintext chunk to a store for the given convergence secret and tree level.
type ReadCapability ¶
type ReadCapability struct {
// contains filtered or unexported fields
}
func DecodeCap ¶
func DecodeCap(buf []byte) (cap ReadCapability, err error)
func ParseUrn ¶
func ParseUrn(urn string) (cap ReadCapability, err error)
func (ReadCapability) Bytes ¶
func (cap ReadCapability) Bytes() []byte
func (ReadCapability) String ¶
func (cap ReadCapability) String() (urn string)
type Ref ¶
type Ref [32]byte
func (Ref) String ¶
type Secret ¶
type Secret [32]byte
type Store ¶
type Store interface { Get(ctx context.Context, chunk []byte, ref Ref) error Has(ctx context.Context, ref Ref, chunkSize int) bool Put(ctx context.Context, chunk []byte, ref Ref) error Close() error }
A Store represents some service for storing and retrieving raw ERIS blocks.
type TreeEntry ¶
type TreeEntry struct {
// contains filtered or unexported fields
}
Directories ¶
Path | Synopsis |
---|---|
eris-server |
- Version
- v0.0.0-20221229050044-3faa6e22526f (latest)
- Published
- Dec 29, 2022
- Platform
- linux/amd64
- Imports
- 19 packages (graph)
- Last checked
- 2 months ago –
Tools for package owners.