OdyseeTeam / chainquery

Chainquery parses and syncs the LBRY blockchain data into structured SQL
https://lbry.tech
MIT License
2.25k stars 42 forks source link

Updated claim showing as "spent" / "expired" #83

Closed tzarebczan closed 5 years ago

tzarebczan commented 5 years ago

See https://chainquery.lbry.io/api/sql?query=SELECT%20*%20FROM%20claim%20where%20claim_id=%223187461e9df8554bbac34926f3bbfdddcd528a62%22

tiger5226 commented 5 years ago

I did some research. I don't have an answer yet. I found other claims with a similar problem.

https://chainquery.lbry.io/api/sql?query=SELECT%20*%20FROM%20claim%20INNER%20JOIN%20output%20ON%20output.transaction_hash%20=%20claim.transaction_hash_id%20AND%20output.vout%20=%20claim.vout%20AND%20output.is_spent=0%20WHERE%20claim.bid_state=%22Spent%22%20ORDER%20BY%20claim.modified_at%20DESC

I need to do more investigating to figure out how this could have happened. I see no reason why this would happen.

tzarebczan commented 5 years ago

Also sometimes shows expired : image

tzarebczan commented 5 years ago

It clears itself up after a while...I'm guessing after the claimtrie sync.

tiger5226 commented 5 years ago

So it was showing expired because when it's in the mempool its height is marked as 0. So based on the logic it is expired in this case. I added a check that if it's 0 it's never considered expired.

It was showing as spent sometimes because if the claimtrie sync would run between the claimname and the update processing, it would get marked as spent based on the first. If the timing of the update wasn't right it would get stuck in that state too because the claim trie sync only runs on claims that have been updated.

Fixed with 037ca9dd24bf61aaa2d9217616f0acb66d2dddf2