codeberg.org/eris/eris-go Index | Examples | Files | Directories

package eris

import "codeberg.org/eris/eris-go"

Encoding for Robust Immutable Storage (ERIS).

Index

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

func Get(store Store, ctx context.Context, chunk []byte, pair Pair, level Level) (err error)

Get the plaintext chunk from a store for ref and key at the given tree level.

func ServeCoap

func ServeCoap(network, address string, store Store) error

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 (store BadgerStore) Get(ctx context.Context, chunk []byte, ref Ref) error

func (BadgerStore) Has

func (store BadgerStore) Has(ctx context.Context, ref Ref, chunkSize int) (present bool)

func (BadgerStore) Put

func (store BadgerStore) Put(ctx context.Context, chunk []byte, ref Ref) error

type ChunkSize

type ChunkSize int
const (
    Size1KiB  ChunkSize = 1 << 10
    Size32KiB ChunkSize = 32 << 10
)

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 (store CoapTcpStore) Get(ctx context.Context, chunk []byte, ref Ref) (err error)

func (CoapTcpStore) Has

func (store CoapTcpStore) Has(ctx context.Context, ref Ref, chunkSize int) (present bool)

func (CoapTcpStore) Put

func (store CoapTcpStore) Put(ctx context.Context, chunk []byte, ref Ref) (err error)

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 (dec *Decoder) Read(p []byte) (n int, err error)

func (*Decoder) Seek

func (dec *Decoder) Seek(offset int64, whence int) (pos int64, err error)

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 (store DiscardStore) Get(ctx context.Context, chunk []byte, ref Ref) error

func (DiscardStore) Has

func (store DiscardStore) Has(ctx context.Context, ref Ref, chunkSize int) bool

func (DiscardStore) Put

func (store DiscardStore) Put(ctx context.Context, chunk []byte, ref Ref) error

type Encoder

type Encoder struct {
    // contains filtered or unexported fields
}

func NewConvergentEncoder

func NewConvergentEncoder(store Store, chunkSize ChunkSize) (*Encoder, error)

func NewEncoder

func NewEncoder(store Store, chunkSize ChunkSize) (*Encoder, error)

func NewUniqueEncoder

func NewUniqueEncoder(store Store, secret Secret, chunkSize ChunkSize) (enc *Encoder, err error)

func (*Encoder) Cap

func (enc *Encoder) Cap() (cap ReadCapability, err error)

func (*Encoder) Write

func (enc *Encoder) Write(data []byte) (int, error)

type Key

type Key [32]byte

type Level

type Level uint8

type Pair

type Pair struct {
    // contains filtered or unexported fields
}

func Put

func Put(store Store, ctx context.Context, chunk []byte, secret Secret, level Level) (Pair, error)

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

func (r Ref) String() 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

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