Change query parse order
This commit is contained in:
parent
0b66462c11
commit
21b0c4a48b
@ -9,6 +9,7 @@ from hexathon import (
|
|||||||
add_0x,
|
add_0x,
|
||||||
strip_0x,
|
strip_0x,
|
||||||
)
|
)
|
||||||
|
from chainlib.encode import TxHexNormalizer
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from cic_cache.cache import (
|
from cic_cache.cache import (
|
||||||
@ -27,16 +28,20 @@ re_default_limit = r'/defaultlimit/?'
|
|||||||
|
|
||||||
DEFAULT_LIMIT = 100
|
DEFAULT_LIMIT = 100
|
||||||
|
|
||||||
|
tx_normalize = TxHexNormalizer()
|
||||||
|
|
||||||
def parse_query_account(r):
|
def parse_query_account(r):
|
||||||
address = strip_0x(r[1])
|
address = strip_0x(r[1])
|
||||||
|
#address = tx_normalize.wallet_address(address)
|
||||||
limit = DEFAULT_LIMIT
|
limit = DEFAULT_LIMIT
|
||||||
g = r.groups()
|
g = r.groups()
|
||||||
if len(g) > 3:
|
if len(g) > 3:
|
||||||
limit = r[4]
|
limit = int(r[4])
|
||||||
|
if limit == 0:
|
||||||
|
limit = DEFAULT_LIMIT
|
||||||
offset = 0
|
offset = 0
|
||||||
if len(g) > 4:
|
if len(g) > 4:
|
||||||
offset = r[6]
|
offset = int(r[6])
|
||||||
|
|
||||||
logg.debug('account query is address {} offset {} limit {}'.format(address, offset, limit))
|
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'))
|
r = re.match(re_transactions_account_bloom, env.get('PATH_INFO'))
|
||||||
if not r:
|
if not r:
|
||||||
return None
|
return None
|
||||||
|
logg.debug('match account bloom')
|
||||||
|
|
||||||
(address, offset, limit,) = parse_query_account(r)
|
(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'))
|
r = re.match(re_transactions_all_bloom, env.get('PATH_INFO'))
|
||||||
if not r:
|
if not r:
|
||||||
return None
|
return None
|
||||||
|
logg.debug('match all bloom')
|
||||||
|
|
||||||
(limit, offset, block_offset, block_end,) = parse_query_any(r)
|
(limit, offset, block_offset, block_end,) = parse_query_any(r)
|
||||||
|
|
||||||
@ -128,6 +135,7 @@ def process_transactions_all_data(session, env):
|
|||||||
return None
|
return None
|
||||||
#if env.get('HTTP_X_CIC_CACHE_MODE') != 'all':
|
#if env.get('HTTP_X_CIC_CACHE_MODE') != 'all':
|
||||||
# return None
|
# return None
|
||||||
|
logg.debug('match all data')
|
||||||
|
|
||||||
logg.debug('got data request {}'.format(env))
|
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'))
|
r = re.match(re_transactions_account_data, env.get('PATH_INFO'))
|
||||||
if not r:
|
if not r:
|
||||||
return None
|
return None
|
||||||
|
logg.debug('match account data')
|
||||||
#if env.get('HTTP_X_CIC_CACHE_MODE') != 'all':
|
#if env.get('HTTP_X_CIC_CACHE_MODE') != 'all':
|
||||||
# return None
|
# return None
|
||||||
|
|
||||||
|
@ -46,10 +46,10 @@ def application(env, start_response):
|
|||||||
|
|
||||||
session = SessionBase.create_session()
|
session = SessionBase.create_session()
|
||||||
for handler in [
|
for handler in [
|
||||||
|
process_transactions_account_data,
|
||||||
|
process_transactions_account_bloom,
|
||||||
process_transactions_all_data,
|
process_transactions_all_data,
|
||||||
process_transactions_all_bloom,
|
process_transactions_all_bloom,
|
||||||
process_transactions_account_bloom,
|
|
||||||
process_transactions_account_data,
|
|
||||||
process_default_limit,
|
process_default_limit,
|
||||||
]:
|
]:
|
||||||
r = None
|
r = None
|
||||||
|
@ -574,7 +574,6 @@ components:
|
|||||||
description: Cached transaction data
|
description: Cached transaction data
|
||||||
items:
|
items:
|
||||||
$ref: "#/components/schemas/Transaction"
|
$ref: "#/components/schemas/Transaction"
|
||||||
|
|
||||||
Transaction:
|
Transaction:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = cic-cache
|
name = cic-cache
|
||||||
description = CIC Cache API and server
|
description = CIC Cache API and server
|
||||||
|
version = 0.2.1a2
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
url = https://gitlab.com/grassrootseconomics/cic-eth
|
url = https://gitlab.com/grassrootseconomics/cic-eth
|
||||||
|
@ -1,38 +1,38 @@
|
|||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
import configparser
|
#import configparser
|
||||||
import os
|
import os
|
||||||
import time
|
#import time
|
||||||
|
|
||||||
from cic_cache.version import (
|
#from cic_cache.version import (
|
||||||
version_object,
|
# version_object,
|
||||||
version_string
|
# version_string
|
||||||
)
|
# )
|
||||||
|
#
|
||||||
class PleaseCommitFirstError(Exception):
|
#class PleaseCommitFirstError(Exception):
|
||||||
pass
|
# pass
|
||||||
|
#
|
||||||
def git_hash():
|
#def git_hash():
|
||||||
import subprocess
|
# import subprocess
|
||||||
git_diff = subprocess.run(['git', 'diff'], capture_output=True)
|
# git_diff = subprocess.run(['git', 'diff'], capture_output=True)
|
||||||
if len(git_diff.stdout) > 0:
|
# if len(git_diff.stdout) > 0:
|
||||||
raise PleaseCommitFirstError()
|
# raise PleaseCommitFirstError()
|
||||||
git_hash = subprocess.run(['git', 'rev-parse', 'HEAD'], capture_output=True)
|
# git_hash = subprocess.run(['git', 'rev-parse', 'HEAD'], capture_output=True)
|
||||||
git_hash_brief = git_hash.stdout.decode('utf-8')[:8]
|
# git_hash_brief = git_hash.stdout.decode('utf-8')[:8]
|
||||||
return git_hash_brief
|
# return git_hash_brief
|
||||||
|
#
|
||||||
version_string = str(version_object)
|
#version_string = str(version_object)
|
||||||
|
#
|
||||||
try:
|
#try:
|
||||||
version_git = git_hash()
|
# version_git = git_hash()
|
||||||
version_string += '+build.{}'.format(version_git)
|
# version_string += '+build.{}'.format(version_git)
|
||||||
except FileNotFoundError:
|
#except FileNotFoundError:
|
||||||
time_string_pair = str(time.time()).split('.')
|
# time_string_pair = str(time.time()).split('.')
|
||||||
version_string += '+build.{}{:<09d}'.format(
|
# version_string += '+build.{}{:<09d}'.format(
|
||||||
time_string_pair[0],
|
# time_string_pair[0],
|
||||||
int(time_string_pair[1]),
|
# int(time_string_pair[1]),
|
||||||
)
|
# )
|
||||||
print('final version string will be {}'.format(version_string))
|
#print('final version string will be {}'.format(version_string))
|
||||||
|
|
||||||
requirements = []
|
requirements = []
|
||||||
f = open('requirements.txt', 'r')
|
f = open('requirements.txt', 'r')
|
||||||
@ -54,7 +54,7 @@ f.close()
|
|||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
version=version_string,
|
# version=version_string,
|
||||||
install_requires=requirements,
|
install_requires=requirements,
|
||||||
tests_require=test_requirements,
|
tests_require=test_requirements,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user