mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
Merge pull request #620 from hermeznetwork/feature/priceupdater-by-SC-addr
Add coingecko client to price updater
This commit is contained in:
@@ -486,23 +486,14 @@ func (hdb *HistoryDB) GetAllTokens() ([]TokenWithUSD, error) {
|
||||
return db.SlicePtrsToSlice(tokens).([]TokenWithUSD), tracerr.Wrap(err)
|
||||
}
|
||||
|
||||
// GetTokenSymbols returns all the token symbols from the DB
|
||||
func (hdb *HistoryDB) GetTokenSymbols() ([]string, error) {
|
||||
var tokenSymbols []string
|
||||
rows, err := hdb.dbRead.Query("SELECT symbol FROM token;")
|
||||
if err != nil {
|
||||
return nil, tracerr.Wrap(err)
|
||||
}
|
||||
defer db.RowsClose(rows)
|
||||
sym := new(string)
|
||||
for rows.Next() {
|
||||
err = rows.Scan(sym)
|
||||
if err != nil {
|
||||
return nil, tracerr.Wrap(err)
|
||||
}
|
||||
tokenSymbols = append(tokenSymbols, *sym)
|
||||
}
|
||||
return tokenSymbols, nil
|
||||
// GetTokenSymbolsAndAddrs returns all the token symbols and addresses from the DB
|
||||
func (hdb *HistoryDB) GetTokenSymbolsAndAddrs() ([]TokenSymbolAndAddr, error) {
|
||||
var tokens []*TokenSymbolAndAddr
|
||||
err := meddler.QueryAll(
|
||||
hdb.dbRead, &tokens,
|
||||
"SELECT symbol, eth_addr FROM token;",
|
||||
)
|
||||
return db.SlicePtrsToSlice(tokens).([]TokenSymbolAndAddr), tracerr.Wrap(err)
|
||||
}
|
||||
|
||||
// AddAccounts insert accounts into the DB
|
||||
|
||||
@@ -147,6 +147,12 @@ type txWrite struct {
|
||||
Nonce *common.Nonce `meddler:"nonce"`
|
||||
}
|
||||
|
||||
// TokenSymbolAndAddr token representation with only Eth addr and symbol
|
||||
type TokenSymbolAndAddr struct {
|
||||
Symbol string `meddler:"symbol"`
|
||||
Addr ethCommon.Address `meddler:"eth_addr"`
|
||||
}
|
||||
|
||||
// TokenWithUSD add USD info to common.Token
|
||||
type TokenWithUSD struct {
|
||||
ItemID uint64 `json:"itemId" meddler:"item_id"`
|
||||
|
||||
Reference in New Issue
Block a user