Browse Source

class HTTPClient: `proto` -> `network_proto`

The MMGen Project 6 months ago
parent
commit
7cfa87ba6a

+ 5 - 5
mmgen/http.py

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

+ 1 - 1
mmgen/proto/rune/params.py

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

+ 4 - 4
mmgen/proto/rune/rpc/remote.py

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

+ 2 - 2
mmgen/swap/proto/thorchain/thornode.py

@@ -30,8 +30,8 @@ class ThornodeRPCClient(HTTPClient):
 	host = 'thornode.ninerealms.com'
 	host = 'thornode.ninerealms.com'
 	timeout = 5
 	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:
 class Thornode:
 
 

+ 3 - 3
test/overlay/fakemods/mmgen/swap/proto/thorchain/thornode.py

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

+ 3 - 3
test/overlay/fakemods/mmgen/tx/tx_proxy.py

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