mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-28 13:41:21 +00:00
Add serial=on option for CounterApplication
This commit is contained in:
parent
6a5b804523
commit
7448cdc154
@ -35,6 +35,7 @@ type CounterAppContext struct {
|
|||||||
hashCount int
|
hashCount int
|
||||||
txCount int
|
txCount int
|
||||||
commitCount int
|
commitCount int
|
||||||
|
serial bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (appC *CounterAppContext) Echo(message string) string {
|
func (appC *CounterAppContext) Echo(message string) string {
|
||||||
@ -46,10 +47,22 @@ func (appC *CounterAppContext) Info() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (appC *CounterAppContext) SetOption(key string, value string) types.RetCode {
|
func (appC *CounterAppContext) SetOption(key string, value string) types.RetCode {
|
||||||
|
if key == "serial" && value == "on" {
|
||||||
|
appC.serial = true
|
||||||
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (appC *CounterAppContext) AppendTx(tx []byte) ([]types.Event, 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) {
|
||||||
|
return nil, types.RetCodeInternalError
|
||||||
|
}
|
||||||
|
}
|
||||||
appC.txCount += 1
|
appC.txCount += 1
|
||||||
return nil, 0
|
return nil, 0
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user