query

package
v0.0.0-...-4e0ae02 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2016 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package query implements indexing and querying of annotated blockchain data.

Index

Constants

View Source
const (
	// TxPinName is used to identify the pin associated
	// with the transaction block processor.
	TxPinName = "tx"
)

Variables

View Source
var (
	ErrBadAfter               = errors.New("malformed pagination parameter after")
	ErrParameterCountMismatch = errors.New("wrong number of parameters to query")
)

Functions

This section is empty.

Types

type Annotator

type Annotator func(ctx context.Context, txs []map[string]interface{}) 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

func NewIndexer(db pg.DB, c *protocol.Chain, pinStore *pin.Store) *Indexer

NewIndexer constructs a new indexer for indexing transactions.

func (*Indexer) Accounts

func (ind *Indexer) Accounts(ctx context.Context, p filter.Predicate, vals []interface{}, after string, limit int) ([]map[string]interface{}, string, error)

Accounts queries the blockchain for accounts matching the query `q`.

func (*Indexer) Assets

func (ind *Indexer) Assets(ctx context.Context, p filter.Predicate, vals []interface{}, after string, limit int) ([]map[string]interface{}, string, error)

Assets queries the blockchain for annotated assets matching the query.

func (*Indexer) Balances

func (ind *Indexer) Balances(ctx context.Context, p filter.Predicate, vals []interface{}, sumBy []filter.Field, timestampMS uint64) ([]interface{}, error)

Balances performs a balances query against the annotated_outputs.

func (*Indexer) IndexTransactions

func (ind *Indexer) IndexTransactions(ctx context.Context, b *bc.Block) error

IndexTransactions is registered as a block callback on the Chain. It saves all annotated transactions to the database.

func (*Indexer) LookupTxAfter

func (ind *Indexer) LookupTxAfter(ctx context.Context, begin, end uint64) (TxAfter, error)

LookupTxAfter looks up the transaction `after` for the provided time range.

func (*Indexer) Outputs

func (ind *Indexer) Outputs(ctx context.Context, p filter.Predicate, vals []interface{}, timestampMS uint64, after *OutputsAfter, limit int) ([]interface{}, *OutputsAfter, error)

func (*Indexer) ProcessBlocks

func (ind *Indexer) ProcessBlocks(ctx context.Context)

func (*Indexer) RegisterAnnotator

func (ind *Indexer) RegisterAnnotator(annotator Annotator)

RegisterAnnotator adds an additional annotator capable of mutating the annotated transaction object.

func (*Indexer) SaveAnnotatedAccount

func (ind *Indexer) SaveAnnotatedAccount(ctx context.Context, accountID string, account map[string]interface{}) error

SaveAnnotatedAccount saves an annotated account to the query indexes.

func (*Indexer) SaveAnnotatedAsset

func (ind *Indexer) SaveAnnotatedAsset(ctx context.Context, assetID bc.AssetID, asset map[string]interface{}, sortID string) error

SaveAnnotatedAsset saves an annotated asset to the query indexes.

func (*Indexer) Transactions

func (ind *Indexer) Transactions(ctx context.Context, p filter.Predicate, vals []interface{}, after TxAfter, limit int, asc bool) ([]interface{}, *TxAfter, error)

Transactions queries the blockchain for transactions matching the filter predicate `p`.

func (*Indexer) TxFeeds

func (ind *Indexer) TxFeeds(ctx context.Context, after string, limit int) ([]*txfeed.TxFeed, string, error)

TxFeeds queries the blockchain for txfeeds matching the query.

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
}

func DecodeTxAfter

func DecodeTxAfter(str string) (c TxAfter, err error)

func (TxAfter) String

func (after TxAfter) String() string

Directories

Path Synopsis
Package filter parses and evaluates Chain filter expressions.
Package filter parses and evaluates Chain filter expressions.

Jump to

Keyboard shortcuts

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