mirror of
https://github.com/colinear-labs/chain.git
synced 2026-03-04 23:44:24 -08:00
fully migrate to colinearcore params
- No more auctionconfig - Now includes GPU model list support - CPU vendors are still hardcoded
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"colinear/x/colinearcore/auctionconfig"
|
||||
"colinear/x/colinearcore/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@@ -28,7 +27,7 @@ func (k msgServer) LockFunds(goCtx context.Context, msg *types.MsgLockFunds) (*t
|
||||
// return nil, errors.New("unable to get locked users")
|
||||
}
|
||||
|
||||
required := big.NewInt(auctionconfig.ProviderMinLockedUClr)
|
||||
required := big.NewInt(int64(k.GetParams(ctx).ProviderMinLockedUClr))
|
||||
|
||||
paying := new(big.Int)
|
||||
paying.SetString(msg.Amount, 10)
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"math/big"
|
||||
"strconv"
|
||||
|
||||
"colinear/x/colinearcore/auctionconfig"
|
||||
"colinear/x/colinearcore/memdb"
|
||||
"colinear/x/colinearcore/types"
|
||||
|
||||
@@ -26,27 +25,27 @@ func (k msgServer) NewAuction(goCtx context.Context, msg *types.MsgNewAuction) (
|
||||
auctionLen := msg.LeaseEnd - uint64(ctx.BlockTime().Unix())
|
||||
|
||||
// check that submitted denom is allowed
|
||||
for _, denom := range auctionconfig.AllowedAuctionDenoms {
|
||||
for _, denom := range k.GetParams(ctx).AllowedAuctionDenoms {
|
||||
if msg.Denom == denom {
|
||||
goto found
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("denom %s is not allowed; must be in %v", msg.Denom, auctionconfig.AllowedAuctionDenoms)
|
||||
return nil, fmt.Errorf("denom %s is not allowed; must be in %v", msg.Denom, k.GetParams(ctx).AllowedAuctionDenoms)
|
||||
found:
|
||||
|
||||
if auctionLen < auctionconfig.MinLeasePeriod {
|
||||
if uint32(auctionLen) < k.GetParams(ctx).MinLeasePeriod {
|
||||
return nil, fmt.Errorf(
|
||||
"Auction length %d is below min lease period of %d",
|
||||
auctionLen,
|
||||
auctionconfig.MinLeasePeriod,
|
||||
k.GetParams(ctx).MinLeasePeriod,
|
||||
)
|
||||
}
|
||||
|
||||
if auctionLen > auctionconfig.MaxLeasePeriod {
|
||||
if uint32(auctionLen) > k.GetParams(ctx).MaxLeasePeriod {
|
||||
return nil, fmt.Errorf(
|
||||
"Auction length %d is above max lease period of %d",
|
||||
auctionLen,
|
||||
auctionconfig.MaxLeasePeriod,
|
||||
k.GetParams(ctx).MaxLeasePeriod,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -55,8 +54,8 @@ found:
|
||||
return nil, fmt.Errorf("sender address `%s` format invalid (bech32 required)", msg.Creator)
|
||||
}
|
||||
|
||||
if len(msg.VerifiedProviders) > auctionconfig.MaxVerifiedProviders {
|
||||
return nil, fmt.Errorf("must submit no more than %d verified providers (got %d)", auctionconfig.MaxVerifiedProviders, len(msg.VerifiedProviders))
|
||||
if uint32(len(msg.VerifiedProviders)) > k.GetParams(ctx).MaxVerifiedProviders {
|
||||
return nil, fmt.Errorf("must submit no more than %d verified providers (got %d)", k.GetParams(ctx).MaxVerifiedProviders, len(msg.VerifiedProviders))
|
||||
}
|
||||
|
||||
bech32Len := len("colinear") + 39
|
||||
@@ -78,7 +77,7 @@ found:
|
||||
Description: msg.Description,
|
||||
// best bid -> null
|
||||
// Best: new(types.Bid),
|
||||
Deadline: uint64(ctx.BlockHeight()) + auctionconfig.AuctionTime,
|
||||
Deadline: uint64(ctx.BlockHeight()) + uint64(k.GetParams(ctx).AuctionTime),
|
||||
Denom: msg.Denom,
|
||||
Owner: msg.Creator,
|
||||
Ceiling: msg.Ceiling,
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"math/big"
|
||||
"reflect"
|
||||
|
||||
"colinear/x/colinearcore/auctionconfig"
|
||||
"colinear/x/colinearcore/memdb"
|
||||
"colinear/x/colinearcore/types"
|
||||
|
||||
@@ -22,13 +21,13 @@ func (k msgServer) NewBid(goCtx context.Context, msg *types.MsgNewBid) (*types.M
|
||||
return nil, errors.New("unable to read locked providers (uninitialized)")
|
||||
}
|
||||
if lockedAmtStr, ok := lockedUsers.Users[msg.Creator]; !ok {
|
||||
return nil, fmt.Errorf("provider has not locked CLR tokens (min: %d uCLR)", auctionconfig.ProviderMinLockedUClr)
|
||||
return nil, fmt.Errorf("provider has not locked CLR tokens (min: %d uCLR)", k.GetParams(ctx).ProviderMinLockedUClr)
|
||||
} else {
|
||||
lockedAmt := new(big.Int)
|
||||
lockedAmt.SetString(lockedAmtStr, 10)
|
||||
required := big.NewInt(auctionconfig.ProviderMinLockedUClr)
|
||||
required := big.NewInt(int64(k.GetParams(ctx).ProviderMinLockedUClr))
|
||||
if lockedAmt.Cmp(required) == -1 {
|
||||
return nil, fmt.Errorf("provider has not locked enough CLR tokens (min: %d uCLR, locked: %s)", auctionconfig.ProviderMinLockedUClr, lockedAmt.String())
|
||||
return nil, fmt.Errorf("provider has not locked enough CLR tokens (min: %d uCLR, locked: %s)", k.GetParams(ctx).ProviderMinLockedUClr, lockedAmt.String())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user