search

package
v1.99.99 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const HeightByBlockHashCommand = "heightbyblockhash"

HeightByBlockHashCommand is a QueryParams command for searching block height by block hash.

View Source
const HeightByTxHashCommand = "heightbytxhash"

HeightByTxHashCommand is a QueryParams command for searching block height by tx hash.

View Source
const HeightsByTxTypesCommand = "heightsbytxtypes"

HeightsByTxTypesCommand is a QueryParams command for searching block heights by tx types.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountHistoryParams

type AccountHistoryParams struct {
	Address     string `json:"addr"`
	AfterHeight uint64 `json:"afterheight"`
	Limit       int    `json:"limit"`
}

AccountHistoryParams is a json-friendly struct for the /account/history endpoint.

func (*AccountHistoryParams) DecodeMsg

func (z *AccountHistoryParams) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (AccountHistoryParams) EncodeMsg

func (z AccountHistoryParams) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (AccountHistoryParams) MarshalMsg

func (z AccountHistoryParams) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (AccountHistoryParams) Msgsize

func (z AccountHistoryParams) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*AccountHistoryParams) UnmarshalMsg

func (z *AccountHistoryParams) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type AccountHistoryResponse

type AccountHistoryResponse struct {
	Txs  []AccountTxValueData `msg:"t"`
	More bool                 `msg:"m"`
}

AccountHistoryResponse is the return value from the account history endpoint.

func (*AccountHistoryResponse) DecodeMsg

func (z *AccountHistoryResponse) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*AccountHistoryResponse) EncodeMsg

func (z *AccountHistoryResponse) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*AccountHistoryResponse) Marshal

func (response *AccountHistoryResponse) Marshal() string

Marshal the account history response into something we can pass over RPC.

func (*AccountHistoryResponse) MarshalMsg

func (z *AccountHistoryResponse) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*AccountHistoryResponse) Msgsize

func (z *AccountHistoryResponse) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*AccountHistoryResponse) Unmarshal

func (response *AccountHistoryResponse) Unmarshal(searchValue string) error

Unmarshal the account history response from something we received over RPC.

func (*AccountHistoryResponse) UnmarshalMsg

func (z *AccountHistoryResponse) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type AccountListParams

type AccountListParams struct {
	Address string `json:"addr"`
	After   string `json:"after"`
	Limit   int    `json:"limit"`
}

AccountListParams is a json-friendly struct for the /account/list endpoint.

func (*AccountListParams) DecodeMsg

func (z *AccountListParams) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (AccountListParams) EncodeMsg

func (z AccountListParams) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (AccountListParams) MarshalMsg

func (z AccountListParams) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (AccountListParams) Msgsize

func (z AccountListParams) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*AccountListParams) UnmarshalMsg

func (z *AccountListParams) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type AccountTxValueData

type AccountTxValueData struct {
	BlockHeight uint64     `msg:"h"`
	TxOffset    int        `msg:"o"`
	Balance     types.Ndau `msg:"b"`
}

AccountTxValueData is like TxValueData that stores account balance at the associated block. We could index a Ref target hash, but that would use more space than just storing the balance.

func (*AccountTxValueData) DecodeMsg

func (z *AccountTxValueData) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*AccountTxValueData) EncodeMsg

func (z *AccountTxValueData) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*AccountTxValueData) Marshal

func (valueData *AccountTxValueData) Marshal() string

Marshal the value data into a search value string to index it with its search key string.

func (*AccountTxValueData) MarshalMsg

func (z *AccountTxValueData) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*AccountTxValueData) Msgsize

func (z *AccountTxValueData) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*AccountTxValueData) Unmarshal

func (valueData *AccountTxValueData) Unmarshal(searchValue string) error

Unmarshal the given search value string that was indexed with its search key string.

func (*AccountTxValueData) UnmarshalMsg

func (z *AccountTxValueData) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type AppIndexable

type AppIndexable interface {
	GetAccountAddresses(tx metatx.Transactable) ([]string, error)
	GetState() metastate.State
	CalculateTxFeeNapu(tx metatx.Transactable) (uint64, error)
	CalculateTxSIBNapu(tx metatx.Transactable) (uint64, error)
}

AppIndexable is an app which can help index its transactions.

It's really only a thing in order to avoid circular imports; it will always in actuality be an ndau.App

type Client

type Client struct {
	*metasearch.Client
	// contains filtered or unexported fields
}

Client is a search Client that implements IncrementalIndexer.

func NewClient

func NewClient(address string, version int, app AppIndexable) (search *Client, err error)

NewClient is a factory method for Client.

func (*Client) BlockTime

func (search *Client) BlockTime(height uint64) (math.Timestamp, error)

BlockTime returns the timestamp for the block at a given height returns the zero value and no error if the block is unknown

func (*Client) GetTxTypeAtHeight

func (search *Client) GetTxTypeAtHeight(height uint64, txType string, limit int) (TxListValueData, error)

func (*Client) IndexBlockchain

func (search *Client) IndexBlockchain(
	db datas.Database, ds datas.Dataset,
) (updateCount int, insertCount int, err error)

IndexBlockchain fills the index with data from the blockchain, from the head block down to just before the last block we indexed.

func (*Client) OnBeginBlock

func (search *Client) OnBeginBlock(height uint64, blockTime math.Timestamp, tmHash string) error

OnBeginBlock resets our local cache for incrementally indexing the block at the given height.

func (*Client) OnCommit

func (search *Client) OnCommit() error

OnCommit indexes all the transaction data we collected since the last BeginBlock().

func (*Client) OnDeliverTx

func (search *Client) OnDeliverTx(appI interface{}, tx metatx.Transactable) error

OnDeliverTx grabs the fields out of this transaction to index when the block is committed.

func (*Client) SearchAccountHistory

func (search *Client) SearchAccountHistory(
	addr string, afterHeight uint64, limit int,
) (ahr *AccountHistoryResponse, err error)

SearchAccountHistory returns an array of block height and txoffset pairs associated with the given account address. Pass in 0, 0 for the paging params to get the entire history.

func (*Client) SearchBlockHash

func (search *Client) SearchBlockHash(blockHash string) (uint64, error)

SearchBlockHash returns the height of the given block hash. Returns 0 and no error if the given block hash was not found in the index.

func (*Client) SearchMarketPrice

func (search *Client) SearchMarketPrice(params PriceQueryParams) (PriceQueryResults, error)

SearchMarketPrice searches for market price records

In the parameters: Before and After have exclusive semantics.

The zero value of Before and After are treated as open-ended ranges. The zero value of Limit returns all results.

func (*Client) SearchMostRecentRegisterNode

func (search *Client) SearchMostRecentRegisterNode(address string) (*TxValueData, error)

SearchMostRecentRegisterNode returns tx data for the most recent RegisterNode transactions for the given address.

Returns a nil for TxValueData if the node has never been registered.

func (*Client) SearchSysvarHistory

func (search *Client) SearchSysvarHistory(
	sysvar string, afterHeight uint64, limit int,
) (khr *query.SysvarHistoryResponse, err error)

SearchSysvarHistory returns value history for the given sysvar using an index under the hood. The response is sorted by ascending block height, each entry is where the key's value changed. Pass in 0,0 for the paging params to get the entire history.

func (*Client) SearchTargetPrice

func (search *Client) SearchTargetPrice(params PriceQueryParams) (PriceQueryResults, error)

SearchTargetPrice searches for target price records

In the parameters: Before and After have exclusive semantics.

The zero value of Before and After are treated as open-ended ranges. The zero value of Limit returns all results.

func (*Client) SearchTxHash

func (search *Client) SearchTxHash(txHash string) (TxValueData, error)

SearchTxHash returns tx data for the given tx hash.

func (*Client) SearchTxTypes

func (search *Client) SearchTxTypes(txHashOrHeight string, txTypes []string, limit int) (TxListValueData, error)

SearchTxTypes returns tx data for a range of transactions on or before the given tx hash. If txHashOrHeight is "", this will return the latest page of transactions from the blockchain. txHashOrHeight can be a block height. Transactions in and before that block are returned. If txTypes is empty, this will return zero results. If limit is non-positive, this will return results as if the page size is infinite.

type MarketPriceIndexable

type MarketPriceIndexable interface {
	metatx.Transactable

	GetMarketPrice() pricecurve.Nanocent
}

MarketPriceIndexable is a Transactable that has updated the market price

type PriceQueryParams

type PriceQueryParams struct {
	After  RangeEndpoint `json:"after,omitempty"`
	Before RangeEndpoint `json:"before,omitempty"`
	Limit  uint          `json:"limit,omitempty"`
}

PriceQueryParams is a json-friendly struct for querying price history

Before and After have exclusive semantics.

The zero value of Before and After are treated as open-ended ranges. The zero value of Limit returns all results.

func (*PriceQueryParams) DecodeMsg

func (z *PriceQueryParams) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*PriceQueryParams) EncodeMsg

func (z *PriceQueryParams) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*PriceQueryParams) MarshalMsg

func (z *PriceQueryParams) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*PriceQueryParams) Msgsize

func (z *PriceQueryParams) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*PriceQueryParams) UnmarshalMsg

func (z *PriceQueryParams) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type PriceQueryResult

type PriceQueryResult struct {
	Price     pricecurve.Nanocent `json:"price_nanocents"`
	PriceS    string              `json:"price,omitempty"`
	Height    uint64              `json:"block_height"`
	Timestamp math.Timestamp      `json:"timestamp"`
}

PriceQueryResult is a json-friendly struct returning price history data

func (*PriceQueryResult) DecodeMsg

func (z *PriceQueryResult) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*PriceQueryResult) EncodeMsg

func (z *PriceQueryResult) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*PriceQueryResult) MarshalMsg

func (z *PriceQueryResult) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*PriceQueryResult) Msgsize

func (z *PriceQueryResult) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*PriceQueryResult) UnmarshalMsg

func (z *PriceQueryResult) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type PriceQueryResults

type PriceQueryResults struct {
	Items []PriceQueryResult `json:"-"`
	More  bool               `json:"-"`
}

PriceQueryResults encapsulates a set of price history data

It is _not_ json-friendly; More should be replaced with Next at the API level More is true when more results exist than were returned

func (*PriceQueryResults) DecodeMsg

func (z *PriceQueryResults) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*PriceQueryResults) EncodeMsg

func (z *PriceQueryResults) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*PriceQueryResults) MarshalMsg

func (z *PriceQueryResults) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*PriceQueryResults) Msgsize

func (z *PriceQueryResults) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*PriceQueryResults) UnmarshalMsg

func (z *PriceQueryResults) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type QueryParams

type QueryParams struct {
	// App-specific command.
	Command string `json:"command"`

	// A block hash or tx hash (or any other kind of hash), depending on the command.
	Hash string `json:"hash"`

	// List of tx types, or any other format depending on the command.
	Types []string `json:"types"`

	// Useful for paging queries.
	Limit int `json:"limit"`
}

QueryParams is a json-friendly struct for passing query terms over endpoints.

func (*QueryParams) DecodeMsg

func (z *QueryParams) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*QueryParams) EncodeMsg

func (z *QueryParams) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*QueryParams) MarshalMsg

func (z *QueryParams) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*QueryParams) Msgsize

func (z *QueryParams) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*QueryParams) UnmarshalMsg

func (z *QueryParams) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type RangeEndpoint

type RangeEndpoint struct {
	Height    uint64         `json:"block_height,omitempty"`
	Timestamp math.Timestamp `json:"timestamp,omitempty"`
}

RangeEndpoint is a json-friendly struct for choosing the end of a range

At most one of (`Height`, `Timestamp`) should ever be set. If both are set, `Timestamp` takes precedence.

func (*RangeEndpoint) DecodeMsg

func (z *RangeEndpoint) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*RangeEndpoint) EncodeMsg

func (z *RangeEndpoint) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (RangeEndpoint) GetTimestamp

func (r RangeEndpoint) GetTimestamp(search *Client) math.Timestamp

GetTimestamp gets and caches the timestamp from this range endpoint, whether originally specified or implied by the block height.

func (*RangeEndpoint) MarshalMsg

func (z *RangeEndpoint) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*RangeEndpoint) Msgsize

func (z *RangeEndpoint) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*RangeEndpoint) UnmarshalMsg

func (z *RangeEndpoint) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type SysvarHistoryParams

type SysvarHistoryParams struct {
	Name        string `json:"name"`
	AfterHeight uint64 `json:"afterheight"`
	Limit       int    `json:"limit"`
}

SysvarHistoryParams is a json-friendly struct for the /sysvar/history endpoint.

func (*SysvarHistoryParams) DecodeMsg

func (z *SysvarHistoryParams) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (SysvarHistoryParams) EncodeMsg

func (z SysvarHistoryParams) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (SysvarHistoryParams) MarshalMsg

func (z SysvarHistoryParams) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (SysvarHistoryParams) Msgsize

func (z SysvarHistoryParams) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*SysvarHistoryParams) UnmarshalMsg

func (z *SysvarHistoryParams) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type SysvarIndexable

type SysvarIndexable interface {
	metatx.Transactable

	// We use separate methods (instead of a struct to house the data) to avoid extra memory use.
	GetName() string
	GetValue() []byte
}

SysvarIndexable is a Transactable that has sysar data that we want to index.

type TargetPriceIndexable

type TargetPriceIndexable interface {
	metatx.Transactable

	UpdatedTargetPrice()
}

TargetPriceIndexable is a marker interface for a Transactable, indicating that this tx has updated the target price.

type TxListValueData

type TxListValueData struct {
	Txs        []TxValueData `json:"txs" msg:"t"`
	NextTxHash string        `json:"next" msg:"n"`
}

TxListValueData is used for data about a list of transactions.

func (*TxListValueData) DecodeMsg

func (z *TxListValueData) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*TxListValueData) EncodeMsg

func (z *TxListValueData) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*TxListValueData) Marshal

func (valueData *TxListValueData) Marshal() string

Marshal the value data into a search value string to index it with its search key string.

func (*TxListValueData) MarshalMsg

func (z *TxListValueData) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*TxListValueData) Msgsize

func (z *TxListValueData) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*TxListValueData) Unmarshal

func (valueData *TxListValueData) Unmarshal(searchValue string) error

Unmarshal the given search value string that was indexed with its search key string.

func (*TxListValueData) UnmarshalMsg

func (z *TxListValueData) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type TxValueData

type TxValueData struct {
	BlockHeight uint64 `json:"height" msg:"h"`
	TxOffset    int    `json:"offset" msg:"o"`
	Fee         uint64 `json:"fee" msg:"f"`
	SIB         uint64 `json:"sib" msg:"s"`
}

TxValueData is used for data about a particular transaction.

func (*TxValueData) DecodeMsg

func (z *TxValueData) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*TxValueData) EncodeMsg

func (z *TxValueData) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*TxValueData) Marshal

func (valueData *TxValueData) Marshal() string

Marshal the value data into a search value string to index it with its search key string.

func (*TxValueData) MarshalMsg

func (z *TxValueData) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*TxValueData) Msgsize

func (z *TxValueData) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*TxValueData) Unmarshal

func (valueData *TxValueData) Unmarshal(searchValue string) error

Unmarshal the given search value string that was indexed with its search key string.

func (*TxValueData) UnmarshalMsg

func (z *TxValueData) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type ValueData

type ValueData struct {
	Height      uint64 `msg:"h"`
	ValueBase64 string `msg:"v"`
}

ValueData is used for skipping duplicate key value pairs while iterating the blockchain.

func (*ValueData) DecodeMsg

func (z *ValueData) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (ValueData) EncodeMsg

func (z ValueData) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*ValueData) Marshal

func (valueData *ValueData) Marshal() string

Marshal the value data into a search value string to index it with its search key string.

func (ValueData) MarshalMsg

func (z ValueData) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (ValueData) Msgsize

func (z ValueData) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*ValueData) Unmarshal

func (valueData *ValueData) Unmarshal(searchValue string) error

Unmarshal the given search value string that was indexed with its search key string.

func (*ValueData) UnmarshalMsg

func (z *ValueData) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

Jump to

Keyboard shortcuts

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