Skip to content

Commit

Permalink
minSafeRazor fix (#669)
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhar2807 authored Apr 6, 2022
1 parent 9979d65 commit 457fede
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 45 deletions.
20 changes: 0 additions & 20 deletions utils/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,26 +102,6 @@ func (*UtilsStruct) GetMinStakeAmount(client *ethclient.Client) (*big.Int, error
return minStake, nil
}

func (*UtilsStruct) GetMinSafeRazor(client *ethclient.Client) (*big.Int, error) {
var (
minStake *big.Int
err error
)
err = retry.Do(
func() error {
minStake, err = BlockManagerInterface.MinStake(client)
if err != nil {
log.Error("Error in fetching minimum stake amount.... Retrying")
return err
}
return nil
}, RetryInterface.RetryAttempts(core.MaxRetries))
if err != nil {
return nil, err
}
return minStake, nil
}

func (*UtilsStruct) GetMaxAltBlocks(client *ethclient.Client) (uint8, error) {
var (
maxAltBlocks uint8
Expand Down
2 changes: 1 addition & 1 deletion utils/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ type StakeManagerUtils interface {
GetStakerId(client *ethclient.Client, address common.Address) (uint32, error)
GetStaker(*ethclient.Client, uint32) (bindings.StructsStaker, error)
GetNumStakers(*ethclient.Client) (uint32, error)
GetMinSafeRazor(client *ethclient.Client) (*big.Int, error)
MinSafeRazor(client *ethclient.Client) (*big.Int, error)
Locks(client *ethclient.Client, address common.Address, address1 common.Address, lockType uint8) (types.Locks, error)
MaxCommission(*ethclient.Client) (uint8, error)
EpochLimitForUpdateCommission(*ethclient.Client) (uint16, error)
Expand Down
46 changes: 23 additions & 23 deletions utils/mocks/stake_manager_utils.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions utils/stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,23 @@ func (*UtilsStruct) GetStakerSRZRBalance(client *ethclient.Client, staker bindin
}
return sRZRBalance, nil
}

func (*UtilsStruct) GetMinSafeRazor(client *ethclient.Client) (*big.Int, error) {
var (
minSafeRazor *big.Int
err error
)
err = retry.Do(
func() error {
minSafeRazor, err = StakeManagerInterface.MinSafeRazor(client)
if err != nil {
log.Error("Error in fetching minimum safe razor.... Retrying")
return err
}
return nil
}, RetryInterface.RetryAttempts(core.MaxRetries))
if err != nil {
return nil, err
}
return minSafeRazor, nil
}
2 changes: 1 addition & 1 deletion utils/struct-utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (s StakeManagerStruct) GetNumStakers(client *ethclient.Client) (uint32, err
return stakeManager.GetNumStakers(&opts)
}

func (s StakeManagerStruct) GetMinSafeRazor(client *ethclient.Client) (*big.Int, error) {
func (s StakeManagerStruct) MinSafeRazor(client *ethclient.Client) (*big.Int, error) {
stakeManager, opts := UtilsInterface.GetStakeManagerWithOpts(client)
return stakeManager.MinSafeRazor(&opts)
}
Expand Down

0 comments on commit 457fede

Please sign in to comment.