near / near-indexer-for-explorer

Watch NEAR network and store all the data from NEAR blockchain to PostgreSQL database
https://near-indexers.io/docs/projects/near-indexer-for-explorer
GNU General Public License v3.0
124 stars 56 forks source link

`accounts.last_update_block_height` does not show corresponding data #91

Closed telezhnaya closed 3 years ago

telezhnaya commented 3 years ago

Just checked on the data: accounts.last_update_block_height is equal to accounts.deleted_by_receipt_id if the account was deleted; otherwise, it is equal to accounts.created_by_receipt_id. Intuitively, I was waiting for the block height with the last update on this account. By the way, I am not sure we need this info since it will produce many updates in DB.

I suggest to get rid of this column and add columns created_at_block_height and deleted_at_block_height. We have to make 4 joins to find this info right now 😢

frol commented 3 years ago

Oh, sorry for the confusing name. This field is important for another reason. It ensures that when we run two or more indexers from different checkpoints, they don't blindly override data from one another. This is an anchor for concurrent:

UPDATE accounts SET created_by_receipt_id = 'zxc' WHERE last_update_block_height < :current_block_height
UPDATE accounts SET deleted_by_receipt_id = 'zxc' WHERE last_update_block_height < :current_block_height