Skip to content
Snippets Groups Projects
Unverified Commit 6e3bafce authored by Justin Welch's avatar Justin Welch Committed by GitHub
Browse files

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

route get_state witnesses
parents 431bd3cb 273b9dec
No related branches found
No related tags found
No related merge requests found
......@@ -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(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment