forked from bitcoinafterlife/bal-electrum-plugin
docs(willexecutors.py): Add comprehensive documentation for methods
This commit is contained in:
@@ -40,12 +40,31 @@ class Willexecutors:
|
|||||||
- Download and update executor lists from remote sources
|
- Download and update executor lists from remote sources
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
"""Save executive list to plugin settings.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
bal_plugin: BAL plugin instance
|
||||||
|
willexecutors: Dictionary of executors by URL
|
||||||
|
"""
|
||||||
def save(bal_plugin, willexecutors):
|
def save(bal_plugin, willexecutors):
|
||||||
_logger.debug(f"save {willexecutors},{chainname}")
|
_logger.debug(f"save {willexecutors},{chainname}")
|
||||||
aw = bal_plugin.WILLEXECUTORS.get()
|
aw = bal_plugin.WILLEXECUTORS.get()
|
||||||
aw[chainname] = willexecutors
|
aw[chainname] = willexecutors
|
||||||
bal_plugin.WILLEXECUTORS.set(aw)
|
bal_plugin.WILLEXECUTORS.set(aw)
|
||||||
_logger.debug(f"saved: {aw}")
|
_logger.debug(f"saved: {aw}")
|
||||||
|
"""
|
||||||
|
Retrieve and update executor list.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
bal_plugin: BAL plugin instance
|
||||||
|
update: Ping servers for fresh data
|
||||||
|
bal_window: GUI window for prompts
|
||||||
|
force: Force update regardless of settings
|
||||||
|
task: Run as background task
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Sorted dict of executor configurations
|
||||||
|
"""
|
||||||
# bal_plugin.WILLEXECUTORS.set(willexecutors)
|
# bal_plugin.WILLEXECUTORS.set(willexecutors)
|
||||||
|
|
||||||
def get_willexecutors(
|
def get_willexecutors(
|
||||||
@@ -101,6 +120,16 @@ class Willexecutors:
|
|||||||
|
|
||||||
def is_selected(willexecutor, value=None):
|
def is_selected(willexecutor, value=None):
|
||||||
if not willexecutor:
|
if not willexecutor:
|
||||||
|
"""
|
||||||
|
Check or set executor selection status.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
willexecutor: Executor config dict
|
||||||
|
value: Selection value to set (optional)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Boolean selection status
|
||||||
|
"""
|
||||||
return False
|
return False
|
||||||
if value is not None:
|
if value is not None:
|
||||||
willexecutor["selected"] = value
|
willexecutor["selected"] = value
|
||||||
@@ -146,6 +175,22 @@ class Willexecutors:
|
|||||||
# )
|
# )
|
||||||
|
|
||||||
def send_request(
|
def send_request(
|
||||||
|
"""
|
||||||
|
Send HTTP request to executor server.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
method: HTTP method (get/post)
|
||||||
|
url: Target URL
|
||||||
|
data: Request payload
|
||||||
|
timeout: Timeout in seconds
|
||||||
|
handle_response: Response handler function
|
||||||
|
count_reply: Retry counter
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Server response
|
||||||
|
|
||||||
|
Retries up to 10 times on timeout.
|
||||||
|
"""
|
||||||
method, url, data=None, *, timeout=10, handle_response=None, count_reply=0
|
method, url, data=None, *, timeout=10, handle_response=None, count_reply=0
|
||||||
):
|
):
|
||||||
network = Network.get_instance()
|
network = Network.get_instance()
|
||||||
@@ -221,6 +266,18 @@ class Willexecutors:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def push_transactions_to_willexecutor(willexecutor):
|
def push_transactions_to_willexecutor(willexecutor):
|
||||||
|
"""
|
||||||
|
Push timelocked transactions to executor.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
willexecutor: Executor dict with url and txs
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
True on success, False on failure
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
AlreadyPresentException: If txs already exist
|
||||||
|
"""
|
||||||
out = True
|
out = True
|
||||||
try:
|
try:
|
||||||
_logger.debug(f"{willexecutor['url']}: {willexecutor['txs']}")
|
_logger.debug(f"{willexecutor['url']}: {willexecutor['txs']}")
|
||||||
@@ -251,6 +308,16 @@ class Willexecutors:
|
|||||||
|
|
||||||
def get_info_task(url, willexecutor):
|
def get_info_task(url, willexecutor):
|
||||||
w = None
|
w = None
|
||||||
|
"""
|
||||||
|
Fetch executor info from server.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
url: Server URL
|
||||||
|
willexecutor: Config dict to update
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Updated config with fee, address, status
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
_logger.info("GETINFO_WILLEXECUTOR")
|
_logger.info("GETINFO_WILLEXECUTOR")
|
||||||
_logger.debug(url)
|
_logger.debug(url)
|
||||||
@@ -286,6 +353,15 @@ class Willexecutors:
|
|||||||
willexecutors = Willexecutors.send_request(
|
willexecutors = Willexecutors.send_request(
|
||||||
"get",
|
"get",
|
||||||
f"https://welist.bitcoin-after.life/data/{chainname}?page=0&limit=100",
|
f"https://welist.bitcoin-after.life/data/{chainname}?page=0&limit=100",
|
||||||
|
"""
|
||||||
|
Download executor list from remote source.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
old_willexecutors: Previous configs for merge
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Dictionary of executor configs
|
||||||
|
"""
|
||||||
)
|
)
|
||||||
# del willexecutors["status"]
|
# del willexecutors["status"]
|
||||||
for w in willexecutors:
|
for w in willexecutors:
|
||||||
|
|||||||
Reference in New Issue
Block a user