From 4a0469d3ecb9a699bcde7801724ce15a9075372b Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Tue, 8 Dec 2015 21:52:40 -0800 Subject: [PATCH] Make counter app use LittleEndian uint64 encoding --- example/counter.go | 11 +++++------ test.sh | 10 +++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/example/counter.go b/example/counter.go index 9e4b8671a..e96e78e5d 100644 --- a/example/counter.go +++ b/example/counter.go @@ -57,11 +57,10 @@ func (appC *CounterAppContext) SetOption(key string, value string) types.RetCode func (appC *CounterAppContext) AppendTx(tx []byte) ([]types.Event, types.RetCode) { if appC.serial { - txValue, bz := binary.Varint(tx) - if bz <= 0 { - return nil, types.RetCodeInternalError - } - if txValue != int64(appC.txCount) { + tx8 := make([]byte, 8) + copy(tx8, tx) + txValue := binary.LittleEndian.Uint64(tx8) + if txValue != uint64(appC.txCount) { return nil, types.RetCodeInternalError } } @@ -75,7 +74,7 @@ func (appC *CounterAppContext) GetHash() ([]byte, types.RetCode) { return nil, 0 } else { hash := make([]byte, 32) - binary.PutVarint(hash, int64(appC.txCount)) + binary.LittleEndian.PutUint64(hash, uint64(appC.txCount)) return hash, 0 } } diff --git a/test.sh b/test.sh index 4bc0f8db7..2f4458612 100755 --- a/test.sh +++ b/test.sh @@ -76,20 +76,20 @@ OUTPUT=`(tmsp batch) <