Documentation ¶
Index ¶
- Variables
- func AbortMultipartUpload(ctx context.Context, tx sql.Tx, bucket, key string, uploadID string) error
- func Accounts(ctx context.Context, tx sql.Tx, owner string) ([]api.Account, error)
- func AncestorContracts(ctx context.Context, tx sql.Tx, fcid types.FileContractID, startHeight uint64) ([]api.ArchivedContract, error)
- func ArchiveContract(ctx context.Context, tx sql.Tx, fcid types.FileContractID, reason string) error
- func Autopilot(ctx context.Context, tx sql.Tx, id string) (api.Autopilot, error)
- func Autopilots(ctx context.Context, tx sql.Tx) ([]api.Autopilot, error)
- func Bucket(ctx context.Context, tx sql.Tx, bucket string) (api.Bucket, error)
- func Contract(ctx context.Context, tx sql.Tx, fcid types.FileContractID) (api.ContractMetadata, error)
- func ContractMetrics(ctx context.Context, tx sql.Tx, start time.Time, n uint64, ...) ([]api.ContractMetric, error)
- func ContractPruneMetrics(ctx context.Context, tx sql.Tx, start time.Time, n uint64, ...) ([]api.ContractPruneMetric, error)
- func ContractRoots(ctx context.Context, tx sql.Tx, fcid types.FileContractID) ([]types.Hash256, error)
- func ContractSetChurnMetrics(ctx context.Context, tx sql.Tx, start time.Time, n uint64, ...) ([]api.ContractSetChurnMetric, error)
- func ContractSetID(ctx context.Context, tx sql.Tx, contractSet string) (int64, error)
- func ContractSetMetrics(ctx context.Context, tx sql.Tx, start time.Time, n uint64, ...) ([]api.ContractSetMetric, error)
- func ContractSets(ctx context.Context, tx sql.Tx) ([]string, error)
- func ContractSize(ctx context.Context, tx sql.Tx, id types.FileContractID) (api.ContractSize, error)
- func ContractSizes(ctx context.Context, tx sql.Tx) (map[types.FileContractID]api.ContractSize, error)
- func Contracts(ctx context.Context, tx sql.Tx, opts api.ContractsOpts) ([]api.ContractMetadata, error)
- func CopyObject(ctx context.Context, tx sql.Tx, ...) (api.ObjectMetadata, error)
- func DeleteBucket(ctx context.Context, tx sql.Tx, bucket string) error
- func DeleteHostSector(ctx context.Context, tx sql.Tx, hk types.PublicKey, root types.Hash256) (int, error)
- func DeleteMetadata(ctx context.Context, tx sql.Tx, objID int64) error
- func DeleteSettings(ctx context.Context, tx sql.Tx, key string) error
- func DeleteWebhook(ctx context.Context, tx sql.Tx, wh webhooks.Webhook) error
- func FetchUsedContracts(ctx context.Context, tx sql.Tx, fcids []types.FileContractID) (map[types.FileContractID]UsedContract, error)
- func GetContractState(ctx context.Context, tx sql.Tx, fcid types.FileContractID) (api.ContractState, error)
- func HostAllowlist(ctx context.Context, tx sql.Tx) ([]types.PublicKey, error)
- func HostBlocklist(ctx context.Context, tx sql.Tx) ([]string, error)
- func HostsForScanning(ctx context.Context, tx sql.Tx, maxLastScan time.Time, offset, limit int) ([]api.HostAddress, error)
- func InsertBufferedSlab(ctx context.Context, tx sql.Tx, fileName string, contractSetID int64, ...) (int64, error)
- func InsertContract(ctx context.Context, tx sql.Tx, rev rhpv2.ContractRevision, ...) (api.ContractMetadata, error)
- func InsertMetadata(ctx context.Context, tx sql.Tx, objID, muID *int64, md api.ObjectUserMetadata) error
- func InsertMultipartUpload(ctx context.Context, tx sql.Tx, bucket, key string, ec object.EncryptionKey, ...) (string, error)
- func InsertObject(ctx context.Context, tx sql.Tx, key string, bucketID, size int64, ...) (int64, error)
- func ListBuckets(ctx context.Context, tx sql.Tx) ([]api.Bucket, error)
- func ListObjects(ctx context.Context, tx Tx, bucket, prefix, sortBy, sortDir, marker string, ...) (api.ObjectsListResponse, error)
- func MarkPackedSlabUploaded(ctx context.Context, tx Tx, slab api.UploadedPackedSlab) (string, error)
- func MultipartUpload(ctx context.Context, tx sql.Tx, uploadID string) (api.MultipartUpload, error)
- func MultipartUploadForCompletion(ctx context.Context, tx sql.Tx, bucket, key, uploadID string, ...) (multipartUpload, []multipartUploadPart, int64, string, error)
- func MultipartUploadParts(ctx context.Context, tx sql.Tx, bucket, key, uploadID string, marker int, ...) (api.MultipartListPartsResponse, error)
- func MultipartUploads(ctx context.Context, tx sql.Tx, ...) (api.MultipartListUploadsResponse, error)
- func NormalizePeer(peer string) (string, error)
- func Object(ctx context.Context, tx Tx, bucket, key string) (api.Object, error)
- func ObjectEntries(ctx context.Context, tx Tx, ...) ([]api.ObjectMetadata, bool, error)
- func ObjectMetadata(ctx context.Context, tx Tx, bucket, key string) (api.Object, error)
- func ObjectsBySlabKey(ctx context.Context, tx Tx, bucket string, slabKey object.EncryptionKey) ([]api.ObjectMetadata, error)
- func ObjectsStats(ctx context.Context, tx sql.Tx, opts api.ObjectsStatsOpts) (api.ObjectsStatsResponse, error)
- func PeerBanned(ctx context.Context, tx sql.Tx, addr string) (bool, error)
- func PeerInfo(ctx context.Context, tx sql.Tx, addr string) (syncer.PeerInfo, error)
- func Peers(ctx context.Context, tx sql.Tx) ([]syncer.PeerInfo, error)
- func PrepareSlabHealth(ctx context.Context, tx sql.Tx, limit int64, now time.Time) error
- func PruneMetrics(ctx context.Context, tx sql.Tx, metric string, cutoff time.Time) error
- func QueryContracts(ctx context.Context, tx sql.Tx, whereExprs []string, whereArgs []any) ([]api.ContractMetadata, error)
- func RecordContractMetric(ctx context.Context, tx sql.Tx, metrics ...api.ContractMetric) error
- func RecordContractPruneMetric(ctx context.Context, tx sql.Tx, metrics ...api.ContractPruneMetric) error
- func RecordContractSetChurnMetric(ctx context.Context, tx sql.Tx, metrics ...api.ContractSetChurnMetric) error
- func RecordContractSetMetric(ctx context.Context, tx sql.Tx, metrics ...api.ContractSetMetric) error
- func RecordContractSpending(ctx context.Context, tx Tx, fcid types.FileContractID, ...) error
- func RecordHostScans(ctx context.Context, tx sql.Tx, scans []api.HostScan) error
- func RecordPriceTables(ctx context.Context, tx sql.Tx, priceTableUpdates []api.HostPriceTableUpdate) error
- func RecordWalletMetric(ctx context.Context, tx sql.Tx, metrics ...api.WalletMetric) error
- func RemoveContractSet(ctx context.Context, tx sql.Tx, contractSet string) error
- func RemoveOfflineHosts(ctx context.Context, tx sql.Tx, minRecentFailures uint64, ...) (int64, error)
- func RenewContract(ctx context.Context, tx sql.Tx, rev rhpv2.ContractRevision, ...) (api.ContractMetadata, error)
- func RenewedContract(ctx context.Context, tx sql.Tx, renewedFrom types.FileContractID) (api.ContractMetadata, error)
- func ResetChainState(ctx context.Context, tx sql.Tx) error
- func ResetLostSectors(ctx context.Context, tx sql.Tx, hk types.PublicKey) error
- func SearchHosts(ctx context.Context, tx sql.Tx, ...) ([]api.Host, error)
- func SearchObjects(ctx context.Context, tx Tx, bucket, substring string, offset, limit int) ([]api.ObjectMetadata, error)
- func Setting(ctx context.Context, tx sql.Tx, key string) (string, error)
- func Settings(ctx context.Context, tx sql.Tx) ([]string, error)
- func Slab(ctx context.Context, tx sql.Tx, key object.EncryptionKey) (object.Slab, error)
- func SlabBuffers(ctx context.Context, tx sql.Tx) (map[string]string, error)
- func Tip(ctx context.Context, tx sql.Tx) (types.ChainIndex, error)
- func UnhealthySlabs(ctx context.Context, tx sql.Tx, healthCutoff float64, set string, limit int) ([]api.UnhealthySlab, error)
- func UnmarshalEventData(b []byte, t string) (dst wallet.EventData, err error)
- func UnspentSiacoinElements(ctx context.Context, tx sql.Tx) (elements []types.SiacoinElement, err error)
- func UpdateBucketPolicy(ctx context.Context, tx sql.Tx, bucket string, bp api.BucketPolicy) error
- func UpdateChainIndex(ctx context.Context, tx sql.Tx, index types.ChainIndex, l *zap.SugaredLogger) error
- func UpdateContract(ctx context.Context, tx sql.Tx, fcid types.FileContractID, ...) error
- func UpdateContractProofHeight(ctx context.Context, tx sql.Tx, fcid types.FileContractID, proofHeight uint64, ...) error
- func UpdateContractState(ctx context.Context, tx sql.Tx, fcid types.FileContractID, ...) error
- func UpdateFailedContracts(ctx context.Context, tx sql.Tx, blockHeight uint64, l *zap.SugaredLogger) error
- func UpdateMetadata(ctx context.Context, tx sql.Tx, objID int64, md api.ObjectUserMetadata) error
- func UpdatePeerInfo(ctx context.Context, tx sql.Tx, addr string, fn func(*syncer.PeerInfo)) error
- func UpdateWalletSiacoinElementProofs(ctx context.Context, tx sql.Tx, updater wallet.ProofUpdater) error
- func WalletEventCount(ctx context.Context, tx sql.Tx) (count uint64, err error)
- func WalletEvents(ctx context.Context, tx sql.Tx, offset, limit int) (events []wallet.Event, _ error)
- func WalletMetrics(ctx context.Context, tx sql.Tx, start time.Time, n uint64, ...) ([]api.WalletMetric, error)
- func Webhooks(ctx context.Context, tx sql.Tx) ([]webhooks.Webhook, error)
- type AutopilotConfig
- type BCurrency
- type BigInt
- type BusSetting
- type ChainUpdateTx
- type ContractMetricsQueryOpts
- type ContractRow
- type ContractState
- type Currency
- type Database
- type DatabaseTx
- type DurationMS
- type EncryptionKey
- type FileContractID
- type Hash256
- type HostSettings
- type LoadedSlabBuffer
- type MerkleProof
- type MetricsDatabase
- type MetricsDatabaseTx
- type PriceTable
- type PublicKey
- type Scanner
- type Tx
- type Uint64Str
- type UnixTimeMS
- type Unsigned64
- type UsedContract
Constants ¶
This section is empty.
Variables ¶
var ErrNegativeOffset = errors.New("offset can not be negative")
var (
ZeroCurrency = Currency(types.ZeroCurrency)
)
Functions ¶
func AbortMultipartUpload ¶
func AncestorContracts ¶
func AncestorContracts(ctx context.Context, tx sql.Tx, fcid types.FileContractID, startHeight uint64) ([]api.ArchivedContract, error)
func ArchiveContract ¶
func Contract ¶ added in v1.1.0
func Contract(ctx context.Context, tx sql.Tx, fcid types.FileContractID) (api.ContractMetadata, error)
func ContractMetrics ¶
func ContractPruneMetrics ¶
func ContractRoots ¶
func ContractSetChurnMetrics ¶
func ContractSetID ¶ added in v1.1.0
func ContractSetMetrics ¶
func ContractSize ¶
func ContractSize(ctx context.Context, tx sql.Tx, id types.FileContractID) (api.ContractSize, error)
func ContractSizes ¶
func ContractSizes(ctx context.Context, tx sql.Tx) (map[types.FileContractID]api.ContractSize, error)
func Contracts ¶
func Contracts(ctx context.Context, tx sql.Tx, opts api.ContractsOpts) ([]api.ContractMetadata, error)
func CopyObject ¶
func CopyObject(ctx context.Context, tx sql.Tx, srcBucket, dstBucket, srcKey, dstKey, mimeType string, metadata api.ObjectUserMetadata) (api.ObjectMetadata, error)
func DeleteHostSector ¶
func FetchUsedContracts ¶
func FetchUsedContracts(ctx context.Context, tx sql.Tx, fcids []types.FileContractID) (map[types.FileContractID]UsedContract, error)
func GetContractState ¶ added in v1.1.0
func GetContractState(ctx context.Context, tx sql.Tx, fcid types.FileContractID) (api.ContractState, error)
func HostsForScanning ¶
func InsertBufferedSlab ¶
func InsertContract ¶ added in v1.1.0
func InsertContract(ctx context.Context, tx sql.Tx, rev rhpv2.ContractRevision, contractPrice, totalCost types.Currency, startHeight uint64, renewedFrom types.FileContractID, state string) (api.ContractMetadata, error)
func InsertMetadata ¶
func InsertMultipartUpload ¶
func InsertObject ¶
func ListObjects ¶
func MarkPackedSlabUploaded ¶ added in v1.1.0
func MultipartUpload ¶
func MultipartUploadParts ¶
func MultipartUploads ¶
func NormalizePeer ¶ added in v1.1.0
func ObjectEntries ¶ added in v1.1.0
func ObjectMetadata ¶ added in v1.1.0
func ObjectsBySlabKey ¶ added in v1.1.0
func ObjectsBySlabKey(ctx context.Context, tx Tx, bucket string, slabKey object.EncryptionKey) ([]api.ObjectMetadata, error)
func ObjectsStats ¶
func ObjectsStats(ctx context.Context, tx sql.Tx, opts api.ObjectsStatsOpts) (api.ObjectsStatsResponse, error)
func PeerBanned ¶ added in v1.1.0
func PrepareSlabHealth ¶
func PruneMetrics ¶
func QueryContracts ¶
func RecordContractMetric ¶
func RecordContractSetMetric ¶
func RecordContractSpending ¶ added in v1.1.0
func RecordContractSpending(ctx context.Context, tx Tx, fcid types.FileContractID, revisionNumber, size uint64, newSpending api.ContractSpending) error
func RecordHostScans ¶
func RecordPriceTables ¶
func RecordWalletMetric ¶
func RemoveContractSet ¶
func RemoveOfflineHosts ¶
func RenewContract ¶ added in v1.1.0
func RenewContract(ctx context.Context, tx sql.Tx, rev rhpv2.ContractRevision, contractPrice, totalCost types.Currency, startHeight uint64, renewedFrom types.FileContractID, state string) (api.ContractMetadata, error)
func RenewedContract ¶
func RenewedContract(ctx context.Context, tx sql.Tx, renewedFrom types.FileContractID) (api.ContractMetadata, error)
func ResetLostSectors ¶
func SearchHosts ¶
func SearchObjects ¶ added in v1.1.0
func UnhealthySlabs ¶ added in v1.1.0
func UnmarshalEventData ¶ added in v1.1.0
func UnspentSiacoinElements ¶ added in v1.1.0
func UpdateBucketPolicy ¶
func UpdateChainIndex ¶ added in v1.1.0
func UpdateChainIndex(ctx context.Context, tx sql.Tx, index types.ChainIndex, l *zap.SugaredLogger) error
func UpdateContract ¶ added in v1.1.0
func UpdateContract(ctx context.Context, tx sql.Tx, fcid types.FileContractID, revisionHeight, revisionNumber, size uint64, l *zap.SugaredLogger) error
func UpdateContractProofHeight ¶ added in v1.1.0
func UpdateContractProofHeight(ctx context.Context, tx sql.Tx, fcid types.FileContractID, proofHeight uint64, l *zap.SugaredLogger) error
func UpdateContractState ¶ added in v1.1.0
func UpdateContractState(ctx context.Context, tx sql.Tx, fcid types.FileContractID, state api.ContractState, l *zap.SugaredLogger) error
func UpdateFailedContracts ¶ added in v1.1.0
func UpdateMetadata ¶
func UpdatePeerInfo ¶ added in v1.1.0
func UpdateWalletSiacoinElementProofs ¶ added in v1.1.0
func WalletEventCount ¶ added in v1.1.0
func WalletEvents ¶ added in v1.1.0
func WalletMetrics ¶
Types ¶
type AutopilotConfig ¶
type AutopilotConfig api.AutopilotConfig
func (*AutopilotConfig) Scan ¶
func (cfg *AutopilotConfig) Scan(value interface{}) error
Scan scan value into AutopilotConfig, implements sql.Scanner interface.
type BCurrency ¶ added in v1.1.0
type BusSetting ¶
type BusSetting string
func (*BusSetting) Scan ¶
func (s *BusSetting) Scan(value interface{}) error
Scan scans value into the BusSetting
func (BusSetting) String ¶
func (s BusSetting) String() string
String implements fmt.Stringer to prevent "s3authentication" settings from getting leaked.
type ChainUpdateTx ¶ added in v1.1.0
type ChainUpdateTx interface { ContractState(fcid types.FileContractID) (api.ContractState, error) UpdateChainIndex(index types.ChainIndex) error UpdateContract(fcid types.FileContractID, revisionHeight, revisionNumber, size uint64) error UpdateContractState(fcid types.FileContractID, state api.ContractState) error UpdateContractProofHeight(fcid types.FileContractID, proofHeight uint64) error UpdateFailedContracts(blockHeight uint64) error UpdateHost(hk types.PublicKey, ha chain.HostAnnouncement, bh uint64, blockID types.BlockID, ts time.Time) error wallet.UpdateTx }
The database interfaces define all methods that a SQL database must implement to be used by the SQLStore.
type ContractMetricsQueryOpts ¶
type ContractMetricsQueryOpts struct { api.ContractMetricsQueryOpts IndexHint string }
type ContractRow ¶
type ContractRow struct { FCID FileContractID RenewedFrom FileContractID ContractPrice Currency State ContractState TotalCost Currency ProofHeight uint64 RevisionHeight uint64 RevisionNumber uint64 Size uint64 StartHeight uint64 WindowStart uint64 WindowEnd uint64 // spending fields UploadSpending Currency DownloadSpending Currency FundAccountSpending Currency DeleteSpending Currency ListSpending Currency ContractSet string NetAddress string PublicKey PublicKey SiamuxPort string }
func (*ContractRow) ContractMetadata ¶
func (r *ContractRow) ContractMetadata() api.ContractMetadata
func (*ContractRow) Scan ¶
func (r *ContractRow) Scan(s Scanner) error
type ContractState ¶
type ContractState uint8
func ContractStateFromString ¶ added in v1.1.0
func ContractStateFromString(state string) ContractState
func (*ContractState) LoadString ¶
func (s *ContractState) LoadString(state string) error
func (ContractState) String ¶
func (s ContractState) String() string
type Currency ¶
type Database ¶
type Database interface { io.Closer // LoadSlabBuffers loads the slab buffers from the database. LoadSlabBuffers(ctx context.Context) ([]LoadedSlabBuffer, []string, error) // Migrate runs all missing migrations on the database. Migrate(ctx context.Context) error // Transaction starts a new transaction. Transaction(ctx context.Context, fn func(DatabaseTx) error) error // Version returns the database version and name. Version(ctx context.Context) (string, string, error) }
The database interfaces define all methods that a SQL database must implement to be used by the SQLStore.
type DatabaseTx ¶
type DatabaseTx interface { // AbortMultipartUpload aborts a multipart upload and deletes it from // the database. AbortMultipartUpload(ctx context.Context, bucket, key string, uploadID string) error // Accounts returns all accounts from the db. Accounts(ctx context.Context, owner string) ([]api.Account, error) // AddMultipartPart adds a part to an unfinished multipart upload. AddMultipartPart(ctx context.Context, bucket, key, contractSet, eTag, uploadID string, partNumber int, slices object.SlabSlices) error // AddPeer adds a peer to the store. AddPeer(ctx context.Context, addr string) error // AddWebhook adds a new webhook to the database. If the webhook already // exists, it is updated. AddWebhook(ctx context.Context, wh webhooks.Webhook) error // AncestorContracts returns all ancestor contracts of the contract up // until the given start height. AncestorContracts(ctx context.Context, id types.FileContractID, startHeight uint64) ([]api.ArchivedContract, error) // ArchiveContract moves a contract from the regular contracts to the // archived ones. ArchiveContract(ctx context.Context, fcid types.FileContractID, reason string) error // Autopilot returns the autopilot with the given ID. Returns // api.ErrAutopilotNotFound if the autopilot doesn't exist. Autopilot(ctx context.Context, id string) (api.Autopilot, error) // Autopilots returns all autopilots. Autopilots(ctx context.Context) ([]api.Autopilot, error) // BanPeer temporarily bans one or more IPs. The addr should either be a // single IP with port (e.g. 1.2.3.4:5678) or a CIDR subnet (e.g. // 1.2.3.4/16). BanPeer(ctx context.Context, addr string, duration time.Duration, reason string) error // Bucket returns the bucket with the given name. If the bucket doesn't // exist, it returns api.ErrBucketNotFound. Bucket(ctx context.Context, bucket string) (api.Bucket, error) // CompleteMultipartUpload completes a multipart upload by combining the // provided parts into an object in bucket 'bucket' with key 'key'. The // parts need to be provided in ascending partNumber order without // duplicates but can contain gaps. CompleteMultipartUpload(ctx context.Context, bucket, key, uploadID string, parts []api.MultipartCompletedPart, opts api.CompleteMultipartOptions) (string, error) // Contract returns the metadata of the contract with the given ID or // ErrContractNotFound. Contract(ctx context.Context, id types.FileContractID) (cm api.ContractMetadata, err error) // ContractRoots returns the roots of the contract with the given ID. ContractRoots(ctx context.Context, fcid types.FileContractID) ([]types.Hash256, error) // Contracts returns contract metadata for all active contracts. The // opts argument can be used to filter the result. Contracts(ctx context.Context, opts api.ContractsOpts) ([]api.ContractMetadata, error) // ContractSetID returns the ID of the contract set with the given name. // NOTE: Our locking strategy requires that the contract set ID is // unique. So even after a contract set was deleted, the ID must not be // reused. ContractSetID(ctx context.Context, contractSet string) (int64, error) // ContractSets returns the names of all contract sets. ContractSets(ctx context.Context) ([]string, error) // ContractSize returns the size of the contract with the given ID as // well as the estimated number of bytes that can be pruned from it. ContractSize(ctx context.Context, id types.FileContractID) (api.ContractSize, error) // ContractSizes returns the sizes of all contracts in the database as // well as the estimated number of bytes that can be pruned from them. ContractSizes(ctx context.Context) (map[types.FileContractID]api.ContractSize, error) // CopyObject copies an object from one bucket and key to another. If // source and destination are the same, only the metadata and mimeType // are overwritten with the provided ones. CopyObject(ctx context.Context, srcBucket, dstBucket, srcKey, dstKey, mimeType string, metadata api.ObjectUserMetadata) (api.ObjectMetadata, error) // CreateBucket creates a new bucket with the given name and policy. If // the bucket already exists, api.ErrBucketExists is returned. CreateBucket(ctx context.Context, bucket string, policy api.BucketPolicy) error // DeleteBucket deletes a bucket. If the bucket isn't empty, it returns // api.ErrBucketNotEmpty. If the bucket doesn't exist, it returns // api.ErrBucketNotFound. DeleteBucket(ctx context.Context, bucket string) error // DeleteHostSector deletes all contract sector links that a host has // with the given root incrementing the lost sector count in the // process. If another contract with a different host exists that // contains the root, latest_host is updated to that host. DeleteHostSector(ctx context.Context, hk types.PublicKey, root types.Hash256) (int, error) // DeleteObject deletes an object from the database and returns true if // the requested object was actually deleted. DeleteObject(ctx context.Context, bucket, key string) (bool, error) // DeleteObjects deletes a batch of objects starting with the given // prefix and returns 'true' if any object was deleted. DeleteObjects(ctx context.Context, bucket, prefix string, limit int64) (bool, error) // DeleteSettings deletes the settings with the given key. DeleteSettings(ctx context.Context, key string) error // DeleteWebhook deletes the webhook with the matching module, event and // URL of the provided webhook. If the webhook doesn't exist, // webhooks.ErrWebhookNotFound is returned. DeleteWebhook(ctx context.Context, wh webhooks.Webhook) error // InsertBufferedSlab inserts a buffered slab into the database. This // includes the creation of a buffered slab as well as the corresponding // regular slab it is linked to. It returns the ID of the buffered slab // that was created. InsertBufferedSlab(ctx context.Context, fileName string, contractSetID int64, ec object.EncryptionKey, minShards, totalShards uint8) (int64, error) // InsertContract inserts a new contract into the database. InsertContract(ctx context.Context, rev rhpv2.ContractRevision, contractPrice, totalCost types.Currency, startHeight uint64, renewedFrom types.FileContractID, state string) (api.ContractMetadata, error) // InsertMultipartUpload creates a new multipart upload and returns a // unique upload ID. InsertMultipartUpload(ctx context.Context, bucket, path string, ec object.EncryptionKey, mimeType string, metadata api.ObjectUserMetadata) (string, error) // InvalidateSlabHealthByFCID invalidates the health of all slabs that // are associated with any of the provided contracts. InvalidateSlabHealthByFCID(ctx context.Context, fcids []types.FileContractID, limit int64) (int64, error) // HostAllowlist returns the list of public keys of hosts on the // allowlist. HostAllowlist(ctx context.Context) ([]types.PublicKey, error) // HostBlocklist returns the list of host addresses on the blocklist. HostBlocklist(ctx context.Context) ([]string, error) // InsertObject inserts a new object into the database. InsertObject(ctx context.Context, bucket, key, contractSet string, o object.Object, mimeType, eTag string, md api.ObjectUserMetadata) error // HostsForScanning returns a list of hosts to scan which haven't been // scanned since at least maxLastScan. HostsForScanning(ctx context.Context, maxLastScan time.Time, offset, limit int) ([]api.HostAddress, error) // ListBuckets returns a list of all buckets in the database. ListBuckets(ctx context.Context) ([]api.Bucket, error) // ListObjects returns a list of objects from the given bucket. ListObjects(ctx context.Context, bucket, prefix, sortBy, sortDir, marker string, limit int) (api.ObjectsListResponse, error) // MakeDirsForPathDeprecated creates all directories for a given // object's path. This method is deprecated and should not be used, it's // used by migration 00008_directories and should be removed when that // migration is squashed. MakeDirsForPathDeprecated(ctx context.Context, path string) (int64, error) // MarkPackedSlabUploaded marks the packed slab as uploaded in the // database, causing the provided shards to be associated with the slab. // The returned string contains the filename of the slab buffer on disk. MarkPackedSlabUploaded(ctx context.Context, slab api.UploadedPackedSlab) (string, error) // MultipartUpload returns the multipart upload with the given ID or // api.ErrMultipartUploadNotFound if the upload doesn't exist. MultipartUpload(ctx context.Context, uploadID string) (api.MultipartUpload, error) // MultipartUploadParts returns a list of all parts for a given // multipart upload MultipartUploadParts(ctx context.Context, bucket, key, uploadID string, marker int, limit int64) (api.MultipartListPartsResponse, error) // MultipartUploads returns a list of all multipart uploads. MultipartUploads(ctx context.Context, bucket, prefix, keyMarker, uploadIDMarker string, limit int) (api.MultipartListUploadsResponse, error) // Object returns an object from the database. Object(ctx context.Context, bucket, key string) (api.Object, error) // ObjectEntries queries the database for objects in a given dir. ObjectEntries(ctx context.Context, bucket, key, prefix, sortBy, sortDir, marker string, offset, limit int) ([]api.ObjectMetadata, bool, error) // ObjectMetadata returns an object's metadata. ObjectMetadata(ctx context.Context, bucket, key string) (api.Object, error) // ObjectsBySlabKey returns all objects that contain a reference to the // slab with the given slabKey. ObjectsBySlabKey(ctx context.Context, bucket string, slabKey object.EncryptionKey) (metadata []api.ObjectMetadata, err error) // ObjectsStats returns overall stats about stored objects ObjectsStats(ctx context.Context, opts api.ObjectsStatsOpts) (api.ObjectsStatsResponse, error) // PeerBanned returns true if the peer is banned. PeerBanned(ctx context.Context, addr string) (bool, error) // PeerInfo returns the metadata for the specified peer or // ErrPeerNotFound if the peer wasn't found in the store. PeerInfo(ctx context.Context, addr string) (syncer.PeerInfo, error) // Peers returns the set of known peers. Peers(ctx context.Context) ([]syncer.PeerInfo, error) // ProcessChainUpdate applies the given chain update to the database. ProcessChainUpdate(ctx context.Context, applyFn func(ChainUpdateTx) error) error // PrunableContractRoots returns the indices of roots that are not in // the contract. PrunableContractRoots(ctx context.Context, fcid types.FileContractID, roots []types.Hash256) (indices []uint64, err error) // PruneSlabs deletes slabs that are no longer referenced by any slice // or slab buffer. PruneSlabs(ctx context.Context, limit int64) (int64, error) // RecordContractSpending records new spending for a contract RecordContractSpending(ctx context.Context, fcid types.FileContractID, revisionNumber, size uint64, newSpending api.ContractSpending) error // RecordHostScans records the results of host scans in the database // such as recording the settings and price table of a host in case of // success and updating the uptime and downtime of a host. // NOTE: The price table is only updated if the known price table is // expired since price tables from scans are not paid for and are // therefore only useful for gouging checks. RecordHostScans(ctx context.Context, scans []api.HostScan) error // RecordPriceTables records price tables for hosts in the database // increasing the successful/failed interactions accordingly. RecordPriceTables(ctx context.Context, priceTableUpdate []api.HostPriceTableUpdate) error // RemoveContractSet removes the contract set with the given name from // the database. RemoveContractSet(ctx context.Context, contractSet string) error // RemoveOfflineHosts removes all hosts that have been offline for // longer than maxDownTime and been scanned at least minRecentFailures // times. The contracts of those hosts are also removed. RemoveOfflineHosts(ctx context.Context, minRecentFailures uint64, maxDownTime time.Duration) (int64, error) // RenameObject renames an object in the database from keyOld to keyNew // and the new directory dirID. returns api.ErrObjectExists if the an // object already exists at the target location or api.ErrObjectNotFound // if the object at keyOld doesn't exist. If force is true, the instead // of returning api.ErrObjectExists, the existing object will be // deleted. RenameObject(ctx context.Context, bucket, keyOld, keyNew string, force bool) error // RenameObjects renames all objects in the database with the given // prefix to the new prefix. If 'force' is true, it will overwrite any // existing objects with the new prefix. If no object can be renamed, // `api.ErrOBjectNotFound` is returned. If 'force' is false and an // object already exists with the new prefix, `api.ErrObjectExists` is // returned. RenameObjects(ctx context.Context, bucket, prefixOld, prefixNew string, force bool) error // RenewContract renews the contract in the database. That means the // contract with the ID of 'renewedFrom' will be moved to the archived // contracts and the new contract will overwrite the existing one, // inheriting its sectors. RenewContract(ctx context.Context, rev rhpv2.ContractRevision, contractPrice, totalCost types.Currency, startHeight uint64, renewedFrom types.FileContractID, state string) (api.ContractMetadata, error) // RenewedContract returns the metadata of the contract that was renewed // from the specified contract or ErrContractNotFound otherwise. RenewedContract(ctx context.Context, renewedFrom types.FileContractID) (api.ContractMetadata, error) // ResetChainState deletes all chain data in the database. ResetChainState(ctx context.Context) error // ResetLostSectors resets the lost sector count for the given host. ResetLostSectors(ctx context.Context, hk types.PublicKey) error // SaveAccounts saves the given accounts in the db, overwriting any // existing ones. SaveAccounts(ctx context.Context, accounts []api.Account) error // SearchHosts returns a list of hosts that match the provided filters SearchHosts(ctx context.Context, autopilotID, filterMode, usabilityMode, addressContains string, keyIn []types.PublicKey, offset, limit int) ([]api.Host, error) // SearchObjects returns a list of objects that contain the provided // substring. SearchObjects(ctx context.Context, bucket, substring string, offset, limit int) ([]api.ObjectMetadata, error) // UpdateContractSet adds/removes the provided contract ids to/from // the contract set. The contract set is created in the process if // it doesn't exist already. UpdateContractSet(ctx context.Context, name string, toAdd, toRemove []types.FileContractID) error // Setting returns the setting with the given key from the database. Setting(ctx context.Context, key string) (string, error) // Settings returns all available settings from the database. Settings(ctx context.Context) ([]string, error) // Slab returns the slab with the given ID or api.ErrSlabNotFound. Slab(ctx context.Context, key object.EncryptionKey) (object.Slab, error) // SlabBuffers returns the filenames and associated contract sets of all // slab buffers. SlabBuffers(ctx context.Context) (map[string]string, error) // Tip returns the sync height. Tip(ctx context.Context) (types.ChainIndex, error) // UnhealthySlabs returns up to 'limit' slabs belonging to the contract // set 'set' with a health smaller than or equal to 'healthCutoff' UnhealthySlabs(ctx context.Context, healthCutoff float64, set string, limit int) ([]api.UnhealthySlab, error) // UnspentSiacoinElements returns all wallet outputs in the database. UnspentSiacoinElements(ctx context.Context) ([]types.SiacoinElement, error) // UpdateAutopilot updates the autopilot with the provided one or // creates a new one if it doesn't exist yet. UpdateAutopilot(ctx context.Context, ap api.Autopilot) error // UpdateBucketPolicy updates the policy of the bucket with the provided // one, fully overwriting the existing policy. UpdateBucketPolicy(ctx context.Context, bucket string, policy api.BucketPolicy) error // UpdateHostAllowlistEntries updates the allowlist in the database UpdateHostAllowlistEntries(ctx context.Context, add, remove []types.PublicKey, clear bool) error // UpdateHostBlocklistEntries updates the blocklist in the database UpdateHostBlocklistEntries(ctx context.Context, add, remove []string, clear bool) error // UpdateHostCheck updates the host check for the given host. UpdateHostCheck(ctx context.Context, autopilot string, hk types.PublicKey, hc api.HostCheck) error // UpdatePeerInfo updates the metadata for the specified peer. UpdatePeerInfo(ctx context.Context, addr string, fn func(*syncer.PeerInfo)) error // UpdateSetting updates the setting with the given key to the given // value. UpdateSetting(ctx context.Context, key, value string) error // UpdateSlab updates the slab in the database. That includes the following: // - Optimistically set health to 100% // - Invalidate health_valid_until // - Update LatestHost for every shard // The operation is not allowed to update the number of shards // associated with a slab or the root/slabIndex of any shard. UpdateSlab(ctx context.Context, s object.Slab, contractSet string, usedContracts []types.FileContractID) error // UpdateSlabHealth updates the health of up to 'limit' slab in the // database if their health is not valid anymore. A random interval // between 'minValidity' and 'maxValidity' is used to determine the time // the health of the updated slabs becomes invalid UpdateSlabHealth(ctx context.Context, limit int64, minValidity, maxValidity time.Duration) (int64, error) // WalletEvents returns all wallet events in the database. WalletEvents(ctx context.Context, offset, limit int) ([]wallet.Event, error) // WalletEventCount returns the total number of events in the database. WalletEventCount(ctx context.Context) (uint64, error) // Webhooks returns all registered webhooks. Webhooks(ctx context.Context) ([]webhooks.Webhook, error) }
The database interfaces define all methods that a SQL database must implement to be used by the SQLStore.
type DurationMS ¶ added in v1.1.0
func (*DurationMS) Scan ¶ added in v1.1.0
func (d *DurationMS) Scan(value interface{}) error
Scan scan value into DurationMS, implements sql.Scanner interface.
type EncryptionKey ¶ added in v1.1.0
type EncryptionKey object.EncryptionKey
func (*EncryptionKey) Scan ¶ added in v1.1.0
func (k *EncryptionKey) Scan(value interface{}) error
Scan scans value into key, implements sql.Scanner interface.
func (EncryptionKey) String ¶ added in v1.1.0
func (k EncryptionKey) String() string
String implements fmt.Stringer to prevent the key from getting leaked in logs.
type FileContractID ¶
type FileContractID types.FileContractID
func (*FileContractID) Scan ¶
func (fcid *FileContractID) Scan(value interface{}) error
Scan scan value into fileContractID, implements sql.Scanner interface.
type Hash256 ¶
type HostSettings ¶
type HostSettings rhpv2.HostSettings
func (*HostSettings) Scan ¶
func (hs *HostSettings) Scan(value interface{}) error
Scan scan value into HostSettings, implements sql.Scanner interface.
type LoadedSlabBuffer ¶
type LoadedSlabBuffer struct { ID int64 ContractSetID int64 Filename string Key object.EncryptionKey MinShards uint8 Size int64 TotalShards uint8 }
The database interfaces define all methods that a SQL database must implement to be used by the SQLStore.
func LoadSlabBuffers ¶
type MerkleProof ¶ added in v1.1.0
func (*MerkleProof) Scan ¶ added in v1.1.0
func (mp *MerkleProof) Scan(value interface{}) error
Scan scans value into a MerkleProof, implements sql.Scanner interface.
type MetricsDatabase ¶
type MetricsDatabase interface { io.Closer // Migrate runs all missing migrations on the database. Migrate(ctx context.Context) error // Transaction starts a new transaction. Transaction(ctx context.Context, fn func(MetricsDatabaseTx) error) error // Version returns the database version and name. Version(ctx context.Context) (string, string, error) }
The database interfaces define all methods that a SQL database must implement to be used by the SQLStore.
type MetricsDatabaseTx ¶
type MetricsDatabaseTx interface { // ContractMetrics returns contract metrics for the given time range // and options. ContractMetrics(ctx context.Context, start time.Time, n uint64, interval time.Duration, opts api.ContractMetricsQueryOpts) ([]api.ContractMetric, error) // ContractPruneMetrics returns the contract prune metrics for the given // time range and options. ContractPruneMetrics(ctx context.Context, start time.Time, n uint64, interval time.Duration, opts api.ContractPruneMetricsQueryOpts) ([]api.ContractPruneMetric, error) // ContractSetChurnMetrics returns the contract set churn metrics for // the given time range and options. ContractSetChurnMetrics(ctx context.Context, start time.Time, n uint64, interval time.Duration, opts api.ContractSetChurnMetricsQueryOpts) ([]api.ContractSetChurnMetric, error) // ContractSetMetrics returns the contract set metrics for the given // time range and options. ContractSetMetrics(ctx context.Context, start time.Time, n uint64, interval time.Duration, opts api.ContractSetMetricsQueryOpts) ([]api.ContractSetMetric, error) // PruneMetrics deletes metrics of a certain type older than the given // cutoff time. PruneMetrics(ctx context.Context, metric string, cutoff time.Time) error // RecordContractMetric records contract metrics. RecordContractMetric(ctx context.Context, metrics ...api.ContractMetric) error // RecordContractPruneMetric records contract prune metrics. RecordContractPruneMetric(ctx context.Context, metrics ...api.ContractPruneMetric) error // RecordContractSetChurnMetric records contract set churn metrics. RecordContractSetChurnMetric(ctx context.Context, metrics ...api.ContractSetChurnMetric) error // RecordContractSetMetric records contract set metrics. RecordContractSetMetric(ctx context.Context, metrics ...api.ContractSetMetric) error // RecordWalletMetric records wallet metrics. RecordWalletMetric(ctx context.Context, metrics ...api.WalletMetric) error // WalletMetrics returns wallet metrics for the given time range WalletMetrics(ctx context.Context, start time.Time, n uint64, interval time.Duration, opts api.WalletMetricsQueryOpts) ([]api.WalletMetric, error) }
The database interfaces define all methods that a SQL database must implement to be used by the SQLStore.
type PriceTable ¶
type PriceTable rhpv3.HostPriceTable
func (*PriceTable) Scan ¶
func (pt *PriceTable) Scan(value interface{}) error
Scan scan value into PriceTable, implements sql.Scanner interface.
type PublicKey ¶
type Tx ¶ added in v1.1.0
type Tx interface { sql.Tx CharLengthExpr() string // ScanObjectMetadata scans the object metadata from the given scanner. // The columns required to scan the metadata are returned by the // SelectObjectMetadataExpr helper method. Additional fields can be // selected and scanned by passing them to the method as 'others'. ScanObjectMetadata(s Scanner, others ...any) (md api.ObjectMetadata, err error) SelectObjectMetadataExpr() string }
Tx is an interface that allows for injecting custom methods into helpers to avoid duplicating code.
type Uint64Str ¶ added in v1.1.0
type Uint64Str uint64
type UnixTimeMS ¶
func (*UnixTimeMS) Scan ¶
func (u *UnixTimeMS) Scan(value interface{}) error
Scan scan value into unixTimeMS, implements sql.Scanner interface.
type Unsigned64 ¶
type Unsigned64 uint64
func (*Unsigned64) Scan ¶
func (u *Unsigned64) Scan(value interface{}) error
Scan scan value into Unsigned64, implements sql.Scanner interface.
type UsedContract ¶
type UsedContract struct { ID int64 FCID FileContractID RenewedFrom FileContractID }
The database interfaces define all methods that a SQL database must implement to be used by the SQLStore.