Skip to content

Commit

Permalink
Fix cache fn load
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-code committed Jul 5, 2024
1 parent 09a6e86 commit 424ec82
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions backend/app/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from flask_sqlalchemy import SQLAlchemy
from flask_caching import Cache
from web3 import Web3, middleware
from web3._utils.rpc_abi import RPC
from web3._utils.caching import (
generate_cache_key,
)
Expand Down Expand Up @@ -112,21 +111,18 @@ def init_web3(app):
w3.provider = app.config["WEB3_PROVIDER"]
if middleware.geth_poa_middleware not in w3.middleware_onion:
w3.middleware_onion.inject(middleware.geth_poa_middleware, layer=0)

middleware.validation.METHODS_TO_VALIDATE.remove(RPC.eth_call)

w3.middleware_onion.add(middleware.time_based_cache_middleware)
w3.middleware_onion.add(middleware.latest_block_based_cache_middleware)
w3.middleware_onion.add(middleware.simple_cache_middleware)
w3.middleware_onion.add(
_create_cache(app, 600, is_glm_or_projects_contract, _generic_should_cache_web3)
)
w3.middleware_onion.add(
_create_cache(app, 60, is_epochs_or_deposits_contract, (lambda x: True))
)
w3.middleware_onion.add(
_create_cache(app, 20, is_get_block_by_number, _generic_should_cache_web3)
)
w3.middleware_onion.add(middleware.time_based_cache_middleware)
w3.middleware_onion.add(middleware.latest_block_based_cache_middleware)
w3.middleware_onion.add(middleware.simple_cache_middleware)
w3.middleware_onion.add(
_create_cache(app, 600, is_glm_or_projects_contract, _generic_should_cache_web3)
)
w3.middleware_onion.add(
_create_cache(app, 60, is_epochs_or_deposits_contract, (lambda x: True))
)
w3.middleware_onion.add(
_create_cache(app, 20, is_get_block_by_number, _generic_should_cache_web3)
)

glm.init_web3(w3, app.config["GLM_CONTRACT_ADDRESS"])
epochs.init_web3(w3, app.config["EPOCHS_CONTRACT_ADDRESS"])
Expand Down

0 comments on commit 424ec82

Please sign in to comment.