May need to reconsider the current method of determining the latest completely indexed block
The c.contract_balance table of the tezos-indexer database is the table that tracks the balances of all contracts (implicit or originated). A row is created in this table for every contract that has had their balances updated and only if they were updated. If a contract has never had any changes in their balance, the contract would never appear in this table.
When the tezos-indexer indexes this table, it will first create a row with the address_id of the contract and the block_hash_id of the block on which the balance was updated. During this phase, the balance is set to null. An RPC call will be made for each row to retrieve the balance which will replace the null value. Once all of the null values have been replaced with balances, the block can be seen as completely indexed with all related data.
In order to work around having this null value being retrieved, Tezgraph will only be retrieving the balances of the blocks that have been determined to be completely indexed (indexed with all related data including contract balances). At the moment, the only way to determine whether a block has been completely indexed is to check if the block in question has any rows in c.contract_balance
with null values in the balance
column. If such rows are found, then the block is considered to be still indexing and not complete. If no such rows are found, then the block is considered to be completely indexed.