class HTTPClient: proto -> network_proto

This commit is contained in:
The MMGen Project 2025-06-06 15:18:17 +03:00
commit 7cfa87ba6a
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
6 changed files with 18 additions and 18 deletions

View file

@ -16,7 +16,7 @@ import requests
class HTTPClient:
proto = 'https'
network_proto = 'https'
host = None
timeout = 60
http_hdrs = {
@ -26,10 +26,10 @@ class HTTPClient:
verify = True
text_mode = True
def __init__(self, cfg, *, proto=None, host=None):
def __init__(self, cfg, *, network_proto=None, host=None):
self.cfg = cfg
if proto:
self.proto = proto
if network_proto:
self.network_proto = network_proto
if host:
self.host = host
self.session = requests.Session()
@ -44,7 +44,7 @@ class HTTPClient:
})
def call(self, name, path, err_fs, timeout, *, data=None):
url = self.proto + '://' + self.host + path
url = self.network_proto + '://' + self.host + path
kwargs = {
'url': url,
'timeout': timeout or self.timeout,

View file

@ -71,7 +71,7 @@ class regtest(testnet): # regtest is deprecated testnet
rpc_remote_params = {
'server_domain': Hostname('localhost')}
rpc_remote_rest_params = {
'proto': 'http',
'network_proto': 'http',
'host': Hostname('localhost:18800'),
'verify': False}
rpc_remote_rpc_params = rpc_remote_rest_params

View file

@ -31,10 +31,10 @@ class ThornodeRemoteRESTClient(HTTPClient):
http_hdrs = {'Content-Type': 'application/json'}
timeout = 5
def __init__(self, cfg, *, proto=None, host=None):
for k, v in cfg._proto.rpc_remote_rest_params.items():
def __init__(self, cfg, proto, *, network_proto=None, host=None):
for k, v in proto.rpc_remote_rest_params.items():
setattr(self, k, v)
super().__init__(cfg, proto=proto, host=host)
super().__init__(cfg, network_proto=network_proto, host=host)
class THORChainRemoteRPCClient(RemoteRPCClient):
server_proto = 'THORChain'
@ -44,7 +44,7 @@ class THORChainRemoteRPCClient(RemoteRPCClient):
setattr(self, k, v)
super().__init__(cfg, proto)
self.caps = ('lbl_id',)
self.rest_api = ThornodeRemoteRESTClient(cfg)
self.rest_api = ThornodeRemoteRESTClient(cfg, proto)
def get_balance(self, addr, *, block=None):
res = process_response(

View file

@ -30,8 +30,8 @@ class ThornodeRPCClient(HTTPClient):
host = 'thornode.ninerealms.com'
timeout = 5
def __init__(self, tx, *, proto=None, host=None):
super().__init__(tx.cfg, proto=proto, host=host)
def __init__(self, tx, *, network_proto=None, host=None):
super().__init__(tx.cfg, network_proto=network_proto, host=host)
class Thornode:

View file

@ -2,10 +2,10 @@ from .thornode_orig import *
class overlay_fake_ThornodeRPCClient:
proto = 'http'
host = 'localhost:18800'
network_proto = 'http'
host = 'localhost:18800'
verify = False
ThornodeRPCClient.proto = overlay_fake_ThornodeRPCClient.proto
ThornodeRPCClient.network_proto = overlay_fake_ThornodeRPCClient.network_proto
ThornodeRPCClient.host = overlay_fake_ThornodeRPCClient.host
ThornodeRPCClient.verify = overlay_fake_ThornodeRPCClient.verify

View file

@ -1,10 +1,10 @@
from .tx_proxy_orig import *
class overlay_fake_EtherscanTxProxyClient:
proto = 'http'
host = 'localhost:28800'
network_proto = 'http'
host = 'localhost:28800'
verify = False
EtherscanTxProxyClient.proto = overlay_fake_EtherscanTxProxyClient.proto
EtherscanTxProxyClient.network_proto = overlay_fake_EtherscanTxProxyClient.network_proto
EtherscanTxProxyClient.host = overlay_fake_EtherscanTxProxyClient.host
EtherscanTxProxyClient.verify = overlay_fake_EtherscanTxProxyClient.verify