types

package
v8.0.0-...-e9c7312 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: ISC Imports: 13 Imported by: 2

Documentation

Index

Constants

View Source
const (
	VoteReject  = -1
	VoteAffirm  = 1
	VoteMissing = 0
)

Types of votes

View Source
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 BytesString(s uint64) string

func UnspentOutputIndices

func UnspentOutputIndices(vouts []Vout) (unspents []int)

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

type AddrPrefix struct {
	Name        string
	Prefix      string
	Description string
}

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 BlockID

type BlockID struct {
	Hash   string
	Height int64
	Time   int64
}

BlockID provides basic identifying information about a block.

type BlockInfo

type BlockInfo struct {
	*BlockBasic
	Confirmations         int64
	PoWHash               string
	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"`
	Dev   int64 `json:"dev"`
}

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

type Conversion struct {
	Value float64 `json:"value"`
	Index string  `json:"index"`
}

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"`
	DevFund               int64                    `json:"dev_fund"` // legacy treasury address
	DevAddress            string                   `json:"dev_address"`
	TreasuryBalance       *dbtypes.TreasuryBalance `json:"treasury_bal"` // new decentralized treasury account
	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) ID

func (mpi *MempoolInfo) ID() uint64

ID can be used to track state changes.

func (*MempoolInfo) Trim

func (mpi *MempoolInfo) Trim() *TrimmedMempoolInfo

Trim converts the MempoolInfo to TrimmedMempoolInfo.

func (*MempoolInfo) Tx

func (mpi *MempoolInfo) Tx(txid string) (MempoolTx, bool)

Tx checks the inventory and searches the appropriate lists for a transaction matching the provided transaction ID.

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

func CopyMempoolTxSlice(s []MempoolTx) []MempoolTx

func (*MempoolTx) DeepCopy

func (mpt *MempoolTx) DeepCopy() *MempoolTx

type MempoolVin

type MempoolVin struct {
	TxId   string
	Inputs []MempoolInput
}

MempoolVin is minimal information about the inputs of a mempool transaction.

type NewMempoolTx

type NewMempoolTx struct {
	Time int64
	Hex  string
}

NewMempoolTx models data sent from the notification handler

type StatsInfo

type StatsInfo struct {
	UltimateSupply             int64
	TotalSupply                int64
	TotalSupplyPercentage      float64
	ProjectFunds               int64
	ProjectAddress             string
	PoWDiff                    float64
	HashRate                   float64
	BlockReward                int64
	NextBlockReward            int64
	PoWReward                  int64
	PoSReward                  int64
	ProjectFundReward          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

type TSpendVote struct {
	TSpend string `json:"tspend"`
	Choice string `json:"choice"`
}

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

type TicketIndex map[string]int

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

type TimeDef struct {
	T time.Time
}

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

func NewTimeDef(t time.Time) TimeDef

NewTimeDef constructs a TimeDef from the given time.Time. It presets the timezone for formatting to UTC.

func NewTimeDefFromUNIX

func NewTimeDefFromUNIX(t int64) TimeDef

NewTimeDefFromUNIX constructs a TimeDef from the given UNIX epoch time stamp in seconds. It presets the timezone for formatting to UTC.

func (*TimeDef) DatetimeWithoutTZ

func (t *TimeDef) DatetimeWithoutTZ() string

DatetimeWithoutTZ formats the time in a human-friendly layout, without time zone.

func (TimeDef) Format

func (t TimeDef) Format(layout string) string

func (*TimeDef) HMSTZ

func (t *TimeDef) HMSTZ() string

HMSTZ is the hour:minute:second with 3-digit timezone code.

func (*TimeDef) MarshalJSON

func (t *TimeDef) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*TimeDef) PrettyMDY

func (t *TimeDef) PrettyMDY() string

PrettyMDY formats the time down to day only, using 3 day month, unpadded day, comma, and 4 digit year.

func (TimeDef) RFC3339

func (t TimeDef) RFC3339() string

RFC3339 formats the time in a machine-friendly layout.

func (TimeDef) String

func (t TimeDef) String() string

String formats the time in a human-friendly layout. This ends up on the explorer web pages.

func (TimeDef) UNIX

func (t TimeDef) UNIX() int64

UNIX returns the UNIX epoch time stamp.

func (*TimeDef) UnmarshalJSON

func (t *TimeDef) UnmarshalJSON(data []byte) error

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

type TrimmedTxInfo struct {
	*TxBasic
	Fees      float64
	VinCount  int
	VoutCount int
	VoteValid bool
}

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 TxInID

type TxInID struct {
	Hash  string
	Index uint32
}

TxInID models the identity of a spending transaction input

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

func (t *TxInfo) BlocksToTicketMaturity() (blocks int64)

BlocksToTicketMaturity will return 0 if this isn't an immature ticket.

func (*TxInfo) IsExpiredTicket

func (t *TxInfo) IsExpiredTicket() bool

IsExpiredTicket verifies the conditions: 1. is a ticket, 2. is mature, 3. hasn't voted, 4. is past expiration.

func (*TxInfo) IsImmature

func (t *TxInfo) IsImmature() bool

IsImmature indicates if the transaction is immature

func (*TxInfo) IsImmatureCoinbase

func (t *TxInfo) IsImmatureCoinbase() bool

IsImmatureCoinbase verifies the conditions: 1. is coinbase, 2. is not mature.

func (*TxInfo) IsImmatureRevocation

func (t *TxInfo) IsImmatureRevocation() bool

IsImmatureRevocation verifies the conditions: 1. is a revocation, 2. is not mature.

func (*TxInfo) IsImmatureTicket

func (t *TxInfo) IsImmatureTicket() bool

IsImmatureTicket verifies the conditions: 1. is a ticket, 2. is not mature.

func (*TxInfo) IsImmatureVote

func (t *TxInfo) IsImmatureVote() bool

IsImmatureVote verifies the conditions: 1. is a vote, 2. is not mature.

func (*TxInfo) IsLiveTicket

func (t *TxInfo) IsLiveTicket() bool

IsLiveTicket verifies the conditions: 1. is a ticket, 2. is mature, 3. hasn't voted, 4. isn't expired.

func (*TxInfo) IsRevocation

func (t *TxInfo) IsRevocation() bool

IsRevocation checks whether this transaction is a revocation.

func (*TxInfo) IsTicket

func (t *TxInfo) IsTicket() bool

IsTicket checks whether this transaction is a ticket.

func (*TxInfo) IsTreasuryAdd

func (t *TxInfo) IsTreasuryAdd() bool

IsTreasuryAdd checks whether this transaction is a tadd.

func (*TxInfo) IsTreasurySpend

func (t *TxInfo) IsTreasurySpend() bool

IsTreasurySpend checks whether this transaction is a tspend.

func (*TxInfo) IsTreasurybase

func (t *TxInfo) IsTreasurybase() bool

IsTreasurybase checks whether this transaction is a treasurybase.

func (*TxInfo) IsVote

func (t *TxInfo) IsVote() bool

IsVote checks whether this transaction is a vote.

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) DeepCopy

func (vi *VoteInfo) DeepCopy() *VoteInfo

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

func (vi *VoteInfo) VotesOnBlock(blockHash string) bool

VotesOnBlock indicates if the vote is voting on the validity of block specified by the given hash.

type VoteTally

type VoteTally struct {
	TicketsPerBlock int    `json:"-"`
	Marks           []bool `json:"marks"`
}

VoteTally manages a list of bools representing the votes for a block.

func (*VoteTally) Affirmations

func (tally *VoteTally) Affirmations() (c int)

Affirmations counts the number of selected ticket holders who have voted in favor of the block for the given hash.

func (*VoteTally) Mark

func (tally *VoteTally) Mark(vote bool)

Mark adds the vote to the VoteTally.

func (*VoteTally) Status

func (tally *VoteTally) Status() ([]int, int)

Status is a list of ints representing votes both received and not yet received for a block, and a single int representing consensus. 0: rejected, 1: affirmed, 2: vote not yet received

func (*VoteTally) VoteCount

func (tally *VoteTally) VoteCount() int

VoteCount is the number of votes received.

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
	OP_TADD         bool
	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

type WebsocketBlock struct {
	Block *BlockInfo `json:"block"`
	Extra *HomeInfo  `json:"extra"`
}

WebsocketBlock wraps the new block info for use in the websocket

Jump to

Keyboard shortcuts

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