Documentation ¶
Overview ¶
Package service is the core backend service for circuit-breaker
Index ¶
- type Service
- func (s *Service) Close() error
- func (s *Service) GetBalancesWeightsAndSupplies(contract *sigmacore.Sigmacore, block uint64, poolAddress string, ...) (balances map[string]interface{}, denormWeights map[string]interface{}, ...)
- func (s *Service) Prepare() error
- func (s *Service) StartBlockListener() error
- func (s *Service) StartWatchers() error
- func (s *Service) UpdateBalancesWeightsAndSupplies(block uint64, pool config.Pool, contract *sigmacore.Sigmacore) (balances map[string]interface{}, denormWeights map[string]interface{}, ...)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service wraps multiple modules to provide the circuit breaking functionality
func New ¶
func New( ctx context.Context, alert *alerts.Alerter, mc *multicall.Multicall, db *database.Database, bc *bclient.Client, auther *utils.Authorizer, logger *zap.Logger, pools []config.Pool, gasConfig config.GasPrice) (*Service, error)
New intializes all needed modules and returns a ready to consume service
func (*Service) Close ¶
Close shuts down all internal modules returning any errors encountered from shutdown
func (*Service) GetBalancesWeightsAndSupplies ¶
func (s *Service) GetBalancesWeightsAndSupplies( contract *sigmacore.Sigmacore, block uint64, poolAddress string, tokens map[string]common.Address, ) ( balances map[string]interface{}, denormWeights map[string]interface{}, totalSupplies map[string]interface{}, err error, )
GetBalancesWeightsAndSupplies returns the balance, weights and total supplies of all tokens held by an IndexPool all keys of the maps are the symbols of a tokein lower case
func (*Service) Prepare ¶
Prepare is used to prepare the service the primary responsibility of this function is to check the database and determine if we need to update the records. This will usually only happen during one of two conditions
- the very first time the service is started on a fresh database
- service starts up after being offline for 1 or more blocks since last run
func (*Service) StartBlockListener ¶
StartBlockListener waits for new blocks to be mined to trigger blockchain db updates
func (*Service) StartWatchers ¶
StartWatchers starts all of our contract watchers which listen for LOG_SWAP events to potentially trigger circuit breaking activities
func (*Service) UpdateBalancesWeightsAndSupplies ¶
func (s *Service) UpdateBalancesWeightsAndSupplies( block uint64, pool config.Pool, contract *sigmacore.Sigmacore, ) ( balances map[string]interface{}, denormWeights map[string]interface{}, totalSupplies map[string]interface{}, err error, )
UpdateBalancesWeightsAndSupplies is used to update all balances, weights, and supplies for a given pool Note: If using from many different threads, caller will want to make sure to call the service named locks