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.

35 lines
955 B

  1. package abciclient
  2. import (
  3. "fmt"
  4. "github.com/tendermint/tendermint/abci/types"
  5. tmsync "github.com/tendermint/tendermint/internal/libs/sync"
  6. )
  7. // Creator creates new ABCI clients.
  8. type Creator func() (Client, error)
  9. // NewLocalCreator returns a Creator for the given app,
  10. // which will be running locally.
  11. func NewLocalCreator(app types.Application) Creator {
  12. mtx := new(tmsync.Mutex)
  13. return func() (Client, error) {
  14. return NewLocalClient(mtx, app), nil
  15. }
  16. }
  17. // NewRemoteCreator returns a Creator for the given address (e.g.
  18. // "192.168.0.1") and transport (e.g. "tcp"). Set mustConnect to true if you
  19. // want the client to connect before reporting success.
  20. func NewRemoteCreator(addr, transport string, mustConnect bool) Creator {
  21. return func() (Client, error) {
  22. remoteApp, err := NewClient(addr, transport, mustConnect)
  23. if err != nil {
  24. return nil, fmt.Errorf("failed to connect to proxy: %w", err)
  25. }
  26. return remoteApp, nil
  27. }
  28. }