Skip to content

Commit

Permalink
Fix duplicate fetch (#26)
Browse files Browse the repository at this point in the history
* fix wrong max block number return

* add README announcement
  • Loading branch information
EtWnn authored Dec 29, 2021
1 parent f1bc48b commit 8054e9f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
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)



0 comments on commit 8054e9f

Please sign in to comment.