Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateHashRate(difficulty, targetTimePerBlock float64) float64
- func CalculateWindowIndex(height, stakeDiffWindowSize int64) int64
- func ChartGroupingToInterval(grouping ChartGrouping) (float64, error)
- func DevSubsidyAddress(params *chaincfg.Params) (string, error)
- func ExtractBlockTransactions(msgBlock *wire.MsgBlock, txTree int8, chainParams *chaincfg.Params, ...) ([]*Tx, [][]*Vout, []VinTxPropertyARRAY)
- type AddrTxnType
- type AddressRow
- type AgendaVoteChoices
- type Block
- type BlockDataBasic
- type BlockStatus
- type BlocksGroupedInfo
- type ChartGrouping
- type ChartsData
- type HistoryChart
- type JSONB
- type MileStone
- type PoolTicketsData
- type ProgressBarLoad
- type ScriptPubKeyData
- type ScriptSig
- type SideChain
- type SyncResult
- type TicketPoolStatus
- type TicketSpendType
- type Tx
- type UInt64Array
- type Vin
- type VinTxProperty
- type VinTxPropertyARRAY
- type VoteChoice
- type Vout
Constants ¶
const ( // InitialDBLoad is a sync where data is first loaded from the chain db into // the respective dbs currently supported. Runs on both liteMode and fullMode. // InitialDBLoad value references the first progress bar id on the status page. InitialDBLoad = "initial-load" // AddressesTableSync is a sync that runs immediately after initialDBLoad. Data // previously loaded into vins table is sync'd with the addresses table. // Runs only in fullMode. AddressesTableSync value references the second // progress bar id on the status page. AddressesTableSync = "addresses-sync" )
Variables ¶
var AddrTxnTypes = map[AddrTxnType]string{ AddrTxnAll: "all", AddrTxnCredit: "credit", AddrTxnDebit: "debit", AddrMergedTxnDebit: "merged_debit", AddrTxnUnknown: "unknown", }
AddrTxnTypes is the canonical mapping from AddrTxnType to string.
var ChartGroupings = map[ChartGrouping]string{ AllChartGrouping: "all", YearChartGrouping: "yr", MonthChartGrouping: "mo", WeekChartGrouping: "wk", DayChartGrouping: "day", }
ChartGroupings helps maping a given chart grouping to its standard string value.
Functions ¶
func CalculateHashRate ¶
CalculateHashRate calculates the hashrate from the difficulty value and the targetTimePerBlock in seconds. The hashrate returned is in form PetaHash per second (PH/s).
func CalculateWindowIndex ¶
CalculateWindowIndex calculates the window index from the quotient of a block height and the chainParams.StakeDiffWindowSize.
func ChartGroupingToInterval ¶
func ChartGroupingToInterval(grouping ChartGrouping) (float64, error)
ChartGroupingToInterval converts the chartGrouping value to an actual time interval based on the gregorian calendar. AllChartGrouping returns 1 while the unknown chartGrouping returns -1 and an error. All the other time interval values is returned in terms of seconds.
func DevSubsidyAddress ¶
DevSubsidyAddress returns the development subsidy address for the specified network.
func ExtractBlockTransactions ¶
func ExtractBlockTransactions(msgBlock *wire.MsgBlock, txTree int8, chainParams *chaincfg.Params, isValid, isMainchain bool) ([]*Tx, [][]*Vout, []VinTxPropertyARRAY)
ExtractBlockTransactions extracts transaction information from a wire.MsgBlock and returns the processed information in slices of the dbtypes Tx, Vout, and VinTxPropertyARRAY.
Types ¶
type AddrTxnType ¶
type AddrTxnType int
AddrTxnType enumerates the different transaction types as displayed by the address page.
const ( AddrTxnAll AddrTxnType = iota AddrTxnCredit AddrTxnDebit AddrMergedTxnDebit AddrTxnUnknown )
func AddrTxnTypeFromStr ¶
func AddrTxnTypeFromStr(txnType string) AddrTxnType
AddrTxnTypeFromStr attempts to decode a string into an AddrTxnType.
func (AddrTxnType) String ¶
func (a AddrTxnType) String() string
type AddressRow ¶
type AddressRow struct { // id int64 Address string ValidMainChain bool // MatchingTxHash provides the relationship between spending tx inputs and // funding tx outputs. MatchingTxHash string IsFunding bool TxBlockTime uint64 TxHash string TxVinVoutIndex uint32 Value uint64 VinVoutDbID uint64 MergedDebitCount uint64 TxType int16 }
AddressRow represents a row in the addresses table
type AgendaVoteChoices ¶
type AgendaVoteChoices struct { Abstain []uint64 `json:"abstain"` Yes []uint64 `json:"yes"` No []uint64 `json:"no"` Total []uint64 `json:"total"` Height []uint64 `json:"height,omitempty"` Time []uint64 `json:"time,omitempty"` }
AgendaVoteChoices contains the vote counts on multiple intervals of time. The interval length may be either a single block, in which case Height contains the block heights, or a day, in which case Time contains the time stamps of each interval. Total is always the sum of Yes, No, and Abstain.
type Block ¶
type Block struct { Hash string `json:"hash"` Size uint32 `json:"size"` Height uint32 `json:"height"` Version uint32 `json:"version"` MerkleRoot string `json:"merkleroot"` StakeRoot string `json:"stakeroot"` NumTx uint32 NumRegTx uint32 Tx []string `json:"tx"` TxDbIDs []uint64 NumStakeTx uint32 STx []string `json:"stx"` STxDbIDs []uint64 Time uint64 `json:"time"` Nonce uint64 `json:"nonce"` VoteBits uint16 `json:"votebits"` FinalState []byte `json:"finalstate"` Voters uint16 `json:"voters"` FreshStake uint8 `json:"freshstake"` Revocations uint8 `json:"revocations"` PoolSize uint32 `json:"poolsize"` Bits uint32 `json:"bits"` SBits uint64 `json:"sbits"` Difficulty float64 `json:"difficulty"` ExtraData []byte `json:"extradata"` StakeVersion uint32 `json:"stakeversion"` PreviousHash string `json:"previousblockhash"` }
Block models a Decred block.
type BlockDataBasic ¶
type BlockDataBasic struct { Height uint32 `json:"height,omitemtpy"` Size uint32 `json:"size,omitemtpy"` Hash string `json:"hash,omitemtpy"` Difficulty float64 `json:"diff,omitemtpy"` StakeDiff float64 `json:"sdiff,omitemtpy"` Time int64 `json:"time,omitemtpy"` NumTx uint32 `json:"txlength,omitempty"` }
type BlockStatus ¶
type BlockStatus struct { IsValid bool `json:"is_valid"` IsMainchain bool `json:"is_mainchain"` Height uint32 `json:"height"` PrevHash string `json:"previous_hash"` Hash string `json:"hash"` NextHash string `json:"next_hash"` }
BlockStatus describes a block's status in the block chain.
type BlocksGroupedInfo ¶
type BlocksGroupedInfo struct { // intrinsic properties WindowIndx int64 EndBlock int64 Difficulty float64 TicketPrice int64 StartTime int64 Size int64 FormattedTime string FormattedSize string // Aggregate properties Voters uint64 Transactions uint64 FreshStake uint64 Revocations uint64 BlocksCount int64 }
BlocksGroupedInfo contains the data about a stake difficulty (ticket price) window, including intrinsic properties (e.g. window index, ticket price, start block, etc.), and aggregate transaction counts (e.g. number of votes, regular transactions, new tickets, etc.)
type ChartGrouping ¶
type ChartGrouping int8
ChartGrouping defines the possible ways that a graph's axis can be grouped according to all, year, month, week or day grouping.
const ( AllChartGrouping ChartGrouping = iota YearChartGrouping MonthChartGrouping WeekChartGrouping DayChartGrouping UnknownGrouping )
func ChartGroupingFromStr ¶
func ChartGroupingFromStr(groupings string) ChartGrouping
ChartGroupingFromStr converts groupings string to its respective chartGrouping value.
func (ChartGrouping) String ¶
func (g ChartGrouping) String() string
type ChartsData ¶
type ChartsData struct { TimeStr []string `json:"timestr,omitempty"` Difficulty []float64 `json:"difficulty,omitempty"` Time []uint64 `json:"time,omitempty"` Value []uint64 `json:"value,omitempty"` Size []uint64 `json:"size,omitempty"` ChainSize []uint64 `json:"chainsize,omitempty"` Count []uint64 `json:"count,omitempty"` SizeF []float64 `json:"sizef,omitempty"` ValueF []float64 `json:"valuef,omitempty"` Unspent []uint64 `json:"unspent,omitempty"` Revoked []uint64 `json:"revoked,omitempty"` Height []uint64 `json:"height,omitempty"` Pooled []uint64 `json:"pooled,omitempty"` Solo []uint64 `json:"solo,omitempty"` SentRtx []uint64 `json:"sentRtx,omitempty"` ReceivedRtx []uint64 `json:"receivedRtx,omitempty"` Tickets []uint64 `json:"tickets,omitempty"` Votes []uint64 `json:"votes,omitempty"` RevokeTx []uint64 `json:"revokeTx,omitempty"` Amount []float64 `json:"amount,omitempty"` Received []float64 `json:"received,omitempty"` Sent []float64 `json:"sent,omitempty"` Net []float64 `json:"net,omitempty"` }
ChartsData defines the fields that store the values needed to plot the charts on the frontend.
type HistoryChart ¶
type HistoryChart int8
HistoryChart is used to differentaite the three distinct graphs that appear on the address history page.
const ( TxsType HistoryChart = iota AmountFlow TotalUnspent ChartUnknown )
type JSONB ¶
type JSONB map[string]interface{}
JSONB is used to implement the sql.Scanner and driver.Valuer interfaces required for the type to make a postgresql compatible JSONB type.
type MileStone ¶
MileStone defines the various stages passed by vote on a given agenda. Activated is the height at which the delay time begins before a vote activates. HardForked is the height at which the consensus rule changes. LockedIn is the height at which voting on an agenda is consided complete.
type PoolTicketsData ¶
type PoolTicketsData struct { Time []uint64 `json:"time,omitempty"` Price []float64 `json:"price,omitempty"` Mempool []uint64 `json:"mempool,omitempty"` Immature []uint64 `json:"immature,omitempty"` Live []uint64 `json:"live,omitempty"` Solo uint64 `json:"solo,omitempty"` Pooled uint64 `json:"pooled,omitempty"` TxSplit uint64 `json:"txsplit,omitempty"` }
PoolTicketsData defines the real time data needed for ticket pool visualization charts.
type ProgressBarLoad ¶
type ProgressBarLoad struct { From int64 To int64 Msg string Subtitle string BarID string Timestamp int64 }
ProgressBarLoad contains the raw data needed to populate the status sync updates. It is used to update the status sync through a channel.
type ScriptPubKeyData ¶
type ScriptPubKeyData struct { ReqSigs uint32 `json:"reqSigs"` Type string `json:"type"` Addresses []string `json:"addresses"` }
ScriptPubKeyData is part of the result of decodescript(ScriptPubKeyHex)
type ScriptSig ¶
ScriptSig models the signature script used to redeem the origin transaction as a JSON object (non-coinbase txns only)
type SyncResult ¶
SyncResult is the result of a database sync operation, containing the height of the last block and an arror value.
type TicketPoolStatus ¶
type TicketPoolStatus int16
const ( PoolStatusLive TicketPoolStatus = iota PoolStatusVoted PoolStatusExpired PoolStatusMissed )
NB:PoolStatusLive also defines immature tickets in addition to defining live tickets.
func (TicketPoolStatus) String ¶
func (p TicketPoolStatus) String() string
type TicketSpendType ¶
type TicketSpendType int16
const ( TicketUnspent TicketSpendType = iota TicketRevoked TicketVoted )
func (TicketSpendType) String ¶
func (p TicketSpendType) String() string
type Tx ¶
type Tx struct { //blockDbID int64 BlockHash string `json:"block_hash"` BlockHeight int64 `json:"block_height"` BlockTime int64 `json:"block_time"` Time int64 `json:"time"` TxType int16 `json:"tx_type"` Version uint16 `json:"version"` Tree int8 `json:"tree"` TxID string `json:"txid"` BlockIndex uint32 `json:"block_index"` Locktime uint32 `json:"locktime"` Expiry uint32 `json:"expiry"` Size uint32 `json:"size"` Spent int64 `json:"spent"` Sent int64 `json:"sent"` Fees int64 `json:"fees"` NumVin uint32 `json:"numvin"` //Vins VinTxPropertyARRAY `json:"vins"` VinDbIds []uint64 `json:"vindbids"` NumVout uint32 `json:"numvout"` Vouts []*Vout `json:"vouts"` VoutDbIds []uint64 `json:"voutdbids"` // NOTE: VoutDbIds may not be needed if there is a vout table since each // vout will have a tx_dbid IsValidBlock bool `json:"valid_block"` IsMainchainBlock bool `json:"mainchain"` }
Tx models a Decred transaction. It is stored in a Block.
type UInt64Array ¶
type UInt64Array []uint64
UInt64Array represents a one-dimensional array of PostgreSQL integer types
func (*UInt64Array) Scan ¶
func (a *UInt64Array) Scan(src interface{}) error
Scan implements the sql.Scanner interface.
type Vin ¶
type Vin struct { //txDbID int64 Coinbase string `json:"coinbase"` TxHash string `json:"txhash"` VoutIdx uint32 `json:"voutidx"` Tree int8 `json:"tree"` Sequence uint32 `json:"sequence"` AmountIn float64 `json:"amountin"` BlockHeight uint32 `json:"blockheight"` BlockIndex uint32 `json:"blockindex"` ScriptHex string `json:"scripthex"` }
Vin models a transaction input.
type VinTxProperty ¶
type VinTxProperty struct { PrevOut string `json:"prevout"` PrevTxHash string `json:"prevtxhash"` PrevTxIndex uint32 `json:"prevvoutidx"` PrevTxTree uint16 `json:"tree"` Sequence uint32 `json:"sequence"` ValueIn int64 `json:"amountin"` TxID string `json:"tx_hash"` TxIndex uint32 `json:"tx_index"` TxTree uint16 `json:"tx_tree"` TxType int16 `json:"tx_type"` BlockHeight uint32 `json:"blockheight"` BlockIndex uint32 `json:"blockindex"` ScriptHex []byte `json:"scripthex"` IsValid bool `json:"is_valid"` IsMainchain bool `json:"is_mainchain"` Time int64 `json:"time"` }
VinTxProperty models a transaction input with previous outpoint information.
type VinTxPropertyARRAY ¶
type VinTxPropertyARRAY []VinTxProperty
VinTxPropertyARRAY is a slice of VinTxProperty sturcts that implements sql.Scanner and driver.Valuer.
func (*VinTxPropertyARRAY) Scan ¶
func (p *VinTxPropertyARRAY) Scan(src interface{}) error
Scan satisfies sql.Scanner
type VoteChoice ¶
type VoteChoice uint8
VoteChoice defines the type of vote choice, and the undelying integer value is stored in the database (do not change these without upgrading the DB!).
const ( Yes VoteChoice = iota Abstain No VoteChoiceUnknown )
func ChoiceIndexFromStr ¶
func ChoiceIndexFromStr(choice string) (VoteChoice, error)
ChoiceIndexFromStr converts the vote choice string to a vote choice index.
func (VoteChoice) String ¶
func (v VoteChoice) String() string
type Vout ¶
type Vout struct { // txDbID int64 TxHash string `json:"tx_hash"` TxIndex uint32 `json:"tx_index"` TxTree int8 `json:"tx_tree"` TxType int16 `json:"tx_type"` Value uint64 `json:"value"` Version uint16 `json:"version"` ScriptPubKey []byte `json:"pkScriptHex"` ScriptPubKeyData ScriptPubKeyData `json:"pkScript"` }
Vout defines a transaction output