-
Notifications
You must be signed in to change notification settings - Fork 20k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider moving ethapi out of internal #20212
Comments
That |
We've been discussing this a bit, but we don't fully understand the need for this. The All in all, if you are writing your own Go code, it might be cleaner to stick to the individual Go types (e.g. block, transaction) and not use the convoluted web3 API specs. You should already be able to convert all Go Ethereum types into json by themselves. Could you detail what you're trying to do exactly? Maybe that would help us understand better as to how that can be done, either without or with modification to the go-ethereum code. |
Hi @karalabe, I can second the above request for making I'm trying to use In order to set up the RPC API I'm using As a result I'm trying to effectively copy & paste the whole Would love to also hear your guidance on how to achieve this and hope this helps support the overall thinking around the To summarize - from my perspective there should be a way to use |
Thank you for the consideration and taking the time to respond @karalabe.
Can you show me an example of how to do that? I see the
My use case specifically is that I would like to cache blocks fetched by Given that there are client implementations in different language (Go, JavaScript, ...), it makes sense to me that there should be a canonical form to serialize/deserialize these structures for use between client implementations. In web3 this is very easy, because we can just Let me know if I am misunderstanding something here. |
@prettymuchbryce The ethclient is a bit special because it does not mirror the web3 RPC API exactly. Instead, it gives you a way to get the core/types data structures out of any implementation of the web3 RPC API. The core/types types cannot represent all the data returned by the API because the API assumes a slightly different data model. If you want to make a generic cache, it would be much better to just decode the RPC results into |
In general, adding JSON marshaling support to |
@Pet3ris running the web3 API on the simulated backend is very nice, and we do want to support it eventually. We're currently refactoring the overall structure of go-ethereum to make the high-level components more independent. I'll see about making package ethapi public after this work has completed. |
Makes sense. Thanks @fjl |
The refactoring mentioned earlier is now complete, but I'll be busy with some other things for a while and can't take on moving internal/ethapi at this time. |
Currently it seems there is no way to convert a
*types.Block
into the canonical JSON form using thego-ethereum
package alone. This is due to the fact thatethapi
resides in an Internal package and cannot be imported.My understanding is that
go-ethereum
is the de-facto standard Go client for Ethereum. Whether that is a strict goal or not, I'm not sure. But Marshaling these common data structures into their canonical JSON forms would be a very useful feature.System information
Geth version:
master/HEAD
OS & Version: Windows/Linux/OSX
Commit hash : db79143
Expected behaviour
go-ethereum should allow downstream modules to marshal blocks and other common types into JSON.
Actual behaviour
ethapi.RPCMarshalBlock
exists in an Internal package and cannot be imported by downstream packages.The text was updated successfully, but these errors were encountered: