lbry-sdk/lbrynet/lbrynet_daemon/Lighthouse.py
Jack 06a88599df --http-auth flag to use authentication, refactor settings
settings will prefer, in order:
-defaults
-settings in config file
-settings given as environmental variables
-settings given as command line args
2016-10-19 00:12:44 -04:00

27 lines
767 B
Python

import logging
import random
from txjsonrpc.web.jsonrpc import Proxy
from lbrynet import settings
log = logging.getLogger(__name__)
class LighthouseClient(object):
def __init__(self, servers=None):
self.servers = servers or settings.search_servers
def _get_random_server(self):
return Proxy(random.choice(self.servers))
def _run_query(self, func, arg):
return self._get_random_server().callRemote(func, arg)
def search(self, search):
return self._run_query('search', search)
def announce_sd(self, sd_hash):
log.info("Announce sd to lighthouse")
return self._run_query('announce_sd', sd_hash)
def check_available(self, sd_hash):
return self._run_query('check_available', sd_hash)