internal

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2017 License: ISC Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InsertAddressRow        = insertAddressRow0 + `RETURNING id;`
	InsertAddressRowChecked = insertAddressRow0 +
		`ON CONFLICT (address, vout_row_id) DO NOTHING RETURNING id;`
	InsertAddressRowReturnID = `WITH inserting AS (` +
		insertAddressRow0 +
		`ON CONFLICT (address, vout_row_id) DO UPDATE
		SET address = NULL WHERE FALSE
		RETURNING id
		)
	 SELECT id FROM inserting
	 UNION  ALL
	 SELECT id FROM addresses
	 WHERE  address = $1 AND vout_row_id = $5
	 LIMIT  1;`

	CreateAddressTable = `` /* 298-byte string literal not displayed */

	SelectAddressAllByAddress          = `SELECT * FROM addresses WHERE address=$1 order by id desc;`
	SelectAddressRecvCount             = `SELECT COUNT(*) FROM addresses WHERE address=$1;`
	SelectAddressUnspentCountAndValue  = `SELECT COUNT(*), SUM(value) FROM addresses WHERE address=$1 and spending_tx_row_id IS NULL;`
	SelectAddressSpentCountAndValue    = `SELECT COUNT(*), SUM(value) FROM addresses WHERE address=$1 and spending_tx_row_id IS NOT NULL;`
	SelectAddressLimitNByAddress       = `SELECT * FROM addresses WHERE address=$1 order by id desc limit $2 offset $3;`
	SelectAddressLimitNByAddressSubQry = `WITH these as (SELECT * FROM addresses WHERE address=$1)
		SELECT * FROM these order by id desc limit $2 offset $3;`
	SelectAddressIDsByFundingOutpoint = `SELECT id, address FROM addresses
		WHERE funding_tx_hash=$1 and funding_tx_vout_index=$2;`
	SelectAddressIDByVoutIDAddress = `SELECT id FROM addresses
		WHERE address=$1 and vout_row_id=$2;`

	SetAddressSpendingForID = `` /* 131-byte string literal not displayed */

	SetAddressSpendingForOutpoint = `` /* 173-byte string literal not displayed */

	IndexAddressTableOnAddress = `CREATE INDEX uix_addresses_address
		ON addresses(address);`
	DeindexAddressTableOnAddress = `DROP INDEX uix_addresses_address;`

	IndexAddressTableOnVoutID = `CREATE UNIQUE INDEX uix_addresses_vout_id
		ON addresses(vout_row_id);`
	DeindexAddressTableOnVoutID = `DROP INDEX uix_addresses_vout_id;`

	IndexAddressTableOnFundingTx = `CREATE INDEX uix_addresses_funding_tx
		ON addresses(funding_tx_hash, funding_tx_vout_index);`
	DeindexAddressTableOnFundingTx = `DROP INDEX uix_addresses_funding_tx;`
)
View Source
const (
	UpdateLastBlockValid = `UPDATE blocks SET is_valid = $2 WHERE id = $1;`

	CreateBlockTable = `` /* 561-byte string literal not displayed */

	IndexBlockTableOnHash = `CREATE UNIQUE INDEX uix_block_hash
		ON blocks(hash);`
	DeindexBlockTableOnHash = `DROP INDEX uix_block_hash;`

	RetrieveBestBlock       = `SELECT * FROM blocks ORDER BY height DESC LIMIT 0, 1;`
	RetrieveBestBlockHeight = `SELECT id, hash, height FROM blocks ORDER BY height DESC LIMIT 1;`

	// block_chain, with primary key that is not a SERIAL
	CreateBlockPrevNextTable = `` /* 164-byte string literal not displayed */

	// Insert includes the primary key, which should be from the blocks table
	InsertBlockPrevNext = `` /* 135-byte string literal not displayed */

	UpdateBlockNext = `UPDATE block_chain set next_hash = $2 WHERE block_db_id = $1;`
)
View Source
const (
	CreateTransactionTable = `` /* 441-byte string literal not displayed */

	SelectTxByHash       = `SELECT id, block_hash, block_index, tree FROM transactions WHERE tx_hash = $1;`
	SelectTxsByBlockHash = `SELECT id, tx_hash, block_index, tree FROM transactions WHERE block_hash = $1;`

	SelectFullTxByHash = `` /* 234-byte string literal not displayed */

	SelectRegularTxByHash = `SELECT id, block_hash, block_index FROM transactions WHERE tx_hash = $1 and tree=0;`
	SelectStakeTxByHash   = `SELECT id, block_hash, block_index FROM transactions WHERE tx_hash = $1 and tree=1;`

	IndexTransactionTableOnBlockIn = `CREATE UNIQUE INDEX uix_tx_block_in
		ON transactions(block_hash, block_index, tree)
		;`  // STORING (tx_hash, block_hash)
	DeindexTransactionTableOnBlockIn = `DROP INDEX uix_tx_block_in;`

	IndexTransactionTableOnHashes = `CREATE UNIQUE INDEX uix_tx_hashes
		 ON transactions(tx_hash, block_hash)
		 ;`  // STORING (block_hash, block_index, tree)
	DeindexTransactionTableOnHashes = `DROP INDEX uix_tx_hashes;`

	RetrieveVoutDbIDs = `SELECT unnest(vout_db_ids) FROM transactions WHERE id = $1;`
	RetrieveVoutDbID  = `SELECT vout_db_ids[$2] FROM transactions WHERE id = $1;`
)
View Source
const (
	CreateVinTable = `` /* 175-byte string literal not displayed */

	InsertVinRow0 = `INSERT INTO vins (tx_hash, tx_index, tx_tree, prev_tx_hash, prev_tx_index, prev_tx_tree)
		VALUES ($1, $2, $3, $4, $5, $6) `
	InsertVinRow        = InsertVinRow0 + `RETURNING id;`
	InsertVinRowChecked = InsertVinRow0 +
		`ON CONFLICT (tx_hash, tx_index, tx_tree) DO NOTHING RETURNING id;`

	IndexVinTableOnVins = `CREATE INDEX uix_vin
		ON vins(tx_hash, tx_index)
		;`  // STORING (prev_tx_hash, prev_tx_index)
	IndexVinTableOnPrevOuts = `CREATE INDEX uix_vin_prevout
		ON vins(prev_tx_hash, prev_tx_index)
		;`  // STORING (tx_hash, tx_index)
	DeindexVinTableOnVins     = `DROP INDEX uix_vin;`
	DeindexVinTableOnPrevOuts = `DROP INDEX uix_vin_prevout;`

	SelectVinIDsALL = `SELECT id FROM vins;`
	CountRow        = `SELECT reltuples::BIGINT AS estimate FROM pg_class WHERE relname='vins';`

	SelectSpendingTxsByPrevTx = `SELECT id, tx_hash, tx_index, prev_tx_index FROM vins WHERE prev_tx_hash=$1;`
	SelectSpendingTxByPrevOut = `SELECT id, tx_hash, tx_index FROM vins 
		WHERE prev_tx_hash=$1 AND prev_tx_index=$2;`
	SelectFundingTxsByTx        = `SELECT id, prev_tx_hash FROM vins WHERE tx_hash=$1;`
	SelectFundingTxByTxIn       = `SELECT id, prev_tx_hash FROM vins WHERE tx_hash=$1 AND tx_index=$2;`
	SelectFundingOutpointByTxIn = `SELECT id, prev_tx_hash, prev_tx_index, prev_tx_tree FROM vins 
		WHERE tx_hash=$1 AND tx_index=$2;`
	SelectFundingOutpointByVinID = `SELECT prev_tx_hash, prev_tx_index, prev_tx_tree FROM vins WHERE id=$1;`
	SelectSpendingTxByVinID      = `SELECT tx_hash, tx_index, tx_tree FROM vins WHERE id=$1;`
	SelectAllVinInfoByID         = `SELECT * FROM vins WHERE id=$1;`

	CreateVinType = `` /* 169-byte string literal not displayed */

	CreateVoutTable = `` /* 231-byte string literal not displayed */

	SelectPkScriptByID     = `SELECT pkscript FROM vouts WHERE id=$1;`
	SelectVoutIDByOutpoint = `SELECT id FROM vouts WHERE tx_hash=$1 and tx_index=$2;`
	SelectVoutByID         = `SELECT * FROM vouts WHERE id=$1;`

	RetrieveVoutValue  = `SELECT value FROM vouts WHERE tx_hash=$1 and tx_index=$2;`
	RetrieveVoutValues = `SELECT value, tx_index, tx_tree FROM vouts WHERE tx_hash=$1;`

	IndexVoutTableOnTxHashIdx = `CREATE INDEX uix_vout_txhash_ind
		ON vouts(tx_hash, tx_index, tx_tree);`
	DeindexVoutTableOnTxHashIdx = `DROP INDEX uix_vout_txhash_ind;`

	IndexVoutTableOnTxHash = `CREATE INDEX uix_vout_txhash
		ON vouts(tx_hash);`
	DeindexVoutTableOnTxHash = `DROP INDEX uix_vout_txhash;`

	CreateVoutType = `` /* 145-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func MakeBlockInsertStatement

func MakeBlockInsertStatement(block *dbtypes.Block, checked bool) string

func MakeTxInsertStatement

func MakeTxInsertStatement(checked bool) string

func MakeVinCopyInStatement

func MakeVinCopyInStatement() string

func MakeVoutCopyInStatement

func MakeVoutCopyInStatement() string

func MakeVoutInsertStatement

func MakeVoutInsertStatement(checked bool) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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