diff --git a/finality-provider/service/fastsync.go b/finality-provider/service/fastsync.go index 7f4b6928..aede1a3d 100644 --- a/finality-provider/service/fastsync.go +++ b/finality-provider/service/fastsync.go @@ -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 { @@ -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 diff --git a/finality-provider/service/fp_instance.go b/finality-provider/service/fp_instance.go index 46435edc..fc3fb844 100644 --- a/finality-provider/service/fp_instance.go +++ b/finality-provider/service/fp_instance.go @@ -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" @@ -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 { @@ -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 { @@ -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) } diff --git a/util/math.go b/lib/math/math.go similarity index 91% rename from util/math.go rename to lib/math/math.go index f9dcb4a8..c4de6dee 100644 --- a/util/math.go +++ b/lib/math/math.go @@ -1,4 +1,4 @@ -package util +package math func MaxUint64(values ...uint64) (max uint64) { for _, v := range values {