Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #924 from hermeznetwork/feature/pu_improvement
Browse files Browse the repository at this point in the history
allows don't specify symbols and addresses in config file
  • Loading branch information
arnaubennassar authored Jul 6, 2021
2 parents 8a39405 + 9ae47bc commit dbb50d3
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions priceupdater/priceupdater.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ func (d *symbolsMap) strToMapSymbol(str string) error {
}
d.Symbols = mapping
log.Debug("Symbol mapping from config file: ", mapping)
} else {
d.Symbols = make(map[uint]string)
}
return lastErr
}
Expand Down Expand Up @@ -141,6 +143,8 @@ func (d *addressesMap) strToMapAddress(str string) error {
}
d.Addresses = mapping
log.Debug("Address mapping from config file: ", mapping)
} else {
d.Addresses = make(map[uint]ethCommon.Address)
}
return lastErr
}
Expand Down Expand Up @@ -331,15 +335,18 @@ func (p *PriceUpdater) UpdateTokenList() error {
}
}
for _, provider := range p.providers {
if len(provider.SymbolsMap.Symbols) != 0 {
switch provider.Provider {
case UpdateMethodTypeBitFinexV2:
if _, ok := provider.SymbolsMap.Symbols[dbToken.TokenID]; !ok {
provider.SymbolsMap.Symbols[dbToken.TokenID] = dbToken.Symbol
}
}
if len(provider.AddressesMap.Addresses) != 0 {
case UpdateMethodTypeCoingeckoV3:
if _, ok := provider.AddressesMap.Addresses[dbToken.TokenID]; !ok {
provider.AddressesMap.Addresses[dbToken.TokenID] = dbToken.Addr
}
default:
log.Warn("This price provider is not supported: ", provider.Provider)
return tracerr.Wrap(fmt.Errorf("Error: Unknown price provider: " + provider.Provider))
}
}
}
Expand Down

0 comments on commit dbb50d3

Please sign in to comment.