def update(self): """Get the latest state of the sensor.""" stats = flexpoolapi.miner(self._address).stats() hashrate = 0 if self._type == "average": hashrate = stats.average_effective_hashrate elif self._type == "effective": hashrate = stats.current_effective_hashrate elif self._type == "reported": hashrate = stats.current_reported_hashrate self._state, self._unit = get_hashrate(hashrate)
def update(self): """Get the latest state of the sensor.""" workers = flexpoolapi.miner(self._address).workers() hashrate = 0 # Ugly but I don't think there is another way for worker in workers: if worker.worker_name != self._worker_name: continue if self._type == "effective": hashrate, _ = worker.current_hashrate() elif self._type == "reported": _, hashrate = worker.current_hashrate() break self._state, self._unit = get_hashrate(hashrate)
def update(self): """Get the latest state of the sensor.""" workers = flexpoolapi.miner(self._address).workers() shares = 0 # Ugly but I don't think there is another way for worker in workers: if worker.worker_name != self._worker_name: continue if self._type == "total": stats = worker.stats() shares = stats.valid_shares + stats.stale_shares + stats.invalid_shares elif self._type == "valid": shares = worker.stats().valid_shares break self._state = shares
def add_workers_sensors_loop(address, async_add_entities): """Get workers and add sensors.""" sensors = [] workers = flexpoolapi.miner(address).workers() for worker in workers: sensors.append( FlexpoolWorkerHashrateSensor("flexpool_worker_reported", address, worker.worker_name)) sensors.append( FlexpoolWorkerHashrateSensor("flexpool_worker_effective", address, worker.worker_name)) sensors.append( FlexpoolWorkerShareSensor("flexpool_worker_daily_valid", address, worker.worker_name)) sensors.append( FlexpoolWorkerShareSensor("flexpool_worker_daily_total", address, worker.worker_name)) async_add_entities(sensors, True)
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, # and to permit persons to whom the Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all copies or substantial portions of # the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO # THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # import flexpoolapi miner = flexpoolapi.miner(flexpoolapi.pool.top_miners()[0].address) print("Using address", miner.address, "(Top miner)") print("\nWorker Count:", miner.worker_count()) print("\n---WORKERS---\n") for worker in miner.workers(): print("Worker Name:", worker.worker_name + ",", "is online:", worker.is_online) print("Last seen:", worker.last_seen_date) current_effective, current_reported = worker.current_hashrate() print("Worker Effective hashrate", current_effective) print("Worker Reported hashrate", current_reported) print("Stats:", worker.stats())
def setup_class(self): flexpoolapi.set_base_endpoint("http://localhost:5000/api/v1") self.miner_api = flexpoolapi.miner(simdata.MINER_ADDRESS)
import flexpoolapi import pygsheets import cryptocompare # ETH Price # cryptocompare.get_price('ETH', curr='USD', full=True, exchange='Coinbase') # Pool # flexpoolapi.pool.hashrate() # flexpoolapi.pool.miners_online() # flexpoolapi.pool.workers_online() # Miner # TODO Replace with your miner address here: miner = flexpoolapi.miner("0x5400c6A42F522ed2F996F25dD468d6d70e065035") # Initialize Google Sheets # TODO Follow the instructions here to download a client_secret.json file # (Enable the Google Drive API and the Google Sheets API for your Google developer account and create a OAuth 2.0 Client ID on Google API with type "Desktop") # https://pygsheets.readthedocs.io/en/stable/authorization.html client = pygsheets.authorize() # TODO Look at the console window, follow the link and authorize the authentication (first time only) # TODO Replace with your Google Sheet url here: sh = client.open_by_url( "https://docs.google.com/spreadsheets/d/1_Hyl4bFd4K2xdYm2YQf3VLd5xkLQiSOeGIJvJWyukyw/edit#gid=1648906181" ) wks = sh.sheet1 # Save data in Sheet 1 or the first sheet
def update(self): """Get the latest state of the sensor.""" miner = flexpoolapi.miner(self._address) balance = round(miner.balance() / 1000000000000000000, 4) self._state = balance
import csv, pandas as pd, flexpoolapi as fp #conversion from wei to eth eth = .000000000000000001 #conversion from hash/s to megahash/s hash = .000001 #declare your worker miner = fp.miner("INSERT WALLET ADDRESS OF WORKER HERE") #eth balance mb = miner.balance() * eth #effective hashrate in mgh/s hr = miner.daily_average_stats().effective_hashrate * hash #estimated daily revenue in eth mdr = miner.estimated_daily_revenue() * eth #valid shares vshares = miner.daily_average_stats().valid_shares #stale shares sshares = miner.daily_average_stats().stale_shares #invalid shares ishares = miner.daily_average_stats().invalid_shares #pool luck % and roundtime in minutes luck, rt = fp.pool.avg_luck_roundtime()
def miner(address): r = requests.get(f"https://flexpool.io/{address}/exists") if r.status_code == 404: return redirect(url_for("index")) else: pass # Address Hyperlink - Etherscan: etherscan_link = f"https://etherscan.io/address/{address}" # Address - Mobile Formatting: address_mobile = f"{address[:8]}...{address[-6:]}" # Miner Variable: miner = flexpoolapi.miner(address) # API Constants: details = miner.details() workers = miner.worker_count() unpaid = miner.balance() stats = miner.stats() # Miner Details: minimum_payout = (details.min_payout_threshold) / 10**18 pool_donation = (details.pool_donation) * 100 # Miner Worker Count: workers_online = workers["online"] workers_offline = workers["offline"] # Miner Balance: unpaid_balance = round((unpaid) / 10**18, 6) # Percentage of Unpaid Balance Mined by Miner: percentage = round(((unpaid_balance) / (minimum_payout)) * 100, 2) # Miner Stats: current_effective = round((stats.current_effective_hashrate) / 10**6, 2) current_reported = round((stats.current_reported_hashrate) / 10**6, 2) average_effective = round((stats.average_effective_hashrate) / 10**6, 2) valid = (stats.valid_shares) stale = (stats.stale_shares) invalid = (stats.invalid_shares) ETHERSCAN_KEY = environ.get("ETHERSCAN_KEY") client = Etherscan(ETHERSCAN_KEY) gas_prices = client.get_gas_oracle() slow = gas_prices.get('SafeGasPrice') normal = gas_prices.get('ProposeGasPrice') fast = gas_prices.get('FastGasPrice') return render_template("miner.html", etherscan=etherscan_link, address=address, address_mobile=address_mobile, minimum_payout=minimum_payout, pool_donation=pool_donation, workers_online=workers_online, workers_offline=workers_offline, unpaid_balance=unpaid_balance, percentage_mined=percentage, current_effective=current_effective, current_reported=current_reported, average_effective=average_effective, valid_shares=valid, stale_shares=stale, invalid_shares=invalid, slow=slow, normal=normal, fast=fast)