Update daemon

This commit is contained in:
Jack 2016-02-11 08:32:48 -05:00
parent 9ba12b3e3f
commit 407ebeb699
4 changed files with 47 additions and 12 deletions

View file

@ -359,6 +359,9 @@ class LBRYcrdWallet(object):
def get_nametrie(self): def get_nametrie(self):
return self._get_nametrie() return self._get_nametrie()
# def update_name(self, name_value):
# return self._update_name(name_value)
def get_name_and_validity_for_sd_hash(self, sd_hash): def get_name_and_validity_for_sd_hash(self, sd_hash):
d = self._get_claim_metadata_for_sd_hash(sd_hash) d = self._get_claim_metadata_for_sd_hash(sd_hash)
d.addCallback(lambda name_txid: threads.deferToThread(self._get_status_of_claim, name_txid[1], name_txid[0], sd_hash) if name_txid is not None else None) d.addCallback(lambda name_txid: threads.deferToThread(self._get_status_of_claim, name_txid[1], name_txid[0], sd_hash) if name_txid is not None else None)
@ -607,6 +610,10 @@ class LBRYcrdWallet(object):
else: else:
raise ValueError raise ValueError
# def _update_name(self, name_value):
# rpc_conn = self._get_rpc_conn()
# return rpc_conn.updatename(name_value)
@_catch_connection_error @_catch_connection_error
def _claim_name(self, name, value, amount): def _claim_name(self, name, value, amount):
rpc_conn = self._get_rpc_conn() rpc_conn = self._get_rpc_conn()

View file

@ -27,6 +27,7 @@ import sys
import json import json
import binascii import binascii
import webbrowser import webbrowser
import xmlrpclib
from decimal import Decimal from decimal import Decimal
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -98,7 +99,7 @@ class LBRYDaemon(xmlrpc.XMLRPC):
os.mkdir(self.db_dir) os.mkdir(self.db_dir)
self.created_data_dir = True self.created_data_dir = True
self.session_settings = None self.session_settings = None
self.data_rate = 0.5 self.data_rate = MIN_BLOB_DATA_PAYMENT_RATE
self.max_key_fee = 100.0 self.max_key_fee = 100.0
self.query_handlers = {} self.query_handlers = {}
@ -424,8 +425,11 @@ class LBRYDaemon(xmlrpc.XMLRPC):
l = json.loads(f.read()) l = json.loads(f.read())
f.close() f.close()
file_name = l['stream_name'].decode('hex') file_name = l['stream_name'].decode('hex')
lbry_file = [file for file in self.lbry_file_manager.lbry_files if file.stream_name == file_name][0] lbry_file = [file for file in self.lbry_file_manager.lbry_files if file.stream_name == file_name]
return lbry_file if lbry_file:
return lbry_file[0]
else:
return None
def _check(info): def _check(info):
stream_hash = info['stream_hash'] stream_hash = info['stream_hash']
@ -543,7 +547,7 @@ class LBRYDaemon(xmlrpc.XMLRPC):
self.fetcher.start() self.fetcher.start()
print '[' + str(datetime.now()) + '] Start autofetcher' print '[' + str(datetime.now()) + '] Start autofetcher'
return str('Started autofetching') return 'Started autofetching'
def xmlrpc_stop_fetcher(self): def xmlrpc_stop_fetcher(self):
""" """
@ -552,7 +556,7 @@ class LBRYDaemon(xmlrpc.XMLRPC):
self.fetcher.stop() self.fetcher.stop()
print '[' + str(datetime.now()) + '] Stop autofetcher' print '[' + str(datetime.now()) + '] Stop autofetcher'
return str('Started autofetching') return 'Stopped autofetching'
def xmlrpc_fetcher_status(self): def xmlrpc_fetcher_status(self):
""" """
@ -777,7 +781,7 @@ class LBRYDaemon(xmlrpc.XMLRPC):
def xmlrpc_delete_lbry_file(self, file_name): def xmlrpc_delete_lbry_file(self, file_name):
def _disp(file_name): def _disp(file_name):
print '[' + str(datetime.now()) + '] Deleted: ' + file_name print '[' + str(datetime.now()) + '] Deleted: ' + file_name
return defer.succeed(str('Deleted: ' + file_name)) return defer.succeed('Deleted: ' + file_name)
lbry_files = [self._delete_lbry_file(f) for f in self.lbry_file_manager.lbry_files if file_name == f.file_name] lbry_files = [self._delete_lbry_file(f) for f in self.lbry_file_manager.lbry_files if file_name == f.file_name]
d = defer.DeferredList(lbry_files) d = defer.DeferredList(lbry_files)
@ -865,7 +869,7 @@ class LBRYDaemon(xmlrpc.XMLRPC):
def _clean(claims): def _clean(claims):
for c in claims: for c in claims:
for k in c.keys(): for k in c.keys():
if type(c[k]) == Decimal: if isinstance(c[k], Decimal):
c[k] = float(c[k]) c[k] = float(c[k])
return claims return claims
@ -880,6 +884,26 @@ class LBRYDaemon(xmlrpc.XMLRPC):
return d return d
# def xmlrpc_update_name(self, metadata):
# def _disp(x):
# print x
# return x
#
# metadata = json.loads(metadata)
#
# required = ['name', 'file_path', 'bid']
#
# for r in required:
# if not r in metadata.keys():
# return defer.fail()
#
# d = defer.Deferred()
# d.addCallback(lambda _: self.session.wallet.update_name(metadata))
# d.addCallback(_disp)
# d.callback(None)
#
# return d
def xmlrpc_toggle_fetcher_verbose(self): def xmlrpc_toggle_fetcher_verbose(self):
if self.fetcher.verbose: if self.fetcher.verbose:
self.fetcher.verbose = False self.fetcher.verbose = False
@ -890,6 +914,12 @@ class LBRYDaemon(xmlrpc.XMLRPC):
def main(): def main():
try:
d = xmlrpclib.ServerProxy('http://localhost:7080')
d.stop()
except:
pass
daemon = LBRYDaemon() daemon = LBRYDaemon()
daemon.setup() daemon.setup()
reactor.listenTCP(7080, server.Site(daemon)) reactor.listenTCP(7080, server.Site(daemon))

View file

@ -10,10 +10,8 @@ def main():
is_running = False is_running = False
if is_running: if is_running:
try: daemon.stop()
daemon.stop() print "LBRYnet daemon stopped"
except:
print "LBRYnet daemon stopped"
else: else:
print "LBRYnet daemon wasn't running" print "LBRYnet daemon wasn't running"

View file

@ -38,7 +38,7 @@ class Publisher(object):
key_fee=None, key_fee_address=None, content_license=None): key_fee=None, key_fee_address=None, content_license=None):
def _show_result(): def _show_result():
message = "[" + str(datetime.now()) + " ] Published " + self.file_name + " --> lbry://" + \ message = "[" + str(datetime.now()) + "] Published " + self.file_name + " --> lbry://" + \
str(self.publish_name) + " with txid: " + str(self.tx_hash) str(self.publish_name) + " with txid: " + str(self.tx_hash)
print message print message
return defer.succeed(message) return defer.succeed(message)