ethereum / go-ethereum

Go implementation of the Ethereum protocol
https://geth.ethereum.org
GNU Lesser General Public License v3.0
47.42k stars 20.07k forks source link

Custom rpc.Client in ethclient.Client #30630

Open LucasALLOIN opened 3 days ago

LucasALLOIN commented 3 days ago

Rationale

This proposal aims to allow developers to use a custom rpc.Client without the need to re-implement all the methods of ethclient.Client. Recently, I required this functionality to automatically intercept all rpc.CallContext calls and add custom features, without having to replicate the same implementation across all functions called by the client.

Implementation

To achieve this, I plan to create an interface that will be used within the ethclient.Client struct. I will handle the implementation myself.

If you have any further requests or suggestions, please feel free to reach out.

lightclient commented 2 days ago

repost from #30631 https://github.com/ethereum/go-ethereum/pull/30631#issuecomment-2423991409

you should use DialHTTPWithClient and pass a custom http.Client with the logging you desire.