Documentation ¶
Index ¶
- type Blockchain
- type ConcurrentAllPriceData
- type Exchange
- type Fetcher
- func (f *Fetcher) AddExchange(exchange Exchange)
- func (f *Fetcher) FetchAllAuthData(timepoint uint64)
- func (f *Fetcher) FetchAuthDataFromBlockchain(allBalances map[string]common.BalanceEntry, allStatuses *sync.Map, ...) error
- func (f *Fetcher) FetchAuthDataFromExchange(wg *sync.WaitGroup, exchange Exchange, allBalances *sync.Map, ...)
- func (f *Fetcher) FetchBalanceFromBlockchain() (map[string]common.BalanceEntry, error)
- func (f *Fetcher) FetchCurrentBlock(timepoint uint64)
- func (f *Fetcher) FetchGlobalData(timepoint uint64)
- func (f *Fetcher) FetchOrderbook(timepoint uint64)
- func (f *Fetcher) FetchRate(timepoint uint64)
- func (f *Fetcher) FetchStatusFromBlockchain(pendings []common.ActivityRecord) (map[common.ActivityID]common.ActivityStatus, error)
- func (f *Fetcher) FetchStatusFromExchange(exchange Exchange, pendings []common.ActivityRecord, timepoint uint64) map[common.ActivityID]common.ActivityStatus
- func (f *Fetcher) PersistSnapshot(ebalances *sync.Map, bbalances map[string]common.BalanceEntry, ...) error
- func (f *Fetcher) Run() error
- func (f *Fetcher) RunAuthDataFetcher()
- func (f *Fetcher) RunBlockFetcher()
- func (f *Fetcher) RunGlobalDataFetcher()
- func (f *Fetcher) RunOrderbookFetcher()
- func (f *Fetcher) RunRateFetcher()
- func (f *Fetcher) SetBlockchain(blockchain Blockchain)
- func (f *Fetcher) Stop() error
- type GlobalStorage
- type Runner
- type Setting
- type Storage
- type TheWorld
- type TickerRunner
- func (tr *TickerRunner) GetAuthDataTicker() <-chan time.Time
- func (tr *TickerRunner) GetBlockTicker() <-chan time.Time
- func (tr *TickerRunner) GetGlobalDataTicker() <-chan time.Time
- func (tr *TickerRunner) GetOrderbookTicker() <-chan time.Time
- func (tr *TickerRunner) GetRateTicker() <-chan time.Time
- func (tr *TickerRunner) Start() error
- func (tr *TickerRunner) Stop() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Blockchain ¶
type Blockchain interface { FetchBalanceData(addr ethereum.Address, atBlock uint64) (map[string]common.BalanceEntry, error) // fetch current raw rates at specific block FetchRates(atBlock uint64, currentBlock uint64) (common.AllRateEntry, error) TxStatus(tx ethereum.Hash) (string, uint64, error) CurrentBlock() (uint64, error) SetRateMinedNonce() (uint64, error) }
Blockchain contains all methods for fetcher to interact with blockchain.
type ConcurrentAllPriceData ¶
type ConcurrentAllPriceData struct {
// contains filtered or unexported fields
}
func NewConcurrentAllPriceData ¶
func NewConcurrentAllPriceData() *ConcurrentAllPriceData
func (*ConcurrentAllPriceData) GetData ¶
func (cap *ConcurrentAllPriceData) GetData() common.AllPriceEntry
func (*ConcurrentAllPriceData) SetBlockNumber ¶ added in v0.1.1
func (cap *ConcurrentAllPriceData) SetBlockNumber(block uint64)
func (*ConcurrentAllPriceData) SetOnePrice ¶
func (cap *ConcurrentAllPriceData) SetOnePrice( exchange common.ExchangeID, pair common.TokenPairID, d common.ExchangePrice)
type Exchange ¶
type Exchange interface { ID() common.ExchangeID Name() string FetchPriceData(timepoint uint64, fetchBTCPrice bool) (map[common.TokenPairID]common.ExchangePrice, error) FetchEBalanceData(timepoint uint64) (common.EBalanceEntry, error) OrderStatus(id string, base, quote string) (string, error) DepositStatus(id common.ActivityID, txHash, currency string, amount float64, timepoint uint64) (string, error) WithdrawStatus(id, currency string, amount float64, timepoint uint64) (string, string, error) TokenAddresses() (map[string]ethereum.Address, error) }
Exchange is the common interface of centralized exchanges.
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
func NewFetcher ¶
func (*Fetcher) AddExchange ¶
func (*Fetcher) FetchAllAuthData ¶ added in v0.1.1
func (*Fetcher) FetchAuthDataFromBlockchain ¶ added in v0.1.1
func (f *Fetcher) FetchAuthDataFromBlockchain( allBalances map[string]common.BalanceEntry, allStatuses *sync.Map, pendings []common.ActivityRecord) error
func (*Fetcher) FetchAuthDataFromExchange ¶ added in v0.1.1
func (*Fetcher) FetchBalanceFromBlockchain ¶ added in v0.1.1
func (f *Fetcher) FetchBalanceFromBlockchain() (map[string]common.BalanceEntry, error)
func (*Fetcher) FetchCurrentBlock ¶ added in v0.1.1
func (*Fetcher) FetchGlobalData ¶ added in v0.1.1
func (*Fetcher) FetchOrderbook ¶ added in v0.1.1
func (*Fetcher) FetchStatusFromBlockchain ¶ added in v0.1.1
func (f *Fetcher) FetchStatusFromBlockchain(pendings []common.ActivityRecord) (map[common.ActivityID]common.ActivityStatus, error)
func (*Fetcher) FetchStatusFromExchange ¶ added in v0.1.1
func (f *Fetcher) FetchStatusFromExchange(exchange Exchange, pendings []common.ActivityRecord, timepoint uint64) map[common.ActivityID]common.ActivityStatus
func (*Fetcher) PersistSnapshot ¶ added in v0.1.1
func (*Fetcher) RunAuthDataFetcher ¶ added in v0.1.1
func (f *Fetcher) RunAuthDataFetcher()
func (*Fetcher) RunBlockFetcher ¶ added in v0.1.1
func (f *Fetcher) RunBlockFetcher()
func (*Fetcher) RunGlobalDataFetcher ¶ added in v0.1.1
func (f *Fetcher) RunGlobalDataFetcher()
func (*Fetcher) RunOrderbookFetcher ¶ added in v0.1.1
func (f *Fetcher) RunOrderbookFetcher()
func (*Fetcher) RunRateFetcher ¶ added in v0.1.1
func (f *Fetcher) RunRateFetcher()
func (*Fetcher) SetBlockchain ¶
func (f *Fetcher) SetBlockchain(blockchain Blockchain)
type GlobalStorage ¶ added in v0.1.1
type GlobalStorage interface { StoreGoldInfo(data common.GoldData) error StoreBTCInfo(data common.BTCData) error StoreUSDInfo(data common.USDData) error GetAllFetcherConfiguration() (common.FetcherConfiguration, error) }
GlobalStorage is the storage to store real world data pricing information.
type Runner ¶ added in v0.1.1
type Runner interface { // Start initializes all tickers. It must be called before runner is usable. Start() error // Stop stops all tickers and free usage resources. // It must only be called after runner is started. Stop() error // All following methods should only becalled after Start() is executed GetGlobalDataTicker() <-chan time.Time GetOrderbookTicker() <-chan time.Time GetAuthDataTicker() <-chan time.Time GetRateTicker() <-chan time.Time GetBlockTicker() <-chan time.Time }
Runner is the common interface of runners that will periodically trigger fetcher jobs.
type Setting ¶ added in v0.1.1
type Setting interface { GetAddress(settings.AddressName) (ethereum.Address, error) GetExchangeStatus() (common.ExchangesStatus, error) UpdateExchangeStatus(common.ExchangesStatus) error }
type Storage ¶
type Storage interface { StorePrice(data common.AllPriceEntry, timepoint uint64) error StoreRate(data common.AllRateEntry, timepoint uint64) error StoreAuthSnapshot(data *common.AuthDataSnapshot, timepoint uint64) error GetPendingActivities() ([]common.ActivityRecord, error) UpdateActivity(id common.ActivityID, act common.ActivityRecord) error CurrentAuthDataVersion(timepoint uint64) (common.Version, error) GetAuthData(common.Version) (common.AuthDataSnapshot, error) }
Storage is the interface that wraps all database operations of fetcher.
type TheWorld ¶ added in v0.1.1
type TheWorld interface { GetGoldInfo() (common.GoldData, error) GetBTCInfo() (common.BTCData, error) GetUSDInfo() (common.USDData, error) }
TheWorld is the interface that wraps all methods to get in real life pricing information. For now, only gold pricing is supported.
type TickerRunner ¶
type TickerRunner struct {
// contains filtered or unexported fields
}
TickerRunner is an implementation of FetcherRunner that use simple time ticker.
func NewTickerRunner ¶
func NewTickerRunner( oduration, aduration, rduration, bduration, globalDataDuration time.Duration) *TickerRunner
NewTickerRunner creates a new instance of TickerRunner with given time durations in parameters.
func (*TickerRunner) GetAuthDataTicker ¶ added in v0.1.1
func (tr *TickerRunner) GetAuthDataTicker() <-chan time.Time
func (*TickerRunner) GetBlockTicker ¶ added in v0.1.1
func (tr *TickerRunner) GetBlockTicker() <-chan time.Time
func (*TickerRunner) GetGlobalDataTicker ¶ added in v0.1.1
func (tr *TickerRunner) GetGlobalDataTicker() <-chan time.Time
func (*TickerRunner) GetOrderbookTicker ¶ added in v0.1.1
func (tr *TickerRunner) GetOrderbookTicker() <-chan time.Time
func (*TickerRunner) GetRateTicker ¶ added in v0.1.1
func (tr *TickerRunner) GetRateTicker() <-chan time.Time
func (*TickerRunner) Start ¶
func (tr *TickerRunner) Start() error
func (*TickerRunner) Stop ¶
func (tr *TickerRunner) Stop() error