diff --git a/src/client/rpc/rpc.ts b/src/client/rpc/rpc.ts index f8e12a0..fbec543 100644 --- a/src/client/rpc/rpc.ts +++ b/src/client/rpc/rpc.ts @@ -137,6 +137,12 @@ export class RPC { return null; } + public deleteCachedRequest(request: RPCRequest): void { + const hash = this.hashRequest(request); + + this.cache.del(hash); + } + private hashRequest(request: RPCRequest): string { const tempRequest = { method: request.method, diff --git a/src/index.ts b/src/index.ts index 8b11804..f654ae0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -74,6 +74,14 @@ interface ConsensusBlockRequest { let client: Client; +const RPC_NO_CACHE = [ + "eth_call", + "eth_estimateGas", + "eth_sendRawTransaction", + "eth_getTransactionReceipt", + "eth_getTransactionCount", +]; + const plugin: Plugin = { name: "eth", async plugin(api: PluginAPI): Promise { @@ -178,6 +186,9 @@ const plugin: Plugin = { } let ret = provider.rpc.getCachedRequest(request); + if (RPC_NO_CACHE.includes(request.method)) { + provider.rpc.deleteCachedRequest(request); + } // @ts-ignore return { ...ret, id: request.id ?? ret.id }; },