Skip to content

Commit 7d5f041

Browse files
zixuanzhcburgdorf
authored andcommitted
Use a TTL cache for tx validation in DefaultTransactionValidator
Fixes #997
1 parent 0a5ffa8 commit 7d5f041

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"web3==4.3.0",
4343
# required for rlp>=1.0.0
4444
"eth-account>=0.2.1,<1",
45+
"cachetools==2.1.*",
4546
],
4647
'test': [
4748
"hypothesis==3.44.26",

trinity/tx_pool/validators.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import cachetools.func
2+
13
from typing import (
24
Type
35
)
@@ -45,6 +47,7 @@ def __call__(self, transaction: BaseTransactionFields) -> bool:
4547
else:
4648
return True
4749

50+
@cachetools.func.ttl_cache(maxsize=1024, ttl=300)
4851
def get_appropriate_tx_class(self) -> Type[BaseTransaction]:
4952
current_tx_class = self.chain.get_vm_class().get_transaction_class()
5053
# If the current head of the chain is still on a fork that is before the currently

0 commit comments

Comments
 (0)