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

R4R: Sortable Decimal Bytes #5360

Merged
merged 10 commits into from
Dec 5, 2019
Merged

R4R: Sortable Decimal Bytes #5360

merged 10 commits into from
Dec 5, 2019

Conversation

sunnya97
Copy link
Member

@sunnya97 sunnya97 commented Dec 3, 2019

Added a function that creates a byte representation of sdk.Dec that is sortable. Can be used in ordered key queues, so that inserted keys are sorted. Similar to the sdk.SortableTimeFormat for time.Time.

Example use cases:
Orderbooks: https://github.com/sunnya97/sdk-dex-mvp/tree/master/x/orderbook
Kava CDP Liquidation Ratios: Requested by @karzak

  • Targeted PR against correct branch (see CONTRIBUTING.md)

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md

  • Re-reviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@sunnya97 sunnya97 added the R4R label Dec 3, 2019
@codecov
Copy link

codecov bot commented Dec 3, 2019

Codecov Report

Merging #5360 into master will increase coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5360      +/-   ##
==========================================
+ Coverage   54.64%   54.68%   +0.04%     
==========================================
  Files         311      311              
  Lines       18447    18459      +12     
==========================================
+ Hits        10080    10094      +14     
+ Misses       7595     7593       -2     
  Partials      772      772
Impacted Files Coverage Δ
types/decimal.go 77.6% <100%> (+1.53%) ⬆️

types/decimal.go Outdated Show resolved Hide resolved
types/decimal.go Outdated Show resolved Hide resolved
sunnya97 and others added 2 commits December 3, 2019 17:11
Co-Authored-By: Jack Zampolin <jack.zampolin@gmail.com>
Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

ACK, missing changelog entry

types/decimal.go Outdated Show resolved Hide resolved
types/decimal.go Outdated Show resolved Hide resolved
types/decimal.go Outdated Show resolved Hide resolved
types/decimal.go Outdated Show resolved Hide resolved
types/decimal.go Outdated Show resolved Hide resolved
types/decimal.go Outdated Show resolved Hide resolved
Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
types/decimal.go Show resolved Hide resolved
@sunnya97
Copy link
Member Author

sunnya97 commented Dec 4, 2019

Added tests to check negatives, MaxSortableDec, -MaxSortableDec, and out of bound panics.

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

ACK

@alexanderbez alexanderbez merged commit 3c2ace9 into master Dec 5, 2019
@alexanderbez alexanderbez deleted the sunny/sortabledecbytes branch December 5, 2019 17:55
xiangjianmeng pushed a commit to xiangjianmeng/cosmos-sdk that referenced this pull request Dec 18, 2019
alexanderbez pushed a commit that referenced this pull request Dec 18, 2019
@alexanderbez alexanderbez mentioned this pull request Dec 18, 2019
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants