internal

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: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InsertAddressRow = insertAddressRow0 + `RETURNING id;`
	// InsertAddressRowChecked = insertAddressRow0 +
	// 	`ON CONFLICT (vout_row_id, address) DO NOTHING RETURNING id;`
	UpsertAddressRow = insertAddressRow0 + `ON CONFLICT (vout_row_id, address) DO UPDATE 
		SET address = $1, vout_row_id = $5 RETURNING id;`
	InsertAddressRowReturnID = `WITH inserting AS (` +
		insertAddressRow0 +
		`ON CONFLICT (vout_row_id, address) 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;`
	SelectAddressesAllTxn     = `` /* 509-byte string literal not displayed */

	SelectAddressesTxnByFundingTx = `` /* 220-byte string literal not displayed */

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

	SelectAddressUnspentWithTxn = `` /* 569-byte string literal not displayed */

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

	// SelectAddressDebitsLimitNByAddress = `SELECT *
	// 	FROM addresses
	// 	WHERE address=$1 AND spending_tx_row_id IS NOT NULL
	// 	ORDER BY id DESC LIMIT $2 OFFSET $3;`
	SelectAddressDebitsLimitNByAddress = `` /* 154-byte string literal not displayed */

	SelectAddressCreditsLimitNByAddress = `` /* 163-byte string literal not displayed */

	// Update Vin due to DCRD AMOUNTIN - START
	SelectAddressIDsByFundingOutpoint = `SELECT id, address, value 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
		ORDER BY id DESC;`

	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, address);`
	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;`

	SelectBlockByTimeRangeSQL = `SELECT hash, height, size, time, numtx
		FROM blocks WHERE time BETWEEN $1 and $2 ORDER BY time DESC LIMIT $3;`
	SelectBlockByTimeRangeSQLNoLimit = `SELECT hash, height, size, time, numtx
		FROM blocks WHERE time BETWEEN $1 and $2 ORDER BY time DESC;`
	SelectBlockHashByHeight = `SELECT hash FROM blocks WHERE height = $1;`
	SelectBlockHeightByHash = `SELECT height FROM blocks WHERE hash = $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;`

	SelectBlockVoteCount = `SELECT voters FROM blocks WHERE hash = $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 */

	SelectBlockChainRowIDByHash = `select block_db_id from block_chain where this_hash = $1;`

	UpdateBlockNext = `UPDATE block_chain set next_hash = $2 WHERE block_db_id = $1;`
)
View Source
const (
	IndexExists = `SELECT 1
FROM   pg_class c
JOIN   pg_namespace n ON n.oid = c.relnamespace
WHERE  c.relname = $1 AND n.nspname = $2;`

	IndexIsUnique = `` /* 167-byte string literal not displayed */

)
View Source
const (
	CreateTicketsTable = `` /* 373-byte string literal not displayed */

	SelectTicketsInBlock         = `SELECT * FROM tickets WHERE block_hash = $1;`
	SelectTicketsTxDbIDsInBlock  = `SELECT purchase_tx_db_id FROM tickets WHERE block_hash = $1;`
	SelectTicketsForAddress      = `SELECT * FROM tickets WHERE stakesubmission_address = $1;`
	SelectTicketsForPriceAtLeast = `SELECT * FROM tickets WHERE price >= $1;`
	SelectTicketsForPriceAtMost  = `SELECT * FROM tickets WHERE price <= $1;`
	SelectTicketIDHeightByHash   = `SELECT id, block_height FROM tickets WHERE tx_hash = $1;`
	SelectTicketIDByHash         = `SELECT id FROM tickets WHERE tx_hash = $1;`
	SelectTicketStatusByHash     = `SELECT id, spend_type, pool_status FROM tickets WHERE tx_hash = $1;`
	SelectUnspentTickets         = `SELECT id, tx_hash FROM tickets WHERE spend_type = 0 OR spend_type = -1;`

	// Update
	SetTicketSpendingInfoForHash = `` /* 136-byte string literal not displayed */

	SetTicketSpendingInfoForTicketDbID = `UPDATE tickets
		SET spend_type = $4, spend_height = $2, spend_tx_db_id = $3, pool_status = $5
		WHERE id = $1;`
	SetTicketSpendingInfoForTxDbID = `` /* 126-byte string literal not displayed */

	SetTicketPoolStatusForTicketDbID = `UPDATE tickets SET pool_status = $2 WHERE id = $1;`
	SetTicketPoolStatusForHash       = `UPDATE tickets SET pool_status = $2 WHERE tx_hash = $1;`

	// Index
	IndexTicketsTableOnHashes = `CREATE UNIQUE INDEX uix_ticket_hashes_index
		ON tickets(tx_hash, block_hash);`
	DeindexTicketsTableOnHashes = `DROP INDEX uix_ticket_hashes_index;`

	IndexTicketsTableOnTxDbID = `CREATE UNIQUE INDEX uix_ticket_ticket_db_id
		ON tickets(purchase_tx_db_id);`
	DeindexTicketsTableOnTxDbID = `DROP INDEX uix_ticket_ticket_db_id;`

	DeleteTicketsDuplicateRows = `` /* 185-byte string literal not displayed */

	CreateVotesTable = `` /* 314-byte string literal not displayed */

	SelectAllVoteDbIDsHeightsTicketHashes = `SELECT id, height, ticket_hash FROM votes;`
	SelectAllVoteDbIDsHeightsTicketDbIDs  = `SELECT id, height, ticket_tx_db_id FROM votes;`

	// Index
	IndexVotesTableOnHashes = `CREATE UNIQUE INDEX uix_votes_hashes_index
		ON votes(tx_hash, block_hash);`
	DeindexVotesTableOnHashes = `DROP INDEX uix_votes_hashes_index;`

	IndexVotesTableOnCandidate = `CREATE INDEX uix_votes_candidate_block
		ON votes(candidate_block_hash);`
	DeindexVotesTableOnCandidate = `DROP INDEX uix_votes_candidate_block;`

	IndexVotesTableOnVoteVersion = `CREATE INDEX uix_votes_vote_version
		ON votes(version);`
	DeindexVotesTableOnVoteVersion = `DROP INDEX uix_votes_vote_version;`

	DeleteVotesDuplicateRows = `` /* 181-byte string literal not displayed */

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

	SelectMissesInBlock = `SELECT ticket_hash FROM misses WHERE block_hash = $1;`

	// Index
	IndexMissesTableOnHashes = `CREATE UNIQUE INDEX uix_misses_hashes_index
		ON misses(ticket_hash, block_hash);`
	DeindexMissesTableOnHashes = `DROP INDEX uix_misses_hashes_index;`

	DeleteMissesDuplicateRows = `` /* 187-byte string literal not displayed */

)
View Source
const (
	CreateTransactionTable = `` /* 409-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;`

	SelectTxIDHeightByHash = `SELECT id, block_height FROM transactions WHERE tx_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);`
	DeindexTransactionTableOnBlockIn = `DROP INDEX uix_tx_block_in;`

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

	DeleteTxDuplicateRows = `` /* 190-byte string literal not displayed */

	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;`
	UpsertVinRow = InsertVinRow0 + `ON CONFLICT (tx_hash, tx_index, tx_tree) DO UPDATE 
		SET tx_hash = $1, tx_index = $2, tx_tree = $3 RETURNING id;`

	DeleteVinsDuplicateRows = `` /* 186-byte string literal not displayed */

	IndexVinTableOnVins = `CREATE UNIQUE INDEX uix_vin
		ON vins(tx_hash, tx_index, tx_tree)
		;`  // 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;`
	CountVinsRows   = `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;`
	SelectFundingTxByVinID       = `SELECT prev_tx_hash 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 */

	DeleteVoutDuplicateRows = `` /* 188-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 UNIQUE INDEX uix_vout_txhash_ind
		ON vouts(tx_hash, tx_index, tx_tree);`
	DeindexVoutTableOnTxHashIdx = `DROP INDEX uix_vout_txhash_ind;`

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

)

Variables

View Source
var (
	SelectAllRevokes = fmt.Sprintf(`SELECT id, tx_hash, block_height, vin_db_ids[0] FROM transactions WHERE tx_type = %d;`, stake.TxTypeSSRtx)
)

Functions

func MakeAddressRowInsertStatement

func MakeAddressRowInsertStatement(checked bool) string

func MakeBlockInsertStatement

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

func MakeMissInsertStatement

func MakeMissInsertStatement(checked bool) string

func MakeTicketInsertStatement

func MakeTicketInsertStatement(checked bool) string

func MakeTxInsertStatement

func MakeTxInsertStatement(checked bool) string

func MakeVinCopyInStatement

func MakeVinCopyInStatement() string

func MakeVinInsertStatement

func MakeVinInsertStatement(checked bool) string

func MakeVoteInsertStatement

func MakeVoteInsertStatement(checked bool) 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