mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-01 12:56:08 +00:00
added counter query support
This commit is contained in:
committed by
Ethan Buchman
parent
465c77e120
commit
c31df4081c
@@ -72,5 +72,14 @@ func (app *CounterApplication) Commit() types.Result {
|
||||
}
|
||||
|
||||
func (app *CounterApplication) Query(query []byte) types.Result {
|
||||
return types.NewResultOK(nil, Fmt("Query is not supported"))
|
||||
queryStr := string(query)
|
||||
|
||||
switch queryStr {
|
||||
case "hash":
|
||||
return types.NewResultOK(nil, Fmt("%v", app.hashCount))
|
||||
case "tx":
|
||||
return types.NewResultOK(nil, Fmt("%v", app.txCount))
|
||||
}
|
||||
|
||||
return types.ErrUnknownRequest.SetLog(Fmt("Invalid nonce. Expected hash or tx, got %v", queryStr))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user