From c31df4081cd660d4e7485bb81594b8c3ab26b636 Mon Sep 17 00:00:00 2001 From: rigelrozanski Date: Thu, 22 Dec 2016 18:24:45 -0500 Subject: [PATCH] added counter query support --- example/counter/counter.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/example/counter/counter.go b/example/counter/counter.go index 3252f9437..58c37c851 100644 --- a/example/counter/counter.go +++ b/example/counter/counter.go @@ -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)) }