diff --git a/deployment/localup/localup.sh b/deployment/localup/localup.sh index 251be926f..ddf2d2006 100644 --- a/deployment/localup/localup.sh +++ b/deployment/localup/localup.sh @@ -154,7 +154,7 @@ function generate_genesis() { sed -i -e "s/\"discontinue_deletion_max\": \"100\"/\"discontinue_deletion_max\": \"2\"/g" ${workspace}/.local/validator${i}/config/genesis.json sed -i -e "s/\"voting_period\": \"30s\"/\"voting_period\": \"5s\"/g" ${workspace}/.local/validator${i}/config/genesis.json sed -i -e "s/\"update_global_price_interval\": \"0\"/\"update_global_price_interval\": \"1\"/g" ${workspace}/.local/validator${i}/config/genesis.json - sed -i -e "s/\"max_update_price_times\": 3/\"max_update_price_times\": 1000000/g" ${workspace}/.local/validator${i}/config/genesis.json + sed -i -e "s/\"update_price_disallowed_days\": 2/\"update_price_disallowed_days\": 0/g" ${workspace}/.local/validator${i}/config/genesis.json #sed -i -e "s/\"community_tax\": \"0.020000000000000000\"/\"community_tax\": \"0\"/g" ${workspace}/.local/validator${i}/config/genesis.json sed -i -e "s/log_level = \"info\"/\log_level= \"debug\"/g" ${workspace}/.local/validator${i}/config/config.toml done diff --git a/e2e/tests/sp_test.go b/e2e/tests/sp_test.go index 6640e4e37..4703cfeb4 100644 --- a/e2e/tests/sp_test.go +++ b/e2e/tests/sp_test.go @@ -161,19 +161,17 @@ func (s *StorageProviderTestSuite) TestUpdateSpStoragePrice() { ctx := context.Background() defer s.revertParams() - // update params - params := s.queryParams() - params.UpdateGlobalPriceInterval = 10 - params.MaxUpdatePriceTimes = 2 - s.updateParams(params) - // query sp storage price by time before it exists, expect error _, err := s.Client.QueryGlobalSpStorePriceByTime(ctx, &sptypes.QueryGlobalSpStorePriceByTimeRequest{ Timestamp: 1, }) s.Require().Error(err) - // check update price + // update params + params := s.queryParams() + params.UpdateGlobalPriceInterval = 5 + s.updateParams(params) + sp := s.BaseSuite.PickStorageProvider() spAddr := sp.OperatorKey.GetAddr().String() spStoragePrice, err := s.Client.QuerySpStoragePrice(ctx, &sptypes.QuerySpStoragePriceRequest{ @@ -182,7 +180,7 @@ func (s *StorageProviderTestSuite) TestUpdateSpStoragePrice() { s.Require().NoError(err) s.T().Log(spStoragePrice) - // update storage price - first update is ok + // update storage price - update is ok msgUpdateSpStoragePrice := &sptypes.MsgUpdateSpStoragePrice{ SpAddress: spAddr, ReadPrice: spStoragePrice.SpStoragePrice.ReadPrice, @@ -191,25 +189,7 @@ func (s *StorageProviderTestSuite) TestUpdateSpStoragePrice() { } _ = s.SendTxBlock(sp.OperatorKey, msgUpdateSpStoragePrice) - // update storage price - secondary update is ok - msgUpdateSpStoragePrice = &sptypes.MsgUpdateSpStoragePrice{ - SpAddress: spAddr, - ReadPrice: spStoragePrice.SpStoragePrice.ReadPrice, - StorePrice: spStoragePrice.SpStoragePrice.StorePrice, - FreeReadQuota: spStoragePrice.SpStoragePrice.FreeReadQuota, - } - _ = s.SendTxBlock(sp.OperatorKey, msgUpdateSpStoragePrice) - - // update storage price - third update is not ok - msgUpdateSpStoragePrice = &sptypes.MsgUpdateSpStoragePrice{ - SpAddress: spAddr, - ReadPrice: spStoragePrice.SpStoragePrice.ReadPrice, - StorePrice: spStoragePrice.SpStoragePrice.StorePrice, - FreeReadQuota: spStoragePrice.SpStoragePrice.FreeReadQuota, - } - s.SendTxBlockWithExpectErrorString(msgUpdateSpStoragePrice, sp.OperatorKey, "cannot update price due to frequency limited") - - time.Sleep(12 * time.Second) + time.Sleep(6 * time.Second) // verify price is updated after interval globalPriceResBefore, _ := s.Client.QueryGlobalSpStorePriceByTime(ctx, &sptypes.QueryGlobalSpStorePriceByTimeRequest{Timestamp: 0}) @@ -235,20 +215,37 @@ func (s *StorageProviderTestSuite) TestUpdateSpStoragePrice() { } } - time.Sleep(12 * time.Second) + time.Sleep(6 * time.Second) globalPriceResAfter2, _ := s.Client.QueryGlobalSpStorePriceByTime(ctx, &sptypes.QueryGlobalSpStorePriceByTimeRequest{Timestamp: 0}) s.T().Log("globalPriceResAfter2", core.YamlString(globalPriceResAfter2)) s.CheckGlobalSpStorePrice() - if !priceChanged { //if price not changed, then after 10 seconds, it should change + if !priceChanged { //if price not changed, then after 6 seconds, it should change s.Require().NotEqual(globalPriceResAfter2.GlobalSpStorePrice.PrimaryStorePrice, globalPriceResBefore.GlobalSpStorePrice.PrimaryStorePrice) s.Require().NotEqual(globalPriceResAfter2.GlobalSpStorePrice.SecondaryStorePrice, globalPriceResBefore.GlobalSpStorePrice.SecondaryStorePrice) s.Require().NotEqual(globalPriceResAfter2.GlobalSpStorePrice.ReadPrice, globalPriceResBefore.GlobalSpStorePrice.ReadPrice) - } else { //if price not changed already, then after 10 seconds, it should not change + } else { //if price not changed already, then after 6 seconds, it should not change s.Require().Equal(globalPriceResAfter2.GlobalSpStorePrice.PrimaryStorePrice, globalPriceResAfter1.GlobalSpStorePrice.PrimaryStorePrice) s.Require().Equal(globalPriceResAfter2.GlobalSpStorePrice.SecondaryStorePrice, globalPriceResAfter1.GlobalSpStorePrice.SecondaryStorePrice) s.Require().Equal(globalPriceResAfter2.GlobalSpStorePrice.ReadPrice, globalPriceResAfter1.GlobalSpStorePrice.ReadPrice) } + + // update params + now := time.Now().UTC() + _, _, day := now.Date() + params = s.queryParams() + params.UpdateGlobalPriceInterval = 0 // update by month + params.UpdatePriceDisallowedDays = uint32(31 - day + 1) + s.updateParams(params) + + // update storage price - third update is not ok + msgUpdateSpStoragePrice = &sptypes.MsgUpdateSpStoragePrice{ + SpAddress: spAddr, + ReadPrice: spStoragePrice.SpStoragePrice.ReadPrice, + StorePrice: spStoragePrice.SpStoragePrice.StorePrice, + FreeReadQuota: spStoragePrice.SpStoragePrice.FreeReadQuota, + } + s.SendTxBlockWithExpectErrorString(msgUpdateSpStoragePrice, sp.OperatorKey, "update price is disallowed") } func (s *StorageProviderTestSuite) CheckGlobalSpStorePrice() { diff --git a/proto/greenfield/sp/params.proto b/proto/greenfield/sp/params.proto index 2581ccabe..2d6f5c3a3 100644 --- a/proto/greenfield/sp/params.proto +++ b/proto/greenfield/sp/params.proto @@ -33,6 +33,6 @@ message Params { int64 num_of_lockup_blocks_for_maintenance = 6 [(gogoproto.moretags) = "yaml:\"num_of_lockup_blocks_for_maintenance\""]; // the time interval to update global storage price, if it is not set then the price will be updated at the first block of each natural month uint64 update_global_price_interval = 7 [(gogoproto.moretags) = "yaml:\"update_global_price_interval\""]; - // the max times allowed to update price during an interval - uint32 max_update_price_times = 8 [(gogoproto.moretags) = "yaml:\"max_update_price_times\""]; + // the days counting backwards from end of a month in which a sp cannot update its price + uint32 update_price_disallowed_days = 8 [(gogoproto.moretags) = "yaml:\"update_price_disallowed_days\""]; } diff --git a/swagger/static/swagger.yaml b/swagger/static/swagger.yaml index 71fde0f24..0d0b5348f 100644 --- a/swagger/static/swagger.yaml +++ b/swagger/static/swagger.yaml @@ -1663,10 +1663,12 @@ paths: the time interval to update global storage price, if it is not set then the price will be updated at the first block of each natural month - max_update_price_times: + update_price_disallowed_days: type: integer format: int64 - title: the max times allowed to update price during an interval + title: >- + the days counting backwards from end of a month in which a + sp cannot update its price description: >- QueryParamsResponse is response type for the Query/Params RPC method. @@ -32861,10 +32863,12 @@ definitions: the time interval to update global storage price, if it is not set then the price will be updated at the first block of each natural month - max_update_price_times: + update_price_disallowed_days: type: integer format: int64 - title: the max times allowed to update price during an interval + title: >- + the days counting backwards from end of a month in which a sp cannot + update its price description: Params defines the parameters for the module. greenfield.sp.QueryGlobalSpStorePriceByTimeResponse: type: object @@ -32929,10 +32933,12 @@ definitions: the time interval to update global storage price, if it is not set then the price will be updated at the first block of each natural month - max_update_price_times: + update_price_disallowed_days: type: integer format: int64 - title: the max times allowed to update price during an interval + title: >- + the days counting backwards from end of a month in which a sp + cannot update its price description: QueryParamsResponse is response type for the Query/Params RPC method. greenfield.sp.QuerySpStoragePriceResponse: type: object diff --git a/x/sp/abci.go b/x/sp/abci.go index ce38208d8..98db68567 100644 --- a/x/sp/abci.go +++ b/x/sp/abci.go @@ -43,6 +43,5 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) { if err != nil { ctx.Logger().Error("fail to update global sp store price", "err", err) } - k.ClearSpUpdatePriceTimes(ctx) } } diff --git a/x/sp/keeper/msg_server.go b/x/sp/keeper/msg_server.go index 2f46baadc..d8bf58637 100644 --- a/x/sp/keeper/msg_server.go +++ b/x/sp/keeper/msg_server.go @@ -153,7 +153,6 @@ func (k msgServer) CreateStorageProvider(goCtx context.Context, msg *types.MsgCr FreeReadQuota: msg.FreeReadQuota, } k.SetSpStoragePrice(ctx, spStoragePrice) - k.SetSpUpdatePriceTimes(ctx, sp.Id, 1) if err = ctx.EventManager().EmitTypedEvents(&types.EventCreateStorageProvider{ SpId: sp.Id, @@ -317,17 +316,10 @@ func (k msgServer) UpdateSpStoragePrice(goCtx context.Context, msg *types.MsgUpd } params := k.GetParams(ctx) - updateTimes := uint32(0) - if params.UpdateGlobalPriceInterval > 0 { // update price by interval - updateTimes = k.GetSpUpdatePriceTimes(ctx, sp.Id) - if updateTimes+1 > params.MaxUpdatePriceTimes { - return nil, errors.Wrapf(types.ErrStorageProviderPriceUpdateNotAllow, "exceeds the limit %d", params.MaxUpdatePriceTimes) - } - updateTimes++ - } else { // update price by month + if params.UpdateGlobalPriceInterval == 0 { // update price by month blockTime := ctx.BlockTime().UTC() - days := 2 - if IsLastDaysOfTheMonth(blockTime, days) { + days := params.UpdatePriceDisallowedDays + if IsLastDaysOfTheMonth(blockTime, int(days)) { return nil, errors.Wrapf(types.ErrStorageProviderPriceUpdateNotAllow, "price cannot be updated in the last %d days of the month", days) } } @@ -341,9 +333,6 @@ func (k msgServer) UpdateSpStoragePrice(goCtx context.Context, msg *types.MsgUpd FreeReadQuota: msg.FreeReadQuota, } k.SetSpStoragePrice(ctx, spStorePrice) - if updateTimes > 0 { - k.SetSpUpdatePriceTimes(ctx, sp.Id, updateTimes) - } return &types.MsgUpdateSpStoragePriceResponse{}, nil } diff --git a/x/sp/keeper/msg_server_test.go b/x/sp/keeper/msg_server_test.go index d854462f1..30ca1666c 100644 --- a/x/sp/keeper/msg_server_test.go +++ b/x/sp/keeper/msg_server_test.go @@ -153,8 +153,8 @@ func (s *KeeperTestSuite) TestMsgCreateStorageProvider() { } func (s *KeeperTestSuite) TestIsLastDaysOfTheMonth() { - s.Require().True(keeper.IsLastDaysOfTheMonth(time.Unix(1693328461, 0), 2)) // 2023-08-30 - s.Require().True(keeper.IsLastDaysOfTheMonth(time.Unix(1693414861, 0), 2)) // 2023-08-31 - s.Require().True(!keeper.IsLastDaysOfTheMonth(time.Unix(1693242061, 0), 2)) // 2023-08-29 - s.Require().True(!keeper.IsLastDaysOfTheMonth(time.Unix(1693587661, 0), 2)) // 2023-09-02 + s.Require().True(!keeper.IsLastDaysOfTheMonth(time.Unix(1693242061, 0).UTC(), 2)) // 2023-08-28 UTC + s.Require().True(!keeper.IsLastDaysOfTheMonth(time.Unix(1693328461, 0).UTC(), 2)) // 2023-08-29 UTC + s.Require().True(keeper.IsLastDaysOfTheMonth(time.Unix(1693414861, 0).UTC(), 2)) // 2023-08-30 UTC + s.Require().True(!keeper.IsLastDaysOfTheMonth(time.Unix(1693587661, 0).UTC(), 2)) // 2023-09-01 UTC } diff --git a/x/sp/keeper/sp_storage_price.go b/x/sp/keeper/sp_storage_price.go index 8bc4b36f2..76e89d245 100644 --- a/x/sp/keeper/sp_storage_price.go +++ b/x/sp/keeper/sp_storage_price.go @@ -1,7 +1,6 @@ package keeper import ( - "encoding/binary" "fmt" "sort" @@ -145,35 +144,3 @@ func (k Keeper) GetGlobalSpStorePriceByTime(ctx sdk.Context, time int64) (val ty val.UpdateTimeSec = updateTimeSec return val, nil } - -func (k Keeper) SetSpUpdatePriceTimes(ctx sdk.Context, spId uint32, times uint32) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.SpStoragePriceUpdateTimesKeyPrefix) - idBz := make([]byte, 4) - binary.BigEndian.PutUint32(idBz, spId) - timesBz := make([]byte, 4) - binary.BigEndian.PutUint32(timesBz, times) - store.Set(idBz, timesBz) -} - -func (k Keeper) GetSpUpdatePriceTimes(ctx sdk.Context, spId uint32) uint32 { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.SpStoragePriceUpdateTimesKeyPrefix) - idBz := make([]byte, 4) - binary.BigEndian.PutUint32(idBz, spId) - timesBz := store.Get(idBz) - if timesBz == nil { - return 0 - } - times := binary.BigEndian.Uint32(timesBz) - return times -} - -func (k Keeper) ClearSpUpdatePriceTimes(ctx sdk.Context) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.SpStoragePriceUpdateTimesKeyPrefix) - - iterator := storetypes.KVStorePrefixIterator(store, []byte{}) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - store.Delete(iterator.Key()) - } -} diff --git a/x/sp/types/errors.go b/x/sp/types/errors.go index ed55ff5c4..3b6594550 100644 --- a/x/sp/types/errors.go +++ b/x/sp/types/errors.go @@ -23,7 +23,7 @@ var ( ErrStorageProviderBlsKeyExists = errors.Register(ModuleName, 15, "StorageProvider already exist for this bls pubkey; must use new bls pubkey") ErrStorageProviderStatusUpdateNotAllow = errors.Register(ModuleName, 16, "StorageProvider status is not allow to change") ErrStorageProviderMaintenanceAddrExists = errors.Register(ModuleName, 17, "StorageProvider already exist for this maintenance address; must use new StorageProvider maintenance address.") - ErrStorageProviderPriceUpdateNotAllow = errors.Register(ModuleName, 18, "StorageProvider cannot update price due to frequency limited.") + ErrStorageProviderPriceUpdateNotAllow = errors.Register(ModuleName, 18, "StorageProvider update price is disallowed") ErrSignerNotGovModule = errors.Register(ModuleName, 40, "signer is not gov module account") ErrSignerEmpty = errors.Register(ModuleName, 41, "signer is empty") diff --git a/x/sp/types/keys.go b/x/sp/types/keys.go index d0d3d464e..717f7d8af 100644 --- a/x/sp/types/keys.go +++ b/x/sp/types/keys.go @@ -24,17 +24,16 @@ const ( var ( ParamsKey = []byte{0x01} - StorageProviderKey = []byte{0x21} // prefix for each key to a storage provider - StorageProviderByOperatorAddrKey = []byte{0x23} // prefix for each key to a storage provider index, by operator address - StorageProviderByFundingAddrKey = []byte{0x24} // prefix for each key to a storage provider index, by funding address - StorageProviderBySealAddrKey = []byte{0x25} // prefix for each key to a storage provider index, by seal address - StorageProviderByApprovalAddrKey = []byte{0x26} // prefix for each key to a storage provider index, by approval address - StorageProviderByGcAddrKey = []byte{0x27} // prefix for each key to a storage provider index, by gc address - SpStoragePriceKeyPrefix = []byte{0x28} - GlobalSpStorePriceKeyPrefix = []byte{0x29} - StorageProviderByBlsPubKeyKey = []byte{0x30} // prefix for each key to a storage provider index, by bls pub key - StorageProviderSequenceKey = []byte{0x31} - SpStoragePriceUpdateTimesKeyPrefix = []byte{0x32} + StorageProviderKey = []byte{0x21} // prefix for each key to a storage provider + StorageProviderByOperatorAddrKey = []byte{0x23} // prefix for each key to a storage provider index, by operator address + StorageProviderByFundingAddrKey = []byte{0x24} // prefix for each key to a storage provider index, by funding address + StorageProviderBySealAddrKey = []byte{0x25} // prefix for each key to a storage provider index, by seal address + StorageProviderByApprovalAddrKey = []byte{0x26} // prefix for each key to a storage provider index, by approval address + StorageProviderByGcAddrKey = []byte{0x27} // prefix for each key to a storage provider index, by gc address + SpStoragePriceKeyPrefix = []byte{0x28} + GlobalSpStorePriceKeyPrefix = []byte{0x29} + StorageProviderByBlsPubKeyKey = []byte{0x30} // prefix for each key to a storage provider index, by bls pub key + StorageProviderSequenceKey = []byte{0x31} StorageProviderMaintenanceRecordPrefix = []byte{0x41} ) diff --git a/x/sp/types/params.go b/x/sp/types/params.go index 059153e0f..83f9502dc 100644 --- a/x/sp/types/params.go +++ b/x/sp/types/params.go @@ -24,8 +24,8 @@ const ( DefaultNumOfLockUpBlocksForMaintenance = 21600 // DefaultUpdateGlobalPriceInterval defines the default time duration for updating global storage price DefaultUpdateGlobalPriceInterval uint64 = 0 // 0 means the global price will be updated at the first day of each month - // DefaultMaxUpdatePriceTimes defines the max allowed times to update price for each sp in one interval - DefaultMaxUpdatePriceTimes uint32 = 3 + // UpdatePriceDisallowedDays defines the days, counting backward from the end of a month, in which sp is not allowed to update its price + DefaultUpdatePriceDisallowedDays uint32 = 2 ) var ( @@ -43,7 +43,7 @@ var ( KeyMaintenanceDurationQuota = []byte("MaintenanceDurationQuota") KeyNumOfLockUpBlocksForMaintenance = []byte("NumOfLockUpBlocksForMaintenance") KeyUpdateGlobalPriceInterval = []byte("UpdateGlobalPriceInterval") - KeyMaxUpdatePriceTimes = []byte("MaxUpdatePriceTimes") + KeyUpdatePriceDisallowedDays = []byte("UpdatePriceDisallowedDays") ) var _ paramtypes.ParamSet = (*Params)(nil) @@ -56,7 +56,7 @@ func ParamKeyTable() paramtypes.KeyTable { // NewParams creates a new Params instance func NewParams(depositDenom string, minDeposit math.Int, secondarySpStorePriceRatio sdk.Dec, historicalBlocksForMaintenanceRecords, maintenanceDurationQuota, lockUpBlocksForMaintenance int64, - updateGlobalPriceInterval uint64, maxUpdatePriceTimes uint32) Params { + updateGlobalPriceInterval uint64, updatePriceDisallowedDays uint32) Params { return Params{ DepositDenom: depositDenom, MinDeposit: minDeposit, @@ -65,7 +65,7 @@ func NewParams(depositDenom string, minDeposit math.Int, secondarySpStorePriceRa MaintenanceDurationQuota: maintenanceDurationQuota, NumOfLockupBlocksForMaintenance: lockUpBlocksForMaintenance, UpdateGlobalPriceInterval: updateGlobalPriceInterval, - MaxUpdatePriceTimes: maxUpdatePriceTimes, + UpdatePriceDisallowedDays: updatePriceDisallowedDays, } } @@ -73,7 +73,7 @@ func NewParams(depositDenom string, minDeposit math.Int, secondarySpStorePriceRa func DefaultParams() Params { return NewParams(DefaultDepositDenom, DefaultMinDeposit, DefaultSecondarySpStorePriceRatio, DefaultNumOfHistoricalBlocksForMaintenanceRecords, DefaultMaintenanceDurationQuota, DefaultNumOfLockUpBlocksForMaintenance, - DefaultUpdateGlobalPriceInterval, DefaultMaxUpdatePriceTimes) + DefaultUpdateGlobalPriceInterval, DefaultUpdatePriceDisallowedDays) } // ParamSetPairs get the params.ParamSet @@ -86,7 +86,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyMaintenanceDurationQuota, &p.MaintenanceDurationQuota, validateMaintenanceDurationQuota), paramtypes.NewParamSetPair(KeyNumOfLockUpBlocksForMaintenance, &p.NumOfLockupBlocksForMaintenance, validateLockUpBlocksForMaintenance), paramtypes.NewParamSetPair(KeyUpdateGlobalPriceInterval, &p.UpdateGlobalPriceInterval, validateUpdateGlobalPriceInterval), - paramtypes.NewParamSetPair(KeyMaxUpdatePriceTimes, &p.MaxUpdatePriceTimes, validateMaxUpdatePriceTimes), + paramtypes.NewParamSetPair(KeyUpdatePriceDisallowedDays, &p.UpdatePriceDisallowedDays, validateUpdatePriceDisallowedDays), } } @@ -115,7 +115,7 @@ func (p Params) Validate() error { if err := validateUpdateGlobalPriceInterval(p.UpdateGlobalPriceInterval); err != nil { return err } - if err := validateMaxUpdatePriceTimes(p.MaxUpdatePriceTimes); err != nil { + if err := validateUpdatePriceDisallowedDays(p.UpdatePriceDisallowedDays); err != nil { return err } @@ -214,13 +214,10 @@ func validateUpdateGlobalPriceInterval(i interface{}) error { return nil } -func validateMaxUpdatePriceTimes(i interface{}) error { - v, ok := i.(uint32) +func validateUpdatePriceDisallowedDays(i interface{}) error { + _, ok := i.(uint32) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } - if v == 0 { - return errors.New("MaxUpdatePriceTimes cannot be zero") - } return nil } diff --git a/x/sp/types/params.pb.go b/x/sp/types/params.pb.go index aadf039b1..bb4bd5d10 100644 --- a/x/sp/types/params.pb.go +++ b/x/sp/types/params.pb.go @@ -41,8 +41,8 @@ type Params struct { NumOfLockupBlocksForMaintenance int64 `protobuf:"varint,6,opt,name=num_of_lockup_blocks_for_maintenance,json=numOfLockupBlocksForMaintenance,proto3" json:"num_of_lockup_blocks_for_maintenance,omitempty" yaml:"num_of_lockup_blocks_for_maintenance"` // the time interval to update global storage price, if it is not set then the price will be updated at the first block of each natural month UpdateGlobalPriceInterval uint64 `protobuf:"varint,7,opt,name=update_global_price_interval,json=updateGlobalPriceInterval,proto3" json:"update_global_price_interval,omitempty" yaml:"update_global_price_interval"` - // the max times allowed to update price during an interval - MaxUpdatePriceTimes uint32 `protobuf:"varint,8,opt,name=max_update_price_times,json=maxUpdatePriceTimes,proto3" json:"max_update_price_times,omitempty" yaml:"max_update_price_times"` + // the days counting backwards from end of a month in which a sp cannot update its price + UpdatePriceDisallowedDays uint32 `protobuf:"varint,8,opt,name=update_price_disallowed_days,json=updatePriceDisallowedDays,proto3" json:"update_price_disallowed_days,omitempty" yaml:"update_price_disallowed_days"` } func (m *Params) Reset() { *m = Params{} } @@ -112,9 +112,9 @@ func (m *Params) GetUpdateGlobalPriceInterval() uint64 { return 0 } -func (m *Params) GetMaxUpdatePriceTimes() uint32 { +func (m *Params) GetUpdatePriceDisallowedDays() uint32 { if m != nil { - return m.MaxUpdatePriceTimes + return m.UpdatePriceDisallowedDays } return 0 } @@ -126,43 +126,43 @@ func init() { func init() { proto.RegisterFile("greenfield/sp/params.proto", fileDescriptor_a5353d8e6e407d7e) } var fileDescriptor_a5353d8e6e407d7e = []byte{ - // 569 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4f, 0x6f, 0xd3, 0x30, - 0x1c, 0x6d, 0xd8, 0x28, 0xc3, 0xb0, 0x4b, 0x40, 0x28, 0xab, 0x20, 0xe9, 0x32, 0xfe, 0x54, 0x43, - 0x6d, 0x90, 0x38, 0x20, 0x0d, 0x4e, 0x51, 0x04, 0x54, 0x02, 0x31, 0x32, 0xe0, 0x80, 0x84, 0x2c, - 0x27, 0x71, 0x5b, 0x6b, 0xb1, 0x1d, 0x62, 0x07, 0xb5, 0x17, 0xc4, 0x47, 0xe0, 0xc8, 0x71, 0x7c, - 0x07, 0x3e, 0xc4, 0x8e, 0x13, 0x27, 0xc4, 0x21, 0x42, 0x2d, 0x07, 0xce, 0xfd, 0x04, 0xc8, 0x4e, - 0xd8, 0x8a, 0xb4, 0x4d, 0xda, 0x29, 0xc9, 0x7b, 0xef, 0xf7, 0xde, 0xef, 0xe7, 0xf8, 0x07, 0x5a, - 0xc3, 0x1c, 0x63, 0x36, 0x20, 0x38, 0x4d, 0x3c, 0x91, 0x79, 0x19, 0xca, 0x11, 0x15, 0xbd, 0x2c, - 0xe7, 0x92, 0x9b, 0xab, 0x47, 0x5c, 0x4f, 0x64, 0xad, 0xb5, 0x98, 0x0b, 0xca, 0x05, 0xd4, 0xa4, - 0x57, 0x7d, 0x54, 0xca, 0xd6, 0xd5, 0x21, 0x1f, 0xf2, 0x0a, 0x57, 0x6f, 0x15, 0xea, 0xfe, 0x6e, - 0x82, 0xe6, 0xb6, 0x36, 0x34, 0x37, 0xc0, 0x6a, 0x82, 0x33, 0x2e, 0x88, 0x84, 0x09, 0x66, 0x9c, - 0x5a, 0x46, 0xdb, 0xe8, 0x5c, 0x0c, 0x2f, 0xd7, 0x60, 0xa0, 0x30, 0xf3, 0x1d, 0xb8, 0x44, 0x09, - 0x83, 0x35, 0x66, 0x9d, 0x53, 0x12, 0xff, 0xd1, 0x7e, 0xe9, 0x34, 0x7e, 0x96, 0xce, 0xed, 0x21, - 0x91, 0xa3, 0x22, 0xea, 0xc5, 0x9c, 0xd6, 0xd9, 0xf5, 0xa3, 0x2b, 0x92, 0x5d, 0x4f, 0x4e, 0x32, - 0x2c, 0x7a, 0x7d, 0x26, 0xbf, 0x7f, 0xeb, 0x82, 0xba, 0xb5, 0x3e, 0x93, 0x21, 0xa0, 0x84, 0x05, - 0x95, 0x9f, 0xf9, 0xc9, 0x00, 0xb6, 0xc0, 0x31, 0x67, 0x09, 0xca, 0x27, 0x50, 0x64, 0x50, 0x48, - 0x9e, 0x63, 0x98, 0xe5, 0x24, 0xc6, 0x30, 0x47, 0x92, 0x70, 0x6b, 0xe9, 0xcc, 0x91, 0x01, 0x8e, - 0x17, 0x22, 0x03, 0x1c, 0x87, 0xad, 0xc3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 0xf7, 0x34, 0xb5, - 0x1b, 0xae, 0x55, 0xf4, 0x13, 0xcd, 0xea, 0xff, 0xdd, 0xaf, 0x39, 0xf3, 0x0d, 0xb8, 0x46, 0xd1, - 0x18, 0xd6, 0xf5, 0x55, 0xa1, 0x24, 0x14, 0x0b, 0x6b, 0xa5, 0x6d, 0x74, 0x56, 0xfd, 0xf5, 0x79, - 0xe9, 0xdc, 0xf8, 0x77, 0x94, 0xc7, 0xe9, 0xdc, 0xf0, 0x0a, 0x45, 0xe3, 0xd7, 0x1a, 0xd7, 0xd6, - 0xaf, 0x14, 0xba, 0xb5, 0xf2, 0x65, 0xcf, 0x69, 0xfc, 0xd9, 0x73, 0x0c, 0x3f, 0xd8, 0x9f, 0xda, - 0xc6, 0xc1, 0xd4, 0x36, 0x7e, 0x4d, 0x6d, 0xe3, 0xf3, 0xcc, 0x6e, 0x1c, 0xcc, 0xec, 0xc6, 0x8f, - 0x99, 0xdd, 0x78, 0xbb, 0xb9, 0x70, 0x81, 0x23, 0x16, 0x75, 0xe3, 0x11, 0x22, 0xcc, 0x5b, 0xd8, - 0xf8, 0xb1, 0xda, 0x79, 0x7d, 0x91, 0xa3, 0xa6, 0xde, 0xd9, 0xfb, 0x7f, 0x03, 0x00, 0x00, 0xff, - 0xff, 0xc5, 0xe6, 0x36, 0x68, 0x11, 0x04, 0x00, 0x00, + // 561 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xbf, 0x6f, 0xd3, 0x40, + 0x14, 0xc7, 0x63, 0x5a, 0x42, 0x31, 0x74, 0xb1, 0x18, 0xdc, 0x08, 0xd9, 0xc1, 0xe5, 0x47, 0x54, + 0xd4, 0x18, 0x89, 0x01, 0xa9, 0x30, 0x45, 0x16, 0x10, 0x09, 0x44, 0x71, 0x37, 0x24, 0x74, 0x3a, + 0xfb, 0x2e, 0xc9, 0xa9, 0xf6, 0xdd, 0x71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 0x67, 0x2c, 0x81, 0x59, 0xbd, 0x05, 0xda, 0x20, 0xde, 0xc3, + 0xcc, 0xbd, 0xd2, 0xb5, 0x7a, 0xeb, 0x83, 0x7b, 0x8b, 0xd2, 0xdf, 0xae, 0xb8, 0xe7, 0xb9, 0x83, + 0x78, 0xab, 0x92, 0x9f, 0x19, 0xd5, 0x7c, 0xef, 0x61, 0xad, 0x35, 0x48, 0x55, 0x12, 0x22, 0x12, + 0x66, 0x19, 0xfb, 0x80, 0x11, 0x40, 0x70, 0x2a, 0xdd, 0x8d, 0xae, 0xd5, 0xdb, 0x5c, 0x41, 0x5a, + 0xe9, 0x5e, 0x92, 0x0c, 0x23, 0x5a, 0x8a, 0x11, 0x9c, 0xca, 0xbd, 0x8d, 0xaf, 0x47, 0x7e, 0xeb, + 0xcf, 0x91, 0x6f, 0x0d, 0xa2, 0xe3, 0x99, 0x67, 0x9d, 0xcc, 0x3c, 0xeb, 0xf7, 0xcc, 0xb3, 0xbe, + 0xcc, 0xbd, 0xd6, 0xc9, 0xdc, 0x6b, 0xfd, 0x9c, 0x7b, 0xad, 0x37, 0x3b, 0x8d, 0x95, 0x4e, 0x68, + 0xb2, 0x9b, 0x4e, 0x20, 0xa1, 0x61, 0xe3, 0x0c, 0xf8, 0xa8, 0x4f, 0x01, 0xb3, 0xda, 0x49, 0xdb, + 0xfc, 0xc5, 0x0f, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x2f, 0xd4, 0x74, 0x7e, 0x23, 0x04, 0x00, + 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -205,7 +205,7 @@ func (this *Params) Equal(that interface{}) bool { if this.UpdateGlobalPriceInterval != that1.UpdateGlobalPriceInterval { return false } - if this.MaxUpdatePriceTimes != that1.MaxUpdatePriceTimes { + if this.UpdatePriceDisallowedDays != that1.UpdatePriceDisallowedDays { return false } return true @@ -230,8 +230,8 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.MaxUpdatePriceTimes != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.MaxUpdatePriceTimes)) + if m.UpdatePriceDisallowedDays != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.UpdatePriceDisallowedDays)) i-- dAtA[i] = 0x40 } @@ -322,8 +322,8 @@ func (m *Params) Size() (n int) { if m.UpdateGlobalPriceInterval != 0 { n += 1 + sovParams(uint64(m.UpdateGlobalPriceInterval)) } - if m.MaxUpdatePriceTimes != 0 { - n += 1 + sovParams(uint64(m.MaxUpdatePriceTimes)) + if m.UpdatePriceDisallowedDays != 0 { + n += 1 + sovParams(uint64(m.UpdatePriceDisallowedDays)) } return n } @@ -541,9 +541,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { } case 8: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxUpdatePriceTimes", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field UpdatePriceDisallowedDays", wireType) } - m.MaxUpdatePriceTimes = 0 + m.UpdatePriceDisallowedDays = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -553,7 +553,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MaxUpdatePriceTimes |= uint32(b&0x7F) << shift + m.UpdatePriceDisallowedDays |= uint32(b&0x7F) << shift if b < 0x80 { break }