Documentation ¶
Index ¶
- Constants
- func IsNullDataScript(name string) bool
- func IsValidScriptClass(name string) (isValid bool)
- func LessByAccessCount(bi, bj *CachedBlock) bool
- func LessByAccessCountThenHeight(bi, bj *CachedBlock) bool
- func LessByAccessTime(bi, bj *CachedBlock) bool
- func LessByHeight(bi, bj *CachedBlock) bool
- func MakeLessByAccessTimeThenCount(millisecondsBinned int64) func(bi, bj *CachedBlock) bool
- func WatchPriorityQueue(bpq *BlockPriorityQueue)
- type APICache
- func (apic *APICache) Capacity() uint32
- func (apic *APICache) Disable()
- func (apic *APICache) Enable()
- func (apic *APICache) GetBlockHash(height int64) string
- func (apic *APICache) GetBlockSize(height int64) int32
- func (apic *APICache) GetBlockSummary(height int64) *BlockDataBasic
- func (apic *APICache) GetBlockSummaryByHash(hash string) *BlockDataBasic
- func (apic *APICache) GetCachedBlockByHash(hash chainhash.Hash) *CachedBlock
- func (apic *APICache) GetCachedBlockByHashStr(hashStr string) *CachedBlock
- func (apic *APICache) GetCachedBlockByHeight(height int64) *CachedBlock
- func (apic *APICache) GetStakeInfo(height int64) *StakeInfoExtended
- func (apic *APICache) GetStakeInfoByHash(hash string) *StakeInfoExtended
- func (apic *APICache) Hits() uint64
- func (apic *APICache) IsEnabled() bool
- func (apic *APICache) Misses() uint64
- func (apic *APICache) RemoveCachedBlock(cachedBlock *CachedBlock)
- func (apic *APICache) RemoveCachedBlockByHeight(height int64)
- func (apic *APICache) SetLessFn(lessFn func(bi, bj *CachedBlock) bool)
- func (apic *APICache) StoreBlockSummary(blockSummary *BlockDataBasic) error
- func (apic *APICache) StoreStakeInfo(stakeInfo *StakeInfoExtended) error
- func (apic *APICache) Utilization() float64
- func (apic *APICache) UtilizationBlocks() int64
- type APIStatus
- type Address
- type AddressTotals
- type AddressTxRaw
- type AddressTxShort
- type AddressTxnOutput
- type AgendaAPIResponse
- type AgendasInfo
- type BlockDataBasic
- type BlockDataWithTxType
- type BlockExplorerBasic
- type BlockExplorerExtraInfo
- type BlockID
- type BlockPriorityQueue
- func (pq *BlockPriorityQueue) Insert(summary *BlockDataBasic, stakeInfo *StakeInfoExtended) (bool, *chainhash.Hash, int64)
- func (pq *BlockPriorityQueue) Len() int
- func (pq *BlockPriorityQueue) Less(i, j int) bool
- func (pq *BlockPriorityQueue) Pop() interface{}
- func (pq *BlockPriorityQueue) Push(blockData interface{})
- func (pq *BlockPriorityQueue) Reheap()
- func (pq *BlockPriorityQueue) RemoveBlock(b *CachedBlock)
- func (pq *BlockPriorityQueue) RemoveIndex(idx int)
- func (pq *BlockPriorityQueue) RescanMinMax()
- func (pq *BlockPriorityQueue) RescanMinMaxForAdd(height uint32)
- func (pq *BlockPriorityQueue) RescanMinMaxForRemove(height uint32)
- func (pq *BlockPriorityQueue) RescanMinMaxForUpdate(heightAdd, heightRemove uint32)
- func (pq *BlockPriorityQueue) ResetHeap(bh []*CachedBlock)
- func (pq *BlockPriorityQueue) SetLessFn(lessFn func(bi, bj *CachedBlock) bool)
- func (pq *BlockPriorityQueue) Swap(i, j int)
- func (pq *BlockPriorityQueue) UpdateBlock(b *CachedBlock, summary *BlockDataBasic, stakeInfo *StakeInfoExtended)
- type BlockRaw
- type BlockSubsidies
- type BlockSummarySaver
- type BlockTransactionCounts
- type BlockTransactions
- type BlockValidation
- type CachedBlock
- type CoinSupply
- type Happy
- type InsightAddr
- type InsightAddress
- type InsightAddressInfo
- type InsightBlockAddrTxSummary
- type InsightBlockResult
- type InsightBlocksSummaryResult
- type InsightMultiAddrsTx
- type InsightMultiAddrsTxOutput
- type InsightPagination
- type InsightRawTx
- type InsightScriptPubKey
- type InsightScriptSig
- type InsightTx
- type InsightVin
- type InsightVout
- type MempoolTicketDetails
- type MempoolTicketFeeInfo
- type MempoolTicketFees
- type OutPoint
- type PowerlessTicket
- type PowerlessTickets
- type PrevOut
- type PriceCountTime
- type ScriptClass
- type ScriptPubKey
- type ScriptSig
- type SpendByFundingHash
- type StakeDiff
- type StakeInfoExtended
- type StakeInfoExtendedEstimates
- type StakeInfoSaver
- type Status
- func (s *Status) API() APIStatus
- func (s *Status) DBHeight() uint32
- func (s *Status) DBUpdate(height uint32, blockTime int64)
- func (s *Status) Happy() Happy
- func (s *Status) Height() uint32
- func (s *Status) NodeConnections() int64
- func (s *Status) Ready() bool
- func (s *Status) SetConnections(conns int64)
- func (s *Status) SetHeight(height uint32)
- func (s *Status) SetReady(ready bool)
- type SyncResponse
- type TSpendVote
- type TicketDetails
- type TicketInfo
- type TicketPoolChartsData
- type TicketPoolInfo
- type TicketPoolValsAndSizes
- type TicketsDetails
- type TimeAPI
- type TinyBlock
- type TrimmedTx
- type Tx
- type TxIn
- type TxInputID
- type TxOut
- type TxRawWithTxType
- type TxRawWithVoteInfo
- type TxShort
- type Txns
- type VinPrevOut
- type VoteInfo
- type Vout
- type VoutMined
Constants ¶
const ( SecondsPerMinute int64 = 60 SecondsPerHour int64 = 60 * 60 SecondsPerDay int64 = 24 * SecondsPerHour SecondsPerWeek int64 = 7 * SecondsPerDay )
constants from time
Variables ¶
This section is empty.
Functions ¶
func IsNullDataScript ¶
IsNullDataScript indicates if the script class name is a nulldata class.
func IsValidScriptClass ¶
IsValidScriptClass indicates the the provided string corresponds to a known ScriptClass (including "nonstandard"). Note that "invalid" is not valid, although a ScriptClassInvalid value mapping to "invalid" exists.
func LessByAccessCount ¶
func LessByAccessCount(bi, bj *CachedBlock) bool
LessByAccessCount defines higher priority CachedBlock as having been accessed more often.
func LessByAccessCountThenHeight ¶
func LessByAccessCountThenHeight(bi, bj *CachedBlock) bool
LessByAccessCountThenHeight compares access count with LessByAccessCount if the blocks have different accessTime values, otherwise it compares height with LessByHeight.
func LessByAccessTime ¶
func LessByAccessTime(bi, bj *CachedBlock) bool
LessByAccessTime defines higher priority CachedBlock as having a more recent access time. More recent accesses have a larger accessTime value (Unix time).
func LessByHeight ¶
func LessByHeight(bi, bj *CachedBlock) bool
LessByHeight defines a higher priority CachedBlock as having a higher height. That is, more recent blocks have higher priority than older blocks.
func MakeLessByAccessTimeThenCount ¶
func MakeLessByAccessTimeThenCount(millisecondsBinned int64) func(bi, bj *CachedBlock) bool
MakeLessByAccessTimeThenCount will create a CachedBlock comparison function given the specified time resolution in milliseconds. Two access times less than the given time apart are considered the same time, and access count is used to break the tie.
func WatchPriorityQueue ¶
func WatchPriorityQueue(bpq *BlockPriorityQueue)
WatchPriorityQueue is a hack since the priority of a CachedBlock is modified (if access or access time is in the LessFn) without triggering a reheap.
Types ¶
type APICache ¶
type APICache struct { MainchainBlocks map[int64]chainhash.Hash // needs to be handled in reorg // contains filtered or unexported fields }
APICache maintains a fixed-capacity cache of CachedBlocks. Use NewAPICache to create the cache with the desired capacity.
func NewAPICache ¶
NewAPICache creates an APICache with the specified capacity.
func (*APICache) Disable ¶
func (apic *APICache) Disable()
Disable sets the isEnabled flag of the APICache.
func (*APICache) Enable ¶
func (apic *APICache) Enable()
Enable sets the isEnabled flag of the APICache.
func (*APICache) GetBlockHash ¶
GetBlockHash attempts to get the block hash for the main chain block at the given height. The empty string ("") is returned in the event of a cache miss.
func (*APICache) GetBlockSize ¶
GetBlockSize attempts to retrieve the block size for the input height. The return is -1 if no block with that height is cached.
func (*APICache) GetBlockSummary ¶
func (apic *APICache) GetBlockSummary(height int64) *BlockDataBasic
GetBlockSummary attempts to retrieve the block summary for the input height. The return is nil if no block with that height is cached.
func (*APICache) GetBlockSummaryByHash ¶
func (apic *APICache) GetBlockSummaryByHash(hash string) *BlockDataBasic
GetBlockSummaryByHash attempts to retrieve the block summary for the given block hash. The return is nil if no block with that hash is cached.
func (*APICache) GetCachedBlockByHash ¶
func (apic *APICache) GetCachedBlockByHash(hash chainhash.Hash) *CachedBlock
GetCachedBlockByHash attempts to fetch a CachedBlock with the given hash. The return is nil if no block with that hash is cached.
func (*APICache) GetCachedBlockByHashStr ¶
func (apic *APICache) GetCachedBlockByHashStr(hashStr string) *CachedBlock
GetCachedBlockByHashStr attempts to fetch a CachedBlock with the given hash. The return is nil if no block with that hash is cached.
func (*APICache) GetCachedBlockByHeight ¶
func (apic *APICache) GetCachedBlockByHeight(height int64) *CachedBlock
GetCachedBlockByHeight attempts to fetch a CachedBlock with the given height. The return is nil if no block with that height is cached.
func (*APICache) GetStakeInfo ¶
func (apic *APICache) GetStakeInfo(height int64) *StakeInfoExtended
GetStakeInfo attempts to retrieve the stake info for block at the the input height. The return is nil if no block with that height is cached.
func (*APICache) GetStakeInfoByHash ¶
func (apic *APICache) GetStakeInfoByHash(hash string) *StakeInfoExtended
GetStakeInfoByHash attempts to retrieve the stake info for block with the input hash. The return is nil if no block with that hash is cached.
func (*APICache) RemoveCachedBlock ¶
func (apic *APICache) RemoveCachedBlock(cachedBlock *CachedBlock)
RemoveCachedBlock removes the input CachedBlock the cache. If the block is not in cache, this is essentially a silent no-op.
func (*APICache) RemoveCachedBlockByHeight ¶
RemoveCachedBlockByHeight attempts to remove a CachedBlock with the given height.
func (*APICache) SetLessFn ¶
func (apic *APICache) SetLessFn(lessFn func(bi, bj *CachedBlock) bool)
SetLessFn sets the comparator used by the priority queue. For information on the input function, see the docs for (pq *BlockPriorityQueue).SetLessFn.
func (*APICache) StoreBlockSummary ¶
func (apic *APICache) StoreBlockSummary(blockSummary *BlockDataBasic) error
StoreBlockSummary caches the input BlockDataBasic, if the priority queue indicates that the block should be added.
func (*APICache) StoreStakeInfo ¶
func (apic *APICache) StoreStakeInfo(stakeInfo *StakeInfoExtended) error
StoreStakeInfo caches the input StakeInfoExtended, if the priority queue indicates that the block should be added.
func (*APICache) Utilization ¶
Utilization returns the percent utilization of the cache
func (*APICache) UtilizationBlocks ¶
UtilizationBlocks returns the number of blocks stored in the cache
type APIStatus ¶
type APIStatus struct { Ready bool `json:"ready"` DBHeight uint32 `json:"db_height"` DBLastBlockTime int64 `json:"db_block_time"` Height uint32 `json:"node_height"` NodeConnections int64 `json:"node_connections"` APIVersion int `json:"api_version"` DcrdataVersion string `json:"dcrdata_version"` NetworkName string `json:"network_name"` }
APIStatus is for the JSON-formatted response at /status.
type Address ¶
type Address struct { Address string `json:"address"` Transactions []*AddressTxShort `json:"address_transactions"` }
Address models the address string with the transactions as AddressTxShort
type AddressTotals ¶
type AddressTotals struct { Address string `json:"address"` BlockHash string `json:"blockhash"` BlockHeight uint64 `json:"blockheight"` NumSpent int64 `json:"num_stxos"` NumUnspent int64 `json:"num_utxos"` CoinsSpent float64 `json:"dcr_spent"` CoinsUnspent float64 `json:"dcr_unspent"` }
AddressTotals represents the number and value of spent and unspent outputs for an address.
type AddressTxRaw ¶
type AddressTxRaw struct { Size int32 `json:"size"` TxID string `json:"txid"` Version int32 `json:"version"` Locktime uint32 `json:"locktime"` Vin []chainjson.VinPrevOut `json:"vin"` Vout []Vout `json:"vout"` Confirmations int64 `json:"confirmations"` BlockHash string `json:"blockhash"` Time TimeAPI `json:"time,omitempty"` Blocktime TimeAPI `json:"blocktime,omitempty"` }
AddressTxRaw is modeled from SearchRawTransactionsResult but with size in place of hex
type AddressTxShort ¶
type AddressTxShort struct { TxID string `json:"txid"` Size int32 `json:"size"` Time TimeAPI `json:"time"` Value float64 `json:"value"` Confirmations int64 `json:"confirmations"` }
AddressTxShort is a subset of AddressTxRaw with just the basic tx details pertaining the particular address
type AddressTxnOutput ¶
type AddressTxnOutput struct { Address string `json:"address"` TxnID string `json:"txid"` Vout uint32 `json:"vout"` BlockTime int64 `json:"ts,omitempty"` ScriptPubKey string `json:"scriptPubKey"` Height int64 `json:"height,omitempty"` BlockHash string `json:"block_hash,omitempty"` Amount float64 `json:"amount,omitempty"` Atoms int64 `json:"atoms,omitempty"` // Not Required per Insight spec Satoshis int64 `json:"satoshis,omitempty"` Confirmations int64 `json:"confirmations"` }
AddressTxnOutput models an address transaction outputs.
func TxOutFromDB ¶
func TxOutFromDB(dbTxOut *dbtypes.AddressTxnOutput, currentHeight int32) *AddressTxnOutput
TxOutFromDB converts a dbtypes.AddressTxnOutput to a api/types.AddressTxnOutput.
type AgendaAPIResponse ¶
type AgendaAPIResponse struct { ByHeight *dbtypes.AgendaVoteChoices `json:"by_height"` ByTime *dbtypes.AgendaVoteChoices `json:"by_time"` }
AgendaAPIResponse holds two sets of AgendaVoteChoices charts data.
type AgendasInfo ¶
type AgendasInfo struct { Name string `json:"name"` Description string `json:"description"` *dbtypes.MileStone VoteVersion uint32 `json:"voteversion"` Mask uint16 `json:"mask"` }
AgendasInfo holds the high level details about an agenda.
type BlockDataBasic ¶
type BlockDataBasic struct { Height uint32 `json:"height"` Size uint32 `json:"size"` Hash string `json:"hash"` Difficulty float64 `json:"diff"` StakeDiff float64 `json:"sdiff"` Time TimeAPI `json:"time"` NumTx uint32 `json:"txlength"` MiningFee *int64 `json:"fees,omitempty"` TotalSent *int64 `json:"total_sent,omitempty"` // TicketPoolInfo may be nil for side chain blocks. PoolInfo *TicketPoolInfo `json:"ticket_pool,omitempty"` }
BlockDataBasic models primary information about a block.
func NewBlockDataBasic ¶
func NewBlockDataBasic() *BlockDataBasic
NewBlockDataBasic constructs a *BlockDataBasic with pointer fields allocated.
type BlockDataWithTxType ¶
type BlockDataWithTxType struct { *chainjson.GetBlockVerboseResult Votes []TxRawWithVoteInfo Tickets []chainjson.TxRawResult Revs []chainjson.TxRawResult }
BlockDataWithTxType adds an array of TxRawWithTxType to chainjson.GetBlockVerboseResult to include the stake transaction type
type BlockExplorerBasic ¶
type BlockExplorerBasic struct { Height uint32 `json:"height"` Size uint32 `json:"size"` Voters uint16 `json:"votes"` FreshStake uint8 `json:"tickets"` Revocations uint8 `json:"revocations"` StakeDiff float64 `json:"sdiff"` Time dbtypes.TimeDef `json:"time"` BlockExplorerExtraInfo }
BlockExplorerBasic models primary information about block at height Height for the block explorer.
type BlockExplorerExtraInfo ¶
type BlockExplorerExtraInfo struct { TxLen int `json:"tx"` CoinSupply int64 `json:"coin_supply"` NextBlockSubsidy *chainjson.GetBlockSubsidyResult `json:"next_block_subsidy"` }
BlockExplorerExtraInfo contains supplemental block metadata used by the explorer.
type BlockID ¶
type BlockID struct { BlockHash string `json:"blockhash"` BlockHeight int64 `json:"blockheight"` BlockIndex uint32 `json:"blockindex"` Time int64 `json:"time"` BlockTime int64 `json:"blocktime"` }
BlockID models very basic info about a block
type BlockPriorityQueue ¶
type BlockPriorityQueue struct {
// contains filtered or unexported fields
}
BlockPriorityQueue implements heap.Interface and holds CachedBlocks
func NewBlockPriorityQueue ¶
func NewBlockPriorityQueue(capacity uint32) *BlockPriorityQueue
NewBlockPriorityQueue is the constructor for BlockPriorityQueue that initializes an empty heap with the given capacity, and sets the default LessFn as a comparison by access time with 1 day resolution (blocks accessed within the 24 hours are considered to have the same access time), followed by access count. Use BlockPriorityQueue.SetLessFn to redefine the comparator.
func (*BlockPriorityQueue) Insert ¶
func (pq *BlockPriorityQueue) Insert(summary *BlockDataBasic, stakeInfo *StakeInfoExtended) (bool, *chainhash.Hash, int64)
Insert will add an element, while respecting the queue's capacity if at capacity
- compare with top and replace or return
- if replaced top, heapdown (Fix(pq,0))
else (not at capacity)
- heap.Push, which is pq.Push (append at bottom) then heapup
func (*BlockPriorityQueue) Len ¶
func (pq *BlockPriorityQueue) Len() int
Len is require for heap.Interface
func (*BlockPriorityQueue) Less ¶
func (pq *BlockPriorityQueue) Less(i, j int) bool
Less performs the comparison priority(i) < priority(j). Use BlockPriorityQueue.SetLessFn to define the desired behavior for the CachedBlocks heap[i] and heap[j].
func (*BlockPriorityQueue) Pop ¶
func (pq *BlockPriorityQueue) Pop() interface{}
Pop will return an interface{} that may be cast to *CachedBlock. Use heap.Pop, not this.
func (*BlockPriorityQueue) Push ¶
func (pq *BlockPriorityQueue) Push(blockData interface{})
Push a *cachedBlockData. Use heap.Push, not this directly.
func (*BlockPriorityQueue) Reheap ¶
func (pq *BlockPriorityQueue) Reheap()
Reheap is a shortcut for heap.Init(pq)
func (*BlockPriorityQueue) RemoveBlock ¶
func (pq *BlockPriorityQueue) RemoveBlock(b *CachedBlock)
RemoveBlock removes the specified CachedBlock from the queue. Remember to remove it from the actual block cache!
func (*BlockPriorityQueue) RemoveIndex ¶
func (pq *BlockPriorityQueue) RemoveIndex(idx int)
RemoveIndex removes the CachedBlock at the specified position in the heap. This function is NOT thread-safe.
func (*BlockPriorityQueue) RescanMinMax ¶
func (pq *BlockPriorityQueue) RescanMinMax()
RescanMinMax rescans the enitire heap to get the current min/max heights. This function is NOT thread-safe.
func (*BlockPriorityQueue) RescanMinMaxForAdd ¶
func (pq *BlockPriorityQueue) RescanMinMaxForAdd(height uint32)
RescanMinMaxForAdd conditionally updates the heap min/max height given the height of the block to add (push). No scan, just update min/max. This function is NOT thread-safe.
func (*BlockPriorityQueue) RescanMinMaxForRemove ¶
func (pq *BlockPriorityQueue) RescanMinMaxForRemove(height uint32)
RescanMinMaxForRemove conditionally rescans the heap min/max height given the height of the block to remove (pop). Make sure to remove the block BEFORE running this, as any rescan of the heap will see the block. This function is NOT thread-safe.
func (*BlockPriorityQueue) RescanMinMaxForUpdate ¶
func (pq *BlockPriorityQueue) RescanMinMaxForUpdate(heightAdd, heightRemove uint32)
RescanMinMaxForUpdate conditionally rescans the heap min/max height given old and new heights of the CachedBlock being updated. This function is NOT thread-safe.
func (*BlockPriorityQueue) ResetHeap ¶
func (pq *BlockPriorityQueue) ResetHeap(bh []*CachedBlock)
ResetHeap creates a fresh queue given the input []*CachedBlock. For every CachedBlock in the queue, ResetHeap resets the access count and time, and heap index. The min/max heights are reset, the heap is heapifies. NOTE: the input slice is modifed, but not reordered. A fresh slice is created for PQ internal use.
func (*BlockPriorityQueue) SetLessFn ¶
func (pq *BlockPriorityQueue) SetLessFn(lessFn func(bi, bj *CachedBlock) bool)
SetLessFn sets the function called by Less. The input lessFn must accept two *CachedBlock and return a bool, unlike Less, which accepts heap indexes i, j. This allows to define a comparator without requiring a heap.
func (*BlockPriorityQueue) Swap ¶
func (pq *BlockPriorityQueue) Swap(i, j int)
Swap swaps the cachedBlocks at i and j. This is used container/heap.
func (*BlockPriorityQueue) UpdateBlock ¶
func (pq *BlockPriorityQueue) UpdateBlock(b *CachedBlock, summary *BlockDataBasic, stakeInfo *StakeInfoExtended)
UpdateBlock will update the specified CachedBlock, which must be in the queue. This function is NOT thread-safe.
type BlockRaw ¶
type BlockRaw struct { Height uint32 `json:"height"` Hash string `json:"hash"` Hex string `json:"hex"` }
BlockRaw contains the hexadecimal encoded bytes of a serialized block.
type BlockSubsidies ¶
type BlockSubsidies struct { BlockNum int64 `json:"height"` BlockHash string `json:"hash,omitempty"` Work int64 `json:"work_reward"` Stake int64 `json:"stake_reward"` NumVotes int16 `json:"num_votes,omitempty"` TotalStake int64 `json:"stake_reward_total,omitempty"` Tax int64 `json:"project_subsidy"` Total int64 `json:"total,omitempty"` }
BlockSubsidies contains the block reward proportions for a certain block height. The stake_reward is per vote, while total is for a certain number of votes.
type BlockSummarySaver ¶
type BlockSummarySaver interface {
StoreBlockSummary(*BlockDataBasic) error
}
BlockSummarySaver is likely to be required to be implemented by the type utilizing APICache.
type BlockTransactionCounts ¶
BlockTransactionCounts contains the regular and stake transaction counts for a block.
type BlockTransactions ¶
BlockTransactions models an array of stake and regular transactions for a block
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
type CachedBlock ¶
type CachedBlock struct {
// contains filtered or unexported fields
}
CachedBlock represents a block that is managed by the cache.
func (*CachedBlock) Access ¶
func (b *CachedBlock) Access() *BlockDataBasic
Access increments the access count and sets the accessTime to now. The BlockDataBasic stored in the CachedBlock is returned.
func (CachedBlock) String ¶
func (b CachedBlock) String() string
String satisfies the Stringer interface.
type CoinSupply ¶
type CoinSupply struct { Height int64 `json:"block_height"` Hash string `json:"block_hash"` Mined int64 `json:"supply_mined"` Ultimate int64 `json:"supply_ultimate"` }
CoinSupply models the coin supply at a certain best block.
type Happy ¶
type Happy struct { Happy bool `json:"happy"` APIReady bool `json:"api_ready"` TipAge int64 `json:"tip_age"` NodeConnections int64 `json:"node_connections"` }
Happy describes just how happy dcrdata is.
type InsightAddr ¶
type InsightAddr struct {
Addrs string `json:"addrs"`
}
InsightAddr models the multi-address post data structure.
type InsightAddress ¶
type InsightAddress struct { Address string `json:"address,omitempty"` From int `json:"from"` To int `json:"to"` Transactions []InsightTx `json:"items,omitempty"` }
InsightAddress models an address' transactions.
type InsightAddressInfo ¶
type InsightAddressInfo struct { Address string `json:"addrStr,omitempty"` Balance float64 `json:"balance"` BalanceSat int64 `json:"balanceSat"` TotalReceived float64 `json:"totalReceived"` TotalReceivedSat int64 `json:"totalReceivedSat"` TotalSent float64 `json:"totalSent"` TotalSentSat int64 `json:"totalSentSat"` UnconfirmedBalance float64 `json:"unconfirmedBalance"` UnconfirmedBalanceSat int64 `json:"unconfirmedBalanceSat"` UnconfirmedTxAppearances int64 `json:"unconfirmedTxApperances"` // [sic] TxAppearances int64 `json:"txApperances"` // [sic] TransactionsID []string `json:"transactions,omitempty"` }
InsightAddressInfo models basic information about an address.
type InsightBlockAddrTxSummary ¶
type InsightBlockAddrTxSummary struct { PagesTotal int64 `json:"pagesTotal"` Txs []InsightTx `json:"txs"` }
InsightBlockAddrTxSummary models the data required by addrtx json return for Insight API
type InsightBlockResult ¶
type InsightBlockResult struct { Hash string `json:"hash"` Confirmations int64 `json:"confirmations"` Size int32 `json:"size"` Height int64 `json:"height"` Version int32 `json:"version"` MerkleRoot string `json:"merkleroot"` Tx []string `json:"tx,omitempty"` Time int64 `json:"time"` Nonce uint32 `json:"nonce"` Bits string `json:"bits"` Difficulty float64 `json:"difficulty"` PreviousHash string `json:"previousblockhash"` NextHash string `json:"nextblockhash,omitempty"` Reward float64 `json:"reward"` IsMainChain bool `json:"isMainChain"` }
InsightBlockResult models the data required by a block json return for Insight API
type InsightBlocksSummaryResult ¶
type InsightBlocksSummaryResult struct { Blocks []dbtypes.BlockDataBasic `json:"blocks"` Length int `json:"length"` Pagination struct { Next string `json:"next"` Prev string `json:"prev"` CurrentTs int64 `json:"currentTs"` Current string `json:"current"` IsToday bool `json:"isToday"` More bool `json:"more"` MoreTs int64 `json:"moreTs,omitempty"` } `json:"pagination"` }
InsightBlocksSummaryResult models data required by blocks json return for Insight API
type InsightMultiAddrsTx ¶
type InsightMultiAddrsTx struct { Addresses string `json:"addrs"` From json.Number `json:"from,omitempty"` To json.Number `json:"to,omitempty"` NoAsm json.Number `json:"noAsm"` NoScriptSig json.Number `json:"noScriptSig"` NoSpent json.Number `json:"noSpent"` }
InsightMultiAddrsTx models the POST request for the multi-address endpoints.
type InsightMultiAddrsTxOutput ¶
type InsightMultiAddrsTxOutput struct { TotalItems int64 `json:"totalItems"` From int `json:"from"` To int `json:"to"` Items []InsightTx `json:"items"` }
InsightMultiAddrsTxOutput models the response to the multi-address transactions POST request.
type InsightPagination ¶
type InsightPagination struct { Next string `json:"next,omitempty"` Prev string `json:"prev,omitempty"` IsToday string `json:"isToday,omitempty"` }
InsightPagination models basic pagination output for a result.
type InsightRawTx ¶
type InsightRawTx struct {
Rawtx string `json:"rawtx"`
}
InsightRawTx contains the raw transaction string of a transaction.
type InsightScriptPubKey ¶
type InsightScriptSig ¶
type InsightTx ¶
type InsightTx struct { Txid string `json:"txid,omitempty"` Version int32 `json:"version,omitempty"` Locktime uint32 `json:"locktime"` IsCoinBase bool `json:"isCoinBase,omitempty"` IsTreasurybase bool `json:"isTreasurybase,omitempty"` Vins []*InsightVin `json:"vin,omitempty"` Vouts []*InsightVout `json:"vout,omitempty"` Blockhash string `json:"blockhash,omitempty"` Blockheight int64 `json:"blockheight"` Confirmations int64 `json:"confirmations"` Time int64 `json:"time,omitempty"` Blocktime int64 `json:"blocktime,omitempty"` ValueOut float64 `json:"valueOut,omitempty"` Size uint32 `json:"size,omitempty"` ValueIn float64 `json:"valueIn,omitempty"` Fees float64 `json:"fees,omitempty"` }
type InsightVin ¶
type InsightVin struct { Txid string `json:"txid,omitempty"` Vout *uint32 `json:"vout,omitempty"` Sequence *uint32 `json:"sequence,omitempty"` N int `json:"n"` ScriptSig *InsightScriptSig `json:"scriptSig,omitempty"` Addr string `json:"addr,omitempty"` ValueSat int64 `json:"valueSat"` Value float64 `json:"value"` CoinBase string `json:"coinbase,omitempty"` }
type InsightVout ¶
type InsightVout struct { Value float64 `json:"value"` N uint32 `json:"n"` ScriptPubKey InsightScriptPubKey `json:"scriptPubKey,omitempty"` SpentTxID interface{} `json:"spentTxId"` // Insight requires null if unspent and spending TxID if spent SpentIndex interface{} `json:"spentIndex"` // Insight requires null if unspent and Index if spent SpentHeight interface{} `json:"spentHeight"` // Insight requires null if unspent and SpentHeight if spent }
type MempoolTicketDetails ¶
type MempoolTicketDetails struct { Height uint32 `json:"height"` Time int64 `json:"time"` Length uint32 `json:"length"` Total uint32 `json:"total"` Tickets TicketsDetails `json:"tickets"` }
MempoolTicketDetails models basic mempool info with ticket details Tickets
type MempoolTicketFeeInfo ¶
type MempoolTicketFeeInfo struct { Height uint32 `json:"height"` Time int64 `json:"time"` chainjson.FeeInfoMempool LowestMineable float64 `json:"lowest_mineable"` }
MempoolTicketFeeInfo models statistical ticket fee info at block height Height
type MempoolTicketFees ¶
type MempoolTicketFees struct { Height uint32 `json:"height"` Time int64 `json:"time"` Length uint32 `json:"length"` Total uint32 `json:"total"` FeeRates []float64 `json:"top_fees"` }
MempoolTicketFees models info about ticket fees at block height Height
type OutPoint ¶
type OutPoint struct { Hash string `json:"hash"` Index uint32 `json:"index"` Tree int8 `json:"tree"` }
OutPoint is used to track previous transaction outputs.
type PowerlessTicket ¶
PowerlessTicket is the purchase block height and value of a missed or expired ticket.
type PowerlessTickets ¶
type PowerlessTickets struct { Unspent []PowerlessTicket `json:"unspent"` Revoked []PowerlessTicket `json:"revoked"` }
PowerlessTickets contains expired and missed tickets sorted into slices of unspent and revoked.
type PrevOut ¶
type PrevOut struct { Addresses []string `json:"addresses,omitempty"` Value float64 `json:"value"` }
PrevOut represents previous output for an input Vin.
type PriceCountTime ¶
type PriceCountTime struct { Price float64 `json:"price"` Count int `json:"count"` Time dbtypes.TimeDef `json:"time"` }
PriceCountTime is a basic set of information about ticket in the mempool.
type ScriptClass ¶
type ScriptClass uint8
ScriptClass represent the type of a transaction output's pkscript. The values of this type are NOT compatible with dcrd's txscript.ScriptClass values! Use ScriptClassFromName to get a text representation of a ScriptClass.
const ( ScriptClassNonStandard ScriptClass = iota // None of the recognized forms. ScriptClassPubKey // Pay pubkey. ScriptClassPubkeyAlt // Alternative signature pubkey. ScriptClassPubKeyHash // Pay pubkey hash. ScriptClassPubkeyHashAlt // Alternative signature pubkey hash. ScriptClassScriptHash // Pay to script hash. ScriptClassMultiSig // Multi signature. ScriptClassNullData // Empty data-only (provably prunable). ScriptClassStakeSubmission // Stake submission. ScriptClassStakeGen // Stake generation ScriptClassStakeRevocation // Stake revocation. ScriptClassStakeSubChange // Change for stake submission tx. ScriptClassInvalid )
Classes of script payment known about in the blockchain.
func ScriptClassFromName ¶
func ScriptClassFromName(name string) ScriptClass
ScriptClassFromName attempts to identify the ScriptClass for the given script class/type name. An unknown script name will return ScriptClassInvalid. This may be used to map the Type field of the ScriptPubKey data type to a known class. If dcrd's txscript package changes its strings, this function may be unable to identify the types from dcrd.
func (ScriptClass) String ¶
func (sc ScriptClass) String() string
String returns the name of the ScriptClass. If the ScriptClass is unrecognized it is treated as ScriptClassInvalid.
type ScriptPubKey ¶
type ScriptPubKey struct { Asm string `json:"asm"` Hex string `json:"hex"` ReqSigs int32 `json:"reqSigs,omitempty"` Type string `json:"type"` Addresses []string `json:"addresses,omitempty"` CommitAmt *float64 `json:"commitamt,omitempty"` }
ScriptPubKey is 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 SpendByFundingHash ¶
type SpendByFundingHash struct { FundingTxVoutIndex uint32 SpendingTxVinIndex interface{} SpendingTxHash interface{} BlockHeight interface{} }
SpendByFundingHash models a return from SpendDetailsForFundingTx.
type StakeDiff ¶
type StakeDiff struct { chainjson.GetStakeDifficultyResult Estimates chainjson.EstimateStakeDiffResult `json:"estimates"` IdxBlockInWindow int `json:"window_block_index"` PriceWindowNum int `json:"window_number"` }
StakeDiff represents data about the evaluated stake difficulty and estimates
type StakeInfoExtended ¶
type StakeInfoExtended struct { Hash string `json:"hash"` Feeinfo chainjson.FeeInfoBlock `json:"feeinfo"` StakeDiff float64 `json:"stakediff"` PriceWindowNum int `json:"window_number"` IdxBlockInWindow int `json:"window_block_index"` PoolInfo *TicketPoolInfo `json:"ticket_pool"` }
StakeInfoExtended models data about the fee, pool and stake difficulty
func NewStakeInfoExtended ¶
func NewStakeInfoExtended() *StakeInfoExtended
NewStakeInfoExtended constructs a *StakeInfoExtended with pointer fields allocated.
type StakeInfoExtendedEstimates ¶
type StakeInfoExtendedEstimates struct { Hash string `json:"hash"` Feeinfo chainjson.FeeInfoBlock `json:"feeinfo"` StakeDiff StakeDiff `json:"stakediff"` PriceWindowNum int `json:"window_number"` IdxBlockInWindow int `json:"window_block_index"` PoolInfo *TicketPoolInfo `json:"ticket_pool"` }
StakeInfoExtendedEstimates is similar to StakeInfoExtended but includes stake difficulty estimates with the stake difficulty
type StakeInfoSaver ¶
type StakeInfoSaver interface {
StoreStakeInfo(*StakeInfoExtended) error
}
StakeInfoSaver is likely to be required to be implemented by the type utilizing APICache.
type Status ¶
Status indicates the state of the server. All fields are mutex protected and and should be set with the getters and setters.
func NewStatus ¶
func NewStatus(nodeHeight uint32, conns int64, apiVersion int, dcrdataVersion, netName string) *Status
NewStatus is the constructor for a new Status.
func (*Status) DBUpdate ¶
DBUpdate updates both the height and time of the best DB block. Status.ready is set to true if Status.height is the same as Status.dbHeight and the node has connections.
func (*Status) NodeConnections ¶
NodeConnections gets the number of node peer connections.
func (*Status) SetConnections ¶
SetConnections sets the node connection count.
type SyncResponse ¶
type SyncResponse struct { Status string `json:"status"` BlockChainHeight int64 `json:"blockChainHeight"` SyncPercentage int64 `json:"syncPercentage"` Height int64 `json:"height"` Error *string `json:"error"` Type string `json:"type"` }
SyncResponse contains sync status information.
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 TicketDetails ¶
type TicketDetails struct { Hash string `json:"hash"` Fee float64 `json:"abs_fee"` FeeRate float64 `json:"fee"` Size int32 `json:"size"` Height int64 `json:"height_received"` }
TicketDetails models details about ticket Hash received at height Height
type TicketInfo ¶
type TicketInfo struct { Status string `json:"status"` PurchaseBlock *TinyBlock `json:"purchase_block"` MaturityHeight uint32 `json:"maturity_height"` ExpirationHeight uint32 `json:"expiration_height"` LotteryBlock *TinyBlock `json:"lottery_block"` Vote *string `json:"vote"` Revocation *string `json:"revocation"` }
TicketInfo combines spend and pool statuses and relevant block and spending transaction IDs.
type TicketPoolChartsData ¶
type TicketPoolChartsData struct { ChartHeight uint64 `json:"height"` TimeChart *dbtypes.PoolTicketsData `json:"time_chart"` PriceChart *dbtypes.PoolTicketsData `json:"price_chart"` OutputsChart *dbtypes.PoolTicketsData `json:"outputs_chart"` Mempool *PriceCountTime `json:"mempool"` }
TicketPoolChartsData is for data used to display ticket pool statistics at /ticketpool.
type TicketPoolInfo ¶
type TicketPoolInfo struct { Height uint32 `json:"height"` Size uint32 `json:"size"` Value float64 `json:"value"` ValAvg float64 `json:"valavg"` Winners []string `json:"winners"` }
TicketPoolInfo models data about ticket pool
type TicketPoolValsAndSizes ¶
type TicketPoolValsAndSizes struct { StartHeight uint32 `json:"start_height"` EndHeight uint32 `json:"end_height"` Value []float64 `json:"value"` Size []uint32 `json:"size"` }
TicketPoolValsAndSizes models two arrays, one each for ticket values and sizes for blocks StartHeight to EndHeight
type TicketsDetails ¶
type TicketsDetails []*TicketDetails
TicketsDetails is an array of pointers of TicketDetails used in MempoolTicketDetails
type TimeAPI ¶
TimeAPI is a fall back dbtypes.TimeDef wrapper that allows API endpoints that previously returned a timestamp instead of a formatted string time to continue working.
func NewTimeAPI ¶
NewTimeAPI constructs a TimeAPI from the given time.Time. It presets the timezone for formatting to UTC.
func NewTimeAPIFromUNIX ¶
NewTimeAPIFromUNIX constructs a TimeAPI from the given UNIX epoch time stamp in seconds. It presets the timezone for formatting to UTC.
func (*TimeAPI) MarshalJSON ¶
MarshalJSON is set as the default marshalling function for TimeAPI struct.
func (*TimeAPI) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type TrimmedTx ¶
type TrimmedTx struct { TxID string `json:"txid"` Version int32 `json:"version"` Locktime uint32 `json:"locktime"` Expiry uint32 `json:"expiry"` Vin []chainjson.Vin `json:"vin"` Vout []Vout `json:"vout"` }
TrimmedTx models data to resemble to result of the decoderawtransaction RPC.
type Tx ¶
type Tx struct { TxShort Confirmations int64 `json:"confirmations"` Block *BlockID `json:"block,omitempty"` }
Tx models TxShort with the number of confirmations and block info Block
type TxIn ¶
type TxIn struct { // Non-witness PreviousOutPoint OutPoint `json:"prevout"` Sequence uint32 `json:"sequence"` // Witness ValueIn float64 `json:"value"` BlockHeight uint32 `json:"blockheight"` BlockIndex uint32 `json:"blockindex"` SignatureScript string `json:"sigscript"` }
TxIn defines a decred transaction input.
type TxOut ¶
type TxOut struct { Value float64 `json:"value"` Version uint16 `json:"version"` ScriptPubKeyDecoded ScriptPubKey `json:"scriptPubKey"` }
TxOut defines a decred transaction output.
type TxRawWithTxType ¶
type TxRawWithTxType struct { chainjson.TxRawResult TxType string }
TxRawWithTxType adds the stake transaction type to chainjson.TxRawResult
type TxRawWithVoteInfo ¶
type TxRawWithVoteInfo struct { chainjson.TxRawResult VoteInfo VoteInfo }
TxRawWithVoteInfo adds the vote info to chainjson.TxRawResult
type TxShort ¶
type TxShort struct { TxID string `json:"txid"` Size int32 `json:"size"` Version int32 `json:"version"` Locktime uint32 `json:"locktime"` Expiry uint32 `json:"expiry"` Vin []chainjson.Vin `json:"vin"` Vout []Vout `json:"vout"` }
TxShort models info about transaction TxID
type Txns ¶
type Txns struct {
Transactions []string `json:"transactions"`
}
Txns models the multi transaction post data structure
type VinPrevOut ¶
type VinPrevOut struct { Coinbase string `json:"coinbase"` Stakebase string `json:"stakebase"` Txid string `json:"txid"` Vout uint32 `json:"vout"` Tree int8 `json:"tree"` AmountIn *float64 `json:"amountin,omitempty"` BlockHeight *uint32 `json:"blockheight,omitempty"` BlockIndex *uint32 `json:"blockindex,omitempty"` ScriptSig *ScriptSig `json:"scriptSig"` PrevOut *PrevOut `json:"prevOut"` Sequence uint32 `json:"sequence"` }
VinPrevOut is like Vin except it includes PrevOut. It is used by searchrawtransaction
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"` TSpends []*TSpendVote `json:"tspend_votes,omitempty"` }
VoteInfo models data about a SSGen transaction (vote)