Documentation ¶
Overview ¶
Package stake contains code for all of dcrd's stake transaction chain handling and other portions related to the Proof-of-Stake (PoS) system.
At the heart of the PoS system are tickets, votes and revocations. These 3 pieces work together to determine if previous blocks are valid and their txs should be confirmed.
Important Parts included in stake package:
- Processing SSTx (tickets), SSGen (votes), SSRtx (revocations) - TicketDB - Stake Reward calculation - Stake transaction identification (IsSStx, IsSSGen, IsSSRtx)
Index ¶
- Constants
- func AddrFromSStxPkScrCommitment(pkScript []byte, params *chaincfg.Params) (dcrutil.Address, error)
- func AmountFromSStxPkScrCommitment(pkScript []byte) (dcrutil.Amount, error)
- func CalculateRewards(amounts []int64, amountTicket int64, subsidy int64) []int64
- func DisableLog()
- func FindTicketIdxs(size int64, n int, prng *Hash256PRNG) ([]int, error)
- func IsSSGen(tx *dcrutil.Tx) (bool, error)
- func IsSSRtx(tx *dcrutil.Tx) (bool, error)
- func IsSStx(tx *dcrutil.Tx) (bool, error)
- func IsStakeBase(tx *dcrutil.Tx) bool
- func SSGenBlockVotedOn(tx *dcrutil.Tx) (chainhash.Hash, uint32, error)
- func SSGenVoteBits(tx *dcrutil.Tx) uint16
- func SStxNullOutputAmounts(amounts []int64, changeAmounts []int64, amountTicket int64) (int64, []int64, error)
- func SStxStakeOutputInfo(outs []*MinimalOutput) ([]bool, [][]byte, []int64, []int64, [][]bool, [][]uint16)
- func SetLogWriter(w io.Writer, level string) error
- func SetTxTree(tx *dcrutil.Tx)
- func TxSSGenStakeOutputInfo(tx *dcrutil.Tx, params *chaincfg.Params) ([]bool, [][]byte, []int64, error)
- func TxSSRtxStakeOutputInfo(tx *dcrutil.Tx, params *chaincfg.Params) ([]bool, [][]byte, []int64, error)
- func TxSStxStakeOutputInfo(tx *dcrutil.Tx) ([]bool, [][]byte, []int64, []int64, [][]bool, [][]uint16)
- func UseLogger(logger btclog.Logger)
- func VerifySStxAmounts(sstxAmts []int64, sstxCalcAmts []int64) error
- func VerifyStakingPkhsAndAmounts(sstxTypes []bool, sstxPkhs [][]byte, ssSpendAmts []int64, ssSpendTypes []bool, ...) error
- func WriteConnectedBestNode(dbTx database.Tx, node *Node, hash chainhash.Hash) error
- func WriteDisconnectedBestNode(dbTx database.Tx, node *Node, hash chainhash.Hash, ...) error
- type ErrorCode
- type Hash256PRNG
- type MinimalOutput
- type Node
- func (sn *Node) ConnectNode(header wire.BlockHeader, ...) (*Node, error)
- func (sn *Node) DisconnectNode(parentHeader wire.BlockHeader, parentUtds UndoTicketDataSlice, ...) (*Node, error)
- func (sn *Node) ExistsExpiredTicket(ticket chainhash.Hash) bool
- func (sn *Node) ExistsLiveTicket(ticket chainhash.Hash) bool
- func (sn *Node) ExistsMissedTicket(ticket chainhash.Hash) bool
- func (sn *Node) ExistsRevokedTicket(ticket chainhash.Hash) bool
- func (sn *Node) FinalState() [6]byte
- func (sn *Node) Height() uint32
- func (sn *Node) LiveTickets() []chainhash.Hash
- func (sn *Node) MissedByBlock() []chainhash.Hash
- func (sn *Node) MissedTickets() []chainhash.Hash
- func (sn *Node) NewTickets() []chainhash.Hash
- func (sn *Node) PoolSize() int
- func (sn *Node) RevokedTickets() []*chainhash.Hash
- func (sn *Node) SpentByBlock() []chainhash.Hash
- func (sn *Node) UndoData() UndoTicketDataSlice
- func (sn *Node) Winners() []chainhash.Hash
- type RuleError
- type TxType
- type UndoTicketDataSlice
Constants ¶
const ( // ErrSStxTooManyInputs indicates that a given SStx contains too many // inputs. ErrSStxTooManyInputs = iota // ErrSStxTooManyOutputs indicates that a given SStx contains too many // outputs. ErrSStxTooManyOutputs // ErrSStxNoOutputs indicates that a given SStx has no outputs. ErrSStxNoOutputs // ErrSStxInvalidInput indicates that an invalid output has been used as // an input for a SStx; only non-SStx tagged outputs may be used to // purchase stake tickets. // TODO: Add this into validate // Ensure that all inputs are not tagged SStx outputs of some sort, // along with checks to make sure they exist and are available. ErrSStxInvalidInputs // ErrSStxInvalidOutput indicates that the output for an SStx tx is // invalid; in particular, either the output was not tagged SStx or the // OP_RETURNs were missing or contained invalid addresses. ErrSStxInvalidOutputs // ErrSStxInOutProportions indicates the the number of inputs in an SStx // was not equal to the number of output minus one. ErrSStxInOutProportions // ErrSStxBadCommitAmount indicates that a ticket tried to commit 0 or // a negative value as the commitment amount. ErrSStxBadCommitAmount // ErrSStxBadChangeAmts indicates that the change amount for some SStx // was invalid, for instance spending more than its inputs. ErrSStxBadChangeAmts // ErrSStxVerifyCalcAmts indicates that passed calculated amounts failed // to conform to the amounts found in the ticket. ErrSStxVerifyCalcAmts // ErrSSGenWrongNumInputs indicates that a given SSGen tx contains an // invalid number of inputs. ErrSSGenWrongNumInputs // ErrSSGenTooManyOutputs indicates that a given SSGen tx contains too // many outputs. ErrSSGenTooManyOutputs // ErrSSGenNoOutputs indicates that a given SSGen has no outputs. ErrSSGenNoOutputs // ErrSSGenWrongIndex indicates that a given SSGen sstx input was not // using the correct index. ErrSSGenWrongIndex // ErrSSGenWrongTxTree indicates that a given SSGen tx input was not found in // the stake tx tree. ErrSSGenWrongTxTree // ErrSSGenNoStakebase indicates that the SSGen tx did not contain a // valid StakeBase in the zeroeth position of inputs. ErrSSGenNoStakebase // ErrSSGenNoReference indicates that there is no reference OP_RETURN // included as the first output. ErrSSGenNoReference // ErrSSGenNoReference indicates that the OP_RETURN included as the // first output was corrupted in some way. ErrSSGenBadReference // ErrSSGenNoVotePush indicates that there is no vote bits OP_RETURN // included as the second output. ErrSSGenNoVotePush // ErrSSGenBadVotePush indicates that the OP_RETURN included as the // second output was corrupted in some way. ErrSSGenBadVotePush // ErrSSGenBadGenOuts indicates that the something was wrong with the // stake generation outputs that were present after the first two // OP_RETURN pushes in an SSGen tx. ErrSSGenBadGenOuts // ErrSSRtxWrongNumInputs indicates that a given SSRtx contains an // invalid number of inputs. ErrSSRtxWrongNumInputs // ErrSSRtxTooManyOutputs indicates that a given SSRtx contains too many // outputs. ErrSSRtxTooManyOutputs // ErrSSRtxNoOutputs indicates that a given SSRtx has no outputs. ErrSSRtxNoOutputs // ErrSSRtxWrongTxTree indicates that a given SSRtx input was not found in // the stake tx tree. ErrSSRtxWrongTxTree // ErrSSRtxBadGenOuts indicates that there was a non-SSRtx tagged output // present in an SSRtx. ErrSSRtxBadOuts // ErrVerSStxAmts indicates there was an error verifying the calculated // SStx out amounts and the actual SStx out amounts. ErrVerSStxAmts // ErrVerifyInput indicates that there was an error in verification // function input. ErrVerifyInput // ErrVerifyOutType indicates that there was a non-equivalence in the // output type. ErrVerifyOutType // ErrVerifyTooMuchFees indicates that a transaction's output gave // too much in fees after taking into accounts the limits imposed // by the SStx output's version field. ErrVerifyTooMuchFees // ErrVerifySpendTooMuch indicates that a transaction's output spent more // than it was allowed to spend based on the calculated subsidy or return // for a vote or revocation. ErrVerifySpendTooMuch // ErrVerifyOutputAmt indicates that for a vote/revocation spend output, // the rule was given that it must exactly match the calculated maximum, // however the amount in the output did not (e.g. it gave fees). ErrVerifyOutputAmt // ErrVerifyOutPkhs indicates that the recipient of the P2PKH or P2SH // script was different from that indicated in the SStx input. ErrVerifyOutPkhs // ErrDatabaseCorrupt indicates a database inconsistency. ErrDatabaseCorrupt // ErrMissingDatabaseTx indicates that a node disconnection failed to // pass a database transaction when attempted to remove a very old // node. ErrMissingDatabaseTx // ErrMemoryCorruption indicates that memory has somehow become corrupt, // for example invalid block header serialization from an in memory // struct. ErrMemoryCorruption // ErrFindTicketIdxs indicates a failure to find the selected ticket // indexes from the block header. ErrFindTicketIdxs // ErrMissingTicket indicates that a ticket was missing in one of the // ticket treaps when it was attempted to be fetched. ErrMissingTicket // ErrDuplicateTicket indicates that a duplicate ticket was attempted // to be inserted into a ticket treap or the database. ErrDuplicateTicket // ErrUnknownTicketSpent indicates that an unknown ticket was spent by // the block. ErrUnknownTicketSpent )
These constants are used to identify a specific RuleError.
const ( TxTypeRegular = 0 TxTypeSStx = 1 TxTypeSSGen = 2 TxTypeSSRtx = 3 )
Possible TxTypes. Statically declare these so that they might be used in consensus code.
const ( // MaxInputsPerSStx is the maximum number of inputs allowed in an SStx. MaxInputsPerSStx = 64 // MaxOutputsPerSStx is the maximum number of outputs allowed in an SStx; // you need +1 for the tagged SStx output. MaxOutputsPerSStx = MaxInputsPerSStx*2 + 1 // NumInputsPerSSGen is the exact number of inputs for an SSGen // (stakebase) tx. Inputs are a tagged SStx output and a stakebase (null) // input. NumInputsPerSSGen = 2 // SStx and stakebase // MaxOutputsPerSSGen is the maximum number of outputs in an SSGen tx, // which are all outputs to the addresses specified in the OP_RETURNs of // the original SStx referenced as input plus reference and vote // OP_RETURN outputs in the zeroeth and first position. MaxOutputsPerSSGen = MaxInputsPerSStx + 2 // NumInputsPerSSRtx is the exact number of inputs for an SSRtx (stake // revocation tx); the only input should be the SStx output. NumInputsPerSSRtx = 1 // MaxOutputsPerSSRtx is the maximum number of outputs in an SSRtx, which // are all outputs to the addresses specified in the OP_RETURNs of the // original SStx referenced as input plus a reference to the block header // hash of the block in which voting was missed. MaxOutputsPerSSRtx = MaxInputsPerSStx // SStxPKHMinOutSize is the minimum size of of an OP_RETURN commitment output // for an SStx tx. // 20 bytes P2SH/P2PKH + 8 byte amount + 4 byte fee range limits SStxPKHMinOutSize = 32 // SStxPKHMaxOutSize is the maximum size of of an OP_RETURN commitment output // for an SStx tx. SStxPKHMaxOutSize = 77 // SSGenBlockReferenceOutSize is the size of a block reference OP_RETURN // output for an SSGen tx. SSGenBlockReferenceOutSize = 38 // SSGenVoteBitsOutputMinSize is the minimum size for a VoteBits push // in an SSGen. SSGenVoteBitsOutputMinSize = 4 // SSGenVoteBitsOutputMaxSize is the maximum size for a VoteBits push // in an SSGen. SSGenVoteBitsOutputMaxSize = 77 // MaxSingleBytePushLength is the largest maximum push for an // SStx commitment or VoteBits push. MaxSingleBytePushLength = 75 // SStxVoteReturnFractionMask extracts the return fraction from a // commitment output version. // If after applying this mask &0x003f is given, the entire amount of // the output is allowed to be spent as fees if the flag to allow fees // is set. SStxVoteReturnFractionMask = 0x003f // SStxRevReturnFractionMask extracts the return fraction from a // commitment output version. // If after applying this mask &0x3f00 is given, the entire amount of // the output is allowed to be spent as fees if the flag to allow fees // is set. SStxRevReturnFractionMask = 0x3f00 // SStxVoteFractionFlag is a bitflag mask specifying whether or not to // apply a fractional limit to the amount used for fees in a vote. // 00000000 00000000 = No fees allowed // 00000000 01000000 = Apply fees rule SStxVoteFractionFlag = 0x0040 // SStxRevFractionFlag is a bitflag mask specifying whether or not to // apply a fractional limit to the amount used for fees in a vote. // 00000000 00000000 = No fees allowed // 01000000 00000000 = Apply fees rule SStxRevFractionFlag = 0x4000 )
Variables ¶
This section is empty.
Functions ¶
func AddrFromSStxPkScrCommitment ¶ added in v0.0.8
AddrFromSStxPkScrCommitment extracts a P2SH or P2PKH address from a ticket commitment pkScript.
func AmountFromSStxPkScrCommitment ¶ added in v0.1.0
AmountFromSStxPkScrCommitment extracts a commitment amount from a ticket commitment pkScript.
func CalculateRewards ¶ added in v0.5.0
CalculateRewards takes a list of SStx adjusted output amounts, the amount used to purchase that ticket, and the reward for an SSGen tx and subsequently generates what the outputs should be in the SSGen tx. If used for calculating the outputs for an SSRtx, pass 0 for subsidy.
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.
func FindTicketIdxs ¶
func FindTicketIdxs(size int64, n int, prng *Hash256PRNG) ([]int, error)
FindTicketIdxs is the exported version of findTicketIdxs used for testing.
func IsSSGen ¶
IsSSGen returns whether or not a transaction is an SSGen tx. It does some simple validation steps to make sure the number of inputs, number of outputs, and the input/output scripts are valid.
This does NOT check to see if the subsidy is valid or whether or not the value of input[0] + subsidy = value of the outputs.
SSGen transactions are specified as below. Inputs: Stakebase null input [index 0] SStx-tagged output [index 1]
Outputs: OP_RETURN push of 40 bytes containing: [index 0]
i. 32-byte block header of block being voted on. ii. 8-byte int of this block's height.
OP_RETURN push of 2 bytes containing votebits [index 1] SSGen-tagged output to address from SStx-tagged output's tx index output 1
[index 2]
SSGen-tagged output to address from SStx-tagged output's tx index output 2
[index 3]
... SSGen-tagged output to address from SStx-tagged output's tx index output
MaxInputsPerSStx [index MaxOutputsPerSSgen - 1]
The errors in this function can be ignored if you want to use it in to identify SSGen from a list of stake tx.
func IsSSRtx ¶
IsSSRtx returns whether or not a transaction is an SSRtx. It does some simple validation steps to make sure the number of inputs, number of outputs, and the input/output scripts are valid.
SSRtx transactions are specified as below. Inputs: SStx-tagged output [index 0]
Outputs: SSGen-tagged output to address from SStx-tagged output's tx index output 1
[index 0]
SSGen-tagged output to address from SStx-tagged output's tx index output 2
[index 1]
... SSGen-tagged output to address from SStx-tagged output's tx index output
MaxInputsPerSStx [index MaxOutputsPerSSRtx - 1]
The errors in this function can be ignored if you want to use it in to identify SSRtx from a list of stake tx.
func IsSStx ¶
IsSStx returns whether or not a transaction is an SStx. It does some simple validation steps to make sure the number of inputs, number of outputs, and the input/output scripts are valid.
SStx transactions are specified as below. Inputs: untagged output 1 [index 0] untagged output 2 [index 1] ... untagged output MaxInputsPerSStx [index MaxInputsPerSStx-1]
Outputs: OP_SSTX tagged output [index 0] OP_RETURN push of input 1's address for reward receiving [index 1] OP_SSTXCHANGE tagged output for input 1 [index 2] OP_RETURN push of input 2's address for reward receiving [index 3] OP_SSTXCHANGE tagged output for input 2 [index 4] ... OP_RETURN push of input MaxInputsPerSStx's address for reward receiving
[index (MaxInputsPerSStx*2)-2]
OP_SSTXCHANGE tagged output [index (MaxInputsPerSStx*2)-1]
The output OP_RETURN pushes should be of size 20 bytes (standard address).
The errors in this function can be ignored if you want to use it in to identify SStx from a list of stake tx.
func IsStakeBase ¶
IsStakeBase returns whether or not a tx could be considered as having a topically valid stake base present.
func SSGenBlockVotedOn ¶ added in v0.5.0
SSGenBlockVotedOn takes an SSGen tx and returns the block voted on in the first OP_RETURN by hash and height.
func SSGenVoteBits ¶ added in v0.5.0
SSGenVoteBits takes an SSGen tx as input and scans through its outputs, returning the VoteBits of the index 1 output.
func SStxNullOutputAmounts ¶ added in v0.5.0
func SStxNullOutputAmounts(amounts []int64, changeAmounts []int64, amountTicket int64) (int64, []int64, error)
SStxNullOutputAmounts takes an array of input amounts, change amounts, and a ticket purchase amount, calculates the adjusted proportion from the purchase amount, stores it in an array, then returns the array. That is, for any given SStx, this function calculates the proportional outputs that any single user should receive. Returns: (1) Fees (2) Output Amounts (3) Error
func SStxStakeOutputInfo ¶ added in v0.5.0
func SStxStakeOutputInfo(outs []*MinimalOutput) ([]bool, [][]byte, []int64, []int64, [][]bool, [][]uint16)
SStxStakeOutputInfo takes an SStx as input and scans through its outputs, returning the pubkeyhashs and amounts for any NullDataTy's (future commitments to stake generation rewards).
func SetLogWriter ¶
SetLogWriter uses a specified io.Writer to output package logging info. This allows a caller to direct package logging output without needing a dependency on seelog. If the caller is also using btclog, UseLogger should be used instead.
func TxSSGenStakeOutputInfo ¶ added in v0.5.0
func TxSSGenStakeOutputInfo(tx *dcrutil.Tx, params *chaincfg.Params) ([]bool, [][]byte, []int64, error)
TxSSGenStakeOutputInfo takes an SSGen tx as input and scans through its outputs, returning the amount of the output and the PKH or SH that it was sent to.
func TxSSRtxStakeOutputInfo ¶ added in v0.5.0
func TxSSRtxStakeOutputInfo(tx *dcrutil.Tx, params *chaincfg.Params) ([]bool, [][]byte, []int64, error)
TxSSRtxStakeOutputInfo takes an SSRtx tx as input and scans through its outputs, returning the amount of the output and the pkh that it was sent to.
func TxSStxStakeOutputInfo ¶ added in v0.5.0
func TxSStxStakeOutputInfo(tx *dcrutil.Tx) ([]bool, [][]byte, []int64, []int64, [][]bool, [][]uint16)
TxSStxStakeOutputInfo takes an SStx as input and scans through its outputs, returning the pubkeyhashs and amounts for any NullDataTy's (future commitments to stake generation rewards).
func UseLogger ¶
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.
func VerifySStxAmounts ¶
VerifySStxAmounts compares a list of calculated amounts for ticket commitments to the list of commitment amounts from the actual SStx.
func VerifyStakingPkhsAndAmounts ¶
func VerifyStakingPkhsAndAmounts( sstxTypes []bool, sstxPkhs [][]byte, ssSpendAmts []int64, ssSpendTypes []bool, ssSpendPkhs [][]byte, ssSpendCalcAmts []int64, isVote bool, spendRules [][]bool, spendLimits [][]uint16) error
VerifyStakingPkhsAndAmounts takes the following:
- sstxTypes: A list of types for what the output should be (P2PK or P2SH).
- sstxPkhs: A list of payee PKHs from NullDataTy outputs of an input SStx.
- ssSpendAmts: What the payouts in an SSGen/SSRtx tx actually were.
- ssSpendTypes: A list of types for what the outputs actually were.
- ssSpendPkhs: A list of payee PKHs from OP_SSGEN tagged outputs of the SSGen or SSRtx.
- ssSpendCalcAmts: A list of payee amounts that was calculated based on the input SStx. These are the maximum possible amounts that can be transacted from this output.
- isVote: Whether this is a vote (true) or revocation (false).
- spendRules: Spending rules for each output in terms of fees allowable as extracted from the origin output Version.
- spendLimits: Spending limits for each output in terms of fees allowable as extracted from the origin output Version.
and determines if the two pairs of slices are congruent or not.
func WriteConnectedBestNode ¶ added in v0.5.0
WriteConnectedBestNode writes the newly connected best node to the database under an atomic database transaction, performing all the necessary writes to the database buckets for live, missed, and revoked tickets.
func WriteDisconnectedBestNode ¶ added in v0.5.0
func WriteDisconnectedBestNode(dbTx database.Tx, node *Node, hash chainhash.Hash, childUndoData UndoTicketDataSlice) error
WriteDisconnectedBestNode writes the newly connected best node to the database under an atomic database transaction, performing all the necessary writes to reverse the contents of the database buckets for live, missed, and revoked tickets. It does so by using the parent's block undo data to restore the original state in the database. It also drops new ticket and reversion data for any nodes that have a height higher than this one after.
Types ¶
type Hash256PRNG ¶
type Hash256PRNG struct {
// contains filtered or unexported fields
}
Hash256PRNG is a determinstic pseudorandom number generator that uses a 256-bit secure hashing function to generate random uint32s starting from an initial seed.
func NewHash256PRNG ¶
func NewHash256PRNG(seed []byte) *Hash256PRNG
NewHash256PRNG creates a pointer to a newly created hash256PRNG.
func (*Hash256PRNG) Hash256Rand ¶
func (hp *Hash256PRNG) Hash256Rand() uint32
Hash256Rand returns a uint32 random number using the pseudorandom number generator and updates the state.
func (*Hash256PRNG) StateHash ¶
func (hp *Hash256PRNG) StateHash() chainhash.Hash
StateHash returns a hash referencing the current state the deterministic PRNG.
type MinimalOutput ¶ added in v0.5.0
MinimalOutput is a struct encoding a minimally sized output for use in parsing stake related information.
func ConvertToMinimalOutputs ¶ added in v0.5.0
func ConvertToMinimalOutputs(tx *dcrutil.Tx) []*MinimalOutput
ConvertToMinimalOutputs converts a transaction to its minimal outputs derivative.
type Node ¶ added in v0.5.0
type Node struct {
// contains filtered or unexported fields
}
Node is in-memory stake data for a node. It contains a list of database updates to be written in the case that the block is inserted in the main chain database. Because of its use of immutable treap data structures, it allows for a fast, efficient in-memory representation of the ticket database for each node. It handles connection of and disconnection of new blocks simply.
Like the immutable treap structures, stake nodes themselves are considered to be immutable. The connection or disconnection of past or future nodes returns a pointer to a new stake node, which must be saved and used appropriately.
func InitDatabaseState ¶ added in v0.5.0
InitDatabaseState initializes the chain with the best state being the genesis block.
func LoadBestNode ¶ added in v0.5.0
func LoadBestNode(dbTx database.Tx, height uint32, blockHash chainhash.Hash, header wire.BlockHeader, params *chaincfg.Params) (*Node, error)
LoadBestNode is used when the blockchain is initialized, to get the initial stake node from the database bucket. The blockchain must pass the height and the blockHash to confirm that the ticket database is on the same location in the blockchain as the blockchain itself. This function also checks to ensure that the database has not failed the upgrade process and reports the current version. Upgrades are also handled by this function, when they become applicable.
func (*Node) ConnectNode ¶ added in v0.5.0
func (sn *Node) ConnectNode(header wire.BlockHeader, ticketsSpentInBlock, revokedTickets, newTickets []chainhash.Hash) (*Node, error)
ConnectNode connects a stake node to the node and returns a pointer to the stake node of the child.
func (*Node) DisconnectNode ¶ added in v0.5.0
func (sn *Node) DisconnectNode(parentHeader wire.BlockHeader, parentUtds UndoTicketDataSlice, parentTickets []chainhash.Hash, dbTx database.Tx) (*Node, error)
DisconnectNode disconnects a stake node from the node and returns a pointer to the stake node of the parent.
func (*Node) ExistsExpiredTicket ¶ added in v0.5.0
ExistsExpiredTicket returns whether or not a ticket was ever expired from the perspective of this stake node.
func (*Node) ExistsLiveTicket ¶ added in v0.5.0
ExistsLiveTicket returns whether or not a ticket exists in the live ticket treap for this stake node.
func (*Node) ExistsMissedTicket ¶ added in v0.5.0
ExistsMissedTicket returns whether or not a ticket exists in the missed ticket treap for this stake node.
func (*Node) ExistsRevokedTicket ¶ added in v0.5.0
ExistsRevokedTicket returns whether or not a ticket exists in the revoked ticket treap for this stake node.
func (*Node) FinalState ¶ added in v0.5.0
FinalState returns the final state lottery checksum of the node.
func (*Node) LiveTickets ¶ added in v0.5.0
LiveTickets returns the list of live tickets for this stake node.
func (*Node) MissedByBlock ¶ added in v0.5.0
MissedByBlock returns the tickets that were missed in this block.
func (*Node) MissedTickets ¶ added in v0.5.0
MissedTickets returns the list of missed tickets for this stake node.
func (*Node) NewTickets ¶ added in v0.5.0
NewTickets returns the stored UndoTicketDataSlice used to remove this node and restore it to the parent state.
func (*Node) RevokedTickets ¶ added in v0.5.0
RevokedTickets returns the list of revoked tickets for this stake node.
func (*Node) SpentByBlock ¶ added in v0.5.0
SpentByBlock returns the tickets that were spent in this block.
func (*Node) UndoData ¶ added in v0.5.0
func (sn *Node) UndoData() UndoTicketDataSlice
UndoData returns the stored UndoTicketDataSlice used to remove this node and restore it to the parent state.
type RuleError ¶ added in v0.0.4
type RuleError struct { ErrorCode ErrorCode // Describes the kind of error Description string // Human readable description of the issue }
RuleError identifies a rule violation. It is used to indicate that processing of a block or transaction failed due to one of the many validation rules. 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 TxType ¶
type TxType int
TxType indicates the type of tx (regular or stake type).
func DetermineTxType ¶
DetermineTxType determines the type of stake transaction a transaction is; if none, it returns that it is an assumed regular tx.
type UndoTicketDataSlice ¶ added in v0.5.0
type UndoTicketDataSlice []ticketdb.UndoTicketData
UndoTicketDataSlice is a pass through for ticketdb's UndoTicketData, which is stored in memory in the node.
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
dbnamespace
Package dbnamespace contains constants that define the database namespaces for the purpose of the blockchain, so that external callers may easily access this data.
|
Package dbnamespace contains constants that define the database namespaces for the purpose of the blockchain, so that external callers may easily access this data. |
tickettreap
Package tickettreap implements a treap data structure that is used to hold live tickets ordered by their key along with some associated data using a combination of binary search tree and heap semantics.
|
Package tickettreap implements a treap data structure that is used to hold live tickets ordered by their key along with some associated data using a combination of binary search tree and heap semantics. |