PISAresearch / pisa

Accountable Watching Service
https://pisa.watch
28 stars 9 forks source link

Consolidate BlockItemStore #378

Open bigspider opened 4 years ago

bigspider commented 4 years ago

The BlockItemStore is shared by several classes that need to store information attached to specific blocks (BlockCache/BlockProcessor/BlockchainMachine); moreover, it handles the "batching" to make sure that no inconsistent states are persisted.

The class is too tightly coupled with the other classes, and it is not clear whose responsibility it is to create the batches, and when they should be opened/committed. This suggestes a bigger refactoring is due, which might now take advantage of the fact that both the newBlock and the newHead events are now emitted by the BlockProcessor after #373.