Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

chain: Add price_symbols endpoint #2829

Merged
merged 8 commits into from
Nov 5, 2020

Conversation

thebevrishot
Copy link
Contributor

@thebevrishot thebevrishot commented Nov 4, 2020

Fixed: #2812

Implementation details

  • Change key scheme of prices to make it iterable by min_count and ask_count
  • Add endpoint to query price symbols

Please ensure the following requirements are met before submitting a pull request:

  • The pull request is targeted against the correct target branch
  • The pull request is linked to an issue with appropriate discussion and an accepted design OR is linked to a spec that describes the work.
  • The pull request includes a description of the implementation/work done in detail.
  • The pull request includes any and all appropriate unit/integration tests
  • You have added a relevant changelog entry to CHANGELOG_UNRELEASED.md
  • You have re-reviewed the files affected by the pull request (e.g. using the Files changed tab in the Github PR explorer)

@thebevrishot thebevrishot changed the title chain: Add price_symbols endpoint chain: Added price_symbols endpoint Nov 4, 2020
@thebevrishot thebevrishot changed the title chain: Added price_symbols endpoint chain: Add price_symbols endpoint Nov 4, 2020
it := h.db.NewIterator(nil, nil)
it.Seek(prefix)

prices := []Price{}
Copy link
Member

Choose a reason for hiding this comment

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

change to return a list of string.


prices := []Price{}
for ; it.Valid() && bytes.HasPrefix(it.Key(), prefix); it.Next() {
var p Price
Copy link
Member

Choose a reason for hiding this comment

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

append str(it.Key()[len(prefix):])


bz, height, err := cliCtx.Query(fmt.Sprintf("band/price_symbols/%s/%s", r.FormValue("ask_count"), r.FormValue("min_count")))

prices := []price.Price{}
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Copy link
Member

@taobun taobun left a comment

Choose a reason for hiding this comment

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

LGTM

minCount := common.Atoui(paths[3])

prefix := []byte(fmt.Sprintf("%d,%d,", askCount, minCount))
it := h.db.NewIterator(util.BytesPrefix(prefix), nil)
Copy link
Member

Choose a reason for hiding this comment

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

Looks good :D


bz, height, err := cliCtx.Query(fmt.Sprintf("band/price_symbols/%s/%s", r.FormValue("ask_count"), r.FormValue("min_count")))

symbols := []string{}
Copy link
Member

Choose a reason for hiding this comment

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

Using var symbols []string (Reduce unnecessarily allocate)

@thebevrishot thebevrishot merged commit 514d056 into bandprotocol:master Nov 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

price_symbols endpoint to list all prices if price hook enable.
2 participants