Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.
This repository was archived by the owner on Jun 30, 2021. It is now read-only.

Handle block reorgs appropriately #6

@icook

Description

@icook

This is mostly tough because testing it is somewhat tricky. Either setup complete testing infrastructure and mock everything (time consuming) or do a one off test with testnet in a box and three nodes.

Either way, to be fully featured this is completely necessary. Steps would be approximately:

  1. Check if highest indexed block hash is equal to what the RPC server has for that height.
  2. If not, go backwards and continue comparing until you get a match. Each block that doesn't match needs to:
    1. Be marked as Orphan
    2. Have all linked Transactions remove their block reference.
    3. Add new entry to the "seen in" many to many between blocks and transactions
    4. Update confirmation status of the Transaction (if we start caching this).
  3. Once common ancestor is reached sync as normal.

Doing this after #4 and #1 seems prudent.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions