ARCHIVED
ae_canary.
This project is no longer active superseded byFork Detection
The following steps are repeated with pauses of 180 seconds in between.
1. Update Chain Ends
- Call the endpoint of a single node
http://206.81.24.215:3013/v2/status/chain-ends
- From each unique chain end, recursively query the
prev_key_hash
from the node- Get
prev_key_hash
from current Block ("Block 2") - Query the previous block ("Block 1") from node
- Insert block ("Block 1") in database
- Set reference from inserted ("Block 1") to next block ("Block 2") (via
prev_key_hash
) - Repeat unless the
key_hash
of ("Block 1") is already in the database
- Get
2. Check for Forks
- Search the database for
prev_key_hash
which occur more than once - Get all blocks with these
prev_key_hash
which are not older than 1k blocks from the current top - Run a forward search on these. For each potential fork:
- Get all future blocks (height > current)
- For current Block ("Block 1") get the next block ("Block 2") where
2.prev_key_hash
is1.key_hash
- If there are two next Blocks, do a forward search for each of them and merge the result in current fork
- Repeat 2. & 3. until there are no next blocks
3. Alert for forks
- Remove the longest (highest height - lowest height) fork, its the main chain
- For all other found forks,
- verify that a fork contains more than one block
- check if it has been growing (compare with memory state of last alert iterations)
- if both of the above are true, alert users in telegram group