parser -> decoder

This commit is contained in:
Ethan Buchman 2018-03-21 02:27:50 +01:00
parent e4b8010077
commit c529eccc6e
3 changed files with 13 additions and 13 deletions

View File

@ -32,11 +32,11 @@ func GetAccountDecoder(cdc *wire.Codec) sdk.AccountDecoder {
// GetAccountCmd returns a query account that will display the
// state of the account at a given address
func GetAccountCmd(storeName string, cdc *wire.Codec, parser sdk.AccountDecoder) *cobra.Command {
func GetAccountCmd(storeName string, cdc *wire.Codec, decoder sdk.AccountDecoder) *cobra.Command {
cmdr := commander{
storeName,
cdc,
parser,
decoder,
}
return &cobra.Command{
Use: "account <address>",
@ -48,7 +48,7 @@ func GetAccountCmd(storeName string, cdc *wire.Codec, parser sdk.AccountDecoder)
type commander struct {
storeName string
cdc *wire.Codec
parser sdk.AccountDecoder
decoder sdk.AccountDecoder
}
func (c commander) getAccountCmd(cmd *cobra.Command, args []string) error {
@ -66,8 +66,8 @@ func (c commander) getAccountCmd(cmd *cobra.Command, args []string) error {
res, err := builder.Query(key, c.storeName)
// parse out the value
account, err := c.parser(res)
// decode the value
account, err := c.decoder(res)
if err != nil {
return err
}

View File

@ -16,11 +16,11 @@ import (
type commander struct {
storeName string
cdc *wire.Codec
parser sdk.AccountDecoder
decoder sdk.AccountDecoder
}
func QueryAccountRequestHandler(storeName string, cdc *wire.Codec, parser sdk.AccountDecoder) func(http.ResponseWriter, *http.Request) {
c := commander{storeName, cdc, parser}
func QueryAccountRequestHandler(storeName string, cdc *wire.Codec, decoder sdk.AccountDecoder) func(http.ResponseWriter, *http.Request) {
c := commander{storeName, cdc, decoder}
return func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
addr := vars["address"]
@ -46,8 +46,8 @@ func QueryAccountRequestHandler(storeName string, cdc *wire.Codec, parser sdk.Ac
return
}
// parse out the value
account, err := c.parser(res)
// decode the value
account, err := c.decoder(res)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(fmt.Sprintf("Could't parse query result. Result: %s. Error: %s", res, err.Error())))

View File

@ -27,7 +27,7 @@ const (
type relayCommander struct {
cdc *wire.Codec
address sdk.Address
parser sdk.AccountDecoder
decoder sdk.AccountDecoder
mainStore string
ibcStore string
}
@ -35,7 +35,7 @@ type relayCommander struct {
func IBCRelayCmd(cdc *wire.Codec) *cobra.Command {
cmdr := relayCommander{
cdc: cdc,
parser: authcmd.GetAccountDecoder(cdc),
decoder: authcmd.GetAccountDecoder(cdc),
ibcStore: "ibc",
mainStore: "main",
}
@ -162,7 +162,7 @@ func (c relayCommander) getSequence(node string) int64 {
if err != nil {
panic(err)
}
account, err := c.parser(res)
account, err := c.decoder(res)
if err != nil {
panic(err)
}