From 0d384050fa623437654f47a7fb8a06fa3986f27d Mon Sep 17 00:00:00 2001 From: frrist Date: Mon, 26 Oct 2020 14:20:25 -0700 Subject: [PATCH] polish: add Equals method to MinerInfo shim --- chain/actors/builtin/miner/miner.go | 1 + chain/actors/builtin/miner/v0.go | 9 +++++++++ chain/actors/builtin/miner/v2.go | 9 +++++++++ 3 files changed, 19 insertions(+) diff --git a/chain/actors/builtin/miner/miner.go b/chain/actors/builtin/miner/miner.go index aad41e8a9..5821d092b 100644 --- a/chain/actors/builtin/miner/miner.go +++ b/chain/actors/builtin/miner/miner.go @@ -77,6 +77,7 @@ type State interface { DeadlinesChanged(State) (bool, error) Info() (MinerInfo, error) + MinerInfoChanged(State) (bool, error) DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error) diff --git a/chain/actors/builtin/miner/v0.go b/chain/actors/builtin/miner/v0.go index c79f4a2f7..69160e4e0 100644 --- a/chain/actors/builtin/miner/v0.go +++ b/chain/actors/builtin/miner/v0.go @@ -277,6 +277,15 @@ func (s *state0) DeadlinesChanged(other State) (bool, error) { 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) { info, err := s.State.GetInfo(s.store) if err != nil { diff --git a/chain/actors/builtin/miner/v2.go b/chain/actors/builtin/miner/v2.go index c686fa483..2c67484ea 100644 --- a/chain/actors/builtin/miner/v2.go +++ b/chain/actors/builtin/miner/v2.go @@ -276,6 +276,15 @@ func (s *state2) DeadlinesChanged(other State) (bool, error) { 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) { info, err := s.State.GetInfo(s.store) if err != nil {