added __gte sql criteria and pass header to wallet server advance_txs

This commit is contained in:
Lex Berezhny 2019-05-17 23:52:27 -04:00
parent 1d126913e9
commit bba4c6e4f4
2 changed files with 7 additions and 3 deletions

View file

@ -110,6 +110,8 @@ def constraints_to_sql(constraints, joiner=' AND ', prepend_key=''):
col, op = col[:-len('__lte')], '<=' col, op = col[:-len('__lte')], '<='
elif key.endswith('__gt'): elif key.endswith('__gt'):
col, op = col[:-len('__gt')], '>' col, op = col[:-len('__gt')], '>'
elif key.endswith('__gte'):
col, op = col[:-len('__gte')], '>='
elif key.endswith('__like'): elif key.endswith('__like'):
col, op = col[:-len('__like')], 'LIKE' col, op = col[:-len('__like')], 'LIKE'
elif key.endswith('__not_like'): elif key.endswith('__not_like'):
@ -166,7 +168,7 @@ def query(select, **constraints):
sql.append('WHERE') sql.append('WHERE')
sql.append(where) sql.append(where)
if order_by is not None: if order_by:
sql.append('ORDER BY') sql.append('ORDER BY')
if isinstance(order_by, str): if isinstance(order_by, str):
sql.append(order_by) sql.append(order_by)

View file

@ -377,7 +377,9 @@ class BlockProcessor:
for block in blocks: for block in blocks:
height += 1 height += 1
undo_info = self.advance_txs(height, block.transactions) undo_info = self.advance_txs(
height, block.transactions, self.coin.electrum_header(block.header, height)
)
if height >= min_height: if height >= min_height:
self.undo_infos.append((undo_info, height)) self.undo_infos.append((undo_info, height))
self.db.write_raw_block(block.raw, height) self.db.write_raw_block(block.raw, height)
@ -387,7 +389,7 @@ class BlockProcessor:
self.headers.extend(headers) self.headers.extend(headers)
self.tip = self.coin.header_hash(headers[-1]) self.tip = self.coin.header_hash(headers[-1])
def advance_txs(self, height, txs): def advance_txs(self, height, txs, header):
self.tx_hashes.append(b''.join(tx_hash for tx, tx_hash in txs)) self.tx_hashes.append(b''.join(tx_hash for tx, tx_hash in txs))
# Use local vars for speed in the loops # Use local vars for speed in the loops