Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Get account history starting at a block and ending in head #1820
Reported by Natrium.
Currently I see no easy way of doing this, and it seems like a pretty important thing to have.
What would be the best way to approach this? I don't mind coding it once it's agreed upon.
Also, maybe we could add (block) "height" to the blocks in
You're right, such a feature could come in handy for the
In your earlier edit, you misunderstood the
But, there is another simple, straightforward workaround to gather only new blocks, yet it involves more round trips than being able to set an "end", and has a slight chance of race conditions you'd need to check for:
I actually prefer the simple way to "sync": Don't cache anything locally, simply request the 200 most recent blocks of the Tx history and cut off after that. This way, it's quick, saves round-trips, and you'll never have to deal with forks and stuff. If a user wants to scroll farther back, they can either use a fully fledged block explorer, or one could implement pagination via the "head" option of the "account_history" command.
vs. the standard:
Thank you for digging into this. I was indeed wrong about
Some takeaways then:
@guilhermelawless Expand description
successors definition depends on other descriptions especially on chain & account_history. Default order for chain there is from newest blocks to older. "Returns a list of block hashes in the account chain starting at block up to count" is exactly "chain" description while it should show difference. More clear description may be required, right
Both height & reverse should be easy to impement. Why not
Guilherme is right with his proposal for the successors description.
When I wrote this
state blocks and epoch blocks didn't exist yet. Their role may be worth mentioning.
You can also add the undocumented "offset" parameter for
I looked through the documentation and the only mention of "starting" and "ending" related to blocks in an account is in
I know in the code/protocol it works the other way but for whoever is reading the RPC documentation it makes more sense as I wrote, I think (and we all seem to agree).
referenced this issue
Mar 13, 2019
I think it might be worth repeating
For account_history, offset was available before, just not documented. Since v11 it's there: https://github.com/nanocurrency/nano-node/blob/release_v11/rai/node/rpc.cpp#L1747