use electrum as default
This commit is contained in:
parent
671e6da104
commit
b0bfb5e443
2 changed files with 27 additions and 77 deletions
|
@ -96,8 +96,9 @@ class CryptStreamDownloader(object):
|
||||||
self.starting = True
|
self.starting = True
|
||||||
self.completed = False
|
self.completed = False
|
||||||
self.finished_deferred = defer.Deferred()
|
self.finished_deferred = defer.Deferred()
|
||||||
|
fd = self.finished_deferred
|
||||||
d = self._start()
|
d = self._start()
|
||||||
d.addCallback(lambda _: self.finished_deferred)
|
d.addCallback(lambda _: fd)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def stop(self, err=None):
|
def stop(self, err=None):
|
||||||
|
|
|
@ -7,8 +7,6 @@ import locale
|
||||||
import sys
|
import sys
|
||||||
from yapsy.PluginManager import PluginManager
|
from yapsy.PluginManager import PluginManager
|
||||||
from twisted.internet import defer, threads, stdio, task, error
|
from twisted.internet import defer, threads, stdio, task, error
|
||||||
from twisted.python.failure import Failure
|
|
||||||
# from lbrynet.core.client.AutoDownloader import AutoFetcher
|
|
||||||
from lbrynet.lbrynet_console.ConsoleControl import ConsoleControl
|
from lbrynet.lbrynet_console.ConsoleControl import ConsoleControl
|
||||||
from lbrynet.lbrynet_console.LBRYSettings import LBRYSettings
|
from lbrynet.lbrynet_console.LBRYSettings import LBRYSettings
|
||||||
from lbrynet.lbryfilemanager.LBRYFileManager import LBRYFileManager
|
from lbrynet.lbryfilemanager.LBRYFileManager import LBRYFileManager
|
||||||
|
@ -24,10 +22,8 @@ from lbrynet.lbryfile.client.LBRYFileOptions import add_lbry_file_to_sd_identifi
|
||||||
from lbrynet.lbryfile.client.LBRYFileDownloader import LBRYFileOpenerFactory
|
from lbrynet.lbryfile.client.LBRYFileDownloader import LBRYFileOpenerFactory
|
||||||
from lbrynet.lbryfile.StreamDescriptor import LBRYFileStreamType
|
from lbrynet.lbryfile.StreamDescriptor import LBRYFileStreamType
|
||||||
from lbrynet.lbryfile.LBRYFileMetadataManager import DBLBRYFileMetadataManager, TempLBRYFileMetadataManager
|
from lbrynet.lbryfile.LBRYFileMetadataManager import DBLBRYFileMetadataManager, TempLBRYFileMetadataManager
|
||||||
#from lbrynet.lbrylive.PaymentRateManager import LiveStreamPaymentRateManager
|
|
||||||
from lbrynet.lbrynet_console.ControlHandlers import ApplicationStatusFactory, GetWalletBalancesFactory, ShutDownFactory
|
from lbrynet.lbrynet_console.ControlHandlers import ApplicationStatusFactory, GetWalletBalancesFactory, ShutDownFactory
|
||||||
#from lbrynet.lbrynet_console.ControlHandlers import AutoFetcherStartFactory, AutoFetcherStopFactory
|
from lbrynet.lbrynet_console.ControlHandlers import ImmediateAnnounceAllBlobsFactory
|
||||||
from lbrynet.lbrynet_console.ControlHandlers import ImmediateAnnounceAllBlobsFactory #, AutoFetcherStatusFactory
|
|
||||||
from lbrynet.lbrynet_console.ControlHandlers import LBRYFileStatusFactory, DeleteLBRYFileChooserFactory
|
from lbrynet.lbrynet_console.ControlHandlers import LBRYFileStatusFactory, DeleteLBRYFileChooserFactory
|
||||||
from lbrynet.lbrynet_console.ControlHandlers import ToggleLBRYFileRunningChooserFactory
|
from lbrynet.lbrynet_console.ControlHandlers import ToggleLBRYFileRunningChooserFactory
|
||||||
from lbrynet.lbrynet_console.ControlHandlers import ModifyApplicationDefaultsFactory
|
from lbrynet.lbrynet_console.ControlHandlers import ModifyApplicationDefaultsFactory
|
||||||
|
@ -50,9 +46,9 @@ alert = logging.getLogger("lbryalert." + __name__)
|
||||||
|
|
||||||
class LBRYConsole():
|
class LBRYConsole():
|
||||||
"""A class which can upload and download file streams to and from the network"""
|
"""A class which can upload and download file streams to and from the network"""
|
||||||
def __init__(self, peer_port, dht_node_port, known_dht_nodes, wallet_type,
|
def __init__(self, peer_port, dht_node_port, known_dht_nodes, fake_wallet,
|
||||||
lbrycrd_conf, lbrycrd_dir, use_upnp, data_dir, created_data_dir,
|
lbrycrd_conf, lbrycrd_dir, use_upnp, data_dir, created_data_dir,
|
||||||
lbrycrdd_path, start_lbrycrdd):
|
lbrycrdd_path):
|
||||||
"""
|
"""
|
||||||
@param peer_port: the network port on which to listen for peers
|
@param peer_port: the network port on which to listen for peers
|
||||||
|
|
||||||
|
@ -63,7 +59,7 @@ class LBRYConsole():
|
||||||
self.peer_port = peer_port
|
self.peer_port = peer_port
|
||||||
self.dht_node_port = dht_node_port
|
self.dht_node_port = dht_node_port
|
||||||
self.known_dht_nodes = known_dht_nodes
|
self.known_dht_nodes = known_dht_nodes
|
||||||
self.wallet_type = wallet_type
|
self.fake_wallet = fake_wallet
|
||||||
self.lbrycrd_conf = lbrycrd_conf
|
self.lbrycrd_conf = lbrycrd_conf
|
||||||
self.lbrycrd_dir = lbrycrd_dir
|
self.lbrycrd_dir = lbrycrd_dir
|
||||||
if not self.lbrycrd_dir:
|
if not self.lbrycrd_dir:
|
||||||
|
@ -73,10 +69,7 @@ class LBRYConsole():
|
||||||
self.lbrycrd_dir = os.path.join(os.path.expanduser("~"), ".lbrycrd")
|
self.lbrycrd_dir = os.path.join(os.path.expanduser("~"), ".lbrycrd")
|
||||||
if not self.lbrycrd_conf:
|
if not self.lbrycrd_conf:
|
||||||
self.lbrycrd_conf = os.path.join(self.lbrycrd_dir, "lbrycrd.conf")
|
self.lbrycrd_conf = os.path.join(self.lbrycrd_dir, "lbrycrd.conf")
|
||||||
# self.autofetcher_conf = os.path.join(self.lbrycrd_dir, "autofetcher.conf")
|
|
||||||
self.lbrycrdd_path = lbrycrdd_path
|
self.lbrycrdd_path = lbrycrdd_path
|
||||||
self.default_lbrycrdd_path = "./lbrycrdd"
|
|
||||||
self.start_lbrycrdd = start_lbrycrdd
|
|
||||||
self.use_upnp = use_upnp
|
self.use_upnp = use_upnp
|
||||||
self.lbry_server_port = None
|
self.lbry_server_port = None
|
||||||
self.session = None
|
self.session = None
|
||||||
|
@ -100,7 +93,6 @@ class LBRYConsole():
|
||||||
self.sd_identifier = StreamDescriptorIdentifier()
|
self.sd_identifier = StreamDescriptorIdentifier()
|
||||||
self.plugin_objects = []
|
self.plugin_objects = []
|
||||||
self.db_migration_revisions = None
|
self.db_migration_revisions = None
|
||||||
# self.autofetcher = None
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
"""Initialize the session and restore everything to its saved state"""
|
"""Initialize the session and restore everything to its saved state"""
|
||||||
|
@ -112,7 +104,6 @@ class LBRYConsole():
|
||||||
d.addCallback(lambda _: add_lbry_file_to_sd_identifier(self.sd_identifier))
|
d.addCallback(lambda _: add_lbry_file_to_sd_identifier(self.sd_identifier))
|
||||||
d.addCallback(lambda _: self._setup_lbry_file_manager())
|
d.addCallback(lambda _: self._setup_lbry_file_manager())
|
||||||
d.addCallback(lambda _: self._setup_lbry_file_opener())
|
d.addCallback(lambda _: self._setup_lbry_file_opener())
|
||||||
#d.addCallback(lambda _: self._get_autofetcher())
|
|
||||||
d.addCallback(lambda _: self._setup_control_handlers())
|
d.addCallback(lambda _: self._setup_control_handlers())
|
||||||
d.addCallback(lambda _: self._setup_query_handlers())
|
d.addCallback(lambda _: self._setup_query_handlers())
|
||||||
d.addCallback(lambda _: self._load_plugins())
|
d.addCallback(lambda _: self._load_plugins())
|
||||||
|
@ -121,10 +112,6 @@ class LBRYConsole():
|
||||||
d.addErrback(self._show_start_error)
|
d.addErrback(self._show_start_error)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
# def _get_autofetcher(self):
|
|
||||||
# self.autofetcher = AutoFetcher(self.session, self.lbry_file_manager, self.lbry_file_metadata_manager,
|
|
||||||
# self.session.wallet, self.sd_identifier, self.autofetcher_conf)
|
|
||||||
|
|
||||||
def _show_start_error(self, error):
|
def _show_start_error(self, error):
|
||||||
print error.getTraceback()
|
print error.getTraceback()
|
||||||
log.error("An error occurred during start up: %s", error.getTraceback())
|
log.error("An error occurred during start up: %s", error.getTraceback())
|
||||||
|
@ -201,30 +188,6 @@ class LBRYConsole():
|
||||||
d = self.settings.start()
|
d = self.settings.start()
|
||||||
d.addCallback(lambda _: self.settings.get_lbryid())
|
d.addCallback(lambda _: self.settings.get_lbryid())
|
||||||
d.addCallback(self.set_lbryid)
|
d.addCallback(self.set_lbryid)
|
||||||
d.addCallback(lambda _: self.get_lbrycrdd_path())
|
|
||||||
return d
|
|
||||||
|
|
||||||
def get_lbrycrdd_path(self):
|
|
||||||
|
|
||||||
if not self.start_lbrycrdd:
|
|
||||||
return defer.succeed(None)
|
|
||||||
|
|
||||||
def get_lbrycrdd_path_conf_file():
|
|
||||||
lbrycrdd_path_conf_path = os.path.join(os.path.expanduser("~"), ".lbrycrddpath.conf")
|
|
||||||
if not os.path.exists(lbrycrdd_path_conf_path):
|
|
||||||
return ""
|
|
||||||
lbrycrdd_path_conf = open(lbrycrdd_path_conf_path)
|
|
||||||
lines = lbrycrdd_path_conf.readlines()
|
|
||||||
return lines
|
|
||||||
|
|
||||||
d = threads.deferToThread(get_lbrycrdd_path_conf_file)
|
|
||||||
|
|
||||||
def load_lbrycrdd_path(conf):
|
|
||||||
for line in conf:
|
|
||||||
if len(line.strip()) and line.strip()[0] != "#":
|
|
||||||
self.lbrycrdd_path = line.strip()
|
|
||||||
|
|
||||||
d.addCallback(load_lbrycrdd_path)
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def set_lbryid(self, lbryid):
|
def set_lbryid(self, lbryid):
|
||||||
|
@ -245,21 +208,14 @@ class LBRYConsole():
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def get_wallet():
|
def get_wallet():
|
||||||
if self.wallet_type == "lbrycrd":
|
if self.fake_wallet:
|
||||||
lbrycrdd_path = None
|
d = defer.succeed(PTCWallet(self.db_dir))
|
||||||
if self.start_lbrycrdd is True:
|
elif self.lbrycrdd_path is not None:
|
||||||
lbrycrdd_path = self.lbrycrdd_path
|
|
||||||
if not lbrycrdd_path:
|
|
||||||
lbrycrdd_path = self.default_lbrycrdd_path
|
|
||||||
d = defer.succeed(LBRYcrdWallet(self.db_dir, wallet_dir=self.lbrycrd_dir,
|
d = defer.succeed(LBRYcrdWallet(self.db_dir, wallet_dir=self.lbrycrd_dir,
|
||||||
wallet_conf=self.lbrycrd_conf,
|
wallet_conf=self.lbrycrd_conf,
|
||||||
lbrycrdd_path=lbrycrdd_path))
|
lbrycrdd_path=self.lbrycrdd_path))
|
||||||
elif self.wallet_type == 'ptc':
|
|
||||||
d = defer.succeed(PTCWallet(self.db_dir))
|
|
||||||
elif self.wallet_type == 'lbryum':
|
|
||||||
d = defer.succeed(LBRYumWallet(self.db_dir))
|
|
||||||
else:
|
else:
|
||||||
d = defer.fail(Failure(ValueError("Invalid wallet type")))
|
d = defer.succeed(LBRYumWallet(self.db_dir))
|
||||||
d.addCallback(lambda wallet: {"wallet": wallet})
|
d.addCallback(lambda wallet: {"wallet": wallet})
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
@ -377,14 +333,11 @@ class LBRYConsole():
|
||||||
ModifyLBRYFileOptionsChooserFactory(self.lbry_file_manager),
|
ModifyLBRYFileOptionsChooserFactory(self.lbry_file_manager),
|
||||||
AddStreamFromHashFactory(self.sd_identifier, self.session, self.session.wallet),
|
AddStreamFromHashFactory(self.sd_identifier, self.session, self.session.wallet),
|
||||||
StatusFactory(self, self.session.rate_limiter, self.lbry_file_manager,
|
StatusFactory(self, self.session.rate_limiter, self.lbry_file_manager,
|
||||||
self.session.blob_manager, self.session.wallet if self.wallet_type in ['lbrycrd', 'lbryum'] else None),
|
self.session.blob_manager, self.session.wallet if not self.fake_wallet else None),
|
||||||
# AutoFetcherStartFactory(self.autofetcher),
|
|
||||||
# AutoFetcherStopFactory(self.autofetcher),
|
|
||||||
# AutoFetcherStatusFactory(self.autofetcher),
|
|
||||||
ImmediateAnnounceAllBlobsFactory(self.session.blob_manager)
|
ImmediateAnnounceAllBlobsFactory(self.session.blob_manager)
|
||||||
]
|
]
|
||||||
self.add_control_handlers(handlers)
|
self.add_control_handlers(handlers)
|
||||||
if self.wallet_type in ['lbrycrd', 'lbryum']:
|
if not self.fake_wallet:
|
||||||
lbrycrd_handlers = [
|
lbrycrd_handlers = [
|
||||||
AddStreamFromLBRYcrdNameFactory(self.sd_identifier, self.session,
|
AddStreamFromLBRYcrdNameFactory(self.sd_identifier, self.session,
|
||||||
self.session.wallet),
|
self.session.wallet),
|
||||||
|
@ -524,15 +477,9 @@ def launch_lbry_console():
|
||||||
parser.add_argument("--dht_node_port",
|
parser.add_argument("--dht_node_port",
|
||||||
help="The port on which the console will listen for DHT connections.",
|
help="The port on which the console will listen for DHT connections.",
|
||||||
type=int, default=4444)
|
type=int, default=4444)
|
||||||
parser.add_argument("--wallet_type",
|
parser.add_argument("--fake_wallet",
|
||||||
help="Either 'lbrycrd' or 'ptc' or 'lbryum'.",
|
help="Testing purposes only. Use a non-blockchain wallet.",
|
||||||
type=str, default="lbrycrd")
|
action="store_true")
|
||||||
parser.add_argument("--lbrycrd_wallet_dir",
|
|
||||||
help="The directory in which lbrycrd data will stored. Used if lbrycrdd is "
|
|
||||||
"launched by this application.")
|
|
||||||
parser.add_argument("--lbrycrd_wallet_conf",
|
|
||||||
help="The configuration file for the LBRYcrd wallet. Default: ~/.lbrycrd/lbrycrd.conf",
|
|
||||||
type=str)
|
|
||||||
parser.add_argument("--no_dht_bootstrap",
|
parser.add_argument("--no_dht_bootstrap",
|
||||||
help="Don't try to connect to the DHT",
|
help="Don't try to connect to the DHT",
|
||||||
action="store_true")
|
action="store_true")
|
||||||
|
@ -552,12 +499,15 @@ def launch_lbry_console():
|
||||||
"Default: ~/.lbrynet on linux, ~/Library/Application Support/lbrynet on OS X"),
|
"Default: ~/.lbrynet on linux, ~/Library/Application Support/lbrynet on OS X"),
|
||||||
type=str)
|
type=str)
|
||||||
parser.add_argument("--lbrycrdd_path",
|
parser.add_argument("--lbrycrdd_path",
|
||||||
help="The path to lbrycrdd, which will be launched if it isn't running, unless "
|
help="The path to lbrycrdd, which will be launched if it isn't running. If"
|
||||||
"launching lbrycrdd is disabled by --disable_launch_lbrycrdd. By default, "
|
"this option is chosen, lbrycrdd will be used as the interface to the"
|
||||||
"the file ~/.lbrycrddpath.conf will be checked, and if no path is found "
|
"blockchain. By default, a lightweight interface is used.")
|
||||||
"there, it will be ./lbrycrdd")
|
parser.add_argument("--lbrycrd_wallet_dir",
|
||||||
parser.add_argument("--disable_launch_lbrycrdd",
|
help="The directory in which lbrycrd data will stored. Used if lbrycrdd is "
|
||||||
help="Don't launch lbrycrdd even if it's not running.")
|
"launched by this application.")
|
||||||
|
parser.add_argument("--lbrycrd_wallet_conf",
|
||||||
|
help="The configuration file for the LBRYcrd wallet. Default: ~/.lbrycrd/lbrycrd.conf",
|
||||||
|
type=str)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
@ -599,11 +549,10 @@ def launch_lbry_console():
|
||||||
file_handler.addFilter(logging.Filter("lbrynet"))
|
file_handler.addFilter(logging.Filter("lbrynet"))
|
||||||
logger.addHandler(file_handler)
|
logger.addHandler(file_handler)
|
||||||
|
|
||||||
console = LBRYConsole(peer_port, dht_node_port, bootstrap_nodes, wallet_type=args.wallet_type,
|
console = LBRYConsole(peer_port, dht_node_port, bootstrap_nodes, fake_wallet=args.fake_wallet,
|
||||||
lbrycrd_conf=args.lbrycrd_wallet_conf, lbrycrd_dir=args.lbrycrd_wallet_dir,
|
lbrycrd_conf=args.lbrycrd_wallet_conf, lbrycrd_dir=args.lbrycrd_wallet_dir,
|
||||||
use_upnp=not args.disable_upnp, data_dir=data_dir,
|
use_upnp=not args.disable_upnp, data_dir=data_dir,
|
||||||
created_data_dir=created_data_dir, lbrycrdd_path=args.lbrycrdd_path,
|
created_data_dir=created_data_dir, lbrycrdd_path=args.lbrycrdd_path)
|
||||||
start_lbrycrdd=not args.disable_launch_lbrycrdd)
|
|
||||||
|
|
||||||
d = task.deferLater(reactor, 0, console.start)
|
d = task.deferLater(reactor, 0, console.start)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue