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.

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