Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type FeederPrice
- type MemoryStorage
- func (p *MemoryStorage) Add(_ context.Context, from ethereum.Address, price *messages.Price) error
- func (p *MemoryStorage) GetAll(_ context.Context) (map[FeederPrice]*messages.Price, error)
- func (p *MemoryStorage) GetByAssetPair(_ context.Context, pair string) ([]*messages.Price, error)
- func (p *MemoryStorage) GetByFeeder(_ context.Context, pair string, feeder ethereum.Address) (*messages.Price, error)
- type PriceStore
- func (p *PriceStore) Add(ctx context.Context, from ethereum.Address, msg *messages.Price) error
- func (p *PriceStore) GetAll(ctx context.Context) (map[FeederPrice]*messages.Price, error)
- func (p *PriceStore) GetByAssetPair(ctx context.Context, pair string) ([]*messages.Price, error)
- func (p *PriceStore) GetByFeeder(ctx context.Context, pair string, feeder ethereum.Address) (*messages.Price, error)
- func (p *PriceStore) Start(ctx context.Context) error
- func (p *PriceStore) Wait() chan error
- type Storage
Constants ¶
View Source
const LoggerTag = "PRICE_STORE"
Variables ¶
View Source
var ErrInvalidPrice = errors.New("received price is invalid")
View Source
var ErrInvalidSignature = errors.New("received price has an invalid signature")
View Source
var ErrUnknownPair = errors.New("received pair is not configured")
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Storage is the storage implementation. Storage Storage // Signer is an instance of the ethereum.Signer which will be used to // verify price signatures. Signer ethereum.Signer // Transport is an implementation of transport used to fetch prices from // feeders. Transport transport.Transport // Pairs is the list of asset pairs which are supported by the store. Pairs []string // Logger is a current logger interface used by the PriceStore. // The Logger is required to monitor asynchronous processes. Logger log.Logger }
Config is the configuration for Storage.
type FeederPrice ¶
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
func NewMemoryStorage ¶
func NewMemoryStorage() *MemoryStorage
NewMemoryStorage creates a new store instance.
func (*MemoryStorage) GetAll ¶
func (p *MemoryStorage) GetAll(_ context.Context) (map[FeederPrice]*messages.Price, error)
GetAll implements the store.Storage interface.
func (*MemoryStorage) GetByAssetPair ¶
GetByAssetPair implements the store.Storage interface.
type PriceStore ¶
type PriceStore struct {
// contains filtered or unexported fields
}
PriceStore contains a list of prices.
func (*PriceStore) Add ¶
Add adds a new price to the list. If a price from same feeder already exists, the newer one will be used.
func (*PriceStore) GetAll ¶
func (p *PriceStore) GetAll(ctx context.Context) (map[FeederPrice]*messages.Price, error)
GetAll returns all prices.
func (*PriceStore) GetByAssetPair ¶
GetByAssetPair returns all prices for given asset pair.
func (*PriceStore) GetByFeeder ¶
func (p *PriceStore) GetByFeeder(ctx context.Context, pair string, feeder ethereum.Address) (*messages.Price, error)
GetByFeeder returns the latest price for given asset pair sent by given feeder.
func (*PriceStore) Start ¶
func (p *PriceStore) Start(ctx context.Context) error
Start implements the supervisor.Service interface.
func (*PriceStore) Wait ¶
func (p *PriceStore) Wait() chan error
Wait implements the supervisor.Service interface.
type Storage ¶
type Storage interface { // Add adds a price to the store. The method is thread-safe. Add(ctx context.Context, from ethereum.Address, msg *messages.Price) error // GetAll returns all prices. The method is thread-safe. GetAll(ctx context.Context) (map[FeederPrice]*messages.Price, error) // GetByAssetPair returns all prices for given asset pair. The method is // thread-safe. GetByAssetPair(ctx context.Context, pair string) ([]*messages.Price, error) // GetByFeeder returns the latest price for given asset pair sent by given // feeder. The method is thread-safe. GetByFeeder(ctx context.Context, pair string, feeder ethereum.Address) (*messages.Price, error) }
Storage provides an interface to the price storage.
Click to show internal directories.
Click to hide internal directories.