-
Notifications
You must be signed in to change notification settings - Fork 51
chain: Add price_symbols
endpoint
#2829
chain: Add price_symbols
endpoint
#2829
Conversation
price_symbols
endpointprice_symbols
endpoint
price_symbols
endpointprice_symbols
endpoint
chain/hooks/price/price.go
Outdated
it := h.db.NewIterator(nil, nil) | ||
it.Seek(prefix) | ||
|
||
prices := []Price{} |
There was a problem hiding this comment.
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.
chain/hooks/price/price.go
Outdated
|
||
prices := []Price{} | ||
for ; it.Valid() && bytes.HasPrefix(it.Key(), prefix); it.Next() { | ||
var p Price |
There was a problem hiding this comment.
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):])
chain/x/oracle/client/rest/query.go
Outdated
|
||
bz, height, err := cliCtx.Query(fmt.Sprintf("band/price_symbols/%s/%s", r.FormValue("ask_count"), r.FormValue("min_count"))) | ||
|
||
prices := []price.Price{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good :D
chain/x/oracle/client/rest/query.go
Outdated
|
||
bz, height, err := cliCtx.Query(fmt.Sprintf("band/price_symbols/%s/%s", r.FormValue("ask_count"), r.FormValue("min_count"))) | ||
|
||
symbols := []string{} |
There was a problem hiding this comment.
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)
Fixed: #2812
Implementation details
Please ensure the following requirements are met before submitting a pull request:
CHANGELOG_UNRELEASED.md
Files changed
tab in the Github PR explorer)