Replies: 2 comments 10 replies
-
also it looks like redb now has savepoints, so maybe the answer is just "turn those on and provide a hook to rollback"? |
Beta Was this translation helpful? Give feedback.
9 replies
-
It happened again!
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Right now,
ord
scans forward and indexes the chain into its database. You can see the schema for the database tables here. Those tables store the current state of the chain (ie, no history). The index does store block heights mapped to blockhashes, and when it sees that a previous height in the index doesnt match a previous height from bitcoind, it marks the chain as reorg'd and bails.. That means that if there is a re-org, the indexer does not -- and based on the current schema, can't easily -- roll back state from the orphaned blocks are reindex.While
ord
index operators could do something completely out of band like snapshot their index everyn
hours/days, and then if a re-org is detected go and replace their index and re-index the diff, it would be great if the ord index updater could handle rollback and re-index automatically.It's not obvious to me that there's a good way to do that without storing some amount of previous state in the index. Either a write-ahead-log that can be rewound, or to have a few tables store historic information. I think that would look something like:
Map<blockheight, satspoint>
Map<blockheight, satspoint>
, we can easily get the "latest" valueWhat other mechanisms can we come up with to handle reorgs?
Beta Was this translation helpful? Give feedback.
All reactions