Change query parse order

This commit is contained in:
nolash
2021-11-08 09:58:22 +01:00
parent 0b66462c11
commit 21b0c4a48b
5 changed files with 46 additions and 37 deletions

View File

@@ -9,6 +9,7 @@ from hexathon import (
add_0x,
strip_0x,
)
from chainlib.encode import TxHexNormalizer
# local imports
from cic_cache.cache import (
@@ -27,16 +28,20 @@ re_default_limit = r'/defaultlimit/?'
DEFAULT_LIMIT = 100
tx_normalize = TxHexNormalizer()
def parse_query_account(r):
address = strip_0x(r[1])
#address = tx_normalize.wallet_address(address)
limit = DEFAULT_LIMIT
g = r.groups()
if len(g) > 3:
limit = r[4]
limit = int(r[4])
if limit == 0:
limit = DEFAULT_LIMIT
offset = 0
if len(g) > 4:
offset = r[6]
offset = int(r[6])
logg.debug('account query is address {} offset {} limit {}'.format(address, offset, limit))
@@ -78,6 +83,7 @@ def process_transactions_account_bloom(session, env):
r = re.match(re_transactions_account_bloom, env.get('PATH_INFO'))
if not r:
return None
logg.debug('match account bloom')
(address, offset, limit,) = parse_query_account(r)
@@ -102,6 +108,7 @@ def process_transactions_all_bloom(session, env):
r = re.match(re_transactions_all_bloom, env.get('PATH_INFO'))
if not r:
return None
logg.debug('match all bloom')
(limit, offset, block_offset, block_end,) = parse_query_any(r)
@@ -128,6 +135,7 @@ def process_transactions_all_data(session, env):
return None
#if env.get('HTTP_X_CIC_CACHE_MODE') != 'all':
# return None
logg.debug('match all data')
logg.debug('got data request {}'.format(env))
@@ -155,6 +163,7 @@ def process_transactions_account_data(session, env):
r = re.match(re_transactions_account_data, env.get('PATH_INFO'))
if not r:
return None
logg.debug('match account data')
#if env.get('HTTP_X_CIC_CACHE_MODE') != 'all':
# return None

View File

@@ -46,10 +46,10 @@ def application(env, start_response):
session = SessionBase.create_session()
for handler in [
process_transactions_account_data,
process_transactions_account_bloom,
process_transactions_all_data,
process_transactions_all_bloom,
process_transactions_account_bloom,
process_transactions_account_data,
process_default_limit,
]:
r = None