Browse Source

added counter query support

pull/1780/head
rigelrozanski 8 years ago
committed by Ethan Buchman
parent
commit
c31df4081c
1 changed files with 10 additions and 1 deletions
  1. +10
    -1
      example/counter/counter.go

+ 10
- 1
example/counter/counter.go View File

@ -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))
}

Loading…
Cancel
Save