You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.7 KiB

  1. ## Blockchain Reactor
  2. * coordinates the pool for syncing
  3. * coordinates the store for persistence
  4. * coordinates the playing of blocks towards the app using a sm.BlockExecutor
  5. * handles switching between fastsync and consensus
  6. * it is a p2p.BaseReactor
  7. * starts the pool.Start() and its poolRoutine()
  8. * registers all the concrete types and interfaces for serialisation
  9. ### poolRoutine
  10. * listens to these channels:
  11. * pool requests blocks from a specific peer by posting to requestsCh, block reactor then sends
  12. a &bcBlockRequestMessage for a specific height
  13. * pool signals timeout of a specific peer by posting to timeoutsCh
  14. * switchToConsensusTicker to periodically try and switch to consensus
  15. * trySyncTicker to periodically check if we have fallen behind and then catch-up sync
  16. * if there aren't any new blocks available on the pool it skips syncing
  17. * tries to sync the app by taking downloaded blocks from the pool, gives them to the app and stores
  18. them on disk
  19. * implements Receive which is called by the switch/peer
  20. * calls AddBlock on the pool when it receives a new block from a peer
  21. ## Block Pool
  22. * responsible for downloading blocks from peers
  23. * makeRequestersRoutine()
  24. * removes timeout peers
  25. * starts new requesters by calling makeNextRequester()
  26. * requestRoutine():
  27. * picks a peer and sends the request, then blocks until:
  28. * pool is stopped by listening to pool.Quit
  29. * requester is stopped by listening to Quit
  30. * request is redone
  31. * we receive a block
  32. * gotBlockCh is strange
  33. ## Block Store
  34. * persists blocks to disk
  35. # TODO
  36. * How does the switch from bcR to conR happen? Does conR persist blocks to disk too?
  37. * What is the interaction between the consensus and blockchain reactors?