Comments (4)
if extract_timestamps is not None:
timestamps = extract_timestamps(web3, start_block, end_block)
for log in logs:
block_hash = log["blockHash"]
block_number = int(log["blockNumber"], 16)
# Retrofit our information to the dict
event_signature = log["topics"][0]
log["context"] = context
log["event"] = filter.topics[event_signature]
if extract_timestamps:
try:
log["timestamp"] = timestamps[block_hash]
except KeyError as e:
# If the block hash is not found in the timestamps table, it could be due to a chain reorg.
# In this case, we can try to retrieve the timestamp using the block number instead.
try:
block = web3.eth.getBlock(block_number)
log["timestamp"] = block["timestamp"]
except Exception as e:
raise RuntimeError(
f"Timestamp missing for block number {block_number:,}, hash {block_hash}, our timestamp table has {len(timestamps)} blocks"
) from e
else:
log["timestamp"] = None
This code first checks if extract_timestamps
is not None
, and if it is not, it retrieves the timestamps for the blocks within the specified range using the extract_timestamps
function. Then, for each log in the logs
list, it retrofits the information to the dict and tries to retrieve the timestamp for the block using the block hash. If a KeyError
is raised, it means that the block hash is not found in the timestamps table, which could be due to a chain reorg. In this case, it tries to retrieve the timestamp using the block number instead using the web3.eth.getBlock
method. If this also fails, it raises a RuntimeError
with a message indicating that the timestamp is missing.
from web3-ethereum-defi.
#59 can you check this once @miohtama @hieuh25
from web3-ethereum-defi.
@swarna1101 Thank you for your feedback. I am sorry your comment is not relevant for this issue. Please do not post comments, unless you have more context on the issue.
from web3-ethereum-defi.
Fixed in #62
from web3-ethereum-defi.
Related Issues (20)
- Low-level transactions to open and close Aave positions
- Low-level transactions to open and close short - involves selling the borrowed tokens on an exchange like Uniswap v2 and v3
- Error when loading last N blocks using JSONRPCReorganisationMonitor HOT 2
- Most things do not work? HOT 1
- Ankr specific timestamp reader HOT 1
- Better tracking for Uniswap v3 price estimation
- ValueError: {'code': -32000, 'message': 'the method eth_sendTransaction does not exist/is not available'} HOT 1
- More selective number → string conversion in `fetch_aave_reserves_shapshot` HOT 1
- Something wierd with the log HOT 1
- how to use analyse_trade_by_hash()? HOT 1
- Closed
- Aave deposit function HOT 2
- Support Uniswap v3 swap
- Support Uniswap V3 increaseLiquidity() and decreaseLiquidity() HOT 1
- Enzyme walkthrough test suite
- fix eth_defi uniswap_v2 tests
- Uniswap V3 swap doesn't show up in API documentation HOT 1
- Websocket support HOT 1
- Aave position management code
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from web3-ethereum-defi.