db

package
v0.0.0-...-891ff74 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Hash           types.Bytes
	Height         int32
	Weight         int32
	Size           int64
	Version        int32
	HashMerkleRoot types.Bytes
	WitnessRoot    types.Bytes
	TreeRoot       types.Bytes
	ReservedRoot   types.Bytes
	Mask           types.Bytes
	Time           int32
	Bits           types.Bytes
	Difficulty     float64
	Chainwork      types.Bytes
	Nonce          int64
	ExtraNonce     types.Bytes
	Orphan         bool
}

type CovenantAction

type CovenantAction string
const (
	CovenantActionNONE     CovenantAction = "NONE"
	CovenantActionCLAIM    CovenantAction = "CLAIM"
	CovenantActionOPEN     CovenantAction = "OPEN"
	CovenantActionBID      CovenantAction = "BID"
	CovenantActionREVEAL   CovenantAction = "REVEAL"
	CovenantActionREDEEM   CovenantAction = "REDEEM"
	CovenantActionREGISTER CovenantAction = "REGISTER"
	CovenantActionUPDATE   CovenantAction = "UPDATE"
	CovenantActionRENEW    CovenantAction = "RENEW"
	CovenantActionTRANSFER CovenantAction = "TRANSFER"
	CovenantActionFINALIZE CovenantAction = "FINALIZE"
	CovenantActionREVOKE   CovenantAction = "REVOKE"
)

func (*CovenantAction) Scan

func (e *CovenantAction) Scan(src interface{}) error

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type GetAddressInfoRow

type GetAddressInfoRow struct {
	ValueTotal     int64
	ValueUsed      int64
	TxOutputsTotal int64
	TxOutputsUsed  int64
}

type GetBlockByHashRow

type GetBlockByHashRow struct {
	Hash           types.Bytes
	Height         int32
	Weight         int32
	Size           int64
	Version        int32
	HashMerkleRoot types.Bytes
	WitnessRoot    types.Bytes
	TreeRoot       types.Bytes
	ReservedRoot   types.Bytes
	Mask           types.Bytes
	Time           int32
	Bits           types.Bytes
	Difficulty     float64
	Chainwork      types.Bytes
	Nonce          int64
	ExtraNonce     types.Bytes
	Orphan         bool
	TxsCount       int32
}

type GetBlockByHeightRow

type GetBlockByHeightRow struct {
	Hash           types.Bytes
	Height         int32
	Weight         int32
	Size           int64
	Version        int32
	HashMerkleRoot types.Bytes
	WitnessRoot    types.Bytes
	TreeRoot       types.Bytes
	ReservedRoot   types.Bytes
	Mask           types.Bytes
	Time           int32
	Bits           types.Bytes
	Difficulty     float64
	Chainwork      types.Bytes
	Nonce          int64
	ExtraNonce     types.Bytes
	Orphan         bool
	TxsCount       int32
}

type GetBlocksParams

type GetBlocksParams struct {
	Limit  int32
	Offset int32
}

type GetBlocksRow

type GetBlocksRow struct {
	Hash           types.Bytes
	Height         int32
	Weight         int32
	Size           int64
	Version        int32
	HashMerkleRoot types.Bytes
	WitnessRoot    types.Bytes
	TreeRoot       types.Bytes
	ReservedRoot   types.Bytes
	Mask           types.Bytes
	Time           int32
	Bits           types.Bytes
	Difficulty     float64
	Chainwork      types.Bytes
	Nonce          int64
	ExtraNonce     types.Bytes
	Orphan         bool
	TxsCount       int32
}

type GetLastNameBlockHeightByActionAndHashParams

type GetLastNameBlockHeightByActionAndHashParams struct {
	CovenantAction   CovenantAction
	CovenantNameHash *types.Bytes
}

type GetMempoolTransactionsParams

type GetMempoolTransactionsParams struct {
	Limit  int32
	Offset int32
}

type GetNameBidsByHashParams

type GetNameBidsByHashParams struct {
	NameHash types.Bytes
	Offset   int32
	Limit    int32
}

type GetNameBidsByHashRow

type GetNameBidsByHashRow struct {
	BidTxid             types.Bytes
	BlockHeightNotNull  int32
	RevealTxid          types.Bytes
	RevealHeightNotNull int32
	RevealIndexNotNull  int32
	LockupValue         int64
	RevealValueNotNull  int64
}

func (*GetNameBidsByHashRow) BlockHeight

func (row *GetNameBidsByHashRow) BlockHeight() *int32

func (*GetNameBidsByHashRow) Index

func (row *GetNameBidsByHashRow) Index() *int32

func (*GetNameBidsByHashRow) RevealHeight

func (row *GetNameBidsByHashRow) RevealHeight() *int32

func (*GetNameBidsByHashRow) RevealIndex

func (row *GetNameBidsByHashRow) RevealIndex() *int32

func (*GetNameBidsByHashRow) RevealValue

func (row *GetNameBidsByHashRow) RevealValue() *int64

type GetNameCountsByHashRow

type GetNameCountsByHashRow struct {
	BidsCount    int32
	RecordsCount int32
	ActionsCount int32
}

type GetNameOtherActionsByHashParams

type GetNameOtherActionsByHashParams struct {
	NameHash types.Bytes
	Offset   int32
	Limit    int32
}

type GetNameOtherActionsByHashRow

type GetNameOtherActionsByHashRow struct {
	Txid               types.Bytes
	BlockHeightNotNull int32
	CovenantAction     CovenantAction
}

func (*GetNameOtherActionsByHashRow) BlockHeight

func (row *GetNameOtherActionsByHashRow) BlockHeight() *int32

type GetNameRecordsByHashParams

type GetNameRecordsByHashParams struct {
	NameHash types.Bytes
	Offset   int32
	Limit    int32
}

type GetNameRecordsByHashRow

type GetNameRecordsByHashRow struct {
	Txid               types.Bytes
	BlockHeightNotNull int32
	Data               types.Bytes
}

func (*GetNameRecordsByHashRow) BlockHeight

func (row *GetNameRecordsByHashRow) BlockHeight() *int32

type GetReservedNameRow

type GetReservedNameRow struct {
	OriginName  string
	Name        string
	NameHash    types.Bytes
	ClaimAmount int64
}

type GetTransactionByTxidRow

type GetTransactionByTxidRow struct {
	Txid               types.Bytes
	WitnessTx          types.Bytes
	Fee                int64
	Rate               int64
	BlockHash          *types.Bytes
	Index              sql.NullInt32
	Version            int32
	Locktime           int32
	Size               int64
	BlockHeightNotNull int32
}

func (*GetTransactionByTxidRow) BlockHeight

func (row *GetTransactionByTxidRow) BlockHeight() *int32

type GetTransactionsByBlockHeightParams

type GetTransactionsByBlockHeightParams struct {
	Height int32
	Limit  int32
	Offset int32
}

type GetTransactionsByBlockHeightRow

type GetTransactionsByBlockHeightRow struct {
	Txid               types.Bytes
	WitnessTx          types.Bytes
	Fee                int64
	Rate               int64
	BlockHash          *types.Bytes
	Index              sql.NullInt32
	Version            int32
	Locktime           int32
	Size               int64
	BlockHeightNotNull int32
}

func (*GetTransactionsByBlockHeightRow) BlockHeight

func (row *GetTransactionsByBlockHeightRow) BlockHeight() *int32

type GetTxOutputsByAddressParams

type GetTxOutputsByAddressParams struct {
	Address string
	Offset  int32
	Limit   int32
}

type GetTxOutputsByAddressRow

type GetTxOutputsByAddressRow struct {
	Txid                 types.Bytes
	Index                int32
	Value                int64
	Address              string
	CovenantAction       CovenantAction
	CovenantNameHash     *types.Bytes
	CovenantHeight       *types.Bytes
	CovenantName         *types.Bytes
	CovenantBidHash      *types.Bytes
	CovenantNonce        *types.Bytes
	CovenantRecordData   *types.Bytes
	CovenantBlockHash    *types.Bytes
	CovenantVersion      *types.Bytes
	CovenantAddress      *types.Bytes
	CovenantClaimHeight  *types.Bytes
	CovenantRenewalCount *types.Bytes
	HashPrevoutNotNull   types.Bytes
	IndexPrevoutNotNull  int64
	SpendHeightNotNull   int32
	HeightNotNull        int32
	Name                 string
}

func (*GetTxOutputsByAddressRow) HashPrevout

func (row *GetTxOutputsByAddressRow) HashPrevout() *types.Bytes

func (*GetTxOutputsByAddressRow) Height

func (row *GetTxOutputsByAddressRow) Height() *int32

func (*GetTxOutputsByAddressRow) IndexPrevout

func (row *GetTxOutputsByAddressRow) IndexPrevout() *int64

func (*GetTxOutputsByAddressRow) SpendHeight

func (row *GetTxOutputsByAddressRow) SpendHeight() *int32

type GetTxOutputsByTxidRow

type GetTxOutputsByTxidRow struct {
	Txid                 types.Bytes
	Index                int32
	Value                int64
	Address              string
	CovenantAction       CovenantAction
	CovenantNameHash     *types.Bytes
	CovenantHeight       *types.Bytes
	CovenantName         *types.Bytes
	CovenantBidHash      *types.Bytes
	CovenantNonce        *types.Bytes
	CovenantRecordData   *types.Bytes
	CovenantBlockHash    *types.Bytes
	CovenantVersion      *types.Bytes
	CovenantAddress      *types.Bytes
	CovenantClaimHeight  *types.Bytes
	CovenantRenewalCount *types.Bytes
	Name                 string
}

type InsertBlockParams

type InsertBlockParams struct {
	Hash           types.Bytes
	Height         int32
	Weight         int32
	Size           int64
	Version        int32
	HashMerkleRoot types.Bytes
	WitnessRoot    types.Bytes
	TreeRoot       types.Bytes
	ReservedRoot   types.Bytes
	Mask           types.Bytes
	Time           int32
	Bits           types.Bytes
	Difficulty     float64
	Chainwork      types.Bytes
	Nonce          int64
	ExtraNonce     types.Bytes
}

type InsertTransactionParams

type InsertTransactionParams struct {
	Txid      types.Bytes
	WitnessTx types.Bytes
	Fee       int64
	Rate      int64
	BlockHash *types.Bytes
	Index     sql.NullInt32
	Version   int32
	Locktime  int32
	Size      int64
}

type InsertTxInputParams

type InsertTxInputParams struct {
	Txid         types.Bytes
	Index        int64
	HashPrevout  types.Bytes
	IndexPrevout int64
	Sequence     int64
}

type InsertTxOutputParams

type InsertTxOutputParams struct {
	Txid                 types.Bytes
	Index                int32
	Value                int64
	Address              string
	CovenantAction       CovenantAction
	CovenantNameHash     *types.Bytes
	CovenantHeight       *types.Bytes
	CovenantName         *types.Bytes
	CovenantBidHash      *types.Bytes
	CovenantNonce        *types.Bytes
	CovenantRecordData   *types.Bytes
	CovenantBlockHash    *types.Bytes
	CovenantVersion      *types.Bytes
	CovenantAddress      *types.Bytes
	CovenantClaimHeight  *types.Bytes
	CovenantRenewalCount *types.Bytes
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) AddressExists

func (q *Queries) AddressExists(ctx context.Context, address string) (bool, error)

func (*Queries) DeleteBlocksAfterHeight

func (q *Queries) DeleteBlocksAfterHeight(ctx context.Context, height int32) error

func (*Queries) DeleteMempool

func (q *Queries) DeleteMempool(ctx context.Context) error

func (*Queries) GetAddressInfo

func (q *Queries) GetAddressInfo(ctx context.Context, address string) (GetAddressInfoRow, error)

This query takes a lot of time, perhaps can be optimized further

func (*Queries) GetBlockByHash

func (q *Queries) GetBlockByHash(ctx context.Context, hash types.Bytes) (GetBlockByHashRow, error)

func (*Queries) GetBlockByHeight

func (q *Queries) GetBlockByHeight(ctx context.Context, height int32) (GetBlockByHeightRow, error)

func (*Queries) GetBlockHashByHeight

func (q *Queries) GetBlockHashByHeight(ctx context.Context, height int32) (types.Bytes, error)

func (*Queries) GetBlocks

func (q *Queries) GetBlocks(ctx context.Context, arg GetBlocksParams) ([]GetBlocksRow, error)

func (*Queries) GetBlocksMaxHeight

func (q *Queries) GetBlocksMaxHeight(ctx context.Context) (int32, error)

func (*Queries) GetLastNameBlockHeightByActionAndHash

func (q *Queries) GetLastNameBlockHeightByActionAndHash(ctx context.Context, arg GetLastNameBlockHeightByActionAndHashParams) (int32, error)

func (*Queries) GetMempoolTransactions

func (q *Queries) GetMempoolTransactions(ctx context.Context, arg GetMempoolTransactionsParams) ([]Transaction, error)

func (*Queries) GetNameBidsByHash

func (q *Queries) GetNameBidsByHash(ctx context.Context, arg GetNameBidsByHashParams) ([]GetNameBidsByHashRow, error)

func (*Queries) GetNameCountsByHash

func (q *Queries) GetNameCountsByHash(ctx context.Context, nameHash types.Bytes) (GetNameCountsByHashRow, error)

func (*Queries) GetNameOtherActionsByHash

func (q *Queries) GetNameOtherActionsByHash(ctx context.Context, arg GetNameOtherActionsByHashParams) ([]GetNameOtherActionsByHashRow, error)

func (*Queries) GetNameRecordsByHash

func (q *Queries) GetNameRecordsByHash(ctx context.Context, arg GetNameRecordsByHashParams) ([]GetNameRecordsByHashRow, error)

func (*Queries) GetReservedName

func (q *Queries) GetReservedName(ctx context.Context, name string) (GetReservedNameRow, error)

func (*Queries) GetTransactionByTxid

func (q *Queries) GetTransactionByTxid(ctx context.Context, txid types.Bytes) (GetTransactionByTxidRow, error)

func (*Queries) GetTxInputsByTxid

func (q *Queries) GetTxInputsByTxid(ctx context.Context, txid types.Bytes) ([]TxInput, error)

func (*Queries) GetTxOutputsByAddress

func (q *Queries) GetTxOutputsByAddress(ctx context.Context, arg GetTxOutputsByAddressParams) ([]GetTxOutputsByAddressRow, error)

This query can be optimized to be very quick by removing join for the name, however as it's still quicker than the GetAddressInfo I've left the name for the sake of simplicity

func (*Queries) GetTxOutputsByTxid

func (q *Queries) GetTxOutputsByTxid(ctx context.Context, txid types.Bytes) ([]GetTxOutputsByTxidRow, error)

func (*Queries) InsertBlock

func (q *Queries) InsertBlock(ctx context.Context, arg InsertBlockParams) error

func (*Queries) InsertTransaction

func (q *Queries) InsertTransaction(ctx context.Context, arg InsertTransactionParams) error

func (*Queries) InsertTxInput

func (q *Queries) InsertTxInput(ctx context.Context, arg InsertTxInputParams) error

func (*Queries) InsertTxOutput

func (q *Queries) InsertTxOutput(ctx context.Context, arg InsertTxOutputParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type ReservedName

type ReservedName struct {
	OriginName  types.Bytes
	Name        string
	NameHash    types.Bytes
	ClaimAmount int64
}

type Transaction

type Transaction struct {
	Txid      types.Bytes
	WitnessTx types.Bytes
	Fee       int64
	Rate      int64
	BlockHash *types.Bytes
	Index     sql.NullInt32
	Version   int32
	Locktime  int64
	Size      int64
}

type TxInput

type TxInput struct {
	Txid         types.Bytes
	Index        int64
	HashPrevout  types.Bytes
	IndexPrevout int64
	Sequence     int64
}

type TxOutput

type TxOutput struct {
	Txid                 types.Bytes
	Index                int32
	Value                int64
	Address              string
	CovenantAction       CovenantAction
	CovenantNameHash     *types.Bytes
	CovenantHeight       *types.Bytes
	CovenantName         *types.Bytes
	CovenantBidHash      *types.Bytes
	CovenantNonce        *types.Bytes
	CovenantRecordData   *types.Bytes
	CovenantBlockHash    *types.Bytes
	CovenantVersion      *types.Bytes
	CovenantAddress      *types.Bytes
	CovenantClaimHeight  *types.Bytes
	CovenantRenewalCount *types.Bytes
}

Jump to

Keyboard shortcuts

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