The PutBlock method was introduced as a method to Block in #178. Having PutBlock where it is now adds network dependencies to the types package, which is undesirable. The original thinking in doing so was so that erasured data could be cached instead of recomputed. While caching the erasured data is still a good idea, it was not implemented in #178 and does not necessarily require PutBlock being a method to Block.
We should probably make PutBlock a function and move it to a different package. This will require a general refactor, which includes exporting the utility function shared by PutBlock and fillDataAvailabilityHeader.
As for where to move it, per a suggestion by @liamsi, I think we should move PutBlock and it's related code to lazyledger-core/p2p/ipld.
ref: #178 (comment)
The
PutBlockmethod was introduced as a method toBlockin #178. HavingPutBlockwhere it is now adds network dependencies to thetypespackage, which is undesirable. The original thinking in doing so was so that erasured data could be cached instead of recomputed. While caching the erasured data is still a good idea, it was not implemented in #178 and does not necessarily requirePutBlockbeing a method toBlock.We should probably make
PutBlocka function and move it to a different package. This will require a general refactor, which includes exporting the utility function shared byPutBlockandfillDataAvailabilityHeader.As for where to move it, per a suggestion by @liamsi, I think we should move
PutBlockand it's related code tolazyledger-core/p2p/ipld.ref: #178 (comment)