From 21abda0602e591991a2f1933018c113f0a85b9f6 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Fri, 4 Dec 2015 00:59:26 -0800 Subject: [PATCH] Make Counter app return nil hash initially --- example/counter.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/example/counter.go b/example/counter.go index d4b0e477..7b0ff1f8 100644 --- a/example/counter.go +++ b/example/counter.go @@ -68,10 +68,14 @@ func (appC *CounterAppContext) AppendTx(tx []byte) ([]types.Event, types.RetCode } func (appC *CounterAppContext) GetHash() ([]byte, types.RetCode) { - hash := make([]byte, 32) - binary.PutVarint(hash, int64(appC.txCount)) appC.hashCount += 1 - return hash, 0 + if appC.txCount == 0 { + return nil, 0 + } else { + hash := make([]byte, 32) + binary.PutVarint(hash, int64(appC.txCount)) + return hash, 0 + } } func (appC *CounterAppContext) Commit() types.RetCode {