dbtypes

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2018 License: ISC Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DevSubsidyAddress added in v1.3.0

func DevSubsidyAddress(params *chaincfg.Params) (string, error)

DevSubsidyAddress returns the development subsidy address for the specified network.

func ExtractBlockTransactions

func ExtractBlockTransactions(msgBlock *wire.MsgBlock, txTree int8,
	chainParams *chaincfg.Params) ([]*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 AddressRow

type AddressRow struct {
	// id int64
	Address            string
	FundingTxDbID      uint64
	FundingTxHash      string
	FundingTxVoutIndex uint32
	VoutDbID           uint64
	Value              uint64
	SpendingTxDbID     uint64
	SpendingTxHash     string
	SpendingTxVinIndex uint32
	VinDbID            uint64
}

AddressRow represents a row in the addresses table

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.

func MsgBlockToDBBlock

func MsgBlockToDBBlock(msgBlock *wire.MsgBlock, chainParams *chaincfg.Params) *Block

MsgBlockToDBBlock creates a dbtypes.Block from a wire.MsgBlock

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

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

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

type SyncResult

type SyncResult struct {
	Height int64
	Error  error
}

SyncResult is the result of a database sync operation, containing the height of the last block and an arror value.

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

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.

func (UInt64Array) Value

func (a UInt64Array) Value() (driver.Value, error)

Value implements the driver.Valuer 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     uint64 `json:"amountin"`
	TxID        string `json:"tx_hash"`
	TxIndex     uint32 `json:"tx_index"`
	TxTree      uint16 `json:"tx_tree"`
	BlockHeight uint32 `json:"blockheight"`
	BlockIndex  uint32 `json:"blockindex"`
	ScriptHex   []byte `json:"scripthex"`
}

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

func (VinTxPropertyARRAY) Value

func (p VinTxPropertyARRAY) Value() (driver.Value, error)

Value satisfies driver.Valuer

type Vout

type Vout struct {
	// txDbID           int64
	TxHash           string           `json:"tx_hash"`
	TxIndex          uint32           `json:"tx_index"`
	TxTree           int8             `json:"tx_tree"`
	Value            uint64           `json:"value"`
	Version          uint16           `json:"version"`
	ScriptPubKey     []byte           `json:"pkScriptHex"`
	ScriptPubKeyData ScriptPubKeyData `json:"pkScript"`
}

Vout defines a transaction output

Directories

Path Synopsis
Package internal provides helper functions borrowed from lib/pq's array.go, to facilitate the new UInt64Array type.
Package internal provides helper functions borrowed from lib/pq's array.go, to facilitate the new UInt64Array type.

Jump to

Keyboard shortcuts

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