Documentation ¶
Index ¶
- Constants
- func DbCreate(dbTx database.Tx) error
- func DbDeleteTicket(dbTx database.Tx, ticketBucket []byte, hash *chainhash.Hash) error
- func DbDropBlockUndoData(dbTx database.Tx, height uint32) error
- func DbDropNewTickets(dbTx database.Tx, height uint32) error
- func DbLoadAllTickets(dbTx database.Tx, ticketBucket []byte) (*tickettreap.Immutable, error)
- func DbPutBestState(dbTx database.Tx, bcs BestChainState) error
- func DbPutBlockUndoData(dbTx database.Tx, height uint32, utds []UndoTicketData) error
- func DbPutDatabaseInfo(dbTx database.Tx, dbi *DatabaseInfo) error
- func DbPutNewTickets(dbTx database.Tx, height uint32, ths TicketHashes) error
- func DbPutTicket(dbTx database.Tx, ticketBucket []byte, hash *chainhash.Hash, height uint32, ...) error
- type BestChainState
- type DBError
- type DatabaseInfo
- type ErrorCode
- type TicketHashes
- type UndoTicketData
Constants ¶
const ( // ErrUndoDataShortRead indicates that the given undo serialized data // was took small. ErrUndoDataShortRead = iota // ErrUndoDataNoEntries indicates that the data for undoing ticket data // in a serialized entry was corrupt. ErrUndoDataCorrupt // ErrTicketHashesShortRead indicates that the given ticket hashes // serialized data was took small. ErrTicketHashesShortRead // ErrTicketHashesCorrupt indicates that the data for ticket hashes // in a serialized entry was corrupt. ErrTicketHashesCorrupt // ErrUninitializedBucket indicates that a database bucket was not // initialized and therefore could not be written to or read from. ErrUninitializedBucket // ErrMissingKey indicates that a key was not found in a bucket. ErrMissingKey // ErrChainStateShortRead indicates that the given chain state data // was too small. ErrChainStateShortRead // ErrDatabaseInfoShortRead indicates that the given database information // was too small. ErrDatabaseInfoShortRead // ErrLoadAllTickets indicates that there was an error loading the tickets // from the database, presumably at startup. ErrLoadAllTickets )
These constants are used to identify a specific RuleError.
Variables ¶
This section is empty.
Functions ¶
func DbCreate ¶
DbCreate initializes all the buckets required for the database and stores the current database version information.
func DbDeleteTicket ¶
DbDeleteTicket removes a ticket from one of the ticket database buckets. This differs from the bucket deletion method in that it will fail if the value itself is missing.
func DbDropBlockUndoData ¶
DbDropBlockUndoData drops block undo data from the database at a given height.
func DbDropNewTickets ¶
DbDropNewTickets drops new tickets for a mainchain block data at some height.
func DbLoadAllTickets ¶
DbLoadAllTickets loads all the live tickets from the database into a treap.
func DbPutBestState ¶
func DbPutBestState(dbTx database.Tx, bcs BestChainState) error
DbPutBestState uses an existing database transaction to update the best chain state with the given parameters.
func DbPutBlockUndoData ¶
func DbPutBlockUndoData(dbTx database.Tx, height uint32, utds []UndoTicketData) error
DbPutBlockUndoData inserts block undo data into the database for a given height.
func DbPutDatabaseInfo ¶
func DbPutDatabaseInfo(dbTx database.Tx, dbi *DatabaseInfo) error
DbPutDatabaseInfo uses an existing database transaction to store the database information.
func DbPutNewTickets ¶
func DbPutNewTickets(dbTx database.Tx, height uint32, ths TicketHashes) error
DbPutNewTickets inserts new tickets for a mainchain block data into the database.
Types ¶
type BestChainState ¶
type BestChainState struct { Hash chainhash.Hash Height uint32 Live uint32 Missed uint64 Revoked uint64 PerBlock uint16 NextWinners []chainhash.Hash }
BestChainState represents the data to be stored the database for the current best chain state.
func DbFetchBestState ¶
func DbFetchBestState(dbTx database.Tx) (BestChainState, error)
DbFetchBestState uses an existing database transaction to fetch the best chain state.
type DBError ¶
type DBError struct { ErrorCode ErrorCode // Describes the kind of error Description string // Human readable description of the issue }
DBError identifies a an error in the stake database for tickets. The caller can use type assertions to determine if a failure was specifically due to a rule violation and access the ErrorCode field to ascertain the specific reason for the rule violation.
type DatabaseInfo ¶
DatabaseInfo is the structure for a database.
func DbFetchDatabaseInfo ¶
func DbFetchDatabaseInfo(dbTx database.Tx) (*DatabaseInfo, error)
DbFetchDatabaseInfo uses an existing database transaction to fetch the database versioning and creation information.
type TicketHashes ¶
TicketHashes is a list of ticket hashes that will mature in TicketMaturity many blocks from the block in which they were included.
func DbFetchNewTickets ¶
func DbFetchNewTickets(dbTx database.Tx, height uint32) (TicketHashes, error)
DbFetchNewTickets fetches new tickets for a mainchain block from the database.
type UndoTicketData ¶
type UndoTicketData struct { TicketHash chainhash.Hash TicketHeight uint32 Missed bool Revoked bool Spent bool Expired bool }
UndoTicketData is the data for any ticket that has been spent, missed, or revoked at some new height. It is used to roll back the database in the event of reorganizations or determining if a side chain block is valid. The last 3 are encoded as a single byte of flags. The flags describe a particular state for the ticket:
- Missed is set, but revoked and spent are not (0000 0001). The ticket was selected in the lottery at this block height but missed, or the ticket became too old and was missed. The ticket is being moved to the missed ticket bucket from the live ticket bucket.
- Missed and revoked are set (0000 0011). The ticket was missed previously at a block before this one and was revoked, and as such is being moved to the revoked ticket bucket from the missed ticket bucket.
- Spent is set (0000 0100). The ticket has been spent and is removed from the live ticket bucket.
- No flags are set. The ticket was newly added to the live ticket bucket this block as a maturing ticket.
func DbFetchBlockUndoData ¶
func DbFetchBlockUndoData(dbTx database.Tx, height uint32) ([]UndoTicketData, error)
DbFetchBlockUndoData fetches block undo data from the database.