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.

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