Unverified Commit 6e3bafce authored by Justin Welch's avatar Justin Welch Committed by GitHub

Merge pull request #187 from steemit/route-getstate-witnesses

route get_state witnesses
parents 431bd3cb 273b9dec
......@@ -18,7 +18,7 @@ from .errors import InvalidUpstreamURL
logger = structlog.get_logger(__name__)
ACCOUNT_TRANSFER_PATTERN = re.compile(r'^\/?@([^\/\s]+)/transfers$')
ACCOUNT_TRANSFER_PATTERN = re.compile(r'^\/?(@([^\/\s]+)/transfers|~?witnesses)$')
# -------------------
......@@ -88,14 +88,16 @@ class _Upstreams(object):
@functools.lru_cache(8192)
def url(self, request_urn) -> str:
try:
if (request_urn.api == 'database_api' or request_urn.api == 'condenser_api') and ACCOUNT_TRANSFER_PATTERN.match(
request_urn.params[0]):
url = os.environ.get('JUSSI_ACCOUNT_TRANSFER_STEEMD_URL')
if url:
return url
except Exception:
pass
# certain steemd.get_state paths must be routed differently
if (request_urn.api in ['database_api', 'condenser_api']
and request_urn.method == 'get_state'
and isinstance(request_urn.params, list)
and len(request_urn.params) == 1
and ACCOUNT_TRANSFER_PATTERN.match(request_urn.params[0])):
url = os.environ.get('JUSSI_ACCOUNT_TRANSFER_STEEMD_URL')
if url:
return url
_, url = self.__URLS.longest_prefix(str(request_urn))
if not url:
raise InvalidUpstreamURL(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment