Add RetCodeBadNonce and fix response formats

This commit is contained in:
Jae Kwon
2016-01-12 14:04:24 -08:00
parent 87b9866d1f
commit 44f22e351b
8 changed files with 22 additions and 18 deletions

View File

@@ -38,7 +38,7 @@ func (app *CounterApplication) AppendTx(tx []byte) ([]types.Event, types.RetCode
copy(tx8, tx)
txValue := binary.LittleEndian.Uint64(tx8)
if txValue != uint64(app.txCount) {
return nil, types.RetCodeInternalError
return nil, types.RetCodeBadNonce
}
}
app.txCount += 1
@@ -51,7 +51,7 @@ func (app *CounterApplication) CheckTx(tx []byte) types.RetCode {
copy(tx8, tx)
txValue := binary.LittleEndian.Uint64(tx8)
if txValue < uint64(app.txCount) {
return types.RetCodeInternalError
return types.RetCodeBadNonce
}
}
return 0

View File

@@ -32,7 +32,7 @@ CounterApp.prototype.append_tx = function(txBytes){
r = new msg.buffer(txByteArray)
txValue = wire.decode_big_endian(r, txBytes.length)
if (txValue != this.txCount){
return {"ret_code":1}
return {"ret_code":6}
}
}
this.txCount += 1;
@@ -48,7 +48,7 @@ CounterApp.prototype.check_tx = function(txBytes){
r = new msg.buffer(txByteArray)
txValue = wire.decode_big_endian(r, txBytes.length)
if (txValue < this.txCount){
return {"ret_code":1}
return {"ret_code":6}
}
}
return {"ret_code":0}

View File

@@ -31,7 +31,7 @@ class CounterApplication():
txValue = decode_big_endian(
BytesBuffer(txByteArray), len(txBytes))
if txValue != self.txCount:
return None, 1
return None, 6
self.txCount += 1
return None, 0
@@ -43,7 +43,7 @@ class CounterApplication():
txValue = decode_big_endian(
BytesBuffer(txByteArray), len(txBytes))
if txValue < self.txCount:
return 1
return 6
return 0
def get_hash(self):

View File

@@ -31,7 +31,7 @@ class CounterApplication():
txValue = decode_big_endian(
BytesBuffer(txByteArray), len(txBytes))
if txValue != self.txCount:
return None, 1
return None, 6
self.txCount += 1
return None, 0
@@ -43,7 +43,7 @@ class CounterApplication():
txValue = decode_big_endian(
BytesBuffer(txByteArray), len(txBytes))
if txValue < self.txCount:
return 1
return 6
return 0
def get_hash(self):