Documentation
¶
Index ¶
- Variables
- type Account
- func (a *Account) ID() rhpv3.Account
- func (a *Account) Key() types.PrivateKey
- func (a *Account) ScheduleSync()
- func (a *Account) WithDeposit(amtFn func(types.Currency) (types.Currency, error)) error
- func (a *Account) WithSync(balanceFn func() (types.Currency, error)) error
- func (a *Account) WithWithdrawal(amtFn func() (types.Currency, error)) error
- type AccountFunder
- type AccountMgr
- type AccountStore
- type AccountSyncer
- type Bus
- type ConsensusState
- type DownloadContracts
- type EventHandler
- type EventSubscriber
- type WebhookManager
- type WorkerCache
Constants ¶
This section is empty.
Variables ¶
var (
ErrAccountNotFound = errors.New("account doesn't exist")
)
Functions ¶
This section is empty.
Types ¶
type Account ¶ added in v1.1.0
type Account struct {
// contains filtered or unexported fields
}
func (*Account) Key ¶ added in v1.1.0
func (a *Account) Key() types.PrivateKey
func (*Account) ScheduleSync ¶ added in v1.1.0
func (a *Account) ScheduleSync()
scheduleSync sets the requiresSync flag of an account.
func (*Account) WithDeposit ¶ added in v1.1.0
WithDeposit increases the balance of an account by the amount returned by amtFn if amtFn doesn't return an error.
func (*Account) WithSync ¶ added in v1.1.0
WithSync syncs an accounts balance with the bus. To do so, the account is locked while the balance is fetched through balanceFn.
func (*Account) WithWithdrawal ¶ added in v1.1.0
WithWithdrawal decreases the balance of an account by the amount returned by amtFn. The amount is still withdrawn if amtFn returns an error since some costs are non-refundable.
type AccountFunder ¶ added in v1.1.0
type AccountMgr ¶ added in v1.1.0
type AccountMgr struct {
// contains filtered or unexported fields
}
func NewAccountManager ¶ added in v1.1.0
func NewAccountManager(key utils.AccountsKey, owner string, alerter alerts.Alerter, funder AccountFunder, syncer AccountSyncer, cs ConsensusState, dc DownloadContracts, s AccountStore, refillInterval time.Duration, l *zap.Logger) (*AccountMgr, error)
NewAccountManager creates a new account manager. It will load all accounts from the given store and mark the shutdown as unclean. When Shutdown is called it will save all accounts.
func (*AccountMgr) Account ¶ added in v1.1.0
func (a *AccountMgr) Account(hostKey types.PublicKey) api.Account
Account returns the account with the given id.
func (*AccountMgr) Accounts ¶ added in v1.1.0
func (a *AccountMgr) Accounts() []api.Account
Accounts returns all accounts.
func (*AccountMgr) ForHost ¶ added in v1.1.0
func (a *AccountMgr) ForHost(hk types.PublicKey) *Account
ForHost returns an account to use for a given host. If the account doesn't exist, a new one is created.
func (*AccountMgr) ResetDrift ¶ added in v1.1.0
func (a *AccountMgr) ResetDrift(id rhpv3.Account) error
ResetDrift resets the drift on an account.
type AccountStore ¶ added in v1.1.0
type AccountSyncer ¶ added in v1.1.0
type Bus ¶
type Bus interface { Contracts(ctx context.Context, opts api.ContractsOpts) ([]api.ContractMetadata, error) GougingParams(ctx context.Context) (api.GougingParams, error) }
type ConsensusState ¶ added in v1.1.0
type ConsensusState interface {
ConsensusState(ctx context.Context) (api.ConsensusState, error)
}
type DownloadContracts ¶ added in v1.1.0
type DownloadContracts interface {
DownloadContracts(ctx context.Context) ([]api.ContractMetadata, error)
}
type EventHandler ¶ added in v1.1.0
type EventHandler interface { HandleEvent(event webhooks.Event) error Subscribe(e EventSubscriber) error }
type EventSubscriber ¶ added in v1.1.0
type EventSubscriber interface { AddEventHandler(id string, h EventHandler) (chan struct{}, error) ProcessEvent(event webhooks.Event) Register(ctx context.Context, eventURL string, opts ...webhooks.HeaderOption) error Shutdown(context.Context) error }
func NewEventSubscriber ¶ added in v1.1.0
func NewEventSubscriber(a alerts.Alerter, w WebhookManager, l *zap.Logger, registerInterval time.Duration) EventSubscriber
type WebhookManager ¶ added in v1.1.0
type WorkerCache ¶
type WorkerCache interface { DownloadContracts(ctx context.Context) ([]api.ContractMetadata, error) GougingParams(ctx context.Context) (api.GougingParams, error) HandleEvent(event webhooks.Event) error Subscribe(e EventSubscriber) error }