[ethereum/go-ethereum] contracts: add checkpoint registrar smart contract (#16842)

rjl493456442 commented on this pull request.

> + }
+ // Note several events have same index may be received because of chain reorg and
+ // the modification of the latest checkpoint.
+ if checkpoint == nil || event.Index.Uint64() > checkpoint.SectionIdx {
+ log.Info(“Receive new checkpoint event”, “section”, event.Index, “hash”, common.Hash(event.CheckpointHash).Hex(),
+ “grantor”, event.Grantor.Hex())
+ announcement[event.Index.Uint64()] = common.Hash(event.CheckpointHash)
+ }
+ case head := checkpoint.SectionIdx {
+ hash, ok := announcement[idx]

We will match and generate a stable checkpoint only when we receive a checkpoint announcement and the local indexer has calculated it. But the order doesn’t matter here. Since whatever which one arrives first(In the normal case, local indexer should calculate it early than checkpoint announcement, but we keep the possibility if admin fetches the calculated unstable checkpoint from a `very fast node`, while our local node is `very slow node` which needs to take a long time to calculate unstable checkpoint), we will match the hash always. If announcement’s hash is not equal with local one, we will keep match every block until find a valid one.

This post was last modified on July 11, 2018, 7:56 am