Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

gnorkle source pure

Functions 1

func NewInstance

1func NewInstance() *Instance
source

NewInstance creates a new instance of an oracle.

Types 7

type Feed

interface
1type Feed interface {
2	ID() string
3	Type() feed.Type
4	Value() (value feed.Value, dataType string, consumable bool)
5	Ingest(funcType message.FuncType, rawMessage, providerAddress string) error
6	MarshalJSON() ([]byte, error)
7	Tasks() []feed.Task
8	IsActive() bool
9}
source

Feed is an abstraction used by a gnorkle `Instance` to ingest data from agents and provide data feeds to consumers.

type FeedWithWhitelist

struct
1type FeedWithWhitelist struct {
2	Feed
3	Whitelist
4}
source

FeedWithWhitelist associates a `Whitelist` with a `Feed`.

type Ingester

interface
1type Ingester interface {
2	Type() ingester.Type
3	Ingest(value, providerAddress string) (canAutoCommit bool, err error)
4	CommitValue(storage Storage, providerAddress string) error
5}
source

Ingester is the abstraction that allows a `Feed` to ingest data from agents and commit it to storage using zero or more intermediate aggregation steps.

type Instance

struct
1type Instance struct {
2	feeds     *avl.Tree
3	whitelist agent.Whitelist
4}
source

Instance is a single instance of an oracle.

Methods on Instance

func AddFeeds

method on Instance
1func (i *Instance) AddFeeds(feeds ...Feed) error
source

AddFeeds adds feeds to the instance with empty whitelists.

func AddFeedsWithWhitelists

method on Instance
1func (i *Instance) AddFeedsWithWhitelists(feeds ...FeedWithWhitelist) error
source

AddFeedsWithWhitelists adds feeds to the instance with the given whitelists.

func AddToWhitelist

method on Instance
1func (i *Instance) AddToWhitelist(feedID string, addresses []string) error
source

AddToWhitelist adds the given addresses to the whitelist of the instance or feed depending on the feed ID.

func ClearWhitelist

method on Instance
1func (i *Instance) ClearWhitelist(feedID string) error
source

ClearWhitelist clears the whitelist of the instance or feed depending on the feed ID.

func GetFeedDefinitions

method on Instance
1func (i *Instance) GetFeedDefinitions(forAddress string) (string, error)
source

GetFeedDefinitions returns a JSON string representing the feed definitions for which the given agent address is whitelisted to provide values for ingestion.

func GetFeedValue

method on Instance
1func (i *Instance) GetFeedValue(id string) (feed.Value, string, bool, error)
source

GetFeedValue returns the most recently published value of a feed along with a string representation of the value's type and boolean indicating whether the value is okay for consumption.

func HandleMessage

method on Instance
1func (i *Instance) HandleMessage(msg string, postHandler PostMessageHandler) (string, error)
source

HandleMessage handles a message from an agent and routes to either the logic that returns feed definitions or the logic that allows a feed to ingest a message.

TODO: Consider further message types that could allow administrative action such as modifying a feed's whitelist without the owner of this oracle having to maintain a reference to it.

func RemoveFeed

method on Instance
1func (i *Instance) RemoveFeed(id string)
source

RemoveFeed removes a feed from the instance.

func RemoveFromWhitelist

method on Instance
1func (i *Instance) RemoveFromWhitelist(feedID string, address_XXX string) error
source

RemoveFromWhitelist removes the given address from the whitelist of the instance or feed depending on the feed ID.

type PostMessageHandler

interface
1type PostMessageHandler interface {
2	Handle(i *Instance, funcType message.FuncType, feed Feed) error
3}
source

PostMessageHandler is a type that allows for post-processing of feed state after a feed ingests a message from an agent.

type Storage

interface
1type Storage interface {
2	Put(value string) error
3	GetLatest() feed.Value
4	GetHistory() []feed.Value
5}
source

Storage defines how published feed values should be read and written.

type Whitelist

interface
1type Whitelist interface {
2	ClearAddresses()
3	AddAddresses(addresses []string)
4	RemoveAddress(address_XXX string)
5	HasDefinition() bool
6	HasAddress(address_XXX string) bool
7}
source

Whitelist is used to manage which agents are allowed to interact.

Imports 8

Source Files 6