Documentation ¶
Index ¶
- Constants
- func Create(namespace walletdb.Namespace) error
- func DisableLog()
- func UseLogger(logger btclog.Logger)
- type ErrorCode
- type StakeNotification
- type StakeStore
- func (s *StakeStore) CheckHashInStore(hash *chainhash.Hash) bool
- func (s *StakeStore) Close() error
- func (s *StakeStore) DumpSSGenHashes() ([]chainhash.Hash, error)
- func (s *StakeStore) DumpSSRtxHashes() ([]chainhash.Hash, error)
- func (s *StakeStore) DumpSSRtxTickets() ([]chainhash.Hash, error)
- func (s *StakeStore) DumpSStxHashes() ([]chainhash.Hash, error)
- func (s *StakeStore) DumpSStxHashesForAddress(addr dcrutil.Address) ([]chainhash.Hash, error)
- func (s StakeStore) HandleMissedTicketsNtfn(blockHash *chainhash.Hash, blockHeight int64, tickets []*chainhash.Hash) ([]*StakeNotification, error)
- func (s StakeStore) HandleWinningTicketsNtfn(blockHash *chainhash.Hash, blockHeight int64, tickets []*chainhash.Hash, ...) ([]*StakeNotification, error)
- func (s *StakeStore) InsertSSGen(blockHash *chainhash.Hash, blockHeight int64, ssgenHash *chainhash.Hash, ...) error
- func (s *StakeStore) InsertSSRtx(blockHash *chainhash.Hash, blockHeight int64, ssrtxHash *chainhash.Hash, ...) error
- func (s *StakeStore) InsertSStx(sstx *dcrutil.Tx, voteBits uint16) error
- func (s *StakeStore) SStxVoteBits(sstx *chainhash.Hash) (bool, uint16, error)
- func (s *StakeStore) SendRawTransaction(msgTx *wire.MsgTx) (*chainhash.Hash, error)
- func (s *StakeStore) SetChainSvr(chainSvr *walletchain.RPCClient)
- func (s *StakeStore) SignVRTransaction(msgTx *wire.MsgTx, sstx *dcrutil.Tx, isSSGen bool) error
- func (s *StakeStore) UpdateSStxVoteBits(sstx *chainhash.Hash, voteBits uint16) error
- type StakeStoreError
Constants ¶
const (
// LatestStakeMgrVersion is the most recent tx store version.
LatestStakeMgrVersion = 1
)
Variables ¶
This section is empty.
Functions ¶
func Create ¶
Create creates a new persistent stake manager in the passed database namespace. A ManagerError with an error code of ErrAlreadyExists will be returned the address manager already exists in the specified namespace.
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.
Types ¶
type ErrorCode ¶
type ErrorCode int
ErrorCode identifies a kind of error.
const ( // ErrDatabase indicates a generic error with the underlying database. // When this error code is set, the Err field of the TxStoreError will // be set to the underlying error returned from the database. ErrDatabase ErrorCode = iota // ErrInput indicates there was a problem with the input given. ErrInput // ErrNoExist indicates that the specified database does not exist. ErrNoExist // ErrAlreadyExists indicates that the specified database already exists. ErrAlreadyExists // ErrSStxNotFound indicates that the requested tx hash is not known to // the SStx store. ErrSStxNotFound // ErrSSGensNotFound indicates that the requested tx hash is not known to // the SSGens store. ErrSSGensNotFound // ErrSSRtxsNotFound indicates that the requested tx hash is not known to // the SSRtxs store. ErrSSRtxsNotFound // ErrStoreClosed indicates that a function was called after the stake // store was closed. ErrStoreClosed )
These constants are used to identify a specific StakeStoreError.
type StakeNotification ¶
type StakeNotification struct { TxType int8 // These are the same as in staketx.go of stake, but int8 TxHash chainhash.Hash BlockHash chainhash.Hash // SSGen only Height int32 // SSGen only Amount int64 // SStx only SStxIn chainhash.Hash // SSGen and SSRtx VoteBits uint16 // SSGen only }
StakeNotification is the data structure that contains information about an SStx (ticket), SSGen (vote), or SSRtx (revocation) produced by wallet.
type StakeStore ¶
type StakeStore struct { Params *chaincfg.Params Manager *waddrmgr.Manager // contains filtered or unexported fields }
StakeStore represents a safely accessible database of stake transactions.
func Open ¶
func Open(namespace walletdb.Namespace, manager *waddrmgr.Manager, params *chaincfg.Params) (*StakeStore, error)
Open loads an existing stake manager from the given namespace, waddrmgr, and network parameters.
A ManagerError with an error code of ErrNoExist will be returned if the passed manager does not exist in the specified namespace.
func (*StakeStore) CheckHashInStore ¶
func (s *StakeStore) CheckHashInStore(hash *chainhash.Hash) bool
CheckHashInStore is the exported version of CheckHashInStore that is safe for concurrent access.
func (*StakeStore) Close ¶
func (s *StakeStore) Close() error
Close cleanly shuts down the stake store.
func (*StakeStore) DumpSSGenHashes ¶
func (s *StakeStore) DumpSSGenHashes() ([]chainhash.Hash, error)
DumpSSGenHashes is the exported version of dumpSSGenHashes that is safe for concurrent access.
func (*StakeStore) DumpSSRtxHashes ¶
func (s *StakeStore) DumpSSRtxHashes() ([]chainhash.Hash, error)
DumpSSRtxHashes is the exported version of dumpSSRtxHashes that is safe for concurrent access.
func (*StakeStore) DumpSSRtxTickets ¶
func (s *StakeStore) DumpSSRtxTickets() ([]chainhash.Hash, error)
DumpSSRtxTickets is the exported version of dumpSSRtxTickets that is safe for concurrent access.
func (*StakeStore) DumpSStxHashes ¶
func (s *StakeStore) DumpSStxHashes() ([]chainhash.Hash, error)
DumpSStxHashes is the exported version of dumpSStxHashes that is safe for concurrent access.
func (*StakeStore) DumpSStxHashesForAddress ¶
DumpSStxHashesForAddress is the exported version of dumpSStxHashesForAddress that is safe for concurrent access.
func (StakeStore) HandleMissedTicketsNtfn ¶
func (s StakeStore) HandleMissedTicketsNtfn(blockHash *chainhash.Hash, blockHeight int64, tickets []*chainhash.Hash) ([]*StakeNotification, error)
HandleMissedTicketsNtfn scans the list of missed tickets and, if any of these tickets in the sstx store match these tickets, spends them as SSRtx.
func (StakeStore) HandleWinningTicketsNtfn ¶
func (s StakeStore) HandleWinningTicketsNtfn(blockHash *chainhash.Hash, blockHeight int64, tickets []*chainhash.Hash, defaultVoteBits uint16) ([]*StakeNotification, error)
HandleWinningTicketsNtfn scans the list of eligible tickets and, if any of these tickets in the sstx store match these tickets, spends them as votes.
func (*StakeStore) InsertSSGen ¶
func (s *StakeStore) InsertSSGen(blockHash *chainhash.Hash, blockHeight int64, ssgenHash *chainhash.Hash, voteBits uint16, sstxHash *chainhash.Hash) error
InsertSSGen is the exported version of insertSSGen that is safe for concurrent access.
func (*StakeStore) InsertSSRtx ¶
func (s *StakeStore) InsertSSRtx(blockHash *chainhash.Hash, blockHeight int64, ssrtxHash *chainhash.Hash, sstxHash *chainhash.Hash) error
InsertSSRtx is the exported version of insertSSRtx that is safe for concurrent access.
func (*StakeStore) InsertSStx ¶
func (s *StakeStore) InsertSStx(sstx *dcrutil.Tx, voteBits uint16) error
InsertSStx is the exported version of insertSStx that is safe for concurrent access.
func (*StakeStore) SStxVoteBits ¶
SStxVoteBits is the exported version of sstxVoteBits that is safe for concurrent access.
func (*StakeStore) SendRawTransaction ¶
SendRawTransaction sends a raw transaction using the chainSvr. TODO Shouldn't this be locked? Eventually import the mutex lock from wallet maybe.
func (*StakeStore) SetChainSvr ¶
func (s *StakeStore) SetChainSvr(chainSvr *walletchain.RPCClient)
SetChainSvr is used to set the chainSvr to a given pointer. Should be called after chainSvr is initialized in wallet.
func (*StakeStore) SignVRTransaction ¶
SignVRTransaction signs a vote (SSGen) or revocation (SSRtx) transaction. isSSGen indicates if it is an SSGen; if it's not, it's an SSRtx.
func (*StakeStore) UpdateSStxVoteBits ¶
func (s *StakeStore) UpdateSStxVoteBits(sstx *chainhash.Hash, voteBits uint16) error
UpdateSStxVoteBits is the exported version of updateSStxVoteBits that is safe for concurrent access.
type StakeStoreError ¶
type StakeStoreError struct { ErrorCode ErrorCode // Describes the kind of error Description string // Human readable description of the issue Err error // Underlying error }
StakeStoreError provides a single type for errors that can happen during stake store operation. It is similar to waddrmgr.ManagerError.
func (StakeStoreError) Error ¶
func (e StakeStoreError) Error() string
Error satisfies the error interface and prints human-readable errors.