Indexer Fetcher Implementation - Algorand
Indexer Fetcher Implementation
post by gidon on Jan 5, 2022
I am trying to read the implementation of the indexer but I am not familiar with the Go language.
In https://github.com/algorand/indexer/blob/develop/fetcher/fetcher.go, once caught up, how does the indexer know that a new block has been added? Line 136 comment is
// wait for algod to notify of a new round, then fetch that block
but I don’t see in the code where this is happening. Line 194 has a sleep call so is it correct that the indexer is just waiting 5 seconds each time and then querying to see if there is a new block?
Thanks
post by fabrice on Jan 5, 2022
The indexer uses the StatusAfterBlock REST API call:
which is also what is used in general for waiting for confirmation of a block in the developer API documentation
post by gidon on Jan 6, 2022
I see, thanks for the explanation. What is the purpose of the sleeping for 5 seconds on line 194? Is it a timeout to see if the indexer recovers from an error from failing to fetch the next block?