Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete recent price from db when delisting #753

Merged
merged 5 commits into from
Jun 22, 2020
Merged

Conversation

EnderCrypto
Copy link
Contributor

Description

add a description of your changes here...

Rationale

tell us why we need these changes...

Example

add an example CLI or API response...

Changes

Notable changes:

  • add each change in a bullet point here
  • ...

Preflight checks

  • build passed (make build)
  • tests passed (make test)
  • integration tests passed (make integration_test)
  • manual transaction test passed (cli invoke)

Already reviewed by

...

Related issues

... reference related issue #'s here ...

}
func removePrice(price []int64, i int) []int64 {
return append(price[:i], price[i+1:]...)
}
Copy link
Contributor

@rickyyangz rickyyangz Jun 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest giving the RecentPrice struct a method(like removePair) to remove both pair and price at the same time.

@@ -172,6 +173,36 @@ func (m mapper) GetRecentPrices(ctx sdk.Context, pricesStoreEvery, numPricesStor
return recentPrices
}

func (m mapper) DeleteRecentPrices(ctx sdk.Context, baseAsset, quoteAsset string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just pass the trading symbol as the parameter

@@ -949,6 +949,7 @@ func (kp *DexKeeper) DelistTradingPair(ctx sdk.Context, symbol string, postAlloc
if err != nil {
kp.logger.Error("delete trading pair error", "err", err.Error())
}
kp.PairMapper.DeleteRecentPrices(ctx, baseAsset, quoteAsset)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better wrap a method to remove both from memory and db.


func TestMapper_DeleteRecentPrices(t *testing.T) {
pairMapper, ctx := setup()
for i := 0; i < 3000; i++ {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be much smaller if it is not a benchmark

require.Equal(t, []interface{}{int64(10), int64(10), int64(10), int64(10), int64(10)}, allRecentPrices["ABC_BNB"].Elements())

pairMapper.DeleteRecentPrices(ctx, "ABC", "BNB")
allRecentPrices = pairMapper.GetRecentPrices(ctx, 2, 5)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the parameters (ctx, 2, 5) are different from the above (ctx, 2, 10).
I suggest using a const instead.

pairMapper.AddTradingPair(ctx, tradingPair)
}

for i := 0; i < 2000; i++ {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using some const instead to make it more readable.

@@ -35,3 +35,15 @@ type RecentPrice struct {
Pair []string
Price []int64
}

func (prices *RecentPrice) removeRecentPrice(symbolToDelete string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a little confusing about the name. "recentPrice.removeRecentPrice"

pairMapper, ctx := setup()
for i := 0; i < 30; i++ {
lastPrices := make(map[string]int64, pairNum)
lastPrices["ABC_BNB"] = 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make some changes of the prices

@EnderCrypto EnderCrypto merged commit e21b91b into develop Jun 22, 2020
@EnderCrypto EnderCrypto mentioned this pull request Jun 23, 2020
4 tasks
unclezoro pushed a commit that referenced this pull request Jun 29, 2020
delete recent price from db when delisting
EnderCrypto added a commit that referenced this pull request Jul 1, 2020
* delete recent price from db when delisting (#753)

delete recent price from db when delisting

* bump up version

* update changelog

* delete recent price key when recent price map is empty (#760)

* Force match all BEP2 symbols on BEP8 upgrade height to update last ma… (#758)

 Force match all BEP2 symbols on BEP8 upgrade height to update last match height

* Fix mini msg (#762)

* fix unfreeze err msg; adjust mini issue/list fee; update changelog
unclezoro pushed a commit that referenced this pull request Jul 8, 2020
delete recent price from db when delisting
@unclezoro unclezoro deleted the fix_recent_price branch May 10, 2022 06:11
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* delete recent price from db when delisting (#753)

delete recent price from db when delisting

* bump up version

* update changelog

* delete recent price key when recent price map is empty (#760)

* Force match all BEP2 symbols on BEP8 upgrade height to update last ma… (#758)

 Force match all BEP2 symbols on BEP8 upgrade height to update last match height

* Fix mini msg (#762)

* fix unfreeze err msg; adjust mini issue/list fee; update changelog
forcodedancing pushed a commit that referenced this pull request May 19, 2022
delete recent price from db when delisting
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* delete recent price from db when delisting (#753)

delete recent price from db when delisting

* bump up version

* update changelog

* delete recent price key when recent price map is empty (#760)

* Force match all BEP2 symbols on BEP8 upgrade height to update last ma… (#758)

 Force match all BEP2 symbols on BEP8 upgrade height to update last match height

* Fix mini msg (#762)

* fix unfreeze err msg; adjust mini issue/list fee; update changelog
forcodedancing pushed a commit that referenced this pull request May 19, 2022
delete recent price from db when delisting
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* delete recent price from db when delisting (#753)

delete recent price from db when delisting

* bump up version

* update changelog

* delete recent price key when recent price map is empty (#760)

* Force match all BEP2 symbols on BEP8 upgrade height to update last ma… (#758)

 Force match all BEP2 symbols on BEP8 upgrade height to update last match height

* Fix mini msg (#762)

* fix unfreeze err msg; adjust mini issue/list fee; update changelog
forcodedancing pushed a commit that referenced this pull request May 19, 2022
delete recent price from db when delisting
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* delete recent price from db when delisting (#753)

delete recent price from db when delisting

* bump up version

* update changelog

* delete recent price key when recent price map is empty (#760)

* Force match all BEP2 symbols on BEP8 upgrade height to update last ma… (#758)

 Force match all BEP2 symbols on BEP8 upgrade height to update last match height

* Fix mini msg (#762)

* fix unfreeze err msg; adjust mini issue/list fee; update changelog
forcodedancing pushed a commit that referenced this pull request May 19, 2022
delete recent price from db when delisting
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* delete recent price from db when delisting (#753)

delete recent price from db when delisting

* bump up version

* update changelog

* delete recent price key when recent price map is empty (#760)

* Force match all BEP2 symbols on BEP8 upgrade height to update last ma… (#758)

 Force match all BEP2 symbols on BEP8 upgrade height to update last match height

* Fix mini msg (#762)

* fix unfreeze err msg; adjust mini issue/list fee; update changelog
forcodedancing pushed a commit that referenced this pull request May 19, 2022
delete recent price from db when delisting
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* delete recent price from db when delisting (#753)

delete recent price from db when delisting

* bump up version

* update changelog

* delete recent price key when recent price map is empty (#760)

* Force match all BEP2 symbols on BEP8 upgrade height to update last ma… (#758)

 Force match all BEP2 symbols on BEP8 upgrade height to update last match height

* Fix mini msg (#762)

* fix unfreeze err msg; adjust mini issue/list fee; update changelog
forcodedancing pushed a commit that referenced this pull request May 19, 2022
delete recent price from db when delisting
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* delete recent price from db when delisting (#753)

delete recent price from db when delisting

* bump up version

* update changelog

* delete recent price key when recent price map is empty (#760)

* Force match all BEP2 symbols on BEP8 upgrade height to update last ma… (#758)

 Force match all BEP2 symbols on BEP8 upgrade height to update last match height

* Fix mini msg (#762)

* fix unfreeze err msg; adjust mini issue/list fee; update changelog
forcodedancing pushed a commit that referenced this pull request May 19, 2022
delete recent price from db when delisting
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* delete recent price from db when delisting (#753)

delete recent price from db when delisting

* bump up version

* update changelog

* delete recent price key when recent price map is empty (#760)

* Force match all BEP2 symbols on BEP8 upgrade height to update last ma… (#758)

 Force match all BEP2 symbols on BEP8 upgrade height to update last match height

* Fix mini msg (#762)

* fix unfreeze err msg; adjust mini issue/list fee; update changelog
forcodedancing pushed a commit that referenced this pull request May 19, 2022
delete recent price from db when delisting
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* delete recent price from db when delisting (#753)

delete recent price from db when delisting

* bump up version

* update changelog

* delete recent price key when recent price map is empty (#760)

* Force match all BEP2 symbols on BEP8 upgrade height to update last ma… (#758)

 Force match all BEP2 symbols on BEP8 upgrade height to update last match height

* Fix mini msg (#762)

* fix unfreeze err msg; adjust mini issue/list fee; update changelog
forcodedancing pushed a commit that referenced this pull request May 19, 2022
delete recent price from db when delisting
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* delete recent price from db when delisting (#753)

delete recent price from db when delisting

* bump up version

* update changelog

* delete recent price key when recent price map is empty (#760)

* Force match all BEP2 symbols on BEP8 upgrade height to update last ma… (#758)

 Force match all BEP2 symbols on BEP8 upgrade height to update last match height

* Fix mini msg (#762)

* fix unfreeze err msg; adjust mini issue/list fee; update changelog
forcodedancing pushed a commit that referenced this pull request May 19, 2022
delete recent price from db when delisting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants