Documentation ¶
Index ¶
- Constants
- func BytesString(s uint64) string
- func UnspentOutputIndices(vouts []Vout) (unspents []int)
- type AddrPrefix
- type BlockBasic
- type BlockID
- type BlockInfo
- type BlockSubsidy
- type BlockValidation
- type BlockValidatorIndex
- type ChainParams
- type Conversion
- type HomeInfo
- type LikelyMineable
- type MPTxsByHeight
- type MPTxsByTime
- type MempoolInfo
- type MempoolInput
- type MempoolShort
- type MempoolTx
- type MempoolVin
- type NewMempoolTx
- type StatsInfo
- type TSpendVote
- type TicketIndex
- type TicketInfo
- type TicketPoolInfo
- type TimeDef
- func (t *TimeDef) DatetimeWithoutTZ() string
- func (t TimeDef) Format(layout string) string
- func (t *TimeDef) HMSTZ() string
- func (t *TimeDef) MarshalJSON() ([]byte, error)
- func (t *TimeDef) PrettyMDY() string
- func (t TimeDef) RFC3339() string
- func (t TimeDef) String() string
- func (t TimeDef) UNIX() int64
- func (t *TimeDef) UnmarshalJSON(data []byte) error
- type TrimmedBlockInfo
- type TrimmedMempoolInfo
- type TrimmedTxInfo
- type TxBasic
- type TxInID
- type TxInfo
- func (t *TxInfo) BlocksToTicketMaturity() (blocks int64)
- func (t *TxInfo) IsExpiredTicket() bool
- func (t *TxInfo) IsImmature() bool
- func (t *TxInfo) IsImmatureCoinbase() bool
- func (t *TxInfo) IsImmatureRevocation() bool
- func (t *TxInfo) IsImmatureTicket() bool
- func (t *TxInfo) IsImmatureVote() bool
- func (t *TxInfo) IsLiveTicket() bool
- func (t *TxInfo) IsRevocation() bool
- func (t *TxInfo) IsTicket() bool
- func (t *TxInfo) IsTreasuryAdd() bool
- func (t *TxInfo) IsTreasurySpend() bool
- func (t *TxInfo) IsTreasurybase() bool
- func (t *TxInfo) IsVote() bool
- type Vin
- type VoteInfo
- type VoteTally
- type VotingInfo
- type Vout
- type WebBasicBlock
- type WebsocketBlock
Constants ¶
const ( VoteReject = -1 VoteAffirm = 1 VoteMissing = 0 )
Types of votes
const ( TicketTypeStr = "Ticket" VoteTypeStr = "Vote" RevTypeStr = "Revocation" CoinbaseTypeStr = "Coinbase" // What actually happens is treasuryadd burns coins and credits the treasury // account. treasuryspend creates coins and debits the treasury account. // treasurybase is analogous to a coinbase in that it credits the treasury // without spending/burning any coins (aka creates them out of thin air, // just like coinbases do). TreasurybaseTypeStr = "Treasurybase" TreasuryAddTypeStr = "Treasury Add" TreasurySpendTypeStr = "Treasury Spend" )
These are the text representations of the various special transaction types. These strings should match the strings returned by txhelpers.TxTypeToString.
Variables ¶
This section is empty.
Functions ¶
func BytesString ¶
func UnspentOutputIndices ¶
UnspentOutputIndices finds the indices of the transaction outputs that appear unspent. The indices returned are the index within the passed slice, not within the transaction.
Types ¶
type AddrPrefix ¶
AddrPrefix represent the address name it's prefix and description
func AddressPrefixes ¶
func AddressPrefixes(params *chaincfg.Params) []AddrPrefix
AddressPrefixes generates an array AddrPrefix by using chaincfg.Params
type BlockBasic ¶
type BlockBasic struct { Height int64 `json:"height"` Hash string `json:"hash"` Version int32 `json:"version"` Size int32 `json:"size"` Valid bool `json:"valid"` MainChain bool `json:"mainchain"` Voters uint16 `json:"votes"` Transactions int `json:"tx"` IndexVal int64 `json:"windowIndex"` FreshStake uint8 `json:"tickets"` Revocations uint32 `json:"revocations"` TxCount uint32 `json:"tx_count"` BlockTime TimeDef `json:"time"` FormattedBytes string `json:"formatted_bytes"` Total float64 `json:"total"` }
BlockBasic models data for the explorer's explorer page
type BlockInfo ¶
type BlockInfo struct { *BlockBasic Confirmations int64 StakeRoot string MerkleRoot string TxAvailable bool Tx []*TrimmedTxInfo Treasury []*TrimmedTxInfo Tickets []*TrimmedTxInfo Revs []*TrimmedTxInfo Votes []*TrimmedTxInfo Misses []string Nonce uint32 VoteBits uint16 FinalState string PoolSize uint32 Bits string SBits float64 Difficulty float64 ExtraData string StakeVersion uint32 PreviousHash string NextHash string TotalSent float64 MiningFee float64 TotalMixed int64 StakeValidationHeight int64 Subsidy *chainjson.GetBlockSubsidyResult }
BlockInfo models data for display on the block page
type BlockSubsidy ¶
type BlockSubsidy struct { Total int64 `json:"total"` PoW int64 `json:"pow"` PoS int64 `json:"pos"` }
BlockSubsidy is an implementation of chainjson.GetBlockSubsidyResult
type BlockValidation ¶
type BlockValidation struct { Hash string `json:"hash"` Height int64 `json:"height"` Validity bool `json:"validity"` }
BlockValidation models data about a vote's decision on a block
func (*BlockValidation) ForBlock ¶
func (v *BlockValidation) ForBlock(blockHash string) bool
ForBlock indicates if the validation choice is for the specified block.
type BlockValidatorIndex ¶
type BlockValidatorIndex map[string]TicketIndex
BlockValidatorIndex keeps a list of arbitrary indexes for unique combinations of block hash and the ticket being spent to validate the block, i.e. map[validatedBlockHash]map[ticketHash]index.
type ChainParams ¶
type ChainParams struct { WindowSize int64 `json:"window_size"` RewardWindowSize int64 `json:"reward_window_size"` TargetPoolSize int64 `json:"target_pool_size"` BlockTime int64 `json:"target_block_time"` MeanVotingBlocks int64 }
ChainParams models simple data about the chain server's parameters used for some info on the front page.
type Conversion ¶
Conversion is a representation of some amount of DCR in another index.
type HomeInfo ¶
type HomeInfo struct { CoinSupply int64 `json:"coin_supply"` MixedPercent float64 `json:"mixed_percent"` StakeDiff float64 `json:"sdiff"` NextExpectedStakeDiff float64 `json:"next_expected_sdiff"` NextExpectedBoundsMin float64 `json:"next_expected_min"` NextExpectedBoundsMax float64 `json:"next_expected_max"` IdxBlockInWindow int `json:"window_idx"` IdxInRewardWindow int `json:"reward_idx"` Difficulty float64 `json:"difficulty"` TicketReward float64 `json:"reward"` RewardPeriod string `json:"reward_period"` ASR float64 `json:"ASR"` NBlockSubsidy BlockSubsidy `json:"subsidy"` Params ChainParams `json:"params"` PoolInfo TicketPoolInfo `json:"pool_info"` TotalLockedDCR float64 `json:"total_locked_dcr"` HashRate float64 `json:"hash_rate"` HashRateChangeDay float64 `json:"hash_rate_change_day"` HashRateChangeMonth float64 `json:"hash_rate_change_month"` ExchangeRate *Conversion `json:"exchange_rate,omitempty"` }
HomeInfo represents data used for the home page
type LikelyMineable ¶
type LikelyMineable struct { Total float64 `json:"total"` Size int32 `json:"size"` FormattedSize string `json:"formatted_size"` RegularTotal float64 `json:"regular_total"` TicketTotal float64 `json:"ticket_total"` VoteTotal float64 `json:"vote_total"` RevokeTotal float64 `json:"revoke_total"` TSpendTotal float64 `json:"tspend_total"` TAddTotal float64 `json:"tadd_total"` Count int `json:"count"` }
LikelyMineable holds the totals for all mempool transactions except for votes on non-tip blocks and multiple votes that spend the same ticket.
type MPTxsByHeight ¶
type MPTxsByHeight []MempoolTx
func (MPTxsByHeight) Len ¶
func (votes MPTxsByHeight) Len() int
func (MPTxsByHeight) Less ¶
func (votes MPTxsByHeight) Less(i, j int) bool
func (MPTxsByHeight) Swap ¶
func (votes MPTxsByHeight) Swap(i, j int)
type MPTxsByTime ¶
type MPTxsByTime []MempoolTx
func (MPTxsByTime) Len ¶
func (txs MPTxsByTime) Len() int
func (MPTxsByTime) Less ¶
func (txs MPTxsByTime) Less(i, j int) bool
func (MPTxsByTime) Swap ¶
func (txs MPTxsByTime) Swap(i, j int)
type MempoolInfo ¶
type MempoolInfo struct { sync.RWMutex MempoolShort Transactions []MempoolTx `json:"tx"` Tickets []MempoolTx `json:"tickets"` Votes []MempoolTx `json:"votes"` Revocations []MempoolTx `json:"revs"` TSpends []MempoolTx `json:"tspends"` TAdds []MempoolTx `json:"tadds"` Ident uint64 `json:"id"` }
MempoolInfo models data to update mempool info on the home page.
func (*MempoolInfo) DeepCopy ¶
func (mpi *MempoolInfo) DeepCopy() *MempoolInfo
DeepCopy makes a deep copy of MempoolInfo, where all the slice and map data are copied over.
func (*MempoolInfo) Trim ¶
func (mpi *MempoolInfo) Trim() *TrimmedMempoolInfo
Trim converts the MempoolInfo to TrimmedMempoolInfo.
type MempoolInput ¶
type MempoolInput struct { TxId string `json:"txid"` Index uint32 `json:"index"` Outdex uint32 `json:"vout"` }
MempoolInput is basic information about a transaction input.
func MsgTxMempoolInputs ¶
func MsgTxMempoolInputs(msgTx *wire.MsgTx) (inputs []MempoolInput)
MsgTxMempoolInputs parses a MsgTx and creates a list of MempoolInput.
type MempoolShort ¶
type MempoolShort struct { LastBlockHeight int64 `json:"block_height"` LastBlockHash string `json:"block_hash"` LastBlockTime int64 `json:"block_time"` FormattedBlockTime string `json:"formatted_block_time"` Time int64 `json:"time"` TotalOut float64 `json:"total"` TotalSize int32 `json:"size"` NumTickets int `json:"num_tickets"` NumVotes int `json:"num_votes"` NumRegular int `json:"num_regular"` NumRevokes int `json:"num_revokes"` NumTSpends int `json:"num_tspends"` NumTAdds int `json:"num_tadds"` NumAll int `json:"num_all"` LikelyMineable LikelyMineable `json:"likely_mineable"` LatestTransactions []MempoolTx `json:"latest"` FormattedTotalSize string `json:"formatted_size"` TicketIndexes BlockValidatorIndex `json:"-"` VotingInfo VotingInfo `json:"voting_info"` InvRegular map[string]struct{} `json:"-"` InvStake map[string]struct{} `json:"-"` }
MempoolShort represents the mempool data sent as the mempool update
func (*MempoolShort) DeepCopy ¶
func (mps *MempoolShort) DeepCopy() *MempoolShort
type MempoolTx ¶
type MempoolTx struct { TxID string `json:"txid"` Version int32 `json:"version"` Fees float64 `json:"fees"` FeeRate float64 `json:"fee_rate"` // Consider atom representation: //FeeAmount int64 `json:"fee_amount"` VinCount int `json:"vin_count"` VoutCount int `json:"vout_count"` Vin []MempoolInput `json:"vin,omitempty"` Coinbase bool `json:"coinbase"` // to signal the coinbase tx on new block despite not being in mempool Hash string `json:"hash"` // dup of TxID? Time int64 `json:"time"` Size int32 `json:"size"` TotalOut float64 `json:"total"` // Consider atom representation: //TotalOutAmt int64 `json:"total_amount"` Type string `json:"Type"` TypeID int `json:"typeID"` // stake package types VoteInfo *VoteInfo `json:"vote_info,omitempty"` }
MempoolTx models the tx basic data for the mempool page
func CopyMempoolTxSlice ¶
type MempoolVin ¶
type MempoolVin struct { TxId string Inputs []MempoolInput }
MempoolVin is minimal information about the inputs of a mempool transaction.
type NewMempoolTx ¶
NewMempoolTx models data sent from the notification handler
type StatsInfo ¶
type StatsInfo struct { UltimateSupply int64 TotalSupply int64 TotalSupplyPercentage float64 PoWDiff float64 HashRate float64 BlockReward int64 NextBlockReward int64 PoWReward int64 PoSReward int64 VotesInMempool int TicketsInMempool int TicketPrice float64 NextEstimatedTicketPrice float64 TicketPoolSize uint32 TicketPoolSizePerToTarget float64 TicketPoolValue float64 TPVOfTotalSupplyPeecentage float64 TicketsROI float64 RewardPeriod string ASR float64 APR float64 IdxBlockInWindow int WindowSize int64 BlockTime int64 IdxInRewardWindow int RewardWindowSize int64 }
StatsInfo represents all of the data for the stats page.
type TSpendVote ¶
TSpendVote describes how a SSGen transaction decided on a tspend.
func ConvertTSpendVotes ¶
func ConvertTSpendVotes(tspendChoices []*txhelpers.TSpendVote) []*TSpendVote
ConvertTSpendVotes converts into the api's TSpendVote format.
type TicketIndex ¶
TicketIndex is used to assign an index to a ticket hash.
type TicketInfo ¶
type TicketInfo struct { TicketMaturity int64 TimeTillMaturity float64 // Time before a particular ticket reaches maturity, in hours PoolStatus string SpendStatus string LotteryBlock string // If the ticket was chosen to vote, it was chosen to vote in this block. TicketPoolSize int64 // Total number of ticket in the pool TicketExpiry int64 // Total number of blocks before a ticket expires TicketExpiryDaysLeft float64 // Approximate days left before the given ticket expires TicketLiveBlocks int64 // Total number of confirms after maturity and up until the point the ticket votes or expires BestLuck int64 // Best possible Luck for voting AvgLuck int64 // Average Luck for voting VoteLuck float64 // Actual Luck for voting on a ticket LuckStatus string // Short description based on the VoteLuck Probability float64 // Probability of success before ticket expires }
TicketInfo is used to represent data shown for a sstx transaction.
type TicketPoolInfo ¶
type TicketPoolInfo struct { Size uint32 `json:"size"` Value float64 `json:"value"` ValAvg float64 `json:"valavg"` Percentage float64 `json:"percent"` Target uint32 `json:"target"` PercentTarget float64 `json:"percent_target"` }
TicketPoolInfo describes the live ticket pool
type TimeDef ¶
TimeDef is time.Time wrapper that formats time by default as a string without a timezone. The time Stringer interface formats the time into a string with a timezone.
func NewTimeDef ¶
NewTimeDef constructs a TimeDef from the given time.Time. It presets the timezone for formatting to UTC.
func NewTimeDefFromUNIX ¶
NewTimeDefFromUNIX constructs a TimeDef from the given UNIX epoch time stamp in seconds. It presets the timezone for formatting to UTC.
func (*TimeDef) DatetimeWithoutTZ ¶
DatetimeWithoutTZ formats the time in a human-friendly layout, without time zone.
func (*TimeDef) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*TimeDef) PrettyMDY ¶
PrettyMDY formats the time down to day only, using 3 day month, unpadded day, comma, and 4 digit year.
func (TimeDef) String ¶
String formats the time in a human-friendly layout. This ends up on the explorer web pages.
func (*TimeDef) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type TrimmedBlockInfo ¶
type TrimmedBlockInfo struct { Time TimeDef Height int64 Total float64 Fees float64 Subsidy *chainjson.GetBlockSubsidyResult Votes []*TrimmedTxInfo Tickets []*TrimmedTxInfo Revocations []*TrimmedTxInfo Transactions []*TrimmedTxInfo }
TrimmedBlockInfo models data needed to display block info on the new home page
type TrimmedMempoolInfo ¶
type TrimmedMempoolInfo struct { Transactions []*TrimmedTxInfo Tickets []*TrimmedTxInfo Votes []*TrimmedTxInfo Revocations []*TrimmedTxInfo TSpends []*TrimmedTxInfo TAdds []*TrimmedTxInfo Subsidy BlockSubsidy Total float64 Time int64 Fees float64 }
TrimmedMempoolInfo is mempool data for the home page.
type TrimmedTxInfo ¶
TrimmedTxInfo for use with /visualblocks
func FilterRegularTx ¶
func FilterRegularTx(txs []*TrimmedTxInfo) (transactions []*TrimmedTxInfo)
FilterRegularTx returns a slice of all the regular (non-stake) transactions in the input slice, excluding coinbase (reward) transactions.
func FilterUniqueLastBlockVotes ¶
func FilterUniqueLastBlockVotes(txs []*TrimmedTxInfo) (votes []*TrimmedTxInfo)
FilterUniqueLastBlockVotes returns a slice of all the vote transactions from the input slice that are flagged as voting on the previous block.
func TrimMempoolTx ¶
func TrimMempoolTx(tx *MempoolTx) (trimmedTx *TrimmedTxInfo)
TrimMempoolTx converts the input []MempoolTx to a []*TrimmedTxInfo.
func TrimMempoolTxs ¶
func TrimMempoolTxs(txs []MempoolTx) []*TrimmedTxInfo
TrimMempoolTxs converts the input []MempoolTx to a []*TrimmedTxInfo.
type TxBasic ¶
type TxBasic struct { TxID string Type string Version int32 FormattedSize string Total float64 Fee dcrutil.Amount FeeRate dcrutil.Amount VoteInfo *VoteInfo Coinbase bool Treasurybase bool MixCount uint32 MixDenom int64 }
TxBasic models data for transactions on the block page
type TxInfo ¶
type TxInfo struct { *TxBasic SpendingTxns []TxInID Vin []Vin Vout []Vout BlockHeight int64 BlockIndex uint32 BlockHash string BlockMiningFee int64 Confirmations int64 Time TimeDef Mature string VoteFundsLocked string Maturity int64 // Total number of blocks before mature MaturityTimeTill float64 // Time in hours until mature TSpendMeta *dbtypes.TreasurySpendMetaData TicketInfo }
TxInfo models data needed for display on the tx page
func (*TxInfo) BlocksToTicketMaturity ¶
BlocksToTicketMaturity will return 0 if this isn't an immature ticket.
func (*TxInfo) IsExpiredTicket ¶
IsExpiredTicket verifies the conditions: 1. is a ticket, 2. is mature, 3. hasn't voted, 4. is past expiration.
func (*TxInfo) IsImmature ¶
IsImmature indicates if the transaction is immature
func (*TxInfo) IsImmatureCoinbase ¶
IsImmatureCoinbase verifies the conditions: 1. is coinbase, 2. is not mature.
func (*TxInfo) IsImmatureRevocation ¶
IsImmatureRevocation verifies the conditions: 1. is a revocation, 2. is not mature.
func (*TxInfo) IsImmatureTicket ¶
IsImmatureTicket verifies the conditions: 1. is a ticket, 2. is not mature.
func (*TxInfo) IsImmatureVote ¶
IsImmatureVote verifies the conditions: 1. is a vote, 2. is not mature.
func (*TxInfo) IsLiveTicket ¶
IsLiveTicket verifies the conditions: 1. is a ticket, 2. is mature, 3. hasn't voted, 4. isn't expired.
func (*TxInfo) IsRevocation ¶
IsRevocation checks whether this transaction is a revocation.
func (*TxInfo) IsTreasuryAdd ¶
IsTreasuryAdd checks whether this transaction is a tadd.
func (*TxInfo) IsTreasurySpend ¶
IsTreasurySpend checks whether this transaction is a tspend.
func (*TxInfo) IsTreasurybase ¶
IsTreasurybase checks whether this transaction is a treasurybase.
type Vin ¶
type Vin struct { *chainjson.Vin Addresses []string FormattedAmount string Index uint32 DisplayText string TextIsHash bool Link string }
Vin models basic data about a tx input for display
type VoteInfo ¶
type VoteInfo struct { Validation BlockValidation `json:"block_validation"` Version uint32 `json:"vote_version"` Bits uint16 `json:"vote_bits"` Choices []*txhelpers.VoteChoice `json:"vote_choices"` TicketSpent string `json:"ticket_spent"` MempoolTicketIndex int `json:"mempool_ticket_index"` ForLastBlock bool `json:"last_block"` TSpends []*TSpendVote `json:"tspend_votes,omitempty"` }
VoteInfo models data about a SSGen transaction (vote)
func (*VoteInfo) SetTicketIndex ¶
func (vi *VoteInfo) SetTicketIndex(ticketSpendInds BlockValidatorIndex)
SetTicketIndex assigns the VoteInfo an index based on the block that the vote is (in)validating and the spent ticket hash. The ticketSpendInds tracks known combinations of target block and spent ticket hash. This index is used for sorting in views and counting total unique votes for a block.
func (*VoteInfo) VotesOnBlock ¶
VotesOnBlock indicates if the vote is voting on the validity of block specified by the given hash.
type VoteTally ¶
VoteTally manages a list of bools representing the votes for a block.
func (*VoteTally) Affirmations ¶
Affirmations counts the number of selected ticket holders who have voted in favor of the block for the given hash.
type VotingInfo ¶
type VotingInfo struct { TicketsVoted uint16 `json:"tickets_voted"` MaxVotesPerBlock uint16 `json:"max_votes_per_block"` VotedTickets map[string]bool `json:"-"` // VoteTallys maps block hash to vote counts. VoteTallys map[string]*VoteTally `json:"vote_tally"` }
VotingInfo models data about the validity of the next block from mempool.
func NewVotingInfo ¶
func NewVotingInfo(votesPerBlock uint16) VotingInfo
NewVotingInfo initializes a VotingInfo.
func (*VotingInfo) BlockStatus ¶
func (vi *VotingInfo) BlockStatus(hash string) ([]int, int)
BlockStatus fetches a list of votes in mempool, for the provided block hash. If not found, a list of VoteMissing is returned.
func (*VotingInfo) Tally ¶
func (vi *VotingInfo) Tally(vinfo *VoteInfo)
Tally adds the VoteInfo to the VotingInfo.VoteTally
type Vout ¶
type Vout struct { Addresses []string Amount float64 FormattedAmount string Type string Spent bool OP_RETURN string Index uint32 Version uint16 }
Vout models basic data about a tx output for display
type WebBasicBlock ¶
type WebBasicBlock struct { Height uint32 `json:"height"` Size uint32 `json:"size"` Hash string `json:"hash"` Difficulty float64 `json:"diff"` StakeDiff float64 `json:"sdiff"` Time int64 `json:"time"` NumTx uint32 `json:"txlength"` PoolSize uint32 `json:"poolsize"` PoolValue float64 `json:"poolvalue"` PoolValAvg float64 `json:"poolvalavg"` PoolWinners []string `json:"winners"` }
WebBasicBlock is used for quick DB data without rpc calls
type WebsocketBlock ¶
WebsocketBlock wraps the new block info for use in the websocket