Per-block diffs
ConsensusChange
contains a set of diffs that provide convenient information about outputs, file contracts, and more. Without these diffs, a subscriber would have to maintain an entire separate database to lookup the value of a particular SiacoinInput
, for example.
Unfortunately, each ConsensusChange
contains a single set of diffs, even though a ConsensusChange
may contain multiple blocks. This means that, for example, if a ConsensusChange
contains a diff for a miner payout that matured, there is no easy way to tell which block the payout matured in. This is further complicated by the fact that the diff "direction" is overloaded: "revert" can either mean that an output was spent, or that it was created in a block that was reverted.
This MR adds two fields to ConsensusChange
that allow a subscriber to match each reverted or applied block with the specific diffs that the block triggered. To facilitate this, I added a ConsensusChangeDiffs
type that simply aggregates all of the Diff
fields. I did not change the encoding of ConsensusChange
, so HTTP subscribers won't see these fields, but I'm leaning towards adding them. (The downside is that you end up encoding each diff twice, so we'll have to decide whether it's worth it.)
Marking this as WIP for now as the design isn't final and I haven't written tests yet.