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 ¶
- Variables
- func ExpiredPath(ps ...string) []string
- func MalformedPath(ps ...string) []string
- type KeyFunc
- type T
- func (t *T) Add(st *sharetoken.T) (err error)
- func (t *T) Del(st *sharetoken.T) (err error)
- func (t *T) Exp(st *sharetoken.T) (err error)
- func (t *T) Filter(k1, k2 string) (r []*sharetoken.T)
- func (t *T) Load(st *sharetoken.T, ps ...string) (err error)
- func (t *T) SettlingAt(rpk string, utime int64) map[string]int
Constants ¶
This section is empty.
Variables ¶
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
var DuplicateSTError = errors.New("duplicate sharetoken")
DuplicateSTError is returned if a sharetoken which was already seen is being added to the store.
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 MalformedPath ¶ added in v0.3.8
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 ¶
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".