Browse Source

s/Dummy/KVStore/g

pull/1780/head
zramsay 7 years ago
parent
commit
a3362ccf35
9 changed files with 123 additions and 102 deletions
  1. +7
    -8
      README.md
  2. +31
    -9
      cmd/abci-cli/abci-cli.go
  3. +4
    -4
      example/example_test.go
  4. +6
    -6
      example/kvstore/README.md
  5. +10
    -10
      example/kvstore/dummy.go
  6. +39
    -39
      example/kvstore/dummy_test.go
  7. +3
    -3
      example/kvstore/helpers.go
  8. +21
    -21
      example/kvstore/persistent_dummy.go
  9. +2
    -2
      tests/client_server_test.go

+ 7
- 8
README.md View File

@ -87,7 +87,7 @@ See [the documentation](http://tendermint.readthedocs.io/en/master/) for more de
### Examples ### Examples
Check out the variety of example applications in the [example directory](example/). Check out the variety of example applications in the [example directory](example/).
It also contains the code refered to by the `counter` and `dummy` apps; these apps come
It also contains the code refered to by the `counter` and `kvstore` apps; these apps come
built into the `abci-cli` binary. built into the `abci-cli` binary.
#### Counter #### Counter
@ -122,21 +122,21 @@ func cmdCounter(cmd *cobra.Command, args []string) error {
and can be found in [this file](cmd/abci-cli/abci-cli.go). and can be found in [this file](cmd/abci-cli/abci-cli.go).
#### Dummy
#### kvstore
The `abci-cli dummy` application, which illustrates a simple key-value Merkle tree
The `abci-cli kvstore` application, which illustrates a simple key-value Merkle tree
```golang ```golang
func cmdDummy(cmd *cobra.Command, args []string) error {
func cmdKVStore(cmd *cobra.Command, args []string) error {
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)) logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
// Create the application - in memory or persisted to disk // Create the application - in memory or persisted to disk
var app types.Application var app types.Application
if flagPersist == "" { if flagPersist == "" {
app = dummy.NewDummyApplication()
app = dummy.NewKVStoreApplication()
} else { } else {
app = dummy.NewPersistentDummyApplication(flagPersist)
app.(*dummy.PersistentDummyApplication).SetLogger(logger.With("module", "dummy"))
app = dummy.NewPersistentKVStoreApplication(flagPersist)
app.(*dummy.PersistentKVStoreApplication).SetLogger(logger.With("module", "kvstore"))
} }
// Start the listener // Start the listener
@ -157,4 +157,3 @@ func cmdDummy(cmd *cobra.Command, args []string) error {
return nil return nil
} }
``` ```

+ 31
- 9
cmd/abci-cli/abci-cli.go View File

@ -17,7 +17,7 @@ import (
abcicli "github.com/tendermint/abci/client" abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/example/code" "github.com/tendermint/abci/example/code"
"github.com/tendermint/abci/example/counter" "github.com/tendermint/abci/example/counter"
"github.com/tendermint/abci/example/dummy"
"github.com/tendermint/abci/example/kvstore"
"github.com/tendermint/abci/server" "github.com/tendermint/abci/server"
servertest "github.com/tendermint/abci/tests/server" servertest "github.com/tendermint/abci/tests/server"
"github.com/tendermint/abci/types" "github.com/tendermint/abci/types"
@ -47,7 +47,7 @@ var (
flagAddrC string flagAddrC string
flagSerial bool flagSerial bool
// dummy
// kvstore
flagAddrD string flagAddrD string
flagPersist string flagPersist string
) )
@ -59,7 +59,7 @@ var RootCmd = &cobra.Command{
PersistentPreRunE: func(cmd *cobra.Command, args []string) error { PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
switch cmd.Use { switch cmd.Use {
case "counter", "dummy": // for the examples apps, don't pre-run
case "counter", "kvstore", "dummy": // for the examples apps, don't pre-run
return nil return nil
case "version": // skip running for version command case "version": // skip running for version command
return nil return nil
@ -133,6 +133,12 @@ func addDummyFlags() {
dummyCmd.PersistentFlags().StringVarP(&flagAddrD, "addr", "", "tcp://0.0.0.0:46658", "listen address") dummyCmd.PersistentFlags().StringVarP(&flagAddrD, "addr", "", "tcp://0.0.0.0:46658", "listen address")
dummyCmd.PersistentFlags().StringVarP(&flagPersist, "persist", "", "", "directory to use for a database") dummyCmd.PersistentFlags().StringVarP(&flagPersist, "persist", "", "", "directory to use for a database")
} }
func addKVStoreFlags() {
kvstoreCmd.PersistentFlags().StringVarP(&flagAddrD, "addr", "", "tcp://0.0.0.0:46658", "listen address")
kvstoreCmd.PersistentFlags().StringVarP(&flagPersist, "persist", "", "", "directory to use for a database")
}
func addCommands() { func addCommands() {
RootCmd.AddCommand(batchCmd) RootCmd.AddCommand(batchCmd)
RootCmd.AddCommand(consoleCmd) RootCmd.AddCommand(consoleCmd)
@ -150,8 +156,12 @@ func addCommands() {
// examples // examples
addCounterFlags() addCounterFlags()
RootCmd.AddCommand(counterCmd) RootCmd.AddCommand(counterCmd)
// deprecated, left for backwards compatibility
addDummyFlags() addDummyFlags()
RootCmd.AddCommand(dummyCmd) RootCmd.AddCommand(dummyCmd)
// replaces dummy, see issue #196
addKVStoreFlags()
RootCmd.AddCommand(kvstoreCmd)
} }
var batchCmd = &cobra.Command{ var batchCmd = &cobra.Command{
@ -285,13 +295,25 @@ var counterCmd = &cobra.Command{
}, },
} }
// deprecated, left for backwards compatibility
var dummyCmd = &cobra.Command{ var dummyCmd = &cobra.Command{
Use: "dummy",
Use: "dummy",
Deprecated: "use: [abci-cli kvstore] instead",
Short: "ABCI demo example",
Long: "ABCI demo example",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
return cmdKVStore(cmd, args)
},
}
var kvstoreCmd = &cobra.Command{
Use: "kvstore",
Short: "ABCI demo example", Short: "ABCI demo example",
Long: "ABCI demo example", Long: "ABCI demo example",
Args: cobra.ExactArgs(0), Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
return cmdDummy(cmd, args)
return cmdKVStore(cmd, args)
}, },
} }
@ -654,16 +676,16 @@ func cmdCounter(cmd *cobra.Command, args []string) error {
return nil return nil
} }
func cmdDummy(cmd *cobra.Command, args []string) error {
func cmdKVStore(cmd *cobra.Command, args []string) error {
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)) logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
// Create the application - in memory or persisted to disk // Create the application - in memory or persisted to disk
var app types.Application var app types.Application
if flagPersist == "" { if flagPersist == "" {
app = dummy.NewDummyApplication()
app = kvstore.NewDummyApplication()
} else { } else {
app = dummy.NewPersistentDummyApplication(flagPersist)
app.(*dummy.PersistentDummyApplication).SetLogger(logger.With("module", "dummy"))
app = kvstore.NewPersistentDummyApplication(flagPersist)
app.(*kvstore.PersistentDummyApplication).SetLogger(logger.With("module", "kvstore"))
} }
// Start the listener // Start the listener


+ 4
- 4
example/example_test.go View File

@ -16,14 +16,14 @@ import (
abcicli "github.com/tendermint/abci/client" abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/example/code" "github.com/tendermint/abci/example/code"
"github.com/tendermint/abci/example/dummy"
"github.com/tendermint/abci/example/kvstore"
abciserver "github.com/tendermint/abci/server" abciserver "github.com/tendermint/abci/server"
"github.com/tendermint/abci/types" "github.com/tendermint/abci/types"
) )
func TestDummy(t *testing.T) {
fmt.Println("### Testing Dummy")
testStream(t, dummy.NewDummyApplication())
func TestKVStore(t *testing.T) {
fmt.Println("### Testing KVStore")
testStream(t, dummy.NewKVStoreApplication())
} }
func TestBaseApp(t *testing.T) { func TestBaseApp(t *testing.T) {


example/dummy/README.md → example/kvstore/README.md View File


example/dummy/dummy.go → example/kvstore/dummy.go View File


example/dummy/dummy_test.go → example/kvstore/dummy_test.go View File


example/dummy/helpers.go → example/kvstore/helpers.go View File


example/dummy/persistent_dummy.go → example/kvstore/persistent_dummy.go View File


+ 2
- 2
tests/client_server_test.go View File

@ -6,14 +6,14 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
abciclient "github.com/tendermint/abci/client" abciclient "github.com/tendermint/abci/client"
"github.com/tendermint/abci/example/dummy"
"github.com/tendermint/abci/example/kvstore"
abciserver "github.com/tendermint/abci/server" abciserver "github.com/tendermint/abci/server"
) )
func TestClientServerNoAddrPrefix(t *testing.T) { func TestClientServerNoAddrPrefix(t *testing.T) {
addr := "localhost:46658" addr := "localhost:46658"
transport := "socket" transport := "socket"
app := dummy.NewDummyApplication()
app := kvstore.NewKVStoreApplication()
server, err := abciserver.NewServer(addr, transport, app) server, err := abciserver.NewServer(addr, transport, app)
assert.NoError(t, err, "expected no error on NewServer") assert.NoError(t, err, "expected no error on NewServer")


Loading…
Cancel
Save