hexresearch / hschain

Other
4 stars 0 forks source link

Change encoding for state view #700

Closed Shimuuar closed 3 years ago

Shimuuar commented 3 years ago

Curx of problem is creation of blocks. Creation of new block generally need some information that we as library have no information: private key for coinbase, spend script for it, etc. Thus we can't just put createBlock function into StateView dictionary. This became very obvious in cypra.

One possible solution is to turn state view into data type and turn StateView into type class (this PR does just this). This makes writing code for dealing with state much mode straightforward.

Downside is now we have relations betwenn 3 types: block type @b@, monad type in which we work: @m@, and state view @view@. Encoding it using type families is rather straightforward, but type signatures become unwieldy