Documentation
¶
Index ¶
- type Store
- func (s *Store) AccountBalance(accountID rhp3.Account) (balance types.Currency, err error)
- func (s *Store) AccountFunding(account rhp3.Account) (srcs []accounts.FundingSource, err error)
- func (s *Store) Accounts(limit, offset int) (acc []accounts.Account, err error)
- func (s *Store) AddContract(revision contracts.SignedRevision, formationSet []types.Transaction, ...) error
- func (s *Store) AddTemporarySectors(sectors []storage.TempSector) error
- func (s *Store) AddVolume(localPath string, readOnly bool) (volumeID int64, err error)
- func (s *Store) Close() error
- func (s *Store) Contract(id types.FileContractID) (contract contracts.Contract, err error)
- func (s *Store) ContractAction(height uint64, contractFn func(types.FileContractID, uint64, string)) error
- func (s *Store) ContractFormationSet(id types.FileContractID) ([]types.Transaction, error)
- func (s *Store) Contracts(filter contracts.ContractFilter) (contracts []contracts.Contract, count int, err error)
- func (s *Store) CreditAccountWithContract(fund accounts.FundAccountWithContract) (balance types.Currency, err error)
- func (s *Store) DebitAccount(accountID rhp3.Account, usage accounts.Usage) (balance types.Currency, err error)
- func (s *Store) ExpireContract(id types.FileContractID, status contracts.ContractStatus) error
- func (s *Store) ExpireContractSectors(height uint64) error
- func (s *Store) ExpireTempSectors(height uint64) error
- func (s *Store) GetRegistryValue(key rhp3.RegistryKey) (entry rhp3.RegistryValue, _ error)
- func (s *Store) GrowVolume(id int64, maxSectors uint64) error
- func (s *Store) HasSector(root types.Hash256) (bool, error)
- func (s *Store) HostKey() (pk types.PrivateKey)
- func (s *Store) IncrementRHPDataUsage(ingress, egress uint64) error
- func (s *Store) IncrementRegistryAccess(read, write uint64) error
- func (s *Store) IncrementSectorStats(reads, writes, cacheHit, cacheMiss uint64) error
- func (s *Store) LastAnnouncement() (ann settings.Announcement, err error)
- func (s *Store) LastContractChange() (id modules.ConsensusChangeID, err error)
- func (s *Store) LastSettingsConsensusChange() (cc modules.ConsensusChangeID, height uint64, err error)
- func (s *Store) LastWalletChange() (id modules.ConsensusChangeID, height uint64, err error)
- func (s *Store) Metrics(timestamp time.Time) (m metrics.Metrics, err error)
- func (s *Store) MigrateSectors(volumeID int64, startIndex uint64, ...) error
- func (s *Store) PeriodMetrics(start time.Time, n int, interval metrics.Interval) ([]metrics.Metrics, error)
- func (s *Store) PruneAccounts(height uint64) error
- func (s *Store) RegisterWebHook(url, secret string, scopes []string) (id int64, err error)
- func (s *Store) RegistryEntries() (count, max uint64, err error)
- func (s *Store) RemoveSector(root types.Hash256) (err error)
- func (s *Store) RemoveVolume(id int64) error
- func (s *Store) RemoveWebHook(id int64) error
- func (s *Store) RenewContract(renewal contracts.SignedRevision, clearing contracts.SignedRevision, ...) error
- func (s *Store) ResetWallet(seedHash types.Hash256) error
- func (s *Store) RevertLastAnnouncement() error
- func (s *Store) ReviseContract(revision contracts.SignedRevision, oldRoots []types.Hash256, ...) error
- func (s *Store) SectorLocation(root types.Hash256) (storage.SectorLocation, func() error, error)
- func (s *Store) SectorReferences(root types.Hash256) (refs storage.SectorReference, err error)
- func (s *Store) SectorRoots(contractID types.FileContractID) (roots []types.Hash256, err error)
- func (s *Store) SetAvailable(volumeID int64, available bool) error
- func (s *Store) SetReadOnly(volumeID int64, readOnly bool) error
- func (s *Store) SetRegistryValue(entry rhp3.RegistryEntry, expiration uint64) error
- func (s *Store) Settings() (config settings.Settings, err error)
- func (s *Store) ShrinkVolume(id int64, maxSectors uint64) error
- func (s *Store) StorageUsage() (usedSectors, totalSectors uint64, err error)
- func (s *Store) StoreSector(root types.Hash256, fn func(loc storage.SectorLocation, exists bool) error) (func() error, error)
- func (s *Store) TransactionCount() (count uint64, err error)
- func (s *Store) Transactions(limit, offset int) (txns []wallet.Transaction, err error)
- func (s *Store) UnspentSiacoinElements() (utxos []wallet.SiacoinElement, err error)
- func (s *Store) UpdateContractState(ccID modules.ConsensusChangeID, height uint64, ...) error
- func (s *Store) UpdateLastAnnouncement(ann settings.Announcement) error
- func (s *Store) UpdateSettings(settings settings.Settings) error
- func (s *Store) UpdateWallet(ccID modules.ConsensusChangeID, height uint64, ...) error
- func (s *Store) UpdateWebHook(id int64, url string, scopes []string) error
- func (s *Store) VerifyWalletKey(seedHash types.Hash256) error
- func (s *Store) Volume(id int64) (storage.Volume, error)
- func (s *Store) Volumes() ([]storage.Volume, error)
- func (s *Store) WebHooks() ([]webhooks.WebHook, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
A Store is a persistent store that uses a SQL database as its backend.
func OpenDatabase ¶
OpenDatabase creates a new SQLite store and initializes the database. If the database does not exist, it is created.
func (*Store) AccountBalance ¶
AccountBalance returns the balance of the account with the given ID.
func (*Store) AccountFunding ¶ added in v0.2.0
AccountFunding returns all contracts that were used to fund the account.
func (*Store) AddContract ¶
func (s *Store) AddContract(revision contracts.SignedRevision, formationSet []types.Transaction, lockedCollateral types.Currency, initialUsage contracts.Usage, negotationHeight uint64) error
AddContract adds a new contract to the database.
func (*Store) AddTemporarySectors ¶
func (s *Store) AddTemporarySectors(sectors []storage.TempSector) error
AddTemporarySectors adds the roots of sectors that are temporarily stored on the host. The sectors will be deleted after the expiration height.
func (*Store) AddVolume ¶
AddVolume initializes a new storage volume and adds it to the volume store. GrowVolume must be called afterwards to initialize the volume to its desired size.
func (*Store) ContractAction ¶
func (s *Store) ContractAction(height uint64, contractFn func(types.FileContractID, uint64, string)) error
ContractAction calls contractFn on every contract in the store that needs a lifecycle action performed.
func (*Store) ContractFormationSet ¶
func (s *Store) ContractFormationSet(id types.FileContractID) ([]types.Transaction, error)
ContractFormationSet returns the set of transactions that were created during contract formation.
func (*Store) Contracts ¶
func (s *Store) Contracts(filter contracts.ContractFilter) (contracts []contracts.Contract, count int, err error)
Contracts returns a paginated list of contracts.
func (*Store) CreditAccountWithContract ¶ added in v0.2.0
func (s *Store) CreditAccountWithContract(fund accounts.FundAccountWithContract) (balance types.Currency, err error)
CreditAccountWithContract adds the specified amount to the account with the given ID.
func (*Store) DebitAccount ¶
func (s *Store) DebitAccount(accountID rhp3.Account, usage accounts.Usage) (balance types.Currency, err error)
DebitAccount subtracts the specified amount from the account with the given ID. Returns the remaining balance of the account.
func (*Store) ExpireContract ¶ added in v0.1.1
func (s *Store) ExpireContract(id types.FileContractID, status contracts.ContractStatus) error
ExpireContract expires a contract and updates its status. Should only be used if the contract is active or pending.
func (*Store) ExpireContractSectors ¶
ExpireContractSectors expires all sectors that are no longer covered by an active contract.
func (*Store) ExpireTempSectors ¶
ExpireTempSectors deletes the roots of sectors that are no longer temporarily stored on the host.
func (*Store) GetRegistryValue ¶
func (s *Store) GetRegistryValue(key rhp3.RegistryKey) (entry rhp3.RegistryValue, _ error)
GetRegistryValue returns the registry value for the given key. If the key is not found should return ErrEntryNotFound.
func (*Store) GrowVolume ¶
GrowVolume grows a storage volume's metadata by n sectors.
func (*Store) HasSector ¶ added in v1.0.0
HasSector returns true if the sector is stored on the host.
func (*Store) HostKey ¶
func (s *Store) HostKey() (pk types.PrivateKey)
HostKey returns the host's private key.
func (*Store) IncrementRHPDataUsage ¶ added in v1.0.0
IncrementRHPDataUsage increments the RHP3 ingress and egress metrics.
func (*Store) IncrementRegistryAccess ¶
IncrementRegistryAccess increments the registry read and write metrics.
func (*Store) IncrementSectorStats ¶
IncrementSectorStats increments the sector read, write and cache metrics.
func (*Store) LastAnnouncement ¶ added in v0.2.2
func (s *Store) LastAnnouncement() (ann settings.Announcement, err error)
LastAnnouncement returns the last announcement.
func (*Store) LastContractChange ¶
func (s *Store) LastContractChange() (id modules.ConsensusChangeID, err error)
LastContractChange gets the last consensus change processed by the contractor.
func (*Store) LastSettingsConsensusChange ¶ added in v0.2.2
func (s *Store) LastSettingsConsensusChange() (cc modules.ConsensusChangeID, height uint64, err error)
LastSettingsConsensusChange returns the last processed consensus change ID of the settings manager
func (*Store) LastWalletChange ¶
func (s *Store) LastWalletChange() (id modules.ConsensusChangeID, height uint64, err error)
LastWalletChange gets the last consensus change processed by the wallet.
func (*Store) MigrateSectors ¶
func (s *Store) MigrateSectors(volumeID int64, startIndex uint64, migrateFn func(location storage.SectorLocation) error) error
MigrateSectors migrates each occupied sector of a volume starting at startIndex. The sector data should be copied to the new location and synced to disk during migrateFn.
func (*Store) PeriodMetrics ¶
func (s *Store) PeriodMetrics(start time.Time, n int, interval metrics.Interval) ([]metrics.Metrics, error)
PeriodMetrics returns aggregate metrics for n periods starting at start
func (*Store) PruneAccounts ¶
PruneAccounts removes all accounts that have expired
func (*Store) RegisterWebHook ¶ added in v1.0.0
RegisterWebHook registers a new webhook.
func (*Store) RegistryEntries ¶
RegistryEntries returns the current number of entries as well as the maximum number of entries the registry can hold.
func (*Store) RemoveSector ¶
RemoveSector removes the metadata of a sector and returns its location in the volume.
func (*Store) RemoveVolume ¶
RemoveVolume removes a storage volume from the volume store. If there are used sectors in the volume, ErrVolumeNotEmpty is returned. If force is true, the volume is removed regardless of whether it is empty.
func (*Store) RemoveWebHook ¶ added in v1.0.0
RemoveWebHook removes a webhook.
func (*Store) RenewContract ¶
func (s *Store) RenewContract(renewal contracts.SignedRevision, clearing contracts.SignedRevision, renewalTxnSet []types.Transaction, lockedCollateral types.Currency, clearingUsage, renewalUsage contracts.Usage, negotationHeight uint64) error
RenewContract adds a new contract to the database and sets the old contract's renewed_from field. The old contract's sector roots are copied to the new contract.
func (*Store) ResetWallet ¶
ResetWallet resets the wallet to its initial state. This is used when a consensus subscription error occurs.
func (*Store) RevertLastAnnouncement ¶ added in v0.2.2
RevertLastAnnouncement reverts the last announcement.
func (*Store) ReviseContract ¶
func (s *Store) ReviseContract(revision contracts.SignedRevision, oldRoots []types.Hash256, usage contracts.Usage, sectorChanges []contracts.SectorChange) error
ReviseContract atomically updates a contract's revision and sectors
func (*Store) SectorLocation ¶
SectorLocation returns the location of a sector or an error if the sector is not found. The sector is locked until release is called.
func (*Store) SectorReferences ¶ added in v1.0.0
SectorReferences returns the references, if any of a sector root
func (*Store) SectorRoots ¶
SectorRoots returns the sector roots for a contract. The contract must be locked before calling.
func (*Store) SetAvailable ¶
SetAvailable sets the available flag on a volume.
func (*Store) SetReadOnly ¶
SetReadOnly sets the read-only flag on a volume.
func (*Store) SetRegistryValue ¶
func (s *Store) SetRegistryValue(entry rhp3.RegistryEntry, expiration uint64) error
SetRegistryValue sets the registry value for the given key.
func (*Store) ShrinkVolume ¶
ShrinkVolume shrinks a storage volume's metadata to maxSectors. If there are used sectors outside of the new maximum, ErrVolumeNotEmpty is returned.
func (*Store) StorageUsage ¶
StorageUsage returns the number of sectors stored and the total number of sectors available in the storage pool.
func (*Store) StoreSector ¶
func (s *Store) StoreSector(root types.Hash256, fn func(loc storage.SectorLocation, exists bool) error) (func() error, error)
StoreSector calls fn with an empty location in a writable volume. If the sector root already exists, fn is called with the existing location and exists is true. Unless exists is true, The sector must be written to disk within fn. If fn returns an error, the metadata is rolled back. If no space is available, ErrNotEnoughStorage is returned. The location is locked until release is called.
The sector should be referenced by either a contract or temp store before release is called to prevent it from being pruned
func (*Store) TransactionCount ¶
TransactionCount returns the total number of transactions in the wallet.
func (*Store) Transactions ¶
func (s *Store) Transactions(limit, offset int) (txns []wallet.Transaction, err error)
Transactions returns a paginated list of transactions ordered by block height descending. If no transactions are found, (nil, nil) is returned.
func (*Store) UnspentSiacoinElements ¶
func (s *Store) UnspentSiacoinElements() (utxos []wallet.SiacoinElement, err error)
UnspentSiacoinElements returns the spendable siacoin outputs in the wallet.
func (*Store) UpdateContractState ¶
func (s *Store) UpdateContractState(ccID modules.ConsensusChangeID, height uint64, fn func(contracts.UpdateStateTransaction) error) error
UpdateContractState atomically updates the contractor's state.
func (*Store) UpdateLastAnnouncement ¶ added in v0.2.2
func (s *Store) UpdateLastAnnouncement(ann settings.Announcement) error
UpdateLastAnnouncement updates the last announcement.
func (*Store) UpdateSettings ¶
UpdateSettings updates the host's stored settings.
func (*Store) UpdateWallet ¶
func (s *Store) UpdateWallet(ccID modules.ConsensusChangeID, height uint64, fn func(wallet.UpdateTransaction) error) error
UpdateWallet begins an update transaction on the wallet store.
func (*Store) UpdateWebHook ¶ added in v1.0.0
UpdateWebHook updates a webhook.
func (*Store) VerifyWalletKey ¶
VerifyWalletKey checks that the wallet seed matches the seed hash. This detects if the user's recovery phrase has changed and the wallet needs to rescan.