bus

package
v1.1.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: MIT Imports: 32 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountManager

type AccountManager interface {
	Account(id rhpv3.Account, hostKey types.PublicKey) (api.Account, error)
	Accounts() []api.Account
	AddAmount(id rhpv3.Account, hk types.PublicKey, amt *big.Int)
	LockAccount(ctx context.Context, id rhpv3.Account, hostKey types.PublicKey, exclusive bool, duration time.Duration) (api.Account, uint64)
	ResetDrift(id rhpv3.Account) error
	SetBalance(id rhpv3.Account, hk types.PublicKey, balance *big.Int)
	ScheduleSync(id rhpv3.Account, hk types.PublicKey) error
	Shutdown(context.Context) error
	UnlockAccount(id rhpv3.Account, lockID uint64) error
}

type AccountStore added in v1.1.0

type AccountStore interface {
	Accounts(context.Context) ([]api.Account, error)
	SaveAccounts(context.Context, []api.Account) error
	SetUncleanShutdown(context.Context) error
}

AccountStore persists information about accounts. Since accounts are rapidly updated and can be recovered, they are only loaded upon startup and persisted upon shutdown.

type AlertManager added in v1.1.0

type AlertManager interface {
	alerts.Alerter
	RegisterWebhookBroadcaster(b webhooks.Broadcaster)
}

type AutopilotStore

type AutopilotStore interface {
	Autopilot(ctx context.Context, id string) (api.Autopilot, error)
	Autopilots(ctx context.Context) ([]api.Autopilot, error)
	UpdateAutopilot(ctx context.Context, ap api.Autopilot) error
}

An AutopilotStore stores autopilots.

type Bus added in v1.1.0

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

func New

func New(ctx context.Context, am AlertManager, wm WebhooksManager, cm ChainManager, s Syncer, w Wallet, store Store, announcementMaxAge time.Duration, l *zap.Logger) (_ *Bus, err error)

New returns a new Bus

func (*Bus) Handler added in v1.1.0

func (b *Bus) Handler() http.Handler

Handler returns an HTTP handler that serves the bus API.

func (*Bus) Shutdown added in v1.1.0

func (b *Bus) Shutdown(ctx context.Context) error

Shutdown shuts down the bus.

type ChainManager

type ChainManager interface {
	AddBlocks(blocks []types.Block) error
	AddPoolTransactions(txns []types.Transaction) (bool, error)
	AddV2PoolTransactions(basis types.ChainIndex, txns []types.V2Transaction) (known bool, err error)
	Block(id types.BlockID) (types.Block, bool)
	OnReorg(fn func(types.ChainIndex)) (cancel func())
	PoolTransaction(txid types.TransactionID) (types.Transaction, bool)
	PoolTransactions() []types.Transaction
	V2PoolTransactions() []types.V2Transaction
	RecommendedFee() types.Currency
	Tip() types.ChainIndex
	TipState() consensus.State
	UnconfirmedParents(txn types.Transaction) []types.Transaction
	UpdatesSince(index types.ChainIndex, max int) (rus []chain.RevertUpdate, aus []chain.ApplyUpdate, err error)
	V2UnconfirmedParents(txn types.V2Transaction) []types.V2Transaction
}

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
}

A ChainStore stores information about the chain.

type ChainSubscriber added in v1.1.0

type ChainSubscriber interface {
	ChainIndex(context.Context) (types.ChainIndex, error)
	Shutdown(context.Context) error
}

type Client

type Client struct {
	*client.Client
}

Client re-exports the client from the client package.

func NewClient

func NewClient(addr, password string) *Client

NewClient returns a new bus client.

type ContractLocker added in v1.1.0

type ContractLocker interface {
	Acquire(ctx context.Context, priority int, id types.FileContractID, d time.Duration) (uint64, error)
	KeepAlive(id types.FileContractID, lockID uint64, d time.Duration) error
	Release(id types.FileContractID, lockID uint64) error
}

type HostStore added in v1.1.0

type HostStore interface {
	Host(ctx context.Context, hostKey types.PublicKey) (api.Host, error)
	HostAllowlist(ctx context.Context) ([]types.PublicKey, error)
	HostBlocklist(ctx context.Context) ([]string, error)
	HostsForScanning(ctx context.Context, maxLastScan time.Time, offset, limit int) ([]api.HostAddress, error)
	RecordHostScans(ctx context.Context, scans []api.HostScan) error
	RecordPriceTables(ctx context.Context, priceTableUpdate []api.HostPriceTableUpdate) error
	RemoveOfflineHosts(ctx context.Context, minRecentScanFailures uint64, maxDowntime time.Duration) (uint64, error)
	ResetLostSectors(ctx context.Context, hk types.PublicKey) error
	SearchHosts(ctx context.Context, autopilotID, filterMode, usabilityMode, addressContains string, keyIn []types.PublicKey, offset, limit int) ([]api.Host, error)
	UpdateHostAllowlistEntries(ctx context.Context, add, remove []types.PublicKey, clear bool) error
	UpdateHostBlocklistEntries(ctx context.Context, add, remove []string, clear bool) error
	UpdateHostCheck(ctx context.Context, autopilotID string, hk types.PublicKey, check api.HostCheck) error
}

A HostStore stores information about hosts.

type MetadataStore

type MetadataStore interface {
	AddContract(ctx context.Context, c rhpv2.ContractRevision, contractPrice, totalCost types.Currency, startHeight uint64, state string) (api.ContractMetadata, error)
	AddRenewedContract(ctx context.Context, c rhpv2.ContractRevision, contractPrice, totalCost types.Currency, startHeight uint64, renewedFrom types.FileContractID, state string) (api.ContractMetadata, error)
	AncestorContracts(ctx context.Context, fcid types.FileContractID, minStartHeight uint64) ([]api.ArchivedContract, error)
	ArchiveContract(ctx context.Context, id types.FileContractID, reason string) error
	ArchiveContracts(ctx context.Context, toArchive map[types.FileContractID]string) error
	ArchiveAllContracts(ctx context.Context, reason string) error
	Contract(ctx context.Context, id types.FileContractID) (api.ContractMetadata, error)
	Contracts(ctx context.Context, opts api.ContractsOpts) ([]api.ContractMetadata, error)
	ContractSets(ctx context.Context) ([]string, error)
	RecordContractSpending(ctx context.Context, records []api.ContractSpendingRecord) error
	RemoveContractSet(ctx context.Context, name string) error
	RenewedContract(ctx context.Context, renewedFrom types.FileContractID) (api.ContractMetadata, error)
	SetContractSet(ctx context.Context, set string, contracts []types.FileContractID) error

	ContractRoots(ctx context.Context, id types.FileContractID) ([]types.Hash256, error)
	ContractSizes(ctx context.Context) (map[types.FileContractID]api.ContractSize, error)
	ContractSize(ctx context.Context, id types.FileContractID) (api.ContractSize, error)

	DeleteHostSector(ctx context.Context, hk types.PublicKey, root types.Hash256) (int, error)

	Bucket(_ context.Context, bucketName string) (api.Bucket, error)
	CreateBucket(_ context.Context, bucketName string, policy api.BucketPolicy) error
	DeleteBucket(_ context.Context, bucketName string) error
	ListBuckets(_ context.Context) ([]api.Bucket, error)
	UpdateBucketPolicy(ctx context.Context, bucketName string, policy api.BucketPolicy) error

	CopyObject(ctx context.Context, srcBucket, dstBucket, srcPath, dstPath, mimeType string, metadata api.ObjectUserMetadata) (api.ObjectMetadata, error)
	ListObjects(ctx context.Context, bucketName, prefix, sortBy, sortDir, marker string, limit int) (api.ObjectsListResponse, error)
	Object(ctx context.Context, bucketName, path string) (api.Object, error)
	ObjectMetadata(ctx context.Context, bucketName, path string) (api.Object, error)
	ObjectEntries(ctx context.Context, bucketName, path, prefix, sortBy, sortDir, marker string, offset, limit int) ([]api.ObjectMetadata, bool, error)
	ObjectsBySlabKey(ctx context.Context, bucketName string, slabKey object.EncryptionKey) ([]api.ObjectMetadata, error)
	ObjectsStats(ctx context.Context, opts api.ObjectsStatsOpts) (api.ObjectsStatsResponse, error)
	RemoveObject(ctx context.Context, bucketName, path string) error
	RemoveObjects(ctx context.Context, bucketName, prefix string) error
	RenameObject(ctx context.Context, bucketName, from, to string, force bool) error
	RenameObjects(ctx context.Context, bucketName, from, to string, force bool) error
	SearchObjects(ctx context.Context, bucketName, substring string, offset, limit int) ([]api.ObjectMetadata, error)
	UpdateObject(ctx context.Context, bucketName, path, contractSet, ETag, mimeType string, metadata api.ObjectUserMetadata, o object.Object) error

	AbortMultipartUpload(ctx context.Context, bucketName, path string, uploadID string) (err error)
	AddMultipartPart(ctx context.Context, bucketName, path, contractSet, eTag, uploadID string, partNumber int, slices []object.SlabSlice) (err error)
	CompleteMultipartUpload(ctx context.Context, bucketName, path, uploadID string, parts []api.MultipartCompletedPart, opts api.CompleteMultipartOptions) (_ api.MultipartCompleteResponse, err error)
	CreateMultipartUpload(ctx context.Context, bucketName, path string, ec object.EncryptionKey, mimeType string, metadata api.ObjectUserMetadata) (api.MultipartCreateResponse, error)
	MultipartUpload(ctx context.Context, uploadID string) (resp api.MultipartUpload, _ error)
	MultipartUploads(ctx context.Context, bucketName, prefix, keyMarker, uploadIDMarker string, maxUploads int) (resp api.MultipartListUploadsResponse, _ error)
	MultipartUploadParts(ctx context.Context, bucketName, object string, uploadID string, marker int, limit int64) (resp api.MultipartListPartsResponse, _ error)

	MarkPackedSlabsUploaded(ctx context.Context, slabs []api.UploadedPackedSlab) error
	PackedSlabsForUpload(ctx context.Context, lockingDuration time.Duration, minShards, totalShards uint8, set string, limit int) ([]api.PackedSlab, error)
	SlabBuffers(ctx context.Context) ([]api.SlabBuffer, error)

	AddPartialSlab(ctx context.Context, data []byte, minShards, totalShards uint8, contractSet string) (slabs []object.SlabSlice, bufferSize int64, err error)
	FetchPartialSlab(ctx context.Context, key object.EncryptionKey, offset, length uint32) ([]byte, error)
	Slab(ctx context.Context, key object.EncryptionKey) (object.Slab, error)
	RefreshHealth(ctx context.Context) error
	UnhealthySlabs(ctx context.Context, healthCutoff float64, set string, limit int) ([]api.UnhealthySlab, error)
	UpdateSlab(ctx context.Context, s object.Slab, contractSet string) error
}

A MetadataStore stores information about contracts and objects.

type MetricsStore added in v0.7.0

type MetricsStore interface {
	ContractSetMetrics(ctx context.Context, start time.Time, n uint64, interval time.Duration, opts api.ContractSetMetricsQueryOpts) ([]api.ContractSetMetric, error)

	ContractPruneMetrics(ctx context.Context, start time.Time, n uint64, interval time.Duration, opts api.ContractPruneMetricsQueryOpts) ([]api.ContractPruneMetric, error)
	RecordContractPruneMetric(ctx context.Context, metrics ...api.ContractPruneMetric) error

	ContractMetrics(ctx context.Context, start time.Time, n uint64, interval time.Duration, opts api.ContractMetricsQueryOpts) ([]api.ContractMetric, error)
	RecordContractMetric(ctx context.Context, metrics ...api.ContractMetric) error

	PruneMetrics(ctx context.Context, metric string, cutoff time.Time) error
	ContractSetChurnMetrics(ctx context.Context, start time.Time, n uint64, interval time.Duration, opts api.ContractSetChurnMetricsQueryOpts) ([]api.ContractSetChurnMetric, error)
	RecordContractSetChurnMetric(ctx context.Context, metrics ...api.ContractSetChurnMetric) error

	WalletMetrics(ctx context.Context, start time.Time, n uint64, interval time.Duration, opts api.WalletMetricsQueryOpts) ([]api.WalletMetric, error)
	RecordWalletMetric(ctx context.Context, metrics ...api.WalletMetric) error
}

A MetricsStore stores metrics.

type PinManager added in v1.1.0

type PinManager interface {
	Shutdown(context.Context) error
	TriggerUpdate()
}

type SettingStore

type SettingStore interface {
	DeleteSetting(ctx context.Context, key string) error
	Setting(ctx context.Context, key string) (string, error)
	Settings(ctx context.Context) ([]string, error)
	UpdateSetting(ctx context.Context, key, value string) error
}

A SettingStore stores settings.

type Store added in v1.1.0

Store is a collection of stores used by the bus.

type Syncer

type Syncer interface {
	Addr() string
	BroadcastHeader(h gateway.BlockHeader)
	BroadcastV2BlockOutline(bo gateway.V2BlockOutline)
	BroadcastTransactionSet([]types.Transaction)
	BroadcastV2TransactionSet(index types.ChainIndex, txns []types.V2Transaction)
	Connect(ctx context.Context, addr string) (*syncer.Peer, error)
	Peers() []*syncer.Peer
}

type TransactionPool

type TransactionPool interface {
	AcceptTransactionSet(txns []types.Transaction) error
	Close() error
	RecommendedFee() types.Currency
	Transactions() []types.Transaction
	UnconfirmedParents(txn types.Transaction) ([]types.Transaction, error)
}

A TransactionPool can validate and relay unconfirmed transactions.

type UploadingSectorsCache added in v1.1.0

type UploadingSectorsCache interface {
	AddSector(uID api.UploadID, fcid types.FileContractID, root types.Hash256) error
	FinishUpload(uID api.UploadID)
	HandleRenewal(fcid, renewedFrom types.FileContractID)
	Pending(fcid types.FileContractID) (size uint64)
	Sectors(fcid types.FileContractID) (roots []types.Hash256)
	StartUpload(uID api.UploadID) error
}

type Wallet

type Wallet interface {
	Address() types.Address
	Balance() (wallet.Balance, error)
	Close() error
	FundTransaction(txn *types.Transaction, amount types.Currency, useUnconfirmed bool) ([]types.Hash256, error)
	FundV2Transaction(txn *types.V2Transaction, amount types.Currency, useUnconfirmed bool) (consensus.State, []int, error)
	Redistribute(outputs int, amount, feePerByte types.Currency) (txns []types.Transaction, toSign []types.Hash256, err error)
	RedistributeV2(outputs int, amount, feePerByte types.Currency) (txns []types.V2Transaction, toSign [][]int, err error)
	ReleaseInputs(txns []types.Transaction, v2txns []types.V2Transaction)
	SignTransaction(txn *types.Transaction, toSign []types.Hash256, cf types.CoveredFields)
	SignV2Inputs(state consensus.State, txn *types.V2Transaction, toSign []int)
	SpendableOutputs() ([]types.SiacoinElement, error)
	Tip() (types.ChainIndex, error)
	UnconfirmedEvents() ([]wallet.Event, error)
	UpdateChainState(tx wallet.UpdateTx, reverted []chain.RevertUpdate, applied []chain.ApplyUpdate) error
	Events(offset, limit int) ([]wallet.Event, error)
}

type WalletMetricsRecorder added in v1.1.0

type WalletMetricsRecorder interface {
	Shutdown(context.Context) error
}

type WebhooksManager added in v1.1.0

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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