Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type FeedPrice
- type MemoryStorage
- func (p *MemoryStorage) Add(_ context.Context, from types.Address, price *messages.Price) error
- func (p *MemoryStorage) GetAll(_ context.Context) (map[FeedPrice]*messages.Price, error)
- func (p *MemoryStorage) GetByAssetPair(_ context.Context, pair string) ([]*messages.Price, error)
- func (p *MemoryStorage) GetByFeed(_ context.Context, pair string, feed types.Address) (*messages.Price, error)
- type PriceStore
- func (p *PriceStore) Add(ctx context.Context, from types.Address, msg *messages.Price) error
- func (p *PriceStore) GetAll(ctx context.Context) (map[FeedPrice]*messages.Price, error)
- func (p *PriceStore) GetByAssetPair(ctx context.Context, pair string) ([]*messages.Price, error)
- func (p *PriceStore) GetByFeed(ctx context.Context, pair string, feed types.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 ErrUnknownFeed = errors.New("messages from feed are not allowed")
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 // Transport is an implementation of transport used to fetch prices from // feeds. Transport transport.Service // Pairs is the list of asset pairs which are supported by the store. Pairs []string // Feeds is the list of feeds which are supported by the store. Feeds []types.Address // Logger is a current logger interface used by the PriceStore. // The Logger is required to monitor asynchronous processes. Logger log.Logger // Recoverer provides a method to recover the public key from a signature. // The default is crypto.ECREcoverer. Recoverer crypto.Recoverer }
Config is the configuration for Storage.
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
func NewMemoryStorage ¶
func NewMemoryStorage() *MemoryStorage
NewMemoryStorage creates a new store instance.
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 feed already exists, the newer one will be used.
func (*PriceStore) GetByAssetPair ¶
GetByAssetPair returns all prices for given asset pair.
func (*PriceStore) GetByFeed ¶ added in v0.11.0
func (p *PriceStore) GetByFeed(ctx context.Context, pair string, feed types.Address) (*messages.Price, error)
GetByFeed returns the latest price for given asset pair sent by given feed.
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 types.Address, msg *messages.Price) error // GetAll returns all prices. The method is thread-safe. GetAll(ctx context.Context) (map[FeedPrice]*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) // GetByFeed returns the latest price for given asset pair sent by given // feed. The method is thread-safe. GetByFeed(ctx context.Context, pair string, feed types.Address) (*messages.Price, error) }
Storage provides an interface to the price storage.
Click to show internal directories.
Click to hide internal directories.