Merge pull request #4604 from filecoin-project/frrist/miner-shim-info-equal

polish: add Equals method to MinerInfo shim
This commit is contained in:
Whyrusleeping 2020-10-26 17:54:30 -07:00 committed by GitHub
commit 2b6bc7d59a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 0 deletions

View File

@ -77,6 +77,7 @@ type State interface {
DeadlinesChanged(State) (bool, error) DeadlinesChanged(State) (bool, error)
Info() (MinerInfo, error) Info() (MinerInfo, error)
MinerInfoChanged(State) (bool, error)
DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error) DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error)

View File

@ -277,6 +277,15 @@ func (s *state0) DeadlinesChanged(other State) (bool, error) {
return !s.State.Deadlines.Equals(other0.Deadlines), nil return !s.State.Deadlines.Equals(other0.Deadlines), nil
} }
func (s *state0) MinerInfoChanged(other State) (bool, error) {
other0, ok := other.(*state0)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !s.State.Info.Equals(other0.State.Info), nil
}
func (s *state0) Info() (MinerInfo, error) { func (s *state0) Info() (MinerInfo, error) {
info, err := s.State.GetInfo(s.store) info, err := s.State.GetInfo(s.store)
if err != nil { if err != nil {

View File

@ -276,6 +276,15 @@ func (s *state2) DeadlinesChanged(other State) (bool, error) {
return !s.State.Deadlines.Equals(other2.Deadlines), nil return !s.State.Deadlines.Equals(other2.Deadlines), nil
} }
func (s *state2) MinerInfoChanged(other State) (bool, error) {
other0, ok := other.(*state2)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !s.State.Info.Equals(other0.State.Info), nil
}
func (s *state2) Info() (MinerInfo, error) { func (s *state2) Info() (MinerInfo, error) {
info, err := s.State.GetInfo(s.store) info, err := s.State.GetInfo(s.store)
if err != nil { if err != nil {