Documentation ¶
Index ¶
- func NewPeerStore(s *Store) (syncer.PeerStore, error)
- type PeerStore
- func (ps *PeerStore) AddPeer(peer string) error
- func (ps *PeerStore) Ban(peer string, duration time.Duration, reason string) error
- func (ps *PeerStore) Banned(peer string) (bool, error)
- func (ps *PeerStore) PeerInfo(peer string) (syncer.PeerInfo, error)
- func (ps *PeerStore) Peers() ([]syncer.PeerInfo, error)
- func (ps *PeerStore) UpdatePeerInfo(peer string, fn func(*syncer.PeerInfo)) error
- type Store
- func (s *Store) AddPeer(peer string) error
- func (s *Store) AddWallet(w wallet.Wallet) (wallet.Wallet, error)
- func (s *Store) AddWalletAddress(id wallet.ID, addr wallet.Address) error
- func (s *Store) AddressBalance(address types.Address) (balance wallet.Balance, err error)
- func (s *Store) AddressEvents(address types.Address, offset, limit int) (events []wallet.Event, err error)
- func (s *Store) AddressSiacoinOutputs(address types.Address, index types.ChainIndex, offset, limit int) (siacoins []types.SiacoinElement, err error)
- func (s *Store) AddressSiafundOutputs(address types.Address, offset, limit int) (siafunds []types.SiafundElement, err error)
- func (s *Store) AnnotateV1Events(index types.ChainIndex, timestamp time.Time, v1 []types.Transaction) (annotated []wallet.Event, err error)
- func (s *Store) Ban(peer string, duration time.Duration, reason string) error
- func (s *Store) Banned(peer string) (banned bool, _ error)
- func (s *Store) Close() error
- func (s *Store) DeleteWallet(id wallet.ID) error
- func (s *Store) Events(eventIDs []types.Hash256) (events []wallet.Event, err error)
- func (s *Store) IndexMode() (wallet.IndexMode, error)
- func (s *Store) LastCommittedIndex() (index types.ChainIndex, err error)
- func (s *Store) Peers() (peers []syncer.PeerInfo, _ error)
- func (s *Store) RemoveWalletAddress(id wallet.ID, address types.Address) error
- func (s *Store) ResetLastIndex() error
- func (s *Store) SetIndexMode(mode wallet.IndexMode) error
- func (s *Store) SiacoinElement(id types.SiacoinOutputID) (ele types.SiacoinElement, err error)
- func (s *Store) SiafundElement(id types.SiafundOutputID) (ele types.SiafundElement, err error)
- func (s *Store) UpdateChainState(reverted []chain.RevertUpdate, applied []chain.ApplyUpdate) error
- func (s *Store) UpdateWallet(w wallet.Wallet) (wallet.Wallet, error)
- func (s *Store) WalletAddresses(id wallet.ID) (addresses []wallet.Address, err error)
- func (s *Store) WalletBalance(id wallet.ID) (balance wallet.Balance, err error)
- func (s *Store) WalletEvents(id wallet.ID, offset, limit int) (events []wallet.Event, err error)
- func (s *Store) WalletSiacoinOutputs(id wallet.ID, index types.ChainIndex, offset, limit int) (siacoins []types.SiacoinElement, err error)
- func (s *Store) WalletSiafundOutputs(id wallet.ID, offset, limit int) (siafunds []types.SiafundElement, err error)
- func (s *Store) WalletUnconfirmedEvents(id wallet.ID, index types.ChainIndex, timestamp time.Time, ...) (annotated []wallet.Event, err error)
- func (s *Store) Wallets() (wallets []wallet.Wallet, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type PeerStore ¶
type PeerStore struct {
// contains filtered or unexported fields
}
A PeerStore stores information about peers.
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) AddWalletAddress ¶
AddWalletAddress adds an address to a wallet.
func (*Store) AddressBalance ¶
AddressBalance returns the balance of a single address.
func (*Store) AddressEvents ¶
func (s *Store) AddressEvents(address types.Address, offset, limit int) (events []wallet.Event, err error)
AddressEvents returns the events of a single address.
func (*Store) AddressSiacoinOutputs ¶
func (s *Store) AddressSiacoinOutputs(address types.Address, index types.ChainIndex, offset, limit int) (siacoins []types.SiacoinElement, err error)
AddressSiacoinOutputs returns the unspent siacoin outputs for an address.
func (*Store) AddressSiafundOutputs ¶
func (s *Store) AddressSiafundOutputs(address types.Address, offset, limit int) (siafunds []types.SiafundElement, err error)
AddressSiafundOutputs returns the unspent siafund outputs for an address.
func (*Store) AnnotateV1Events ¶
func (s *Store) AnnotateV1Events(index types.ChainIndex, timestamp time.Time, v1 []types.Transaction) (annotated []wallet.Event, err error)
AnnotateV1Events annotates a list of unconfirmed transactions with relevant addresses and siacoin/siafund elements.
func (*Store) Ban ¶
Ban 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).
func (*Store) DeleteWallet ¶
DeleteWallet deletes a wallet from the database. This does not stop tracking addresses that were previously associated with the wallet.
func (*Store) Events ¶
Events returns the events with the given event IDs. If an event is not found, it is skipped.
func (*Store) LastCommittedIndex ¶
func (s *Store) LastCommittedIndex() (index types.ChainIndex, err error)
LastCommittedIndex returns the last chain index that was committed.
func (*Store) RemoveWalletAddress ¶
RemoveWalletAddress removes an address from a wallet. This does not stop tracking the address.
func (*Store) ResetLastIndex ¶
ResetLastIndex resets the last indexed tip to trigger a full rescan.
func (*Store) SetIndexMode ¶
SetIndexMode sets the index mode. If the index mode is already set, this function will return an error.
func (*Store) SiacoinElement ¶
func (s *Store) SiacoinElement(id types.SiacoinOutputID) (ele types.SiacoinElement, err error)
SiacoinElement returns an unspent Siacoin UTXO by its ID.
func (*Store) SiafundElement ¶
func (s *Store) SiafundElement(id types.SiafundOutputID) (ele types.SiafundElement, err error)
SiafundElement returns an unspent Siafund UTXO by its ID.
func (*Store) UpdateChainState ¶
func (s *Store) UpdateChainState(reverted []chain.RevertUpdate, applied []chain.ApplyUpdate) error
UpdateChainState implements chain.Subscriber
func (*Store) UpdateWallet ¶
UpdateWallet updates a wallet in the database.
func (*Store) WalletAddresses ¶
WalletAddresses returns a slice of addresses registered to the wallet.
func (*Store) WalletBalance ¶
WalletBalance returns the total balance of a wallet.
func (*Store) WalletEvents ¶
WalletEvents returns the events relevant to a wallet, sorted by height descending.
func (*Store) WalletSiacoinOutputs ¶
func (s *Store) WalletSiacoinOutputs(id wallet.ID, index types.ChainIndex, offset, limit int) (siacoins []types.SiacoinElement, err error)
WalletSiacoinOutputs returns the unspent siacoin outputs for a wallet.
func (*Store) WalletSiafundOutputs ¶
func (s *Store) WalletSiafundOutputs(id wallet.ID, offset, limit int) (siafunds []types.SiafundElement, err error)
WalletSiafundOutputs returns the unspent siafund outputs for a wallet.
func (*Store) WalletUnconfirmedEvents ¶
func (s *Store) WalletUnconfirmedEvents(id wallet.ID, index types.ChainIndex, timestamp time.Time, v1 []types.Transaction, v2 []types.V2Transaction) (annotated []wallet.Event, err error)
WalletUnconfirmedEvents annotates a list of unconfirmed transactions with relevant addresses and siacoin/siafund elements.