mirror of
https://github.com/LBRYFoundation/lbry-sdk.git
synced 2025-09-03 20:35:09 +00:00
remove fee checking from autofetcher script
This commit is contained in:
parent
d469ef7bf2
commit
49c26a76b4
1 changed files with 0 additions and 22 deletions
|
@ -2,13 +2,10 @@ import json
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import requests
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
from appdirs import user_data_dir
|
from appdirs import user_data_dir
|
||||||
from twisted.internet.task import LoopingCall
|
from twisted.internet.task import LoopingCall
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
from twisted.internet.threads import deferToThread
|
|
||||||
|
|
||||||
|
|
||||||
if sys.platform != "darwin":
|
if sys.platform != "darwin":
|
||||||
|
@ -42,15 +39,11 @@ class Autofetcher(object):
|
||||||
def __init__(self, api):
|
def __init__(self, api):
|
||||||
self._api = api
|
self._api = api
|
||||||
self._checker = LoopingCall(self._check_for_new_claims)
|
self._checker = LoopingCall(self._check_for_new_claims)
|
||||||
self._price_checker = LoopingCall(self._update_price)
|
|
||||||
self.best_block = None
|
self.best_block = None
|
||||||
self.last_price = None
|
|
||||||
self.price_updated = None
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
reactor.addSystemEventTrigger('before', 'shutdown', self.stop)
|
reactor.addSystemEventTrigger('before', 'shutdown', self.stop)
|
||||||
self._checker.start(5)
|
self._checker.start(5)
|
||||||
self._price_checker.start(30)
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
log.info("Stopping autofetcher")
|
log.info("Stopping autofetcher")
|
||||||
|
@ -66,24 +59,9 @@ class Autofetcher(object):
|
||||||
c = self._api.get_claims_for_tx({'txid': t})
|
c = self._api.get_claims_for_tx({'txid': t})
|
||||||
if len(c):
|
if len(c):
|
||||||
for i in c:
|
for i in c:
|
||||||
if 'fee' in json.loads(i['value']):
|
|
||||||
|
|
||||||
log.info("Downloading stream for claim txid: %s" % t)
|
log.info("Downloading stream for claim txid: %s" % t)
|
||||||
self._api.get({'name': t, 'stream_info': json.loads(i['value'])})
|
self._api.get({'name': t, 'stream_info': json.loads(i['value'])})
|
||||||
|
|
||||||
def _update_price(self):
|
|
||||||
def _check_bittrex():
|
|
||||||
try:
|
|
||||||
r = requests.get("https://bittrex.com/api/v1.1/public/getticker", {'market': 'BTC-LBC'})
|
|
||||||
self.last_price = json.loads(r.text)['result']['Last']
|
|
||||||
self.price_updated = datetime.now()
|
|
||||||
log.info("Updated exchange rate, last BTC-LBC trade: %f" % self.last_price)
|
|
||||||
except:
|
|
||||||
log.info("Failed to update exchange rate")
|
|
||||||
self.last_price = None
|
|
||||||
self.price_updated = datetime.now()
|
|
||||||
return deferToThread(_check_bittrex)
|
|
||||||
|
|
||||||
|
|
||||||
def run(api):
|
def run(api):
|
||||||
fetcher = Autofetcher(api)
|
fetcher = Autofetcher(api)
|
||||||
|
|
Loading…
Add table
Reference in a new issue