Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What I did
web3
objectHow I did it
Middlewares are automagically loaded from all files within
brownie/network/middlewares
. The only requirement is that they subclassBrownieMiddlewareABC
. They are automatically added upon connection and removed at disconnect. The exact spec is fairly well documented within the natspec and comments.The cache has two components:
eth_getCode
under specific conditions (non-zero return value, no presence of theSELFDESTRUCT
opcode). Looking at the Infura dashboard for my most commonly used API key, this endpoint accounts for >20% of the network traffic from Brownie, so it seems like a good first candidate. With the base logic in place for this cache it should be possible to expand it to other endpoints.