balconfig
This commit is contained in:
@@ -8,31 +8,31 @@ from electrum import constants
|
||||
from electrum.logging import get_logger
|
||||
from electrum.gui.qt.util import WaitingDialog
|
||||
from electrum.i18n import _
|
||||
|
||||
from .bal import BalPlugin
|
||||
from .util import Util
|
||||
|
||||
DEFAULT_TIMEOUT = 5
|
||||
_logger = get_logger(__name__)
|
||||
class Willexecutors:
|
||||
def get_willexecutors(bal_plugin, update = False,bal_window=False,force=False,task=True):
|
||||
willexecutors = bal_plugin.config_get(bal_plugin.WILLEXECUTORS)
|
||||
willexecutors = bal_plugin.WILLEXECUTORS.get()
|
||||
for w in willexecutors:
|
||||
Willexecutors.initialize_willexecutor(willexecutors[w],w)
|
||||
|
||||
bal=bal_plugin.DEFAULT_SETTINGS[bal_plugin.WILLEXECUTORS]
|
||||
bal = bal_plugin.WILLEXECUTORS.default
|
||||
for bal_url,bal_executor in bal.items():
|
||||
if not bal_url in willexecutors:
|
||||
_logger.debug("replace bal")
|
||||
willexecutors[bal_url]=bal_executor
|
||||
_logger.debug(f"force add {bal_url} willexecutor")
|
||||
willexecutors[bal_url] = bal_executor
|
||||
if update:
|
||||
found = False
|
||||
for url,we in willexecutors.items():
|
||||
if Willexecutors.is_selected(we):
|
||||
found = True
|
||||
if found or force:
|
||||
if bal_plugin.config_get(bal_plugin.PING_WILLEXECUTORS) or force:
|
||||
if bal_plugin.PING_WILLEXECUTORS.get() or force:
|
||||
ping_willexecutors = True
|
||||
if bal_plugin.config_get(bal_plugin.ASK_PING_WILLEXECUTORS) and not force:
|
||||
if bal_plugin.ASK_PING_WILLEXECUTORS.get() and not force:
|
||||
ping_willexecutors = bal_window.window.question(_("Contact willexecutors servers to update payment informations?"))
|
||||
if ping_willexecutors:
|
||||
if task:
|
||||
@@ -40,6 +40,9 @@ class Willexecutors:
|
||||
else:
|
||||
bal_window.ping_willexecutors_task(willexecutors)
|
||||
return willexecutors
|
||||
def get_willexecutors_as_sorted_list(bal_plugin,update=False,bal_window=False,force=False,task=True):
|
||||
willexecutors=Willexecutors.get_willexecutors(bal_plugin,update,bal_window,force,task)
|
||||
return sorted(willexecutors,key=lambda w:w[1].get('sort',0))
|
||||
|
||||
def is_selected(willexecutor,value=None):
|
||||
if not willexecutor:
|
||||
@@ -90,7 +93,7 @@ class Willexecutors:
|
||||
raise ErrorConnectingServer('You are offline.')
|
||||
_logger.debug(f'<-- {method} {url} {data}')
|
||||
headers = {}
|
||||
headers['user-agent'] = 'BalPlugin'
|
||||
headers['user-agent'] = f"BalPlugin v:{BalPlugin.version()}"
|
||||
headers['Content-Type']='text/plain'
|
||||
|
||||
try:
|
||||
@@ -216,3 +219,22 @@ class Willexecutors:
|
||||
except Exception as e:
|
||||
_logger.error(f"error contacting {url} for checking txs {e}")
|
||||
raise e
|
||||
|
||||
class WillExecutor:
|
||||
def __init__(self,url,base_fee,chain,info,version):
|
||||
self.url = url
|
||||
self.base_fee = base_fee
|
||||
self.chain = chain
|
||||
self.info = info
|
||||
self.version = version
|
||||
|
||||
def from_dict(d):
|
||||
we = WillExecutor(
|
||||
d['url'],
|
||||
d['base_fee'],
|
||||
d['chain'],
|
||||
d['info'],
|
||||
d['version']
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user