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

Provide contextual block information for Watch* call returns #2944

Closed
Reisen opened this issue May 27, 2020 · 2 comments · Fixed by #2971
Closed

Provide contextual block information for Watch* call returns #2944

Reisen opened this issue May 27, 2020 · 2 comments · Fixed by #2971
Assignees
Labels
c:client Category: client interface

Comments

@Reisen
Copy link

Reisen commented May 27, 2020

SUMMARY

Currently when subscribing to Watch* style API endpoints It's impossible to correlate the values with the actual transactions or blocks that they occurred around. For example, if I subscribe to WatchTransfers I will receive a channel that forwards me Transfer events shaped like so:

type TransferEvent struct {                                                                                                                                                                                                       
    From   signature.PublicKey `json:"from"`                                                                                                                            
    To     signature.PublicKey `json:"to"`                                                                                                                      
    Tokens quantity.Quantity   `json:"tokens"`                                                                                                                      
}

The problem is I have no way to tell which block this ocurred in, at what height, what time, or the associated transactions.

An alternative is to not use the Watch methods and instead call GetEvents on every block which will also include a TxHash, but this is much slower when trying to process the whole chain and there is no way to lookup a TxHash using the API yet.

What would be ideal is for common chain information to be included. Things like block height are common to all chains and so I think would be fine to expose regardless of the backing consensus used.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

Any API module providing Watch*.

ADDITIONAL INFORMATION

I'm currently avoiding any Watch* API endpoints because they don't provide enough context to be useful, this means instead I'm calling Get* style API endpoints. The problem there though is the more calls I make during a block the slower processing the chain becomes.

@kostko
Copy link
Member

kostko commented May 27, 2020

This is true, so for staking there is also the GetEvents endpoint which takes a specific height and provides a TxHash field in the result.

I think one way would be to expose an additional method called WatchEvents which would provide the same results as GetEvents (maybe with an additional Height field). What do you think about this idea?

@kostko kostko changed the title Provide contextual block information for Watch* call returns. Provide contextual block information for Watch* call returns May 27, 2020
@Reisen
Copy link
Author

Reisen commented May 27, 2020

That would be awesome! Would adding Height to other Watch* methods be an unreasonable request? I'm not sure how much tooling relies on these methods or what it means for backwards compatibility though. Either way GetEvents alone in this format would be excellent.

@kostko kostko added the c:client Category: client interface label May 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c:client Category: client interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants