bitauth / chaingraph

A multi-node blockchain indexer and GraphQL API
https://chaingraph.cash/
MIT License
49 stars 15 forks source link

Estimate sync progress more accurately (based on transaction count rather than block height) #42

Open bitjson opened 2 years ago

bitjson commented 2 years ago

When logging sync progress percentages, Chaingraph should use the GuessVerificationProgress algorithm from the Satoshi client. The source data should be provided in an environment variable like CHAINGRAPH_ESTIMATED_TRANSACTION_RATES, and rather than attempting to associate the proper estimate with each node/chain, we should just mark each estimate with the block hash. After Chaingraph completes the headers-first sync, it will typically see some block header hash it recognizes, and the better sync progress estimate will be used in agent logging.

We can copy ChainTxData from one of the Satoshi-client derived implementations for each chain/network. E.g. for BCH mainnet currently (hash : timestamp : transaction count : and per-second estimate after timestamp):

CHAINGRAPH_ESTIMATED_TRANSACTION_RATES=000000000000000000d7e938f43eb520468fc75dc626c54ec770f9cd1bd6bc1d:1628025092:1628025092:1.49