Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polish: add ClaimsChanged and DiffClaims method to power shim #4628

Merged
merged 2 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions chain/actors/builtin/power/power.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type State interface {
MinerNominalPowerMeetsConsensusMinimum(address.Address) (bool, error)
ListAllMiners() ([]address.Address, error)
ForEachClaim(func(miner address.Address, claim Claim) error) error
ClaimsChanged(State) (bool, error)
}

type Claim struct {
Expand Down
9 changes: 9 additions & 0 deletions chain/actors/builtin/power/v0.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,12 @@ func (s *state0) ForEachClaim(cb func(miner address.Address, claim Claim) error)
})
})
}

func (s *state0) ClaimsChanged(other State) (bool, error) {
other0, ok := other.(*state0)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !s.State.Claims.Equals(other0.State.Claims), nil
}
9 changes: 9 additions & 0 deletions chain/actors/builtin/power/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,12 @@ func (s *state2) ForEachClaim(cb func(miner address.Address, claim Claim) error)
})
})
}

func (s *state2) ClaimsChanged(other State) (bool, error) {
other2, ok := other.(*state2)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !s.State.Claims.Equals(other2.State.Claims), nil
}