Skip to content
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

Building out general network stats? #3

Open
drbh opened this issue Jul 8, 2019 · 3 comments
Open

Building out general network stats? #3

drbh opened this issue Jul 8, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@drbh
Copy link

drbh commented Jul 8, 2019

@philippgille Great work! this is an awesome library that is forsure going to get alot of use.

I was hoping to build a small app around this sdk and want to provide users with some general network stats.

  • lastest block
  • current block number
  • txs today?

Is there a way I can help add this functionality? I do not see methods for getting network data and only see GetAccountState as a way to look at a specific account. What docs are you following?

Are network stats part of your road map? Thanks!

@philippgille
Copy link
Owner

Hi, thanks for the kind words!

It's correct that those features are currently not implemented, but they would be really useful for something like a block explorer and would fit perfectly into this library.

The last time I checked the Libra documentation was very thin regarding the gRPC interface of the libra nodes, so I had to do some trial and error as well.

The gRPC types.UpdateToLatestLedgerResponse might contain the required information, as long as the correct types.UpdateToLatestLedgerRequest is used when requesting the info.

You can find their gRPC definition here:

This is an example of how to create a request:

requestedItems := []*types.RequestItem{

And this is the related handling of the response:
accStateBlob := updateLedgerResponse.GetResponseItems()[0].GetGetAccountStateResponse().GetAccountStateWithProof().GetBlob().GetBlob()

This will have to look a little different for other types of requests probably, but I think it's the right direction.

As you can see in the comment where the client creates the request for the account state, several request types are allowed to be used. One of them seems is GetTransactionRequest, which sounds very promising for something like "today's tx".
The gRPC type is here:

message GetTransactionsRequest {

A possible next step would be to add a method to the client where you can pass the start_version and limit as parameters. Inside of that method the request is created and sent and the response converted into some useful struct (slice of Transaction or something - maybe we need to differentiate between a tx struct for sending new tx vs. a tx struct for tx info that's already on the ledger).

The response type from gRPC is probably this one:

message GetTransactionsResponse {

Are you interested in contributing this?

@philippgille philippgille added the enhancement New feature or request label Jul 9, 2019
@philippgille
Copy link
Owner

philippgille commented Jul 9, 2019

P.S.: The related Go files for those gRPC types are already generated and they contain some GoDoc:

@drbh
Copy link
Author

drbh commented Jul 13, 2019

Hey @philippgille

I would love to help as much as I can - bit busy at the time but I just pushed a PR with what seems like most of the code needed to get a transaction list. I was just having issue with all the serialization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants