hexresearch / hschain

Other
4 stars 0 forks source link

Pull-based block propagation #552

Open Shimuuar opened 4 years ago

Shimuuar commented 4 years ago

For PoW, light clients etc we need to change block propagation from push-based to pull-based. This change will simplify logic of gossip since we don't need to trace whether node has block or not. It however necessitate creating new subsystem for tracking requests

  1. We need to track which block we need to fetch. That information could be obtained from appTMState TVar
  2. We need to track which nodes likely to have block we need and we need some way to choose such nodes
  3. We need to track requests in flight so we won't flood nodes with duplicate requests

Most straightforward implementation is to create yet another thread which will do exactly that. It will need access to following APIs:

  1. State of consensus engine. This one is already availalble
  2. State of each of existing peers & ability to send message to each individually