Skip to content

Commit

Permalink
chore: removed math from utils
Browse files Browse the repository at this point in the history
  • Loading branch information
RafilxTenfen committed Oct 24, 2024
1 parent 7175eba commit d9fe78c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions finality-provider/service/fastsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"go.uber.org/zap"

"github.com/babylonlabs-io/finality-provider/lib/math"
"github.com/babylonlabs-io/finality-provider/types"
"github.com/babylonlabs-io/finality-provider/util"
)

type FastSyncResult struct {
Expand Down Expand Up @@ -36,7 +36,7 @@ func (fp *FinalityProviderInstance) FastSync(startHeight, endHeight uint64) (*Fa

responses := make([]*types.TxResponse, 0)
// make sure it starts at least at the finality activation height
startHeight = util.MaxUint64(startHeight, activationBlkHeight)
startHeight = math.MaxUint64(startHeight, activationBlkHeight)
// the syncedHeight is at least the starting point
syncedHeight := startHeight
// we may need several rounds to catch-up as we need to limit
Expand Down
6 changes: 3 additions & 3 deletions finality-provider/service/fp_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/avast/retry-go/v4"
bbntypes "github.com/babylonlabs-io/babylon/types"
ftypes "github.com/babylonlabs-io/babylon/x/finality/types"
fppath "github.com/babylonlabs-io/finality-provider/lib/math"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/gogo/protobuf/jsonpb"
"go.uber.org/atomic"
Expand All @@ -23,7 +24,6 @@ import (
"github.com/babylonlabs-io/finality-provider/finality-provider/store"
"github.com/babylonlabs-io/finality-provider/metrics"
"github.com/babylonlabs-io/finality-provider/types"
"github.com/babylonlabs-io/finality-provider/util"
)

type FinalityProviderInstance struct {
Expand Down Expand Up @@ -410,7 +410,7 @@ func (fp *FinalityProviderInstance) fastSyncStartHeight(lastFinalizedHeight uint
}

// return the max start height by checking the finality activation block height
return util.MaxUint64(lastProcessedHeight+1, lastFinalizedHeight+1, finalityActivationBlkHeight), nil
return fppath.MaxUint64(lastProcessedHeight+1, lastFinalizedHeight+1, finalityActivationBlkHeight), nil
}

func (fp *FinalityProviderInstance) hasProcessed(b *types.BlockInfo) bool {
Expand Down Expand Up @@ -624,7 +624,7 @@ func (fp *FinalityProviderInstance) CommitPubRand(tipHeight uint64) (*types.TxRe
// NOTE: currently, calling this will create and save a list of randomness
// in case of failure, randomness that has been created will be overwritten
// for safety reason as the same randomness must not be used twice
pubRandList, err := fp.getPubRandList(util.MaxUint64(startHeight, activationBlkHeight), fp.cfg.NumPubRand)
pubRandList, err := fp.getPubRandList(fppath.MaxUint64(startHeight, activationBlkHeight), fp.cfg.NumPubRand)
if err != nil {
return nil, fmt.Errorf("failed to generate randomness: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion util/math.go → lib/math/math.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package util
package math

func MaxUint64(values ...uint64) (max uint64) {
for _, v := range values {
Expand Down

0 comments on commit d9fe78c

Please sign in to comment.