fetch previous version LedgerInfo via RPC

I’m looking for a way to extract LedgerInfo struct via RPC but for a previous version and not the latest. When doing UpdateToLatestLedger the response object contains the info for the latest block but I can’t see a way to extract it for a previous block…

Any advice?


1 Like

We intentionally don’t currently have a way to do this. If you update to the latest state, you now have a proof of past states. Can you provide your reasoning for wanting to be able to sync to an old state?

1 Like

@kph - developing an librabrowser.io I want to get accurate block times. The most accurate source seems to be the one you confirmed to me in the other thread which is the timestamp_usec field of LedgerInfo. However there doesn’t see, to be a way to properly access it for past blocks.

// Timestamp that represents the microseconds since the epoch (unix time) that is
// generated by the proposer of the block. This is strictly increasing with every block.
// If a client reads a timestamp > the one they specified for transaction expiration time,
// they can be certain that their transaction will never be included in a block in the future
// (assuming that their transaction has not yet been included)
uint64 timestamp_usecs = 6;

1 Like

Eventually the plan is to have a system-defined Time resource that will expose the then current time. In other words, if you wanted to get the time as of version i you would access the state at version i and pull out the value of the time resource.


Hi Ben how have you been?
I think it will be useful to a lot of applications when you expose it.

BTW, any proposal on how to do it now? I’m currently using the heuristic of assuming the expiration time is +100 than the submission time per this code of the default tx submission from the client but it isn’t a reliable way to do it…

1 Like

Hmmm, i guess you could periodically fetch ledger infos and record the timestamps, but I think generally my intuition here would be to only present information that is provably correct vs inferring. This will be addressed well before v1 so I think it may be just best to wait.


got it, thanks. I’ll stay tuned for the update providing access

1 Like