bus

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAcquireContractTimeout = errors.New("acquiring the lock timed out")

ErrAcquireContractTimeout is returned when the context passed in to contractLocks.Acquire is closed before the lock can be acquired.

Functions

func NewChainSubscriber added in v1.1.0

func NewChainSubscriber(whm WebhookManager, cm ChainManager, cs ChainStore, w Wallet, announcementMaxAge time.Duration, logger *zap.Logger) *chainSubscriber

NewChainSubscriber creates a new chain subscriber that will sync with the given chain manager and chain store. The returned subscriber is already running and can be stopped by calling Shutdown.

func NewForexClient

func NewForexClient(url string) *client

func NewPinManager

func NewPinManager(alerts alerts.Alerter, broadcaster webhooks.Broadcaster, s Store, updateInterval, rateWindow time.Duration, l *zap.Logger) *pinManager

NewPinManager returns a new PinManager, responsible for pinning prices to a fixed value in an underlying currency. The returned pin manager is already running and can be stopped by calling Shutdown.

Types

type ChainManager added in v1.1.0

type ChainManager interface {
	OnReorg(fn func(types.ChainIndex)) (cancel func())
	RecommendedFee() types.Currency
	Tip() types.ChainIndex
	UpdatesSince(index types.ChainIndex, max int) (rus []chain.RevertUpdate, aus []chain.ApplyUpdate, err error)
}

type ChainStore added in v1.1.0

type ChainStore interface {
	ChainIndex(ctx context.Context) (types.ChainIndex, error)
	ProcessChainUpdate(ctx context.Context, applyFn func(sql.ChainUpdateTx) error) error
}

type ContractLocker added in v1.1.0

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

func NewContractLocker added in v1.1.0

func NewContractLocker() *ContractLocker

func (*ContractLocker) Acquire added in v1.1.0

func (l *ContractLocker) Acquire(ctx context.Context, priority int, id types.FileContractID, d time.Duration) (uint64, error)

Acquire acquires a contract lock for the given id and provided duration. If acquiring the lock doesn't finish before the context is closed, ErrAcquireContractTimeout is returned. Upon success an identifier is returned which can be used to release the lock before its lock duration has passed. TODO: Extend this with some sort of priority. e.g. migrations would acquire a lock with a low priority but contract maintenance would have a very high one to avoid being starved by low prio tasks.

func (*ContractLocker) KeepAlive added in v1.1.0

func (l *ContractLocker) KeepAlive(id types.FileContractID, lockID uint64, d time.Duration) error

KeepAlive refreshes the timer on a contract lock for a given contract if the lockID matches the one on the lock.

func (*ContractLocker) Release added in v1.1.0

func (l *ContractLocker) Release(id types.FileContractID, lockID uint64) error

Release releases the contract lock for a given contract and lock id.

type MetricsStore added in v1.1.0

type MetricsStore interface {
	RecordWalletMetric(ctx context.Context, metrics ...api.WalletMetric) error
}

type SectorsCache added in v1.1.0

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

func NewSectorsCache added in v1.1.0

func NewSectorsCache() *SectorsCache

func (*SectorsCache) AddSector added in v1.1.0

func (sc *SectorsCache) AddSector(uID api.UploadID, fcid types.FileContractID, root types.Hash256) error

func (*SectorsCache) FinishUpload added in v1.1.0

func (sc *SectorsCache) FinishUpload(uID api.UploadID)

func (*SectorsCache) HandleRenewal added in v1.1.0

func (sc *SectorsCache) HandleRenewal(fcid, renewedFrom types.FileContractID)

func (*SectorsCache) Pending added in v1.1.0

func (sc *SectorsCache) Pending(fcid types.FileContractID) (size uint64)

func (*SectorsCache) Sectors added in v1.1.0

func (sc *SectorsCache) Sectors(fcid types.FileContractID) (roots []types.Hash256)

func (*SectorsCache) StartUpload added in v1.1.0

func (sc *SectorsCache) StartUpload(uID api.UploadID) error

type Store added in v1.1.0

type Store interface {
	Autopilot(ctx context.Context, id string) (api.Autopilot, error)
	Setting(ctx context.Context, key string) (string, error)
	UpdateAutopilot(ctx context.Context, ap api.Autopilot) error
	UpdateSetting(ctx context.Context, key, value string) error
}

type Wallet added in v1.1.0

type Wallet interface {
	UpdateChainState(tx wallet.UpdateTx, reverted []chain.RevertUpdate, applied []chain.ApplyUpdate) error
}

type WalletBalance added in v1.1.0

type WalletBalance interface {
	Balance() (wallet.Balance, error)
}

type WalletMetricsRecorder added in v1.1.0

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

func NewWalletMetricRecorder added in v1.1.0

func NewWalletMetricRecorder(store MetricsStore, wallet WalletBalance, interval time.Duration, logger *zap.Logger) *WalletMetricsRecorder

NewWalletMetricRecorder returns a recorder that periodically records wallet metrics. The recorder is already running and can be stopped by calling Shutdown.

func (*WalletMetricsRecorder) Shutdown added in v1.1.0

func (wmr *WalletMetricsRecorder) Shutdown(ctx context.Context) error

type WebhookManager added in v1.1.0

type WebhookManager interface {
	webhooks.Broadcaster
	Delete(context.Context, webhooks.Webhook) error
	Info() ([]webhooks.Webhook, []webhooks.WebhookQueueInfo)
	Register(context.Context, webhooks.Webhook) error
	Shutdown(context.Context) error
}

Jump to

Keyboard shortcuts

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