types

package
v2.1.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2018 License: ISC Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
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 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 {
	sync.RWMutex

	MainchainBlocks []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

func NewAPICache(capacity uint32) *APICache

NewAPICache creates an APICache with the specified capacity.

NOTE: The consumer of APICache should fill out MainChainBlocks before using it. For example, given a struct DB at height dbHeight with an APICache:

 DB.APICache = NewAPICache(10000)
	DB.APICache.MainchainBlocks = make([]chainhash.Hash, 0, dbHeight+NExtra)
	for i := int64(0); i <= dbHeight; i++ {
		hash := DB.SomeFunctionToGetBlockHash(i)
		DB.APICache.MainchainBlocks = append(DB.APICache.MainchainBlocks, *hash)
	}

func (*APICache) Capacity

func (apic *APICache) Capacity() uint32

Capacity returns the capacity of the APICache

func (*APICache) Disable

func (apic *APICache) Disable()

Disable sets the isEnabled flag of the APICache. The does little presently.

func (*APICache) Enable

func (apic *APICache) Enable()

Enable sets the isEnabled flag of the APICache. The does little presently.

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

func (apic *APICache) Hits() uint64

Hits returns the hit count of the APICache

func (*APICache) Misses

func (apic *APICache) Misses() uint64

Misses returns the miss count of the APICache

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

func (apic *APICache) Utilization() float64

Utilization returns the percent utilization of the cache

func (*APICache) UtilizationBlocks

func (apic *APICache) UtilizationBlocks() int64

UtilizationBlocks returns the number of blocks stored in the cache

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 AddressSpendByFunHash

type AddressSpendByFunHash struct {
	FundingTxVoutIndex uint32
	SpendingTxVinIndex interface{}
	SpendingTxHash     interface{}
	BlockHeight        interface{}
}

AddressSpendByFunHash models a return from GetAddressSpendByFunHash

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           []dcrjson.VinPrevOut `json:"vin"`
	Vout          []Vout               `json:"vout"`
	Confirmations int64                `json:"confirmations"`
	BlockHash     string               `json:"blockhash"`
	Time          int64                `json:"time,omitempty"`
	Blocktime     int64                `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          int64   `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

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"`
	//TicketPoolInfo
	PoolInfo TicketPoolInfo `json:"ticket_pool,omitempty"`
}

BlockDataBasic models primary information about block at height Height

type BlockDataWithTxType

type BlockDataWithTxType struct {
	*dcrjson.GetBlockVerboseResult
	Votes   []TxRawWithVoteInfo
	Tickets []dcrjson.TxRawResult
	Revs    []dcrjson.TxRawResult
}

BlockDataWithTxType adds an array of TxRawWithTxType to dcrjson.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        int64   `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"`
	FormattedTime    string                         `json:"formatted_time"`
	CoinSupply       int64                          `json:"coin_supply"`
	NextBlockSubsidy *dcrjson.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 {
	*sync.RWMutex
	// 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) (bool, *chainhash.Hash)

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(blockSummary interface{})

Push a *BlockDataBasic. 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)

UpdateBlock will update the specified CachedBlock, which must be in the queue. This function is NOT thread-safe.

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(blockSummary *BlockDataBasic) error
}

BlockSummarySaver is likely to be required to be implemented by the type utilizing APICache.

type BlockTransactionCounts

type BlockTransactionCounts struct {
	Tx  int `json:"tx"`
	STx int `json:"stx"`
}

BlockTransactionCounts contains the regular and stake transaction counts for a block.

type BlockTransactions

type BlockTransactions struct {
	Tx  []string `json:"tx"`
	STx []string `json:"stx"`
}

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 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"`
	TxAppearances            int64    `json:"txApperances"`
	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,Number,omitempty"`
	To          json.Number `json:"to,Number,omitempty"`
	NoAsm       json.Number `json:"noAsm"`
	NoScriptSig json.Number `json:"noScriptSig"`
	NoSpent     json.Number `json:"noSpent"`
}

InsightMultiAddrsTx models multi address post data structure

type InsightMultiAddrsTxOutput

type InsightMultiAddrsTxOutput struct {
	TotalItems int64       `json:"totalItems"`
	From       int         `json:"from"`
	To         int         `json:"to"`
	Items      []InsightTx `json:"items"`
}

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 InsightScriptPubKey struct {
	Hex       string   `json:"hex,omitempty"`
	Asm       string   `json:"asm,omitempty"`
	Addresses []string `json:"addresses,omitempty"`
	Type      string   `json:"type,omitempty"`
}

type InsightScriptSig

type InsightScriptSig struct {
	Hex string `json:"hex,omitempty"`
	Asm string `json:"asm,omitempty"`
}

type InsightTx

type InsightTx struct {
	Txid          string         `json:"txid,omitempty"`
	Version       int32          `json:"version,omitempty"`
	Locktime      uint32         `json:"locktime"`
	IsCoinBase    bool           `json:"isCoinBase,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,omitempty"`
	Value     float64           `json:"value,omitempty"`
	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"`
	dcrjson.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 PrevOut

type PrevOut struct {
	Addresses []string `json:"addresses,omitempty"`
	Value     float64  `json:"value"`
}

PrevOut represents previous output for an input Vin.

type ScriptPubKey

type ScriptPubKey struct {
	Asm       string   `json:"asm"`
	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

type ScriptSig struct {
	Asm string `json:"asm,omitempty"`
	Hex string `json:"hex,omitempty"`
}

ScriptSig models the signature script used to redeem the origin transaction as a JSON object (non-coinbase txns only)

type StakeDiff

type StakeDiff struct {
	dcrjson.GetStakeDifficultyResult
	Estimates        dcrjson.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 {
	Feeinfo          dcrjson.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

type StakeInfoExtendedEstimates

type StakeInfoExtendedEstimates struct {
	Feeinfo          dcrjson.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 Status

type Status 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"`
}

Status indicates the state of the server, including the API version and the software version.

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 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        []float64 `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 TrimmedTx

type TrimmedTx struct {
	TxID     string        `json:"txid"`
	Version  int32         `json:"version"`
	Locktime uint32        `json:"locktime"`
	Expiry   uint32        `json:"expiry"`
	Vin      []dcrjson.Vin `json:"vin"`
	Vout     []Vout        `json:"vout"`
}

TrimmedTx models data to resemble to result of the decoderawtransaction call

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"`
	PkScript  string   `json:"pkscript"`
	Addresses []string `json:"addresses,omitempty"`
}

TxOut defines a decred transaction output.

type TxRawWithTxType

type TxRawWithTxType struct {
	dcrjson.TxRawResult
	TxType string
}

TxRawWithTxType adds the stake transaction type to dcrjson.TxRawResult

type TxRawWithVoteInfo

type TxRawWithVoteInfo struct {
	dcrjson.TxRawResult
	VoteInfo VoteInfo
}

TxRawWithVoteInfo adds the vote info to dcrjson.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      []dcrjson.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"`
}

VoteInfo models data about a SSGen transaction (vote)

type Vout

type Vout struct {
	Value               float64      `json:"value"`
	N                   uint32       `json:"n"`
	Version             uint16       `json:"version"`
	ScriptPubKeyDecoded ScriptPubKey `json:"scriptPubKey"`
}

Vout defines a transaction output

type VoutMined

type VoutMined struct {
	Vout
	BestBlock     string `json:"bestblock"`
	Confirmations int64  `json:"confirmations"`
	Coinbase      bool   `json:"coinbase"`
}

VoutMined appends a best block hash, number of confimations and if a transaction is a coinbase to a transaction output

Jump to

Keyboard shortcuts

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