wstakemgr

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 10, 2016 License: ISC Imports: 18 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(namespace walletdb.Namespace) 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 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
)

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.3

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.3

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(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

func (s *StakeStore) DumpSStxHashesForAddress(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(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(blockHash *chainhash.Hash,
	blockHeight int64,
	tickets []*chainhash.Hash,
	defaultVoteBits uint16,
	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(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) SStxAddress added in v0.1.3

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

SStxAddress is the exported, concurrency safe version of sstxAddress.

func (*StakeStore) SStxVoteBits

func (s *StakeStore) SStxVoteBits(sstx *chainhash.Hash) (bool, uint16, error)

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

func (*StakeStore) SendRawTransaction

func (s *StakeStore) SendRawTransaction(msgTx *wire.MsgTx, allowHighFees bool) (*chainhash.Hash,
	error)

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

func (s *StakeStore) SignVRTransaction(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.3

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

StakePoolUserInfo is the exported and concurrency safe form of stakePoolUserInfo.

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.

func (*StakeStore) UpdateStakePoolUserInvalTickets added in v0.1.3

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

UpdateStakePoolUserInvalTickets is the exported and concurrency safe form of updateStakePoolUserInvalTickets.

func (*StakeStore) UpdateStakePoolUserTickets added in v0.1.3

func (s *StakeStore) UpdateStakePoolUserTickets(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.3

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