Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate fetch #26

Merged
merged 2 commits into from
Dec 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ This library is a local tracker of transactions for the Ethereum chain and the B
It is a simple interface with the `etherscan <https://etherscan.io>`_ and the
`bscscan <https://bscscan.com>`_ APIs and will save locally the results to gain time and avoid over-calling the APIs.

Announcement
-------

If you previously used this library with a version inferior to 0.1.3,
please head `here <https://github.com/EtWnn/ScanWatch/discussions/25>`_ to correct a potential bug in the database.


Quick Tour
----------

Expand Down
11 changes: 4 additions & 7 deletions ScanWatch/storage/ScanDataBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,13 @@ def get_last_block_number(self, address: str, nt_type: NETWORK, net: str, tr_typ
:rtype: int
"""
table = get_transaction_table(address, nt_type, net, tr_type)
selection = f"MAX({table.blockNumber})"
result = self.get_conditions_rows(table, selection=selection)
selection = str(table.blockNumber)
query = self.get_conditions_rows(table, selection=selection)
default = 0
try:
result = result[0][0]
except IndexError:
return max([int(e[0]) for e in query])
except ValueError:
return default
if result is None:
return default
return int(result)