datastore

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const LoggerTag = "DATASTORE"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Signer is an instance of the ethereum.Signer which will be used to
	// verify price signatures.
	Signer ethereum.Signer
	// Transport is a implementation of transport used to fetch prices from
	// feeders.
	Transport transport.Transport
	// Pairs is the list supported pairs by the datastore with their
	// configuration.
	Pairs map[string]*Pair
	// Logger is a current logger interface used by the Datastore.
	// The Logger is required to monitor asynchronous processes.
	Logger log.Logger
}

type Datastore

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

Datastore reads and stores prices from the P2P network.

func NewDatastore

func NewDatastore(config Config) *Datastore

func (*Datastore) Prices

func (c *Datastore) Prices() *PriceStore

func (*Datastore) Start

func (c *Datastore) Start() error

func (*Datastore) Stop

func (c *Datastore) Stop() error

type FeederPrice

type FeederPrice struct {
	AssetPair string
	Feeder    ethereum.Address
}

type Pair

type Pair struct {
	// Feeds is the list of Ethereum addresses from which prices will be
	// accepted.
	Feeds []ethereum.Address
}

type PriceStore

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

PriceStore contains a list of messages.Price's.

func NewPriceStore

func NewPriceStore() *PriceStore

NewPriceStore creates a new store instance.

func (*PriceStore) Add

func (p *PriceStore) Add(from ethereum.Address, msg *messages.Price)

Add adds a new price to the list. If a price from same feeder already exists, the newer one will be used.

func (*PriceStore) All

func (p *PriceStore) All() map[FeederPrice]*messages.Price

All returns all prices.

func (*PriceStore) AssetPair

func (p *PriceStore) AssetPair(assetPair string) []*messages.Price

AssetPair returns all prices for given asset pair.

func (*PriceStore) Feeder

func (p *PriceStore) Feeder(assetPair string, feeder ethereum.Address) *messages.Price

Feeder returns the latest price for given asset pair sent by given feeder.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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