watchtower

package
v0.6.1-beta-rc2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPeerPort is the default server port to which clients can
	// connect.
	DefaultPeerPort = 9911

	// DefaultReadTimeout is the default timeout after which the tower will
	// hang up on a client if nothing is received.
	DefaultReadTimeout = 15 * time.Second

	// DefaultWriteTimeout is the default timeout after which the tower will
	// hang up on a client if it is unable to send a message.
	DefaultWriteTimeout = 15 * time.Second
)

Variables

View Source
var (
	// ErrNoListeners signals that no listening ports were provided,
	// rendering the tower unable to receive client requests.
	ErrNoListeners = errors.New("no listening ports were specified")

	// ErrNonExperimentalConf signals that an attempt to apply a
	// non-experimental Conf to a Config was detected.
	ErrNonExperimentalConf = errors.New("cannot use watchtower in non-" +
		"experimental builds")

	// ErrNoNetwork signals that no tor.Net is provided in the Config, which
	// prevents resolution of listening addresses.
	ErrNoNetwork = errors.New("no network specified, must be tor or clearnet")
)
View Source
var (
	// DefaultPeerPortStr is the default server port as a string.
	DefaultPeerPortStr = fmt.Sprintf(":%d", DefaultPeerPort)
)

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type Conf

type Conf struct{}

Conf specifies the watchtower options that be configured from the command line or configuration file. In non-experimental builds, we disallow such configuration.

func (*Conf) Apply

func (c *Conf) Apply(cfg *Config) (*Config, error)

Apply returns an error signaling that the Conf could not be applied in non-experimental builds.

type Config

type Config struct {
	// ChainHash identifies the chain that the watchtower will be monitoring
	// for breaches and that will be advertised in the server's Init message
	// to inbound clients.
	ChainHash chainhash.Hash

	// BlockFetcher supports the ability to fetch blocks from the network by
	// hash.
	BlockFetcher lookout.BlockFetcher

	// DB provides access to persistent storage of sessions and state
	// updates uploaded by watchtower clients, and the ability to query for
	// breach hints when receiving new blocks.
	DB DB

	// EpochRegistrar supports the ability to register for events
	// corresponding to newly created blocks.
	EpochRegistrar lookout.EpochRegistrar

	// Net specifies the network type that the watchtower will use to listen
	// for client connections. Either a clear net or Tor are supported.
	Net tor.Net

	// NewAddress is used to generate reward addresses, where a cut of
	// successfully sent funds can be received.
	NewAddress func() (btcutil.Address, error)

	// NodePrivKey is private key to be used in accepting new brontide
	// connections.
	NodePrivKey *btcec.PrivateKey

	// PublishTx provides the ability to send a signed transaction to the
	// network.
	//
	// TODO(conner): replace with lnwallet.WalletController interface to
	// have stronger guarantees wrt. returned error types.
	PublishTx func(*wire.MsgTx) error

	// ListenAddrs specifies which address to which clients may connect.
	ListenAddrs []net.Addr

	// ReadTimeout specifies how long a client may go without sending a
	// message.
	ReadTimeout time.Duration

	// WriteTimeout specifies how long a client may go without reading a
	// message from the other end, if the connection has stopped buffering
	// the server's replies.
	WriteTimeout time.Duration
}

Config defines the resources and parameters used to configure a Watchtower. All nil-able elements with the Config must be set in order for the Watchtower to function properly.

type DB

type DB interface {
	lookout.DB
	wtserver.DB
}

DB abstracts the persistent functionality required to run the watchtower daemon. It composes the database interfaces required by the lookout and wtserver subsystems.

type Standalone

type Standalone struct {
	// contains filtered or unexported fields
}

Standalone encapsulates the server-side functionality required by watchtower clients. A Standalone couples the two primary subsystems such that, as a unit, this instance can negotiate sessions with clients, accept state updates for active sessions, monitor the chain for breaches matching known breach hints, publish reconstructed justice transactions on behalf of tower clients.

func New

func New(cfg *Config) (*Standalone, error)

New validates the passed Config and returns a fresh Standalone instance if the tower's subsystems could be properly initialized.

func (*Standalone) Start

func (w *Standalone) Start() error

Start idempotently starts the Standalone, an error is returned if the subsystems could not be initialized.

func (*Standalone) Stop

func (w *Standalone) Stop() error

Stop idempotently stops the Standalone and blocks until the subsystems have completed their shutdown.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL