Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

feat(etherscan): add caching #935

Closed
wants to merge 2 commits into from
Closed

feat(etherscan): add caching #935

wants to merge 2 commits into from

Conversation

gakonst
Copy link
Owner

@gakonst gakonst commented Feb 19, 2022

As title, will be useful for avoidign rate limiting when doing mainnet forking in foundry and fetching ABIs/sources for tracing

Comment on lines 239 to 242
let path = cache.join("abis").join(format!("{:?}.json", address));
let reader = std::io::BufReader::new(std::fs::File::create(path)?);
let abi = serde_json::from_reader(reader)?;
return Ok(abi)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we instead continue with the request if this results in an error, like file does not exist?

Comment on lines 39 to 41
let mut this = Self::new(chain, api_key)?;
this.cache = cache;
Ok(this)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatively call Self::new_cached(chain, api_key, None) from Self::new

Comment on lines 267 to 270
let path = cache.join("sources").join(format!("{:?}.json", address));
let reader = std::io::BufReader::new(std::fs::File::create(path)?);
let src = serde_json::from_reader(reader)?;
return Ok(src)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment above.

@gakonst
Copy link
Owner Author

gakonst commented Apr 3, 2022

FYI @onbjerg this had seemed to work but I never tested it. May want to take it over so we don't hit rate limits when tracing with https://github.com/gakonst/foundry/tree/onbjerg/etherscan-identifier or https://github.com/gakonst/foundry/tree/etherscan-identifier-v2

@onbjerg
Copy link
Collaborator

onbjerg commented Apr 4, 2022

Took over in #1108, there is some missing stuff

@gakonst
Copy link
Owner Author

gakonst commented Apr 4, 2022

Ack

@gakonst gakonst closed this Apr 4, 2022
@gakonst gakonst deleted the feat/etherscan-cache branch April 4, 2022 16:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants