dbaccess

package
v0.0.0-...-fa2bc5f Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: ISC Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcceptedTransactionsByBlockHashes

func AcceptedTransactionsByBlockHashes(ctx database.Context, blockHashes []string, preloadedFields ...dbmodels.FieldName) ([]*dbmodels.Transaction, error)

AcceptedTransactionsByBlockHashes retrieves a list of transactions that were accepted by blocks with the given `blockHashes`

func AcceptedTransactionsByBlockID

func AcceptedTransactionsByBlockID(ctx database.Context, blockID uint64, preloadedFields ...dbmodels.FieldName) ([]*dbmodels.Transaction, error)

AcceptedTransactionsByBlockID retrieves a list of transactions that were accepted by block with ID equal to `blockID` If preloadedFields was provided - preloads the requested fields

func AddressesByAddressStrings

func AddressesByAddressStrings(ctx database.Context, addressStrings []string, preloadedFields ...dbmodels.FieldName) ([]*dbmodels.Address, error)

AddressesByAddressStrings retrieves all addresss by their address strings. If preloadedFields was provided - preloads the requested fields

func BlockByHash

func BlockByHash(ctx database.Context, blockHash string, preloadedFields ...dbmodels.FieldName) (*dbmodels.Block, error)

BlockByHash retrieves a block from the database according to its hash If preloadedFields was provided - preloads the requested fields

func Blocks

func Blocks(ctx database.Context, order Order, skip uint64, limit uint64,
	preloadedFields ...dbmodels.FieldName) ([]*dbmodels.Block, error)

Blocks retrieves from the database up to `limit` blocks in the requested `order`, skipping the first `skip` blocks If preloadedFields was provided - preloads the requested fields

func BlocksByHashes

func BlocksByHashes(ctx database.Context, hashes []string, preloadedFields ...dbmodels.FieldName) ([]*dbmodels.Block, error)

BlocksByHashes retreives a list of blocks with the corresponding `hashes`

func BlocksCount

func BlocksCount(ctx database.Context) (uint64, error)

BlocksCount returns the total number of blocks stored in the database

func BluestBlock

func BluestBlock(ctx database.Context) (*dbmodels.Block, error)

BluestBlock fetches the block with the highest blue score from the database Note: this is not necessarily the same as SelectedTip(): In a non-fully synced server - chain is still partial, and therefore SelectedTip() returns a lower block.

func BulkInsert

func BulkInsert(ctx database.Context, objects []interface{}) error

BulkInsert inserts a long list of objects into the database. Utilizes bulk insertion for much faster times.

func DoesBlockExist

func DoesBlockExist(ctx database.Context, blockHash string) (bool, error)

DoesBlockExist checks in the database whether a block with `blockHash` exists.

func ExistingHashes

func ExistingHashes(ctx database.Context, hashes []string) ([]string, error)

ExistingHashes filters out the non existing hashes from the given list

func SelectedTip

func SelectedTip(ctx database.Context) (*dbmodels.Block, error)

SelectedTip fetches the selected tip from the database

func SelectedTipBlueScore

func SelectedTipBlueScore(ctx database.Context) (uint64, error)

SelectedTipBlueScore returns the blue score of the selected tip

func SubnetworksByIDs

func SubnetworksByIDs(ctx database.Context, subnetworkIDs []string, preloadedFields ...dbmodels.FieldName) ([]*dbmodels.Subnetwork, error)

SubnetworksByIDs retrieves all subnetworks by their `subnetworkIDs`. If preloadedFields was provided - preloads the requested fields

func TransactionByHash

func TransactionByHash(ctx database.Context, transactionHash string, preloadedFields ...dbmodels.FieldName) (*dbmodels.Transaction, error)

TransactionByHash retrieves a transaction from the database that has the provided hash If preloadedFields was provided - preloads the requested fields

func TransactionByID

func TransactionByID(ctx database.Context, transactionID string, preloadedFields ...dbmodels.FieldName) (*dbmodels.Transaction, error)

TransactionByID retrieves a transaction from the database that has the provided ID If preloadedFields was provided - preloads the requested fields

func TransactionDoubleSpends

func TransactionDoubleSpends(ctx database.Context, txID string, preloadedFields ...dbmodels.FieldName) ([]*dbmodels.Transaction, error)

TransactionDoubleSpends retrieves transactions, that have at least one input which is the same as in transaction that has the provided txID

func TransactionOutputsByOutpoints

func TransactionOutputsByOutpoints(ctx database.Context, outpoints []*Outpoint) ([]*dbmodels.TransactionOutput, error)

TransactionOutputsByOutpoints retrieves all transaction outputs referenced by `outpoints`. If preloadedFields was provided - preloads the requested fields

func TransactionsByAddress

func TransactionsByAddress(ctx database.Context, address string, order Order, skip uint64, limit uint64, preloadedFields ...dbmodels.FieldName) (
	[]*dbmodels.Transaction, error)

TransactionsByAddress retrieves up to `limit` transactions sent to or from `address`, in the requested `order`, skipping the first `skip` blocks If preloadedFields was provided - preloads the requested fields

func TransactionsByAddressCount

func TransactionsByAddressCount(ctx database.Context, address string) (uint64, error)

TransactionsByAddressCount returns the total number of transactions sent to or from `address`

func TransactionsByBlockHash

func TransactionsByBlockHash(ctx database.Context, blockHash string, preloadedFields ...dbmodels.FieldName) ([]*dbmodels.Transaction, error)

TransactionsByBlockHash retrieves a list of transactions included by the block with the given blockHash

func TransactionsByHashes

func TransactionsByHashes(ctx database.Context, transactionHashes []string,
	preloadedFields ...dbmodels.FieldName) ([]*dbmodels.Transaction, error)

TransactionsByHashes retrieves all transactions by their `transactionHashes`. If preloadedFields was provided - preloads the requested fields

func TransactionsByIDs

func TransactionsByIDs(ctx database.Context, transactionIDs []string, preloadedFields ...dbmodels.FieldName) ([]*dbmodels.Transaction, error)

TransactionsByIDs retrieves all transactions by their `transactionIDs`. If preloadedFields was provided - preloads the requested fields

func TransactionsByIDsAndBlockHash

func TransactionsByIDsAndBlockHash(ctx database.Context, transactionIDs []string, blockHash string, preloadedFields ...dbmodels.FieldName) ([]*dbmodels.Transaction, error)

TransactionsByIDsAndBlockHash retrieves all transactions in a block with the given hash by their `transactionIDs`. If preloadedFields was provided - preloads the requested fields

func TransactionsByIDsAndBlockID

func TransactionsByIDsAndBlockID(ctx database.Context, transactionIDs []string, blockID uint64,
	preloadedFields ...dbmodels.FieldName) ([]*dbmodels.Transaction, error)

TransactionsByIDsAndBlockID retrieves all transactions in a block with the given ID by their `transactionIDs`. If preloadedFields was provided - preloads the requested fields

func UTXOsByAddress

func UTXOsByAddress(ctx database.Context, address string, preloadedFields ...dbmodels.FieldName) ([]*dbmodels.TransactionOutput, error)

UTXOsByAddress retrieves all transaction outputs incoming to `address`. If preloadedFields was provided - preloads the requested fields

func UpdateBlockAcceptingBlockID

func UpdateBlockAcceptingBlockID(ctx database.Context, blockID uint64, acceptingBlockID *uint64) error

UpdateBlockAcceptingBlockID updates blocks with `blockID` to be accepted by `acceptingBlockID `. `acceptingBlockID` can be set nil.

func UpdateBlockIsChainBlock

func UpdateBlockIsChainBlock(ctx database.Context, blockID uint64, isChainBlock bool) error

UpdateBlockIsChainBlock updates the block `blockID` by setting its isChainBlock field to `isChainBlock`

func UpdateBlocksAcceptedByAcceptingBlock

func UpdateBlocksAcceptedByAcceptingBlock(ctx database.Context, currentAcceptingBlockID uint64, newAcceptingBlockID *uint64) error

UpdateBlocksAcceptedByAcceptingBlock updates all blocks which are currently accepted by `currentAcceptingBlockID` to be accepted by `newAcceptingBlockID`. `newAcceptingBlockID` can be set nil.

func UpdateTransactionAcceptingBlockID

func UpdateTransactionAcceptingBlockID(ctx database.Context, transactionID uint64, acceptingBlockID *uint64) error

UpdateTransactionAcceptingBlockID updates the transaction with given `transactionID` to have given `acceptingBlockID`

func UpdateTransactionOutputIsSpent

func UpdateTransactionOutputIsSpent(ctx database.Context, txOutID uint64, isSpent bool) error

UpdateTransactionOutputIsSpent updates transaction-output `txOutID` by setting its IsSpent field to `isSpent`

Types

type Order

type Order string

Order signifies the order at which results to a query are going to be returned.

const (
	OrderUnknown    Order = ""
	OrderAscending  Order = "ASC"
	OrderDescending Order = "DESC"
)

Order constants

func StringToOrder

func StringToOrder(orderString string) (Order, error)

StringToOrder converts an order string into an Order type. Returns OrderUnknown and an error if passed string is not ASC or DESC

type Outpoint

type Outpoint struct {
	TransactionID string
	Index         uint32
}

Outpoint represent an outpoint in a transaction input.

Jump to

Keyboard shortcuts

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