wstakemgr

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2016 License: ISC Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TSImmatureOrLive indicates that the ticket is either
	// live or immature.
	TSImmatureOrLive = iota

	// TSVoted indicates that the ticket was spent as a vote.
	TSVoted

	// TSMissed indicates that the ticket was spent as a
	// revocation.
	TSMissed
)
View Source
const (
	// LatestStakeMgrVersion is the most recent tx store version.
	LatestStakeMgrVersion = 1
)

Variables

This section is empty.

Functions

func Create

func Create(ns walletdb.ReadWriteBucket) error

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.

func DoUpgrades added in v0.5.0

func DoUpgrades(db walletdb.DB, namespaceKey []byte) error

DoUpgrades performs any necessary upgrades to the stake manager contained in the wallet database, namespaced by the top level bucket key namespaceKey.

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

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

	// ErrPoolUserTicketsNotFound indicates that the requested script hash
	// is not known to the meta bucket.
	ErrPoolUserTicketsNotFound

	// ErrPoolUserInvalTcktsNotFound indicates that the requested script hash
	// is not known to the meta bucket.
	ErrPoolUserInvalTcktsNotFound

	// ErrBadPoolUserAddr indicates that the passed pool user address was
	// faulty.
	ErrBadPoolUserAddr

	// ErrStoreClosed indicates that a function was called after the stake
	// store was closed.
	ErrStoreClosed

	// ErrData describes an error where data stored in the stake database
	// is incorrect.  This may be due to missing values, values of
	// wrong sizes, or data from different buckets that is inconsistent with
	// itself.  Recovering from an ErrData requires rebuilding all
	// stake database history or manual database surgery.  If the failure was
	// not due to data corruption, this error category indicates a
	// programming error in this package.
	ErrData
)

These constants are used to identify a specific StakeStoreError.

func (ErrorCode) String

func (e ErrorCode) String() string

String returns the ErrorCode as a human-readable name.

type PoolTicket added in v0.1.2

type PoolTicket struct {
	Ticket       chainhash.Hash
	HeightTicket uint32
	Status       TicketStatus
	HeightSpent  uint32
	SpentBy      chainhash.Hash
}

PoolTicket is a 73-byte struct that is used to preserve user's ticket information when they have an account at the stake pool.

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 StakePoolUser added in v0.1.2

type StakePoolUser struct {
	Tickets        []*PoolTicket
	InvalidTickets []*chainhash.Hash
}

StakePoolUser is a list of tickets for a given user (P2SH address) in the stake pool.

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(ns walletdb.ReadBucket, 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(ns walletdb.ReadBucket) ([]chainhash.Hash, error)

DumpSSGenHashes is the exported version of dumpSSGenHashes that is safe for concurrent access.

func (*StakeStore) DumpSSRtxHashes

func (s *StakeStore) DumpSSRtxHashes(ns walletdb.ReadBucket) ([]chainhash.Hash, error)

DumpSSRtxHashes is the exported version of dumpSSRtxHashes that is safe for concurrent access.

func (*StakeStore) DumpSSRtxTickets

func (s *StakeStore) DumpSSRtxTickets(ns walletdb.ReadBucket) ([]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

func (s *StakeStore) DumpSStxHashesForAddress(ns walletdb.ReadBucket, addr dcrutil.Address) ([]chainhash.Hash, error)

DumpSStxHashesForAddress is the exported version of dumpSStxHashesForAddress that is safe for concurrent access.

func (StakeStore) HandleMissedTicketsNtfn

func (s StakeStore) HandleMissedTicketsNtfn(ns walletdb.ReadWriteBucket, waddrmgrNs walletdb.ReadBucket, blockHash *chainhash.Hash, blockHeight int64, tickets []*chainhash.Hash, allowHighFees bool) ([]*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(ns walletdb.ReadWriteBucket, waddrmgrNs walletdb.ReadBucket, blockHash *chainhash.Hash, blockHeight int64, tickets []*chainhash.Hash, defaultVoteBits stake.VoteBits, allowHighFees bool) ([]*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(ns walletdb.ReadWriteBucket, 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(ns walletdb.ReadWriteBucket, 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(ns walletdb.ReadWriteBucket, sstx *dcrutil.Tx, voteBits stake.VoteBits) error

InsertSStx is the exported version of insertSStx that is safe for concurrent access.

func (*StakeStore) RemoveStakePoolUserInvalTickets added in v0.6.0

func (s *StakeStore) RemoveStakePoolUserInvalTickets(ns walletdb.ReadWriteBucket, user dcrutil.Address,
	ticket *chainhash.Hash) error

RemoveStakePoolUserInvalTickets is the exported and concurrency safe form of removetStakePoolUserInvalTickets.

func (*StakeStore) SStxAddress added in v0.1.2

func (s *StakeStore) SStxAddress(ns walletdb.ReadBucket, hash *chainhash.Hash) (dcrutil.Address, error)

SStxAddress is the exported, concurrency safe version of sstxAddress.

func (*StakeStore) SStxVoteBits

func (s *StakeStore) SStxVoteBits(ns walletdb.ReadBucket, sstx *chainhash.Hash) (bool, stake.VoteBits, error)

SStxVoteBits is the exported version of sstxVoteBits that is safe for concurrent access.

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

func (s *StakeStore) SignVRTransaction(waddrmgrNs walletdb.ReadBucket, msgTx *wire.MsgTx,
	sstx *dcrutil.Tx, isSSGen bool) error

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) StakePoolUserInfo added in v0.1.2

func (s *StakeStore) StakePoolUserInfo(ns walletdb.ReadBucket, user dcrutil.Address) (*StakePoolUser, error)

StakePoolUserInfo is the exported and concurrency safe form of stakePoolUserInfo.

func (*StakeStore) UpdateSStxVoteBits

func (s *StakeStore) UpdateSStxVoteBits(ns walletdb.ReadWriteBucket,
	sstx *chainhash.Hash, voteBits stake.VoteBits) error

UpdateSStxVoteBits is the exported version of updateSStxVoteBits that is safe for concurrent access.

func (*StakeStore) UpdateStakePoolUserInvalTickets added in v0.1.2

func (s *StakeStore) UpdateStakePoolUserInvalTickets(ns walletdb.ReadWriteBucket, user dcrutil.Address, ticket *chainhash.Hash) error

UpdateStakePoolUserInvalTickets is the exported and concurrency safe form of updateStakePoolUserInvalTickets.

func (*StakeStore) UpdateStakePoolUserTickets added in v0.1.2

func (s *StakeStore) UpdateStakePoolUserTickets(ns walletdb.ReadWriteBucket, waddrmgrNs walletdb.ReadBucket, user dcrutil.Address, ticket *PoolTicket) error

UpdateStakePoolUserTickets is the exported and concurrency safe form of updateStakePoolUserTickets.

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.

type TicketStatus added in v0.1.2

type TicketStatus uint8

TicketStatus is the current status of a stake pool ticket.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL