Browse Source

Add way to enforce serial order in counter app from command line

pull/1780/head
Jae Kwon 9 years ago
parent
commit
5c20d1b3e5
3 changed files with 11 additions and 3 deletions
  1. +7
    -1
      cmd/counter/main.go
  2. +4
    -2
      example/counter.go
  3. +0
    -0
      test.sh

+ 7
- 1
cmd/counter/main.go View File

@ -1,6 +1,8 @@
package main
import (
"flag"
. "github.com/tendermint/go-common"
"github.com/tendermint/tmsp/example"
"github.com/tendermint/tmsp/server"
@ -8,8 +10,12 @@ import (
func main() {
serialPtr := flag.Bool("serial", false, "Enforce incrementing (serial) txs")
flag.Parse()
app := example.NewCounterApplication(*serialPtr)
// Start the listener
_, err := server.StartListener("tcp://0.0.0.0:46658", example.NewCounterApplication())
_, err := server.StartListener("tcp://0.0.0.0:46658", app)
if err != nil {
Exit(err.Error())
}


+ 4
- 2
example/counter.go View File

@ -13,10 +13,11 @@ type CounterApplication struct {
hashCount int
txCount int
commitCount int
serial bool
}
func NewCounterApplication() *CounterApplication {
return &CounterApplication{}
func NewCounterApplication(serial bool) *CounterApplication {
return &CounterApplication{serial: serial}
}
func (app *CounterApplication) Open() types.AppContext {
@ -25,6 +26,7 @@ func (app *CounterApplication) Open() types.AppContext {
hashCount: app.hashCount,
txCount: app.txCount,
commitCount: app.commitCount,
serial: app.serial,
}
}


+ 0
- 0
test.sh View File


Loading…
Cancel
Save