diff --git a/brownie/data/default-config.yaml b/brownie/data/default-config.yaml index a0c5ad16f..4389f5c54 100644 --- a/brownie/data/default-config.yaml +++ b/brownie/data/default-config.yaml @@ -71,3 +71,4 @@ hypothesis: autofetch_sources: false dependencies: null dev_deployment_artifacts: false +eager_caching: true diff --git a/brownie/network/middlewares/caching.py b/brownie/network/middlewares/caching.py index c6cb19945..469904fa4 100644 --- a/brownie/network/middlewares/caching.py +++ b/brownie/network/middlewares/caching.py @@ -117,6 +117,9 @@ def start_block_filter_loop(self): @classmethod def get_layer(cls, w3: Web3, network_type: str) -> Optional[int]: + if CONFIG.settings['eager_caching'] is False: + # do not cache when user doesn't want it + return None if network_type != "live": # do not cache on development chains return None diff --git a/docs/config.rst b/docs/config.rst index 946461ccd..70127df5a 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -390,3 +390,10 @@ Other Settings .. code-block:: yaml dotenv: .env + +.. py:attribute:: eager_caching + If set to ``false``, brownie will not start the background caching thread and will only call the RPC on an as-needed basis. + + This is useful for always-on services or while using pay-as-you-go private RPCs + + default value: ``true``