Skip to content

Commit

Permalink
implement NewView on diff
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Laine committed Nov 27, 2023
1 parent 2760af7 commit a7b758b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions vms/platformvm/state/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,20 @@ func NewDiff(
}, nil
}

func (*diff) NewView([]database.BatchOp) (merkledb.TrieView, error) {
return nil, errors.New("TODO")
func (d *diff) NewView(ops []database.BatchOp) (merkledb.TrieView, error) {
parentState, ok := d.stateVersions.GetState(d.parentID)
if !ok {
return nil, fmt.Errorf("%w: %s", ErrMissingParentState, d.parentID)
}

diffOps, err := d.GetMerkleChanges()
if err != nil {
return nil, err
}

ops = append(diffOps, ops...)

return parentState.NewView(ops)
}

func (d *diff) GetTimestamp() time.Time {
Expand Down

0 comments on commit a7b758b

Please sign in to comment.