Skip to content
Discussions/App Development/Tracking offset from the Completion APIForum ↗

Tracking offset from the Completion API

App Development8 posts175 views4 likesLast activity Dec 2021
LE
Leonid_RozenbergOP
Dec 2021

How does one track the offset a client should restart from, when using the completion api? From the CompletionStreamResponse would one track the offset based off of the Checkpoints ?

LE
Leonid_Rozenberg
Dec 2021

In that case, if my client crashes, how do I know from what offset to subscribe?

One could imagine a client that executes just createsAndExercisess and does not listen to the transaction stream.

LE
Leonid_Rozenberg
Dec 2021
stefanobaghino-da:

Subscribe to what?

To completions. In order to construct CompletionStreamRequest one can specify a LedgerOffset, which is described as "This field indicates the minimum offset for completions. This can be used to resume an earlier completion stream. "

I’ll also point out that a committer is mentioned only once within the LedgerAPI spec, in reference to a submission_id? I am confused by this documentation:

RO
Robert_Autenrieth
Dec 2021

If your goal is to create a crash-tolerant application that submits commands exactly once, use command deduplication:
Upon recovering from a crash, just resubmit any command where you are not sure whether you submitted it before or whether it might still be in flight. Command deduplication will take care of handling duplicate submissions. See docs for the existing command deduplication, and docs for the new command deduplication.

Other info possibly related to your question:

  • If you are only interested in the outcome of commands submitted after restarting the completion stream, don’t supply any offset. It will default to the current ledger end.
  • The active contract set service returns an offset at which the ACS was taken. This offset is typically used as the starting point for a flat transaction stream that informs you of changes to the ACS.
ST
stefanobaghino-da
Dec 2021

I’m deleting my answers as those were just wrong.

GE
gerolf
Dec 2021

Yes, each CompletionStreamResponse will also contain a Checkpoint message that contains the offset. You can use that offset to restart the stream at a later point in time to resume the stream from that offset.

LE
Leonid_Rozenberg
Dec 2021

Thank you!

QU
quidagis
Dec 2021

I was wondering :thinking: :grinning_face_with_smiling_eyes:

+1 for honesty.

← Back to Discussions