diff --git a/apps/cic-cache/cic_cache/runnable/daemons/query.py b/apps/cic-cache/cic_cache/runnable/daemons/query.py index 2c586a79..b6b9eca1 100644 --- a/apps/cic-cache/cic_cache/runnable/daemons/query.py +++ b/apps/cic-cache/cic_cache/runnable/daemons/query.py @@ -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 diff --git a/apps/cic-cache/cic_cache/runnable/daemons/server.py b/apps/cic-cache/cic_cache/runnable/daemons/server.py index 17bd2760..16eefed3 100644 --- a/apps/cic-cache/cic_cache/runnable/daemons/server.py +++ b/apps/cic-cache/cic_cache/runnable/daemons/server.py @@ -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 diff --git a/apps/cic-cache/doc/openapi/server.yml b/apps/cic-cache/doc/openapi/server.yml index 14f162af..09889c76 100644 --- a/apps/cic-cache/doc/openapi/server.yml +++ b/apps/cic-cache/doc/openapi/server.yml @@ -574,7 +574,6 @@ components: description: Cached transaction data items: $ref: "#/components/schemas/Transaction" - Transaction: type: object properties: diff --git a/apps/cic-cache/setup.cfg b/apps/cic-cache/setup.cfg index f8393c92..3ffda56c 100644 --- a/apps/cic-cache/setup.cfg +++ b/apps/cic-cache/setup.cfg @@ -1,6 +1,7 @@ [metadata] name = cic-cache description = CIC Cache API and server +version = 0.2.1a2 author = Louis Holbrook author_email = dev@holbrook.no url = https://gitlab.com/grassrootseconomics/cic-eth diff --git a/apps/cic-cache/setup.py b/apps/cic-cache/setup.py index 84d9731a..048a9220 100644 --- a/apps/cic-cache/setup.py +++ b/apps/cic-cache/setup.py @@ -1,38 +1,38 @@ from setuptools import setup -import configparser +#import configparser import os -import time +#import time -from cic_cache.version import ( - version_object, - version_string - ) - -class PleaseCommitFirstError(Exception): - pass - -def git_hash(): - import subprocess - git_diff = subprocess.run(['git', 'diff'], capture_output=True) - if len(git_diff.stdout) > 0: - raise PleaseCommitFirstError() - git_hash = subprocess.run(['git', 'rev-parse', 'HEAD'], capture_output=True) - git_hash_brief = git_hash.stdout.decode('utf-8')[:8] - return git_hash_brief - -version_string = str(version_object) - -try: - version_git = git_hash() - version_string += '+build.{}'.format(version_git) -except FileNotFoundError: - time_string_pair = str(time.time()).split('.') - version_string += '+build.{}{:<09d}'.format( - time_string_pair[0], - int(time_string_pair[1]), - ) -print('final version string will be {}'.format(version_string)) +#from cic_cache.version import ( +# version_object, +# version_string +# ) +# +#class PleaseCommitFirstError(Exception): +# pass +# +#def git_hash(): +# import subprocess +# git_diff = subprocess.run(['git', 'diff'], capture_output=True) +# if len(git_diff.stdout) > 0: +# raise PleaseCommitFirstError() +# git_hash = subprocess.run(['git', 'rev-parse', 'HEAD'], capture_output=True) +# git_hash_brief = git_hash.stdout.decode('utf-8')[:8] +# return git_hash_brief +# +#version_string = str(version_object) +# +#try: +# version_git = git_hash() +# version_string += '+build.{}'.format(version_git) +#except FileNotFoundError: +# time_string_pair = str(time.time()).split('.') +# version_string += '+build.{}{:<09d}'.format( +# time_string_pair[0], +# int(time_string_pair[1]), +# ) +#print('final version string will be {}'.format(version_string)) requirements = [] f = open('requirements.txt', 'r') @@ -54,7 +54,7 @@ f.close() setup( - version=version_string, +# version=version_string, install_requires=requirements, tests_require=test_requirements, )