Hey there guys,
i want to understand what offset is in simple terms, i am new to blockchain, so an answer in that direction might be confusing still, all the questions and answers i see here, seem to be long ago
Anyone care to unblock.
Hey there guys,
i want to understand what offset is in simple terms, i am new to blockchain, so an answer in that direction might be confusing still, all the questions and answers i see here, seem to be long ago
Anyone care to unblock.
Interesting… I cannot find the answer in the docs. Maybe I’m not looking hard enough.
The offset is an incrementing index of the changes made to your node’s copy of the ledger. Think of it as a row number in your view of the immutable ledger. When the ledger is created, the offset is 0. As changes are made to the ledger, the offset increases. That is why you can query for the Active Contract Set at a specific offset.
When you call the Json Ledger API’s /v2/state/ledger-end, it returns the offset at that moment.
Hey @WallaceKelly, long time
does this mean that if i need to query the acs for most recent contractid for a specific party and ledger i would first get the latest offset and then use this value?, or is there anytime i would need to use a value that isn’t the latest value of the ledger, and when might these situations arise
Thanks
if i need to query the acs for most recent contractid for a specific party and ledger i would first get the latest offset and then use this value?
I would say that is one way to do it. And that is a fine way to do it if it meets your application’s needs. An alternative is to subscribe to the stream of events and track the latest value from the stream. For example, the Participant Query Store subscribes to the event stream and writes that data into a Postgres database. You can then query the PQS-maintained Postgres database for the “current value” or any value in the past.
is there anytime i would need to use a value that isn’t the latest value of the ledger, and when might these situations arise
If I understand correctly, that would depend on your application. Some applications might need to look at history. Others may not.
What stream if events do you hint here please, cause i have to pass the offset into the ACS with party filter params
also isn’t the PQS an enterprise feature?, or are there any alternatives to build something similar?
There is a /v2/updates websocket endpoint. It is documented here.
Yes, PQS is an enterprise feature. Other teams also have products in this general domain.
Yes, you could implement your own similar functionality. You could write the events into MongoDb, for example.