ststore

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

The ststore package provides a concurrent in-memory sharetoken store which is synced to disk after modifications.

The ststore package provides a concurrent in-memory sharetoken store which is synced to disk after modifications.

Index

Constants

This section is empty.

Variables

View Source
var ContractKeyFunc = func(st *sharetoken.T) (k1, k2, k3 string) {
	return st.PublicKey.String(), st.RelayPubkey.String(), st.Signature.String()
}

ContractKeyFunc is the standard key derivation function for service contracts. The store is organized as such: servicekey public key -> relay public key -> sharetoken signature + .json

View Source
var DuplicateSTError = errors.New("duplicate sharetoken")

DuplicateSTError is returned if a sharetoken which was already seen is being added to the store.

View Source
var RelayKeyFunc = func(st *sharetoken.T) (k1, k2, k3 string) {
	return st.Contract.PublicKey.String(), st.PublicKey.String(), st.Signature.String()
}

RelayKeyFunc is the standard key derivation function for relays. The store is organized as such: servicekey public key -> service contract public key -> sharetoken signature + .json

Functions

func ExpiredPath added in v0.3.8

func ExpiredPath(ps ...string) []string

func MalformedPath added in v0.3.8

func MalformedPath(ps ...string) []string

Types

type KeyFunc

type KeyFunc func(*sharetoken.T) (string, string, string)

KeyFunc is the type of key derivation functions for this sharetoken store. On taking a sharetoken as argument it should produce keys of 1st, 2nd and 3rd order.

type T

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

T is the type of a sharetoken store.

func New

func New(dir string, keyf KeyFunc) (t *T, err error)

New initializes a sharetoken store in the directory under the path given by the dir argument.

func (*T) Add

func (t *T) Add(st *sharetoken.T) (err error)

Add adds a sharetoken (st) to the map of accumulated sharetokens under the keys generated by t.keyf. It returns DuplicateSTError if this sharetoken was already seen. Additionally, stores the correspondent file.

func (*T) Del

func (t *T) Del(st *sharetoken.T) (err error)

Del deletes a sharetoken (st) from the map of accumulated sharetokens under the keys generated by t.keyf. It can return errors from attempting to delete the file associated with the sharetoken on disk.

func (*T) Exp added in v0.3.8

func (t *T) Exp(st *sharetoken.T) (err error)

Exp expires a sharetoken (st) deleting it from the map of accumulated sharetokens under the keys generated by t.keyf. It can return errors from attempting to move the file associated with the sharetoken on disk.

func (*T) Filter

func (t *T) Filter(k1, k2 string) (r []*sharetoken.T)

Filter returns a list of sharetokens matching the given keys k1 and k2. An empty string for either of the keys is assumed to mean "for all values of this key".

func (*T) Load added in v0.3.8

func (t *T) Load(st *sharetoken.T, ps ...string) (err error)

Load adds a sharetoken (st) to the map of accumulated sharetokens under the keys generated by t.keyf. It returns DuplicateSTError if this sharetoken was already seen.

func (*T) SettlingAt

func (t *T) SettlingAt(rpk string, utime int64) map[string]int

SettlingAt returns a map with counts of sharetokens currently still being settled indexed by relay public key.

Jump to

Keyboard shortcuts

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