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.

36 lines
1.0 KiB

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