techievee / ethash-mining-pool

High Efficient mining pool designed for Ethash based coins
GNU General Public License v3.0
54 stars 104 forks source link

Exchange collection functionality no longer works with coinmarketcap.com #5

Open Serpent6877 opened 4 years ago

Serpent6877 commented 4 years ago

Requires a API key now and JSON format is now strings and ints.

edradev commented 4 years ago

Requires a API key now and JSON format is now strings and ints.

Hello, I have same problem :( Can you provide solution?

edradev commented 4 years ago

Tried with "https://api.coinpaprika.com/v1/tickers/etc-ethereum-classic" but have error:

&{GET https://api.coinpaprika.com/v1/tickers/etc-ethereum-classic HTTP/1.1 1 1 map[Accept:[application/json] Content-Type:[application/json]] 0 [] false api.coinpaprika.com map[] map[] map[] } Failed to fetch data from exchange json: cannot unmarshal object into Go value of type exchange.ExchangeReply

Serpent6877 commented 4 years ago

exchange/exchange.go: Line 40:

type ExchangeReply []map[string]interface{}

storage/redis.go: Line 1315:

func (r *RedisClient) StoreExchangeData(ExchangeData []map[string]interface{}) {

        tx := r.client.Multi()
        defer tx.Close()

        log.Printf("ExchangeData: %s", ExchangeData)

        for _, coindata := range ExchangeData {
                for key, value := range coindata {

                        cmd := tx.HSet(r.formatKey("exchange", coindata["symbol"]), fmt.Sprintf("%v", key), fmt.Sprintf("%v", value))
                        err := cmd.Err()
                        if err != nil {
                                log.Printf("Error while Storing %s : Key-%s , value-%s , Error : %v", coindata["symbol"], key, value, err) 
                        }

                }
        }
        log.Printf("Writing Exchange Data ")
        return
}

Then in your API config:

        "exchange": {
                "enabled": true,
                "url": "https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=ethereum",
                "timeout": "50s",
                "refreshInterval": "900s"
        },

In your ember templates use:

{{format-currency model.exchangedata.current_price decimals=3}} <i class="fa fa-caret-up"></i> (+{{format-percent model.exchangedata.price_change_percentage_24h}})

Or similar if you don't have the format-currency npm.

edradev commented 4 years ago

Many thanks for sharing that! But unfortunately the data doesn't even appear to me. Is that normalto be that?

2020/09/18 15:46:51 &{GET https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=ethereum-classic HTTP/1.1 1 1 map[Accept:[application/json] Content-Type:[application/json]] 0 [] false api.coingecko.com map[] map[] map[] } 2020/09/18 15:46:51 ExchangeData: [map[ath:%!s(float64=44.34) ath_change_percentage:%!s(float64=-88.50359) ath_date:2018-01-14T00:00:00.000Z atl:%!s(float64=0.615038) atl_change_percentage:%!s(float64=728.88534) atl_date:2016-07-25T00:00:00.000Z circulating_supply:%!s(float64=1.1631979e+08) current_price:%!s(float64=5.11) fully_diluted_valuation: high_24h:%!s(float64=5.24) id:ethereum-classic image:https://assets.coingecko.com/coins/images/453/large/ethereum-classic-logo.png?1547034169 last_updated:2020-09-18T15:45:28.561Z low_24h:%!s(float64=5.09) market_cap:%!s(float64=5.93949208e+08) market_cap_change_24h:%!s(float64=-6.48725462643874e+06) market_cap_change_percentage_24h:%!s(float64=-1.08042) market_cap_rank:%!s(float64=35) max_supply: name:Ethereum Classic price_change_24h:%!s(float64=-0.05283968) price_change_percentage_24h:%!s(float64=-1.02372) roi:map[currency:usd percentage:%!s(float64=1035.2706997984462) times:%!s(float64=10.352706997984463)] symbol:etc total_supply:%!s(float64=2.107e+08) total_volume:%!s(float64=4.33797212e+08)]] 2020/09/18 15:46:51 Writing Exchange Data

edradev commented 4 years ago

My ember themplate:

{{format-number stats.model.exchangedata.current_price style='currency' currency='USD'}}

Serpent6877 commented 4 years ago

Go into redis. Then do a "hgetall eth:exchange:eth" you should get all the data. Look for:

15) "current_price" 16) "5.18"

25) "symbol" 26) "eth"

And other data you will want to use in your site. Then look at your stats. http:///api/stats

You should see exchange data:

"exchangedata":{"ath":"1448.18","ath_change_percentage":"-73.67712","ath_date":"2018-01-13T00:00:00.000Z","atl":"0.432979","atl_change_percentage":"87941.91954","atl_date":"2015-10-20T00:00:00.000Z","circulating_supply":"1.126549315615e+08","current_price":"382.65","fully_diluted_valuation":"\u003cnil\u003e","high_24h":"393.8","id":"ethereum","image":"https://assets.coingecko.com/coins/images/279/large/ethereum.png?1595348880","last_updated":"2020-09-18T16:34:56.855Z","low_24h":"379.34","market_cap":"4.3085909665e+10","market_cap_change_24h":"3.61962255e+08","market_cap_change_percentage_24h":"0.84721","market_cap_rank":"2","max_supply":"\u003cnil\u003e","name":"Ethereum","price_change_24h":"2.86","price_change_percentage_24h":"0.75216","roi":"map[currency:btc percentage:4604.829918446882 times:46.048299184468824]","symbol":"eth","total_supply":"\u003cnil\u003e","total_volume":"1.3522348787e+10"

edradev commented 4 years ago

hgetall eth:exchange:eth

When I do http:///api/stats, result:

{"candidatesTotal":0,"exchangedata":{},"hashrate":5054383666,"immatureTotal":8,"maturedTotal":0,"minersTotal":4,"nodes":[{"difficulty":"21845604165879","height":"11229137","lastBeat":"1600448453","name":"main"}],"now":1600448455000,"stats":{"currentRoundShares":12499,"lastBlockFound":1600438538,"lastNValue":11888,"nShares":11888,"roundShares":11888}}

//is there any way to PM you privately, after that will provide solution here

edradev commented 4 years ago

Sure. Find me on Discord. BradD#2334

I sent you a friend request a few days ago. I wrote to you, but you do not answer. eradev#8004

Serpent6877 commented 4 years ago

Additionally you need to have lowercase coin-name in your api config file. This name must match the coin in the "symbol" variable as listed above.