You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.4 KiB

  1. package proxy
  2. import (
  3. "io"
  4. abciclient "github.com/tendermint/tendermint/abci/client"
  5. "github.com/tendermint/tendermint/abci/example/kvstore"
  6. "github.com/tendermint/tendermint/abci/types"
  7. "github.com/tendermint/tendermint/libs/log"
  8. e2e "github.com/tendermint/tendermint/test/e2e/app"
  9. )
  10. // DefaultClientCreator returns a default ClientCreator, which will create a
  11. // local client if addr is one of: 'kvstore',
  12. // 'persistent_kvstore', 'e2e', or 'noop', otherwise - a remote client.
  13. //
  14. // The Closer is a noop except for persistent_kvstore applications,
  15. // which will clean up the store.
  16. func DefaultClientCreator(logger log.Logger, addr, transport, dbDir string) (abciclient.Creator, io.Closer) {
  17. switch addr {
  18. case "kvstore":
  19. return abciclient.NewLocalCreator(kvstore.NewApplication()), noopCloser{}
  20. case "persistent_kvstore":
  21. app := kvstore.NewPersistentKVStoreApplication(logger, dbDir)
  22. return abciclient.NewLocalCreator(app), app
  23. case "e2e":
  24. app, err := e2e.NewApplication(e2e.DefaultConfig(dbDir))
  25. if err != nil {
  26. panic(err)
  27. }
  28. return abciclient.NewLocalCreator(app), noopCloser{}
  29. case "noop":
  30. return abciclient.NewLocalCreator(types.NewBaseApplication()), noopCloser{}
  31. default:
  32. mustConnect := false // loop retrying
  33. return abciclient.NewRemoteCreator(logger, addr, transport, mustConnect), noopCloser{}
  34. }
  35. }
  36. type noopCloser struct{}
  37. func (noopCloser) Close() error { return nil }