Unbounded Currency
The Currency
type can no longer overflow. However, its MarshalSia
method restricts the length prefix to one byte, giving a maximum value of 2^(255 * 8) =~ 10^614. Larger values can be used internally, but will fail to encode correctly.
Also, Currency
arithmetic will always return a new value. This means that you often have to write sum = sum.Add(value)
instead of just sum.Add(value)
, but it isn't a big deal. Plus, you can chain operations now, and they're 10x more readable.
This change might have introduced some sneaky bugs. When I changed the return value from an error
to a Currency
, all the places where we had err = x.Add(y)
threw compiler errors. But the places where we just had x.Add(y)
were silent, so I had to hunt them all down manually. Hopefully I got them all.
Large-scale review of the consensus package is next.