fix: bad indirection of deadline diffing

This commit is contained in:
frrist 2020-10-14 14:50:59 -07:00
parent ea1349205b
commit 28823fb8e9

View File

@ -7,9 +7,9 @@ import (
"github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-state-types/exitcode"
) )
type DeadlinesDiff map[uint64]*DeadlineDiff type DeadlinesDiff map[uint64]DeadlineDiff
func DiffDeadlines(pre, cur State) (*DeadlinesDiff, error) { func DiffDeadlines(pre, cur State) (DeadlinesDiff, error) {
changed, err := pre.DeadlinesChanged(cur) changed, err := pre.DeadlinesChanged(cur)
if err != nil { if err != nil {
return nil, err return nil, err
@ -18,11 +18,7 @@ func DiffDeadlines(pre, cur State) (*DeadlinesDiff, error) {
return nil, nil return nil, nil
} }
numDl, err := pre.NumDeadlines() dlDiff := make(DeadlinesDiff)
if err != nil {
return nil, err
}
dlDiff := make(DeadlinesDiff, numDl)
if err := pre.ForEachDeadline(func(idx uint64, preDl Deadline) error { if err := pre.ForEachDeadline(func(idx uint64, preDl Deadline) error {
curDl, err := cur.LoadDeadline(idx) curDl, err := cur.LoadDeadline(idx)
if err != nil { if err != nil {
@ -39,12 +35,12 @@ func DiffDeadlines(pre, cur State) (*DeadlinesDiff, error) {
}); err != nil { }); err != nil {
return nil, err return nil, err
} }
return &dlDiff, nil return dlDiff, nil
} }
type DeadlineDiff map[uint64]*PartitionDiff type DeadlineDiff map[uint64]*PartitionDiff
func DiffDeadline(pre, cur Deadline) (*DeadlineDiff, error) { func DiffDeadline(pre, cur Deadline) (DeadlineDiff, error) {
changed, err := pre.PartitionsChanged(cur) changed, err := pre.PartitionsChanged(cur)
if err != nil { if err != nil {
return nil, err return nil, err
@ -104,7 +100,7 @@ func DiffDeadline(pre, cur Deadline) (*DeadlineDiff, error) {
return nil, err return nil, err
} }
return &partDiff, nil return partDiff, nil
} }
type PartitionDiff struct { type PartitionDiff struct {