Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 New ¶
func New(s Syncer, am *alerts.Manager, whm *webhooks.Manager, cm ChainManager, tp TransactionPool, w Wallet, hdb HostDB, as AutopilotStore, ms MetadataStore, ss SettingStore, eas EphemeralAccountStore, mtrcs MetricsStore, l *zap.Logger) (*bus, error)
New returns a new Bus.
Types ¶
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 ChainManager ¶
type ChainManager interface { AcceptBlock(types.Block) error BlockAtHeight(height uint64) (types.Block, bool) IndexAtHeight(height uint64) (types.ChainIndex, error) LastBlockTime() time.Time Subscribe(s modules.ConsensusSetSubscriber, ccID modules.ConsensusChangeID, cancel <-chan struct{}) error Synced() bool TipState() consensus.State }
A ChainManager manages blockchain state.
type EphemeralAccountStore ¶
type EphemeralAccountStore interface { Accounts(context.Context) ([]api.Account, error) SaveAccounts(context.Context, []api.Account) error SetUncleanShutdown(context.Context) error }
EphemeralAccountStore persists information about accounts. Since accounts are rapidly updated and can be recovered, they are only loaded upon startup and persisted upon shutdown.
type HostDB ¶
type HostDB 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 HostDB 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) }
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 Syncer ¶
type Syncer interface { BroadcastTransaction(txn types.Transaction, dependsOn []types.Transaction) Connect(addr string) error Peers() []string SyncerAddress(ctx context.Context) (string, error) }
A Syncer can connect to other peers and synchronize the blockchain.
type TransactionPool ¶
type TransactionPool interface { AcceptTransactionSet(txns []types.Transaction) error Close() error RecommendedFee() types.Currency Subscribe(subscriber modules.TransactionPoolSubscriber) Transactions() []types.Transaction UnconfirmedParents(txn types.Transaction) ([]types.Transaction, error) }
A TransactionPool can validate and relay unconfirmed transactions.
type Wallet ¶
type Wallet interface { Address() types.Address Balance() (spendable, confirmed, unconfirmed types.Currency, _ error) FundTransaction(cs consensus.State, txn *types.Transaction, amount types.Currency, useUnconfirmedTxns bool) ([]types.Hash256, error) Height() uint64 Redistribute(cs consensus.State, outputs int, amount, feePerByte types.Currency, pool []types.Transaction) ([]types.Transaction, []types.Hash256, error) ReleaseInputs(txn ...types.Transaction) SignTransaction(cs consensus.State, txn *types.Transaction, toSign []types.Hash256, cf types.CoveredFields) error Transactions(before, since time.Time, offset, limit int) ([]wallet.Transaction, error) UnspentOutputs() ([]wallet.SiacoinElement, error) }
A Wallet can spend and receive siacoins.