proto.rune.params: new rpc_swap_params attribute
This commit is contained in:
parent
8c1972b6f0
commit
a7f0629eba
7 changed files with 12 additions and 16 deletions
|
|
@ -49,6 +49,7 @@ class mainnet(CoinProtocol.Secp256k1):
|
|||
rpc_remote_params = {'server_domain': Hostname('ninerealms.com')}
|
||||
rpc_remote_rest_params = {'host': Hostname('thornode.ninerealms.com')}
|
||||
rpc_remote_rpc_params = {'host': Hostname('rpc.ninerealms.com')}
|
||||
rpc_swap_params = {'host': Hostname('thornode.ninerealms.com')}
|
||||
|
||||
def decode_addr(self, addr):
|
||||
hrp, data = bech32.bech32_decode(addr)
|
||||
|
|
@ -69,6 +70,7 @@ class testnet(mainnet): # testnet is stagenet
|
|||
bech32_hrp = 'sthor'
|
||||
rpc_remote_rest_params = {'host': Hostname('stagenet-thornode.ninerealms.com')}
|
||||
rpc_remote_rpc_params = {'host': Hostname('stagenet-rpc.ninerealms.com')}
|
||||
rpc_swap_params = {'host': Hostname('stagenet-thornode.ninerealms.com')}
|
||||
|
||||
class regtest(testnet): # regtest is deprecated testnet
|
||||
bech32_hrp = 'tthor'
|
||||
|
|
@ -79,3 +81,4 @@ class regtest(testnet): # regtest is deprecated testnet
|
|||
'host': Hostname('localhost:18800'),
|
||||
'verify': False}
|
||||
rpc_remote_rpc_params = rpc_remote_rest_params
|
||||
rpc_swap_params = rpc_remote_rest_params | {'host': Hostname('localhost:18900')}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ swap.proto.thorchain.thornode: THORChain swap protocol network query ops
|
|||
import time, json
|
||||
from collections import namedtuple
|
||||
|
||||
from ....protocol import init_proto
|
||||
from ....amt import UniAmt
|
||||
from ....http import HTTPClient
|
||||
|
||||
|
|
@ -24,13 +25,15 @@ gas_unit_data = {
|
|||
'gwei': _gd('G', 'Gwei'),
|
||||
}
|
||||
|
||||
class ThornodeRPCClient(HTTPClient):
|
||||
class ThornodeSwapClient(HTTPClient):
|
||||
|
||||
http_hdrs = {'Content-Type': 'application/json'}
|
||||
host = 'thornode.ninerealms.com'
|
||||
timeout = 5
|
||||
|
||||
def __init__(self, tx, *, network_proto=None, host=None):
|
||||
rune_proto = init_proto(tx.cfg, 'rune', network=tx.cfg._proto.network)
|
||||
for k, v in rune_proto.rpc_swap_params.items():
|
||||
setattr(self, k, v)
|
||||
super().__init__(tx.cfg, network_proto=network_proto, host=host)
|
||||
|
||||
class Thornode:
|
||||
|
|
@ -38,7 +41,7 @@ class Thornode:
|
|||
def __init__(self, tx, amt):
|
||||
self.tx = tx
|
||||
self.in_amt = UniAmt(f'{amt:.8f}')
|
||||
self.rpc = ThornodeRPCClient(tx)
|
||||
self.rpc = ThornodeSwapClient(tx)
|
||||
|
||||
def get_quote(self, swap_cfg):
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class HTTPD:
|
|||
handler_class = SilentRequestHandler)
|
||||
|
||||
import threading
|
||||
t = threading.Thread(target=self.httpd.serve_forever, name=f'{self.name} thread')
|
||||
t = threading.Thread(target=self.httpd.serve_forever, name=f'{type(self).__name__} thread')
|
||||
t.daemon = True
|
||||
t.start()
|
||||
|
||||
|
|
|
|||
|
|
@ -16,5 +16,4 @@ from .. import HTTPD
|
|||
|
||||
class ThornodeServer(HTTPD):
|
||||
name = 'thornode server'
|
||||
port = 18800
|
||||
content_type = 'application/json'
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ from wsgiref.util import request_uri
|
|||
from . import ThornodeServer
|
||||
|
||||
class ThornodeRPCServer(ThornodeServer):
|
||||
port = 18800
|
||||
name = 'thornode RPC server'
|
||||
|
||||
def make_response_body(self, method, environ):
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ def make_inbound_addr(proto, mmtype):
|
|||
mmtype = mmtype).pubhash2addr(f'{n:040x}')
|
||||
|
||||
class ThornodeSwapServer(ThornodeServer):
|
||||
port = 18900
|
||||
name = 'thornode swap server'
|
||||
request_pat = r'/thorchain/quote/swap\?from_asset=(\S+)\.(\S+)&to_asset=(\S+)\.(\S+)&amount=(\d+)'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
from .thornode_orig import *
|
||||
|
||||
class overlay_fake_ThornodeRPCClient:
|
||||
|
||||
network_proto = 'http'
|
||||
host = 'localhost:18800'
|
||||
verify = False
|
||||
|
||||
ThornodeRPCClient.network_proto = overlay_fake_ThornodeRPCClient.network_proto
|
||||
ThornodeRPCClient.host = overlay_fake_ThornodeRPCClient.host
|
||||
ThornodeRPCClient.verify = overlay_fake_ThornodeRPCClient.verify
|
||||
Loading…
Add table
Add a link
Reference in a new issue