fix send_request version message

This commit is contained in:
2026-03-18 16:25:59 -04:00
parent a022c413cc
commit 9737221914
5 changed files with 47 additions and 35 deletions

View File

@@ -125,14 +125,14 @@ class Willexecutors:
# )
def send_request(
method, url, data=None, *, timeout=10, handle_response=None, count_reply=0
bal_plugin,method, url, data=None, *, timeout=10, handle_response=None, count_reply=0
):
network = Network.get_instance()
if not network:
raise Exception("You are offline.")
_logger.debug(f"<-- {method} {url} {data}")
headers = {}
headers["user-agent"] = f"BalPlugin v:{BalPlugin.version()}"
headers["user-agent"] = f"BalPlugin v:{bal_plugin.version()}"
headers["Content-Type"] = "text/plain"
if not handle_response:
handle_response = Willexecutors.handle_response
@@ -162,6 +162,7 @@ class Willexecutors:
_logger.debug(f"timeout({count_reply}) error: retry in 3 sec...")
time.sleep(3)
return Willexecutors.send_request(
bal_plugin,
method,
url,
data,
@@ -199,11 +200,12 @@ class Willexecutors:
class AlreadyPresentException(Exception):
pass
def push_transactions_to_willexecutor(willexecutor):
def push_transactions_to_willexecutor(bal_plugin, willexecutor):
out = True
try:
_logger.debug(f"{willexecutor['url']}: {willexecutor['txs']}")
if w := Willexecutors.send_request(
bal_plugin,
"post",
willexecutor["url"] + "/" + chainname + "/pushtxs",
data=willexecutor["txs"].encode("ascii"),
@@ -224,16 +226,16 @@ class Willexecutors:
return out
def ping_servers(willexecutors):
def ping_servers(bal_plugin, willexecutors):
for url, we in willexecutors.items():
Willexecutors.get_info_task(url, we)
Willexecutors.get_info_task(bal_plugin,url, we)
def get_info_task(url, willexecutor):
def get_info_task(bal_plugin,url, willexecutor):
w = None
try:
_logger.info("GETINFO_WILLEXECUTOR")
_logger.debug(url)
w = Willexecutors.send_request("get", url + "/" + chainname + "/info")
w = Willexecutors.send_request(bal_plugin,"get", url + "/" + chainname + "/info")
if isinstance(w, dict):
willexecutor["url"] = url
willexecutor["status"] = 200
@@ -263,6 +265,7 @@ class Willexecutors:
def download_list(bal_plugin,old_willexecutors):
try:
willexecutors = Willexecutors.send_request(
bal_plugin,
"get",
f"https://welist.bitcoin-after.life/data/{chainname}?page=0&limit=100",
)
@@ -294,10 +297,11 @@ class Willexecutors:
return {}
def check_transaction(txid, url):
def check_transaction(bal_plugin,txid, url):
_logger.debug(f"{url}:{txid}")
try:
w = Willexecutors.send_request(
bal_plugin,
"post", url + "/searchtx", data=txid.encode("ascii")
)
return w