config.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package stacks
  2. import (
  3. "time"
  4. "github.com/certusone/wormhole/node/pkg/common"
  5. gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
  6. "github.com/certusone/wormhole/node/pkg/query"
  7. "github.com/certusone/wormhole/node/pkg/supervisor"
  8. "github.com/certusone/wormhole/node/pkg/watchers"
  9. "github.com/certusone/wormhole/node/pkg/watchers/interfaces"
  10. "github.com/wormhole-foundation/wormhole/sdk/vaa"
  11. )
  12. // WatcherConfig defines the configuration for the Stacks watcher
  13. type WatcherConfig struct {
  14. NetworkID watchers.NetworkID // human readable name
  15. ChainID vaa.ChainID // ChainID
  16. RPCURL string // Stacks RPC URL
  17. RPCAuthToken string // Stacks RPC Authorization Token
  18. StateContract string // Stacks contract address for the Wormhole core (state) contract
  19. // Optional configurable parameters (zero values will use defaults)
  20. BitcoinBlockPollInterval time.Duration `mapstructure:"bitcoinBlockPollInterval"` // How often to poll for new Bitcoin blocks
  21. }
  22. func (wc *WatcherConfig) GetNetworkID() watchers.NetworkID {
  23. return wc.NetworkID
  24. }
  25. func (wc *WatcherConfig) GetChainID() vaa.ChainID {
  26. return wc.ChainID
  27. }
  28. //nolint:unparam // error is always nil here but the return type is required to satisfy the interface.
  29. func (wc *WatcherConfig) Create(
  30. msgC chan<- *common.MessagePublication,
  31. obsvReqC <-chan *gossipv1.ObservationRequest,
  32. _ <-chan *query.PerChainQueryInternal, // queryReqC - not used for Stacks
  33. _ chan<- *query.PerChainQueryResponseInternal, // queryResponseC - not used for Stacks
  34. _ chan<- *common.GuardianSet, // setC - not used for Stacks
  35. _ common.Environment, // env - not used for Stacks
  36. ) (supervisor.Runnable, interfaces.Reobserver, error) {
  37. watcher := NewWatcher(wc.RPCURL, wc.RPCAuthToken, wc.StateContract, wc.BitcoinBlockPollInterval, msgC, obsvReqC)
  38. return watcher.Run, watcher, nil
  39. }