I'm using dfuse streaming API to built a EOS based application. I want to keep an in-sync view of all the data flowing through my smart contract.
I want to ensure that I will always be in sync so I never miss a single block. Using the dfuse streaming API, how can I achieve that?
Using the with_progress
feature of the Websocket API, you will receive one progress
message after each block was processed.
For a given stream (corresponding to a request and an associated req_id
), when you received a progress
for a block, you are guaranteed to have seen all the contents it contained in your query (the actions for get_action_traces
, or the rows for get_table_rows
).
If you keep track of that block_num
and/or block_id
, upon disconnection/reconnections, you can provide it back in your request, and be guaranteed never to miss a beat, even if that means you're reprocessing 1M blocks.
As of November 22nd 2018, the get_table_rows
request will stream table_delta
messages that include an "undo"
/"redo"
step
. This allows your app to navigate forks and ensure absolute sync of your application with the longest chain's state.
Check the docs at https://docs.dfuse.io/ and search for with_progress
for more details.