Documentation
¶
Overview ¶
Package query implements indexing and querying of annotated blockchain data.
Index ¶
- Constants
- Variables
- func ValidateTransactionFilter(filt string) error
- type AccountKey
- type AnnotatedAccount
- type AnnotatedAsset
- type AnnotatedInput
- type AnnotatedOutput
- type AnnotatedTx
- type Annotator
- type AssetKey
- type Bool
- type Indexer
- func (ind *Indexer) Accounts(ctx context.Context, filt string, vals []interface{}, after string, limit int) ([]*AnnotatedAccount, string, error)
- func (ind *Indexer) Assets(ctx context.Context, filt string, vals []interface{}, after string, limit int) ([]*AnnotatedAsset, string, error)
- func (ind *Indexer) Balances(ctx context.Context, filt string, vals []interface{}, sumBy []filter.Field, ...) ([]interface{}, error)
- func (ind *Indexer) IndexTransactions(ctx context.Context, b *legacy.Block) error
- func (ind *Indexer) LookupTxAfter(ctx context.Context, begin, end uint64) (TxAfter, error)
- func (ind *Indexer) Outputs(ctx context.Context, filt string, vals []interface{}, timestampMS uint64, ...) ([]*AnnotatedOutput, *OutputsAfter, error)
- func (ind *Indexer) ProcessBlocks(ctx context.Context)
- func (ind *Indexer) RegisterAnnotator(annotator Annotator)
- func (ind *Indexer) SaveAnnotatedAccount(ctx context.Context, account *AnnotatedAccount) error
- func (ind *Indexer) SaveAnnotatedAsset(ctx context.Context, asset *AnnotatedAsset, sortID string) error
- func (ind *Indexer) Transactions(ctx context.Context, filt string, vals []interface{}, after TxAfter, limit int, ...) ([]*AnnotatedTx, *TxAfter, error)
- type OutputsAfter
- type TxAfter
Constants ¶
const ( // TxPinName is used to identify the pin associated // with the transaction block processor. TxPinName = "tx" )
Variables ¶
var ( ErrBadAfter = errors.New("malformed pagination parameter after") ErrParameterCountMismatch = errors.New("wrong number of parameters to query") )
Functions ¶
Types ¶
type AccountKey ¶
type AnnotatedAccount ¶
type AnnotatedAccount struct {
ID string `json:"id"`
Alias string `json:"alias,omitempty"`
Keys []*AccountKey `json:"keys"`
Quorum int `json:"quorum"`
Tags *json.RawMessage `json:"tags"`
}
type AnnotatedAsset ¶
type AnnotatedAsset struct {
ID bc.AssetID `json:"id"`
Alias string `json:"alias,omitempty"`
IssuanceProgram chainjson.HexBytes `json:"issuance_program"`
Keys []*AssetKey `json:"keys"`
Quorum int `json:"quorum"`
Definition *json.RawMessage `json:"definition"`
Tags *json.RawMessage `json:"tags"`
IsLocal Bool `json:"is_local"`
}
type AnnotatedInput ¶
type AnnotatedInput struct {
Type string `json:"type"`
AssetID bc.AssetID `json:"asset_id"`
AssetAlias string `json:"asset_alias,omitempty"`
AssetDefinition *json.RawMessage `json:"asset_definition"`
AssetTags *json.RawMessage `json:"asset_tags,omitempty"`
AssetIsLocal Bool `json:"asset_is_local"`
Amount uint64 `json:"amount"`
IssuanceProgram chainjson.HexBytes `json:"issuance_program,omitempty"`
ControlProgram chainjson.HexBytes `json:"-"`
SpentOutputID *bc.Hash `json:"spent_output_id,omitempty"`
AccountID string `json:"account_id,omitempty"`
AccountAlias string `json:"account_alias,omitempty"`
AccountTags *json.RawMessage `json:"account_tags,omitempty"`
ReferenceData *json.RawMessage `json:"reference_data"`
IsLocal Bool `json:"is_local"`
}
type AnnotatedOutput ¶
type AnnotatedOutput struct {
Type string `json:"type"`
Purpose string `json:"purpose,omitempty"`
OutputID bc.Hash `json:"id"`
TransactionID *bc.Hash `json:"transaction_id,omitempty"`
Position int `json:"position"`
AssetID bc.AssetID `json:"asset_id"`
AssetAlias string `json:"asset_alias,omitempty"`
AssetDefinition *json.RawMessage `json:"asset_definition"`
AssetTags *json.RawMessage `json:"asset_tags"`
AssetIsLocal Bool `json:"asset_is_local"`
Amount uint64 `json:"amount"`
AccountID string `json:"account_id,omitempty"`
AccountAlias string `json:"account_alias,omitempty"`
AccountTags *json.RawMessage `json:"account_tags,omitempty"`
ControlProgram chainjson.HexBytes `json:"control_program"`
ReferenceData *json.RawMessage `json:"reference_data"`
IsLocal Bool `json:"is_local"`
}
type AnnotatedTx ¶
type AnnotatedTx struct {
ID bc.Hash `json:"id"`
Timestamp time.Time `json:"timestamp"`
BlockID bc.Hash `json:"block_id"`
BlockHeight uint64 `json:"block_height"`
Position uint32 `json:"position"`
BlockTransactionsCount uint32 `json:"block_transactions_count,omitempty"`
ReferenceData *json.RawMessage `json:"reference_data"`
IsLocal Bool `json:"is_local"`
Inputs []*AnnotatedInput `json:"inputs"`
Outputs []*AnnotatedOutput `json:"outputs"`
}
type Annotator ¶
type Annotator func(ctx context.Context, txs []*AnnotatedTx) error
Annotator describes a function capable of adding annotations to transactions, inputs and outputs.
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
Indexer creates, updates and queries against indexes.
func NewIndexer ¶
NewIndexer constructs a new indexer for indexing transactions.
func (*Indexer) Accounts ¶
func (ind *Indexer) Accounts(ctx context.Context, filt string, vals []interface{}, after string, limit int) ([]*AnnotatedAccount, string, error)
Accounts queries the blockchain for accounts matching the query `q`.
func (*Indexer) Assets ¶
func (ind *Indexer) Assets(ctx context.Context, filt string, vals []interface{}, after string, limit int) ([]*AnnotatedAsset, string, error)
Assets queries the blockchain for annotated assets matching the query.
func (*Indexer) Balances ¶
func (ind *Indexer) Balances(ctx context.Context, filt string, vals []interface{}, sumBy []filter.Field, timestampMS uint64) ([]interface{}, error)
Balances performs a balances query against the annotated_outputs.
func (*Indexer) IndexTransactions ¶
IndexTransactions is registered as a block callback on the Chain. It saves all annotated transactions to the database.
func (*Indexer) LookupTxAfter ¶
LookupTxAfter looks up the transaction `after` for the provided time range.
func (*Indexer) Outputs ¶
func (ind *Indexer) Outputs(ctx context.Context, filt string, vals []interface{}, timestampMS uint64, after *OutputsAfter, limit int) ([]*AnnotatedOutput, *OutputsAfter, error)
func (*Indexer) ProcessBlocks ¶
func (*Indexer) RegisterAnnotator ¶
RegisterAnnotator adds an additional annotator capable of mutating the annotated transaction object.
func (*Indexer) SaveAnnotatedAccount ¶
func (ind *Indexer) SaveAnnotatedAccount(ctx context.Context, account *AnnotatedAccount) error
SaveAnnotatedAccount saves an annotated account to the query indexes.
func (*Indexer) SaveAnnotatedAsset ¶
func (ind *Indexer) SaveAnnotatedAsset(ctx context.Context, asset *AnnotatedAsset, sortID string) error
SaveAnnotatedAsset saves an annotated asset to the query indexes.
type OutputsAfter ¶
type OutputsAfter struct {
// contains filtered or unexported fields
}
func DecodeOutputsAfter ¶
func DecodeOutputsAfter(str string) (c *OutputsAfter, err error)
func (OutputsAfter) String ¶
func (cur OutputsAfter) String() string
type TxAfter ¶
type TxAfter struct {
// FromBlockHeight and FromPosition uniquely identify the last transaction returned
// by a list-transactions query.
//
// If list-transactions is called with a time range instead of an `after`, these fields
// are populated with the position of the transaction at the start of the time range.
FromBlockHeight uint64 // exclusive
FromPosition uint32 // exclusive
// StopBlockHeight identifies the last block that should be included in a transaction
// list. It is used when list-transactions is called with a time range instead
// of an `after`.
StopBlockHeight uint64 // inclusive
}