feeds

package
v0.0.0-...-eb12069 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package feeds implements generic interfaces and methods for time-based feeds indexing schemes are implemented in subpackages - epochs - sequence

Index

Constants

This section is empty.

Variables

View Source
var ErrFeedTypeNotFound = errors.New("no such feed type")

Functions

func FromChunk

func FromChunk(ch swarm.Chunk) (uint64, []byte, error)

FromChunk parses out the timestamp and the payload

func Id

func Id(topic []byte, index Index) ([]byte, error)

Id calculates the feed id from a topic and an index

func Latest

func Latest(ctx context.Context, l Lookup, after int64) (swarm.Chunk, error)

Latest looks up the latest update of the feed after is a unix time hint of the latest known update

func NewUpdate

func NewUpdate(f *Feed, idx Index, timestamp int64, payload, sig []byte) (swarm.Chunk, error)

NewUpdate creates an update from an index, timestamp, payload and signature

func UpdatedAt

func UpdatedAt(ch swarm.Chunk) (uint64, error)

UpdatedAt extracts the time of feed other than update

Types

type Factory

type Factory interface {
	NewLookup(Type, *Feed) (Lookup, error)
}

Factory creates feed lookups for different types of feeds.

type Feed

type Feed struct {
	Topic []byte
	Owner common.Address
}

Feed is representing an epoch based feed

func New

func New(topic []byte, owner common.Address) *Feed

New constructs an epoch based feed from a keccak256 digest of a plaintext topic and an ether address.

func (*Feed) Update

func (f *Feed) Update(index Index) *Update

Update called on a feed with an index and returns an Update

type Getter

type Getter struct {
	*Feed
	// contains filtered or unexported fields
}

Getter encapsulates a chunk Getter getter and a feed and provides non-concurrent lookup methods

func NewGetter

func NewGetter(getter storage.Getter, feed *Feed) *Getter

NewGetter constructs a feed Getter

func (*Getter) Get

func (f *Getter) Get(ctx context.Context, i Index) (swarm.Chunk, error)

Get creates an update of the underlying feed at the given epoch and looks it up in the chunk Getter based on its address

type Index

type Index interface {
	encoding.BinaryMarshaler
	Next(last int64, at uint64) Index
	fmt.Stringer
}

Index is the interface for feed implementations.

type Lookup

type Lookup interface {
	At(ctx context.Context, at, after int64) (chunk swarm.Chunk, currentIndex, nextIndex Index, err error)
}

Lookup is the interface for time based feed lookup

type Putter

type Putter struct {
	*Feed
	// contains filtered or unexported fields
}

Putter encapsulates a chunk store putter and a Feed to store feed updates

func NewPutter

func NewPutter(putter storage.Putter, signer crypto.Signer, topic []byte) (*Putter, error)

NewPutter constructs a feed Putter

func (*Putter) Put

func (u *Putter) Put(ctx context.Context, i Index, at int64, payload []byte) error

Put pushes an update to the feed through the chunk stores

type Type

type Type int

Type enumerates the time-based feed types

const (
	Sequence Type = iota
	Epoch
)

func (*Type) FromString

func (t *Type) FromString(s string) error

FromString constructs the type from a string

func (Type) String

func (t Type) String() string

type Update

type Update struct {
	*Feed
	// contains filtered or unexported fields
}

Update represents an update instance of a feed, i.e., pairing of a Feed with an Epoch

func (*Update) Address

func (u *Update) Address() (swarm.Address, error)

Address calculates the soc address of a feed update

func (*Update) Id

func (u *Update) Id() ([]byte, error)

Id calculates the identifier if a feed update to be used in single owner chunks

type Updater

type Updater interface {
	Update(ctx context.Context, at int64, payload []byte) error
	Feed() *Feed
}

Updater is the generic interface f

Directories

Path Synopsis
Package epochs implements time-based feeds using epochs as index and provide sequential as well as concurrent lookup algorithms
Package epochs implements time-based feeds using epochs as index and provide sequential as well as concurrent lookup algorithms
Package sequence provides implementation of sequential indexing for time-based feeds this feed type is best suited for - version updates - followed updates - frequent or regular-interval updates
Package sequence provides implementation of sequential indexing for time-based feeds this feed type is best suited for - version updates - followed updates - frequent or regular-interval updates
package testing provides tests for update and resolution of time-based feeds
package testing provides tests for update and resolution of time-based feeds

Jump to

Keyboard shortcuts

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