history

package
v0.0.0-...-18d85b2 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: Apache-2.0, Apache-2.0 Imports: 38 Imported by: 0

Documentation

Overview

Package history contains database record definitions useable for reading rows from a the history portion of horizon's database

Index

Constants

View Source
const (
	AllTrades           = "all"
	OrderbookTrades     = "orderbook"
	LiquidityPoolTrades = "liquidity_pool"
)
View Source
const (
	// OrderbookTradeType is a trade which exercises an offer on the orderbook.
	OrderbookTradeType = TradeType(1)
	// LiquidityPoolTradeType is a trade which exercises a liquidity pool.
	LiquidityPoolTradeType = TradeType(2)
)
View Source
const HistoryTradesTableName = "history_trades_60000"

Variables

View Source
var AllowedResolutions = map[time.Duration]struct{}{
	time.Minute:        {},
	time.Minute * 5:    {},
	time.Minute * 15:   {},
	time.Hour:          {},
	time.Hour * 24:     {},
	time.Hour * 24 * 7: {},
}

AllowedResolutions is the set of trade aggregation time windows allowed to be used as the `resolution` parameter.

View Source
var StrictResolutionFiltering = true

StrictResolutionFiltering represents a simple feature flag to determine whether only predetermined resolutions of trade aggregations are allowed.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID      int64  `db:"id"`
	Address string `db:"address"`
}

Account is a row of data from the `history_accounts` table

type AccountDataBatchInsertBuilder

type AccountDataBatchInsertBuilder interface {
	Add(data Data) error
	Exec(ctx context.Context) error
}

type AccountDataKey

type AccountDataKey struct {
	AccountID string
	DataName  string
}

type AccountDataValue

type AccountDataValue []byte

func (AccountDataValue) Base64

func (value AccountDataValue) Base64() string

func (*AccountDataValue) Scan

func (t *AccountDataValue) Scan(src interface{}) error

Scan base64 decodes into an []byte

func (AccountDataValue) Value

func (value AccountDataValue) Value() (driver.Value, error)

Value implements driver.Valuer

type AccountEntry

type AccountEntry struct {
	AccountID            string      `db:"account_id"`
	Balance              int64       `db:"balance"`
	BuyingLiabilities    int64       `db:"buying_liabilities"`
	SellingLiabilities   int64       `db:"selling_liabilities"`
	SequenceNumber       int64       `db:"sequence_number"`
	SequenceLedger       zero.Int    `db:"sequence_ledger"`
	SequenceTime         zero.Int    `db:"sequence_time"`
	NumSubEntries        uint32      `db:"num_subentries"`
	InflationDestination string      `db:"inflation_destination"`
	HomeDomain           string      `db:"home_domain"`
	Flags                uint32      `db:"flags"`
	MasterWeight         byte        `db:"master_weight"`
	ThresholdLow         byte        `db:"threshold_low"`
	ThresholdMedium      byte        `db:"threshold_medium"`
	ThresholdHigh        byte        `db:"threshold_high"`
	LastModifiedLedger   uint32      `db:"last_modified_ledger"`
	Sponsor              null.String `db:"sponsor"`
	NumSponsored         uint32      `db:"num_sponsored"`
	NumSponsoring        uint32      `db:"num_sponsoring"`
}

AccountEntry is a row of data from the `account` table

func (AccountEntry) IsAuthClawbackEnabled

func (account AccountEntry) IsAuthClawbackEnabled() bool

IsAuthClawbackEnabled returns true if the account has the "AUTH_CLAWBACK_ENABLED" option turned on.

func (AccountEntry) IsAuthImmutable

func (account AccountEntry) IsAuthImmutable() bool

IsAuthImmutable returns true if the account has the "AUTH_IMMUTABLE" option turned on.

func (AccountEntry) IsAuthRequired

func (account AccountEntry) IsAuthRequired() bool

IsAuthRequired returns true if the account has the "AUTH_REQUIRED" option turned on.

func (AccountEntry) IsAuthRevocable

func (account AccountEntry) IsAuthRevocable() bool

IsAuthRevocable returns true if the account has the "AUTH_REVOCABLE" option turned on.

type AccountFilterConfig

type AccountFilterConfig struct {
	Enabled      bool           `db:"enabled"`
	Whitelist    pq.StringArray `db:"whitelist"`
	LastModified int64          `db:"last_modified"`
}

type AccountLoader

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

AccountLoader will map account addresses to their history account ids. If there is no existing mapping for a given address, the AccountLoader will insert into the history_accounts table to establish a mapping.

func NewAccountLoader

func NewAccountLoader() *AccountLoader

NewAccountLoader will construct a new AccountLoader instance.

func (*AccountLoader) Exec

func (a *AccountLoader) Exec(ctx context.Context, session db.SessionInterface) error

Exec will look up all the history account ids for the addresses registered in the loader. If there are no history account ids for a given set of addresses, Exec will insert rows into the history_accounts table to establish a mapping between address and history account id.

func (*AccountLoader) GetFuture

func (a *AccountLoader) GetFuture(address string) FutureAccountID

GetFuture registers the given account address into the loader and returns a FutureAccountID which will hold the history account id for the address after Exec() is called.

func (*AccountLoader) GetNow

func (a *AccountLoader) GetNow(address string) (int64, error)

GetNow returns the history account id for the given address. GetNow should only be called on values which were registered by GetFuture() calls. Also, Exec() must be called before any GetNow call can succeed.

type AccountLoaderStub

type AccountLoaderStub struct {
	Loader *AccountLoader
}

AccountLoaderStub is a stub wrapper around AccountLoader which allows you to manually configure the mapping of addresses to history account ids

func NewAccountLoaderStub

func NewAccountLoaderStub() AccountLoaderStub

NewAccountLoaderStub returns a new AccountLoaderStub instance

func (AccountLoaderStub) Insert

func (a AccountLoaderStub) Insert(address string, id int64)

Insert updates the wrapped AccountLoader so that the given account address is mapped to the provided history account id

type AccountSigner

type AccountSigner struct {
	Account string      `db:"account_id"`
	Signer  string      `db:"signer"`
	Weight  int32       `db:"weight"`
	Sponsor null.String `db:"sponsor"`
}

AccountSigner is a row of data from the `accounts_signers` table

type AccountSignersBatchInsertBuilder

type AccountSignersBatchInsertBuilder interface {
	Add(signer AccountSigner) error
	Exec(ctx context.Context) error
}

type AccountsBatchInsertBuilder

type AccountsBatchInsertBuilder interface {
	Add(account AccountEntry) error
	Exec(ctx context.Context) error
}

AccountsBatchInsertBuilder is used to insert accounts into the accounts table

type Asset

type Asset struct {
	ID     int64  `db:"id"`
	Type   string `db:"asset_type"`
	Code   string `db:"asset_code"`
	Issuer string `db:"asset_issuer"`
}

Asset is a row of data from the `history_assets` table

type AssetFilterConfig

type AssetFilterConfig struct {
	Enabled      bool           `db:"enabled"`
	Whitelist    pq.StringArray `db:"whitelist"`
	LastModified int64          `db:"last_modified"`
}

type AssetKey

type AssetKey struct {
	Type   string
	Code   string
	Issuer string
}

func AssetKeyFromXDR

func AssetKeyFromXDR(asset xdr.Asset) AssetKey

AssetKeyFromXDR constructs an AssetKey from an xdr asset

func (AssetKey) String

func (key AssetKey) String() string

type AssetLoader

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

AssetLoader will map assets to their history asset ids. If there is no existing mapping for a given sset, the AssetLoader will insert into the history_assets table to establish a mapping.

func NewAssetLoader

func NewAssetLoader() *AssetLoader

NewAssetLoader will construct a new AssetLoader instance.

func (*AssetLoader) Exec

func (a *AssetLoader) Exec(ctx context.Context, session db.SessionInterface) error

Exec will look up all the history asset ids for the assets registered in the loader. If there are no history asset ids for a given set of assets, Exec will insert rows into the history_assets table.

func (*AssetLoader) GetFuture

func (a *AssetLoader) GetFuture(asset AssetKey) FutureAssetID

GetFuture registers the given asset into the loader and returns a FutureAssetID which will hold the history asset id for the asset after Exec() is called.

func (*AssetLoader) GetNow

func (a *AssetLoader) GetNow(asset AssetKey) (int64, error)

GetNow returns the history asset id for the given asset. GetNow should only be called on values which were registered by GetFuture() calls. Also, Exec() must be called before any GetNow call can succeed.

type AssetLoaderStub

type AssetLoaderStub struct {
	Loader *AssetLoader
}

AssetLoaderStub is a stub wrapper around AssetLoader which allows you to manually configure the mapping of assets to history asset ids

func NewAssetLoaderStub

func NewAssetLoaderStub() AssetLoaderStub

NewAssetLoaderStub returns a new AssetLoaderStub instance

func (AssetLoaderStub) Insert

func (a AssetLoaderStub) Insert(asset AssetKey, id int64)

Insert updates the wrapped AssetLoaderStub so that the given asset address is mapped to the provided history asset id

type ClaimableBalance

type ClaimableBalance struct {
	BalanceID          string      `db:"id"`
	Claimants          Claimants   `db:"claimants"`
	Asset              xdr.Asset   `db:"asset"`
	Amount             xdr.Int64   `db:"amount"`
	Sponsor            null.String `db:"sponsor"`
	LastModifiedLedger uint32      `db:"last_modified_ledger"`
	Flags              uint32      `db:"flags"`
}

ClaimableBalance is a row of data from the `claimable_balances` table.

type ClaimableBalanceBatchInsertBuilder

type ClaimableBalanceBatchInsertBuilder interface {
	Add(claimableBalance ClaimableBalance) error
	Exec(ctx context.Context) error
}

ClaimableBalanceBatchInsertBuilder is used to insert claimable balance into the claimable_balances table

type ClaimableBalanceClaimant

type ClaimableBalanceClaimant struct {
	BalanceID          string `db:"id"`
	Destination        string `db:"destination"`
	LastModifiedLedger uint32 `db:"last_modified_ledger"`
}

ClaimableBalanceClaimant is a row of data from the `claimable_balances_claimants` table. This table exists to allow faster querying for claimable balances for a specific claimant.

type ClaimableBalanceClaimantBatchInsertBuilder

type ClaimableBalanceClaimantBatchInsertBuilder interface {
	Add(claimableBalanceClaimant ClaimableBalanceClaimant) error
	Exec(ctx context.Context) error
}

ClaimableBalanceClaimantBatchInsertBuilder is used to insert claimants into the claimable_balance_claimants table

type ClaimableBalanceLoader

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

ClaimableBalanceLoader will map claimable balance ids to their internal history ids. If there is no existing mapping for a given claimable balance id, the ClaimableBalanceLoader will insert into the history_claimable_balances table to establish a mapping.

func NewClaimableBalanceLoader

func NewClaimableBalanceLoader() *ClaimableBalanceLoader

NewClaimableBalanceLoader will construct a new ClaimableBalanceLoader instance.

func (*ClaimableBalanceLoader) Exec

Exec will look up all the internal history ids for the claimable balances registered in the loader. If there are no internal ids for a given set of claimable balances, Exec will insert rows into the history_claimable_balances table.

func (*ClaimableBalanceLoader) GetFuture

GetFuture registers the given claimable balance into the loader and returns a FutureClaimableBalanceID which will hold the internal history id for the claimable balance after Exec() is called.

type ClaimableBalancesQuery

type ClaimableBalancesQuery struct {
	PageQuery db2.PageQuery
	Asset     *xdr.Asset
	Sponsor   *xdr.AccountId
	Claimant  *xdr.AccountId
}

ClaimableBalancesQuery is a helper struct to configure queries to claimable balances

func (ClaimableBalancesQuery) Cursor

func (cbq ClaimableBalancesQuery) Cursor() (int64, string, error)

Cursor validates and returns the query page cursor

type Claimant

type Claimant struct {
	Destination string             `json:"destination"`
	Predicate   xdr.ClaimPredicate `json:"predicate"`
}

type Claimants

type Claimants []Claimant

func (*Claimants) Scan

func (c *Claimants) Scan(value interface{}) error

func (Claimants) Value

func (c Claimants) Value() (driver.Value, error)

type Data

type Data struct {
	AccountID          string           `db:"account_id"`
	Name               string           `db:"name"`
	Value              AccountDataValue `db:"value"`
	LastModifiedLedger uint32           `db:"last_modified_ledger"`
	Sponsor            null.String      `db:"sponsor"`
}

Data is a row of data from the `account_data` table

type Effect

type Effect struct {
	HistoryAccountID   int64       `db:"history_account_id"`
	Account            string      `db:"address"`
	AccountMuxed       null.String `db:"address_muxed"`
	HistoryOperationID int64       `db:"history_operation_id"`
	Order              int32       `db:"order"`
	Type               EffectType  `db:"type"`
	DetailsString      null.String `db:"details"`
}

Effect is a row of data from the `history_effects` table

func (*Effect) ID

func (r *Effect) ID() string

ID returns a lexically ordered id for this effect record

func (*Effect) LedgerSequence

func (r *Effect) LedgerSequence() int32

LedgerSequence return the ledger in which the effect occurred.

func (*Effect) PagingToken

func (r *Effect) PagingToken() string

PagingToken returns a cursor for this effect

func (*Effect) UnmarshalDetails

func (r *Effect) UnmarshalDetails(dest interface{}) error

UnmarshalDetails unmarshals the details of this effect into `dest`

type EffectBatchInsertBuilder

type EffectBatchInsertBuilder interface {
	Add(
		accountID FutureAccountID,
		muxedAccount null.String,
		operationID int64,
		order uint32,
		effectType EffectType,
		details []byte,
	) error
	Exec(ctx context.Context, session db.SessionInterface) error
}

EffectBatchInsertBuilder is used to insert effects into the history_effects table

type EffectType

type EffectType int

EffectType is the numeric type for an effect, used as the `type` field in the `history_effects` table.

const (

	// EffectAccountCreated effects occur when a new account is created
	EffectAccountCreated EffectType = 0 // from create_account

	// EffectAccountRemoved effects occur when one account is merged into another
	EffectAccountRemoved EffectType = 1 // from merge_account

	// EffectAccountCredited effects occur when an account receives some
	// currency
	//
	// from create_account, payment, path_payment, merge_account, and SAC events
	// involving transfers, mints, and burns.
	EffectAccountCredited EffectType = 2

	// EffectAccountDebited effects occur when an account sends some currency
	//
	// from create_account, payment, path_payment, create_account, and SAC
	// involving transfers, mints, and burns.
	//
	// https://github.com/stellar/rs-soroban-env/blob/5695440da452837555d8f7f259cc33341fdf07b0/soroban-env-host/src/native_contract/token/contract.rs#L51-L63
	EffectAccountDebited EffectType = 3

	// EffectAccountThresholdsUpdated effects occur when an account changes its
	// multisig thresholds.
	EffectAccountThresholdsUpdated EffectType = 4 // from set_options

	// EffectAccountHomeDomainUpdated effects occur when an account changes its
	// home domain.
	EffectAccountHomeDomainUpdated EffectType = 5 // from set_options

	// EffectAccountFlagsUpdated effects occur when an account changes its
	// account flags, either clearing or setting.
	EffectAccountFlagsUpdated EffectType = 6 // from set_options

	// EffectAccountInflationDestinationUpdated effects occur when an account changes its
	// inflation destination.
	EffectAccountInflationDestinationUpdated EffectType = 7 // from set_options

	// EffectSignerCreated occurs when an account gains a signer
	EffectSignerCreated EffectType = 10 // from set_options

	// EffectSignerRemoved occurs when an account loses a signer
	EffectSignerRemoved EffectType = 11 // from set_options

	// EffectSignerUpdated occurs when an account changes the weight of one of its
	// signers.
	EffectSignerUpdated EffectType = 12 // from set_options

	// EffectTrustlineCreated occurs when an account trusts an anchor
	EffectTrustlineCreated EffectType = 20 // from change_trust

	// EffectTrustlineRemoved occurs when an account removes struct by setting the
	// limit of a trustline to 0
	EffectTrustlineRemoved EffectType = 21 // from change_trust

	// EffectTrustlineUpdated occurs when an account changes a trustline's limit
	EffectTrustlineUpdated EffectType = 22 // from change_trust, allow_trust

	// Deprecated: use EffectTrustlineFlagsUpdated instead.
	// EffectTrustlineAuthorized occurs when an anchor has AUTH_REQUIRED flag set
	// to true and it authorizes another account's trustline
	EffectTrustlineAuthorized EffectType = 23 // from allow_trust

	// Deprecated: use EffectTrustlineFlagsUpdated instead.
	// EffectTrustlineDeauthorized occurs when an anchor revokes access to a asset
	// it issues.
	EffectTrustlineDeauthorized EffectType = 24 // from allow_trust

	// Deprecated: use EffectTrustlineFlagsUpdated instead.
	// EffectTrustlineAuthorizedToMaintainLiabilities occurs when an anchor has AUTH_REQUIRED flag set
	// to true and it authorizes another account's trustline to maintain liabilities
	EffectTrustlineAuthorizedToMaintainLiabilities EffectType = 25 // from allow_trust

	// EffectTrustlineFlagsUpdated effects occur when a TrustLine changes its
	// flags, either clearing or setting.
	EffectTrustlineFlagsUpdated EffectType = 26 // from set_trust_line flags

	// EffectTrade occurs when a trade is initiated because of a path payment or
	// offer operation.
	EffectTrade EffectType = 33 // from manage_offer, creat_passive_offer, path_payment

	// EffectDataCreated occurs when an account gets a new data field
	EffectDataCreated EffectType = 40 // from manage_data

	// EffectDataRemoved occurs when an account removes a data field
	EffectDataRemoved EffectType = 41 // from manage_data

	// EffectDataUpdated occurs when an account changes a data field's value
	EffectDataUpdated EffectType = 42 // from manage_data

	// EffectSequenceBumped occurs when an account bumps their sequence number
	EffectSequenceBumped EffectType = 43 // from bump_sequence

	// EffectClaimableBalanceCreated occurs when a claimable balance is created
	EffectClaimableBalanceCreated EffectType = 50 // from create_claimable_balance

	// EffectClaimableBalanceClaimantCreated occurs when a claimable balance claimant is created
	EffectClaimableBalanceClaimantCreated EffectType = 51 // from create_claimable_balance

	// EffectClaimableBalanceClaimed occurs when a claimable balance is claimed
	EffectClaimableBalanceClaimed EffectType = 52 // from claim_claimable_balance

	// EffectAccountSponsorshipCreated occurs when an account ledger entry is sponsored
	EffectAccountSponsorshipCreated EffectType = 60 // from create_account

	// EffectAccountSponsorshipUpdated occurs when the sponsoring of an account ledger entry is updated
	EffectAccountSponsorshipUpdated EffectType = 61 // from revoke_sponsorship

	// EffectAccountSponsorshipRemoved occurs when the sponsorship of an account ledger entry is removed
	EffectAccountSponsorshipRemoved EffectType = 62 // from revoke_sponsorship

	// EffectTrustlineSponsorshipCreated occurs when a trustline ledger entry is sponsored
	EffectTrustlineSponsorshipCreated EffectType = 63 // from change_trust

	// EffectTrustlineSponsorshipUpdated occurs when the sponsoring of a trustline ledger entry is updated
	EffectTrustlineSponsorshipUpdated EffectType = 64 // from revoke_sponsorship

	// EffectTrustlineSponsorshipRemoved occurs when the sponsorship of a trustline ledger entry is removed
	EffectTrustlineSponsorshipRemoved EffectType = 65 // from revoke_sponsorship

	// EffectDataSponsorshipCreated occurs when a trustline ledger entry is sponsored
	EffectDataSponsorshipCreated EffectType = 66 // from manage_data

	// EffectDataSponsorshipUpdated occurs when the sponsoring of a trustline ledger entry is updated
	EffectDataSponsorshipUpdated EffectType = 67 // from revoke_sponsorship

	// EffectDataSponsorshipRemoved occurs when the sponsorship of a trustline ledger entry is removed
	EffectDataSponsorshipRemoved EffectType = 68 // from revoke_sponsorship

	// EffectClaimableBalanceSponsorshipCreated occurs when a claimable balance ledger entry is sponsored
	EffectClaimableBalanceSponsorshipCreated EffectType = 69 // from create_claimable_balance

	// EffectClaimableBalanceSponsorshipUpdated occurs when the sponsoring of a claimable balance ledger entry
	// is updated
	EffectClaimableBalanceSponsorshipUpdated EffectType = 70 // from revoke_sponsorship

	// EffectClaimableBalanceSponsorshipRemoved occurs when the sponsorship of a claimable balance ledger entry
	// is removed
	EffectClaimableBalanceSponsorshipRemoved EffectType = 71 // from claim_claimable_balance

	// EffectSignerSponsorshipCreated occurs when the sponsorship of a signer is created
	EffectSignerSponsorshipCreated EffectType = 72 // from set_options

	// EffectSignerSponsorshipUpdated occurs when the sponsorship of a signer is updated
	EffectSignerSponsorshipUpdated EffectType = 73 // from revoke_sponsorship

	// EffectSignerSponsorshipRemoved occurs when the sponsorship of a signer is removed
	EffectSignerSponsorshipRemoved EffectType = 74 // from revoke_sponsorship

	// EffectClaimableBalanceClawedBack occurs when a claimable balance is clawed back
	EffectClaimableBalanceClawedBack EffectType = 80 // from clawback_claimable_balance

	// EffectLiquidityPoolDeposited occurs when a liquidity pool incurs a deposit
	EffectLiquidityPoolDeposited EffectType = 90 // from liquidity_pool_deposit

	// EffectLiquidityPoolWithdrew occurs when a liquidity pool incurs a withdrawal
	EffectLiquidityPoolWithdrew EffectType = 91 // from liquidity_pool_withdraw

	// EffectLiquidityPoolTrade occurs when a trade happens in a liquidity pool
	EffectLiquidityPoolTrade EffectType = 92

	// EffectLiquidityPoolCreated occurs when a liquidity pool is created
	EffectLiquidityPoolCreated EffectType = 93 // from change_trust

	// EffectLiquidityPoolRemoved occurs when a liquidity pool is removed
	EffectLiquidityPoolRemoved EffectType = 94 // from change_trust

	// EffectLiquidityPoolRevoked occurs when a liquidity pool is revoked
	EffectLiquidityPoolRevoked EffectType = 95 // from change_trust_line_flags and allow_trust

	// EffectContractCredited effects occur when a contract receives some
	// currency from SAC events involving transfers, mints, and burns.
	// https://github.com/stellar/rs-soroban-env/blob/5695440da452837555d8f7f259cc33341fdf07b0/soroban-env-host/src/native_contract/token/contract.rs#L51-L63
	EffectContractCredited EffectType = 96

	// EffectContractDebited effects occur when a contract sends some currency
	// from SAC events involving transfers, mints, and burns.
	// https://github.com/stellar/rs-soroban-env/blob/5695440da452837555d8f7f259cc33341fdf07b0/soroban-env-host/src/native_contract/token/contract.rs#L51-L63
	EffectContractDebited EffectType = 97
)

type EffectsQ

type EffectsQ struct {
	Err error
	// contains filtered or unexported fields
}

EffectsQ is a helper struct to aid in configuring queries that loads slices of Ledger structs.

func (*EffectsQ) ForAccount

func (q *EffectsQ) ForAccount(ctx context.Context, aid string) *EffectsQ

ForAccount filters the operations collection to a specific account

func (*EffectsQ) ForLedger

func (q *EffectsQ) ForLedger(ctx context.Context, seq int32) *EffectsQ

ForLedger filters the query to only effects in a specific ledger, specified by its sequence.

func (*EffectsQ) ForLiquidityPool

func (q *EffectsQ) ForLiquidityPool(ctx context.Context, page db2.PageQuery, id string) *EffectsQ

ForLiquidityPool filters the query to only effects in a specific liquidity pool, specified by its id.

func (*EffectsQ) ForOperation

func (q *EffectsQ) ForOperation(id int64) *EffectsQ

ForOperation filters the query to only effects in a specific operation, specified by its id.

func (*EffectsQ) ForTransaction

func (q *EffectsQ) ForTransaction(ctx context.Context, hash string) *EffectsQ

ForTransaction filters the query to only effects in a specific transaction, specified by the transactions's hex-encoded hash.

func (*EffectsQ) Page

func (q *EffectsQ) Page(page db2.PageQuery) *EffectsQ

Page specifies the paging constraints for the query being built by `q`.

func (*EffectsQ) Select

func (q *EffectsQ) Select(ctx context.Context, dest interface{}) error

Select loads the results of the query specified by `q` into `dest`.

type ExpAssetStat

type ExpAssetStat struct {
	AssetType   xdr.AssetType        `db:"asset_type"`
	AssetCode   string               `db:"asset_code"`
	AssetIssuer string               `db:"asset_issuer"`
	Accounts    ExpAssetStatAccounts `db:"accounts"`
	Balances    ExpAssetStatBalances `db:"balances"`
	Amount      string               `db:"amount"`
	NumAccounts int32                `db:"num_accounts"`
	ContractID  *[]byte              `db:"contract_id"`
}

ExpAssetStat is a row in the exp_asset_stats table representing the stats per Asset

func (*ExpAssetStat) Equals

func (e *ExpAssetStat) Equals(o ExpAssetStat) bool

func (*ExpAssetStat) GetContractID

func (e *ExpAssetStat) GetContractID() ([32]byte, bool)

func (ExpAssetStat) PagingToken

func (e ExpAssetStat) PagingToken() string

PagingToken returns a cursor for this asset stat

func (*ExpAssetStat) SetContractID

func (e *ExpAssetStat) SetContractID(contractID [32]byte)

type ExpAssetStatAccounts

type ExpAssetStatAccounts struct {
	Authorized                      int32 `json:"authorized"`
	AuthorizedToMaintainLiabilities int32 `json:"authorized_to_maintain_liabilities"`
	ClaimableBalances               int32 `json:"claimable_balances"`
	LiquidityPools                  int32 `json:"liquidity_pools"`
	Contracts                       int32 `json:"contracts"`
	Unauthorized                    int32 `json:"unauthorized"`
}

ExpAssetStatAccounts represents the summarized acount numbers for a single Asset

func (ExpAssetStatAccounts) Add

func (ExpAssetStatAccounts) IsZero

func (a ExpAssetStatAccounts) IsZero() bool

func (*ExpAssetStatAccounts) Scan

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

func (ExpAssetStatAccounts) Value

func (e ExpAssetStatAccounts) Value() (driver.Value, error)

type ExpAssetStatBalances

type ExpAssetStatBalances struct {
	Authorized                      string `json:"authorized"`
	AuthorizedToMaintainLiabilities string `json:"authorized_to_maintain_liabilities"`
	ClaimableBalances               string `json:"claimable_balances"`
	LiquidityPools                  string `json:"liquidity_pools"`
	Contracts                       string `json:"contracts"`
	Unauthorized                    string `json:"unauthorized"`
}

ExpAssetStatBalances represents the summarized balances for a single Asset Note: the string representation is in stroops!

func (ExpAssetStatBalances) IsZero

func (e ExpAssetStatBalances) IsZero() bool

func (*ExpAssetStatBalances) Scan

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

func (ExpAssetStatBalances) Value

func (e ExpAssetStatBalances) Value() (driver.Value, error)

type FeeBumpFixture

type FeeBumpFixture struct {
	Ledger            Ledger
	Envelope          xdr.TransactionEnvelope
	Transaction       Transaction
	NormalTransaction Transaction
	OuterHash         string
	InnerHash         string
}

FeeBumpFixture contains the data inserted into the database when running FeeBumpScenario

func FeeBumpScenario

func FeeBumpScenario(tt *test.T, q *Q, successful bool) FeeBumpFixture

FeeBumpScenario creates a ledger containing a fee bump transaction, an operation, and an effect

type FeeStats

type FeeStats struct {
	FeeChargedMax  null.Int `db:"fee_charged_max"`
	FeeChargedMin  null.Int `db:"fee_charged_min"`
	FeeChargedMode null.Int `db:"fee_charged_mode"`
	FeeChargedP10  null.Int `db:"fee_charged_p10"`
	FeeChargedP20  null.Int `db:"fee_charged_p20"`
	FeeChargedP30  null.Int `db:"fee_charged_p30"`
	FeeChargedP40  null.Int `db:"fee_charged_p40"`
	FeeChargedP50  null.Int `db:"fee_charged_p50"`
	FeeChargedP60  null.Int `db:"fee_charged_p60"`
	FeeChargedP70  null.Int `db:"fee_charged_p70"`
	FeeChargedP80  null.Int `db:"fee_charged_p80"`
	FeeChargedP90  null.Int `db:"fee_charged_p90"`
	FeeChargedP95  null.Int `db:"fee_charged_p95"`
	FeeChargedP99  null.Int `db:"fee_charged_p99"`
	MaxFeeMax      null.Int `db:"max_fee_max"`
	MaxFeeMin      null.Int `db:"max_fee_min"`
	MaxFeeMode     null.Int `db:"max_fee_mode"`
	MaxFeeP10      null.Int `db:"max_fee_p10"`
	MaxFeeP20      null.Int `db:"max_fee_p20"`
	MaxFeeP30      null.Int `db:"max_fee_p30"`
	MaxFeeP40      null.Int `db:"max_fee_p40"`
	MaxFeeP50      null.Int `db:"max_fee_p50"`
	MaxFeeP60      null.Int `db:"max_fee_p60"`
	MaxFeeP70      null.Int `db:"max_fee_p70"`
	MaxFeeP80      null.Int `db:"max_fee_p80"`
	MaxFeeP90      null.Int `db:"max_fee_p90"`
	MaxFeeP95      null.Int `db:"max_fee_p95"`
	MaxFeeP99      null.Int `db:"max_fee_p99"`
}

FeeStats is a row of data from the min, mode, percentile aggregate functions over the `history_transactions` table.

type FutureAccountID

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

FutureAccountID represents a future history account. A FutureAccountID is created by an AccountLoader and the account id is available after calling Exec() on the AccountLoader.

func (FutureAccountID) Value

func (a FutureAccountID) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type FutureAssetID

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

FutureAssetID represents a future history asset. A FutureAssetID is created by an AssetLoader and the asset id is available after calling Exec() on the AssetLoader.

func (FutureAssetID) Value

func (a FutureAssetID) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type FutureClaimableBalanceID

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

FutureClaimableBalanceID represents a future history claimable balance. A FutureClaimableBalanceID is created by a ClaimableBalanceLoader and the claimable balance id is available after calling Exec() on the ClaimableBalanceLoader.

func (FutureClaimableBalanceID) Value

Value implements the database/sql/driver Valuer interface.

type FutureLiquidityPoolID

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

FutureLiquidityPoolID represents a future history liquidity pool. A FutureLiquidityPoolID is created by an LiquidityPoolLoader and the liquidity pool id is available after calling Exec() on the LiquidityPoolLoader.

func (FutureLiquidityPoolID) Value

func (a FutureLiquidityPoolID) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type HistoryClaimableBalance

type HistoryClaimableBalance struct {
	BalanceID  string `db:"claimable_balance_id"`
	InternalID int64  `db:"id"`
}

HistoryClaimableBalance is a row of data from the `history_claimable_balances` table

type HistoryLiquidityPool

type HistoryLiquidityPool struct {
	PoolID     string `db:"liquidity_pool_id"`
	InternalID int64  `db:"id"`
}

HistoryLiquidityPool is a row of data from the `history_liquidity_pools` table

type IngestionQ

type IngestionQ interface {
	QAccounts
	QFilter
	QAssetStats
	QClaimableBalances
	QHistoryClaimableBalances
	QData
	QEffects
	QLedgers
	QLiquidityPools
	QHistoryLiquidityPools
	QOffers
	QOperations
	// QParticipants
	// Copy the small interfaces with shared methods directly, otherwise error:
	// duplicate method CreateAccounts
	NewTransactionParticipantsBatchInsertBuilder() TransactionParticipantsBatchInsertBuilder
	NewOperationParticipantBatchInsertBuilder() OperationParticipantBatchInsertBuilder
	QSigners
	//QTrades
	NewTradeBatchInsertBuilder() TradeBatchInsertBuilder
	RebuildTradeAggregationTimes(ctx context.Context, from, to strtime.Millis, roundingSlippageFilter int) error
	RebuildTradeAggregationBuckets(ctx context.Context, fromLedger, toLedger uint32, roundingSlippageFilter int) error
	ReapLookupTables(ctx context.Context, offsets map[string]int64) (map[string]int64, map[string]int64, error)
	CreateAssets(ctx context.Context, assets []xdr.Asset, batchSize int) (map[string]Asset, error)
	QTransactions
	QTrustLines

	Begin(context.Context) error
	BeginTx(context.Context, *sql.TxOptions) error
	Commit() error
	CloneIngestionQ() IngestionQ
	Close() error
	Rollback() error
	GetTx() *sqlx.Tx
	GetIngestVersion(context.Context) (int, error)
	UpdateExpStateInvalid(context.Context, bool) error
	UpdateIngestVersion(context.Context, int) error
	GetExpStateInvalid(context.Context) (bool, error)
	GetLatestHistoryLedger(context.Context) (uint32, error)
	GetOfferCompactionSequence(context.Context) (uint32, error)
	GetLiquidityPoolCompactionSequence(context.Context) (uint32, error)
	TruncateIngestStateTables(context.Context) error
	DeleteRangeAll(ctx context.Context, start, end int64) error
	DeleteTransactionsFilteredTmpOlderThan(ctx context.Context, howOldInSeconds uint64) (int64, error)
	TryStateVerificationLock(ctx context.Context) (bool, error)
}

type InsertTrade

type InsertTrade struct {
	HistoryOperationID int64     `db:"history_operation_id"`
	Order              int32     `db:"order"`
	LedgerCloseTime    time.Time `db:"ledger_closed_at"`

	CounterAssetID         int64    `db:"counter_asset_id"`
	CounterAmount          int64    `db:"counter_amount"`
	CounterAccountID       null.Int `db:"counter_account_id"`
	CounterOfferID         null.Int `db:"counter_offer_id"`
	CounterLiquidityPoolID null.Int `db:"counter_liquidity_pool_id"`

	LiquidityPoolFee null.Int `db:"liquidity_pool_fee"`

	BaseAssetID         int64    `db:"base_asset_id"`
	BaseAmount          int64    `db:"base_amount"`
	BaseAccountID       null.Int `db:"base_account_id"`
	BaseOfferID         null.Int `db:"base_offer_id"`
	BaseLiquidityPoolID null.Int `db:"base_liquidity_pool_id"`

	BaseIsSeller bool      `db:"base_is_seller"`
	BaseIsExact  null.Bool `db:"base_is_exact"`

	Type TradeType `db:"trade_type"`

	PriceN int64 `db:"price_n"`
	PriceD int64 `db:"price_d"`

	RoundingSlippage null.Int `db:"rounding_slippage"`
}

InsertTrade represents the arguments to TradeBatchInsertBuilder.Add() which is used to insert rows into the history_trades table

type LatestLedger

type LatestLedger struct {
	BaseFee  int32 `db:"base_fee"`
	Sequence int32 `db:"sequence"`
}

LatestLedger represents a response from the raw LatestLedgerBaseFeeAndSequence query.

type Ledger

type Ledger struct {
	TotalOrderID
	Sequence                   int32       `db:"sequence"`
	ImporterVersion            int32       `db:"importer_version"`
	LedgerHash                 string      `db:"ledger_hash"`
	PreviousLedgerHash         null.String `db:"previous_ledger_hash"`
	TransactionCount           int32       `db:"transaction_count"`
	SuccessfulTransactionCount *int32      `db:"successful_transaction_count"`
	FailedTransactionCount     *int32      `db:"failed_transaction_count"`
	OperationCount             int32       `db:"operation_count"`
	TxSetOperationCount        *int32      `db:"tx_set_operation_count"`
	ClosedAt                   time.Time   `db:"closed_at"`
	CreatedAt                  time.Time   `db:"created_at"`
	UpdatedAt                  time.Time   `db:"updated_at"`
	TotalCoins                 int64       `db:"total_coins"`
	FeePool                    int64       `db:"fee_pool"`
	BaseFee                    int32       `db:"base_fee"`
	BaseReserve                int32       `db:"base_reserve"`
	MaxTxSetSize               int32       `db:"max_tx_set_size"`
	ProtocolVersion            int32       `db:"protocol_version"`
	LedgerHeaderXDR            null.String `db:"ledger_header"`
}

Ledger is a row of data from the `history_ledgers` table

type LedgerBatchInsertBuilder

type LedgerBatchInsertBuilder interface {
	Add(
		ledger xdr.LedgerHeaderHistoryEntry,
		successTxsCount int,
		failedTxsCount int,
		opCount int,
		txSetOpCount int,
		ingestVersion int,
	) error
	Exec(ctx context.Context, session db.SessionInterface) error
}

LedgerBatchInsertBuilder is used to insert ledgers into the history_ledgers table

type LedgerBounds

type LedgerBounds struct {
	Null      bool
	MaxLedger null.Int
	MinLedger null.Int
}

LedgerBounds represents the ledger bounds of a Stellar transaction

func (*LedgerBounds) Scan

func (t *LedgerBounds) Scan(src interface{}) error

Scan implements the database/sql Scanner interface.

func (LedgerBounds) Value

func (t LedgerBounds) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type LedgerCache

type LedgerCache struct {
	Records map[int32]Ledger
	// contains filtered or unexported fields
}

LedgerCache is a helper struct to load ledger data related to a batch of sequences.

func (*LedgerCache) Load

func (lc *LedgerCache) Load(ctx context.Context, q *Q) error

Load loads a batch of ledgers identified by `sequences`, using `q`, and populates the cache with the results

func (*LedgerCache) Queue

func (lc *LedgerCache) Queue(seq int32)

Queue adds `seq` to the load queue for the cache.

type LedgerCapacityUsageStats

type LedgerCapacityUsageStats struct {
	CapacityUsage null.String `db:"ledger_capacity_usage"`
}

LedgerCapacityUsageStats contains ledgers fullness stats.

type LedgerRange

type LedgerRange struct {
	StartSequence uint32 `db:"start"`
	EndSequence   uint32 `db:"end"`
}

type LedgersQ

type LedgersQ struct {
	Err error
	// contains filtered or unexported fields
}

LedgersQ is a helper struct to aid in configuring queries that loads slices of Ledger structs.

func (*LedgersQ) Page

func (q *LedgersQ) Page(page db2.PageQuery) *LedgersQ

Page specifies the paging constraints for the query being built by `q`.

func (*LedgersQ) Select

func (q *LedgersQ) Select(ctx context.Context, dest interface{}) error

Select loads the results of the query specified by `q` into `dest`.

type LiquidityPool

type LiquidityPool struct {
	PoolID             string                     `db:"id"`
	Type               xdr.LiquidityPoolType      `db:"type"`
	Fee                uint32                     `db:"fee"`
	TrustlineCount     uint64                     `db:"trustline_count"`
	ShareCount         uint64                     `db:"share_count"`
	AssetReserves      LiquidityPoolAssetReserves `db:"asset_reserves"`
	LastModifiedLedger uint32                     `db:"last_modified_ledger"`
	Deleted            bool                       `db:"deleted"`
}

LiquidityPool is a row of data from the `liquidity_pools`.

func MakeTestPool

func MakeTestPool(A xdr.Asset, a uint64, B xdr.Asset, b uint64) LiquidityPool

MakeTestPool is a helper to make liquidity pools for testing purposes. It's public because it's used in other test suites.

type LiquidityPoolAssetReserve

type LiquidityPoolAssetReserve struct {
	Asset   xdr.Asset
	Reserve uint64
}

func (LiquidityPoolAssetReserve) MarshalJSON

func (lpar LiquidityPoolAssetReserve) MarshalJSON() ([]byte, error)

func (*LiquidityPoolAssetReserve) UnmarshalJSON

func (lpar *LiquidityPoolAssetReserve) UnmarshalJSON(data []byte) error

type LiquidityPoolAssetReserves

type LiquidityPoolAssetReserves []LiquidityPoolAssetReserve

func (*LiquidityPoolAssetReserves) Scan

func (c *LiquidityPoolAssetReserves) Scan(value interface{}) error

func (LiquidityPoolAssetReserves) Value

type LiquidityPoolBatchInsertBuilder

type LiquidityPoolBatchInsertBuilder interface {
	Add(liquidityPool LiquidityPool) error
	Exec(ctx context.Context) error
}

type LiquidityPoolLoader

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

LiquidityPoolLoader will map liquidity pools to their internal history ids. If there is no existing mapping for a given liquidity pool, the LiquidityPoolLoader will insert into the history_liquidity_pools table to establish a mapping.

func NewLiquidityPoolLoader

func NewLiquidityPoolLoader() *LiquidityPoolLoader

NewLiquidityPoolLoader will construct a new LiquidityPoolLoader instance.

func (*LiquidityPoolLoader) Exec

Exec will look up all the internal history ids for the liquidity pools registered in the loader. If there are no internal history ids for a given set of liquidity pools, Exec will insert rows into the history_liquidity_pools table.

func (*LiquidityPoolLoader) GetFuture

GetFuture registers the given liquidity pool into the loader and returns a FutureLiquidityPoolID which will hold the internal history id for the liquidity pool after Exec() is called.

func (*LiquidityPoolLoader) GetNow

func (a *LiquidityPoolLoader) GetNow(id string) (int64, error)

GetNow returns the internal history id for the given liquidity pool. GetNow should only be called on values which were registered by GetFuture() calls. Also, Exec() must be called before any GetNow call can succeed.

type LiquidityPoolLoaderStub

type LiquidityPoolLoaderStub struct {
	Loader *LiquidityPoolLoader
}

LiquidityPoolLoaderStub is a stub wrapper around LiquidityPoolLoader which allows you to manually configure the mapping of liquidity pools to history liquidity ppol ids

func NewLiquidityPoolLoaderStub

func NewLiquidityPoolLoaderStub() LiquidityPoolLoaderStub

NewLiquidityPoolLoaderStub returns a new LiquidityPoolLoader instance

func (LiquidityPoolLoaderStub) Insert

func (a LiquidityPoolLoaderStub) Insert(lp string, id int64)

Insert updates the wrapped LiquidityPoolLoader so that the given liquidity pool is mapped to the provided history liquidity pool id

type LiquidityPoolsQuery

type LiquidityPoolsQuery struct {
	PageQuery db2.PageQuery
	Assets    []xdr.Asset
	Account   string
}

LiquidityPoolsQuery is a helper struct to configure queries to liquidity pools

type ManageOffer

type ManageOffer struct {
	OfferID int64 `json:"offer_id"`
}

ManageOffer is a struct of data from `operations.DetailsString` when the operation type is manage sell offer or manage buy offer

type MockAccountDataBatchInsertBuilder

type MockAccountDataBatchInsertBuilder struct {
	mock.Mock
}

func (*MockAccountDataBatchInsertBuilder) Add

func (*MockAccountDataBatchInsertBuilder) Exec

type MockAccountSignersBatchInsertBuilder

type MockAccountSignersBatchInsertBuilder struct {
	mock.Mock
}

func (*MockAccountSignersBatchInsertBuilder) Add

func (*MockAccountSignersBatchInsertBuilder) Exec

type MockAccountsBatchInsertBuilder

type MockAccountsBatchInsertBuilder struct {
	mock.Mock
}

func (*MockAccountsBatchInsertBuilder) Add

func (*MockAccountsBatchInsertBuilder) Exec

type MockClaimableBalanceBatchInsertBuilder

type MockClaimableBalanceBatchInsertBuilder struct {
	mock.Mock
}

func (*MockClaimableBalanceBatchInsertBuilder) Add

func (*MockClaimableBalanceBatchInsertBuilder) Exec

type MockClaimableBalanceClaimantBatchInsertBuilder

type MockClaimableBalanceClaimantBatchInsertBuilder struct {
	mock.Mock
}

func (*MockClaimableBalanceClaimantBatchInsertBuilder) Add

func (*MockClaimableBalanceClaimantBatchInsertBuilder) Exec

type MockEffectBatchInsertBuilder

type MockEffectBatchInsertBuilder struct {
	mock.Mock
}

MockEffectBatchInsertBuilder mock EffectBatchInsertBuilder

func (*MockEffectBatchInsertBuilder) Add

func (m *MockEffectBatchInsertBuilder) Add(
	accountID FutureAccountID,
	muxedAccount null.String,
	operationID int64,
	order uint32,
	effectType EffectType,
	details []byte,
) error

Add mock

func (*MockEffectBatchInsertBuilder) Exec

Exec mock

type MockLedgersBatchInsertBuilder

type MockLedgersBatchInsertBuilder struct {
	mock.Mock
}

func (*MockLedgersBatchInsertBuilder) Add

func (m *MockLedgersBatchInsertBuilder) Add(
	ledger xdr.LedgerHeaderHistoryEntry,
	successTxsCount int,
	failedTxsCount int,
	opCount int,
	txSetOpCount int,
	ingestVersion int,
) error

func (*MockLedgersBatchInsertBuilder) Exec

type MockLiquidityPoolBatchInsertBuilder

type MockLiquidityPoolBatchInsertBuilder struct {
	mock.Mock
}

func (*MockLiquidityPoolBatchInsertBuilder) Add

func (*MockLiquidityPoolBatchInsertBuilder) Exec

type MockOffersBatchInsertBuilder

type MockOffersBatchInsertBuilder struct {
	mock.Mock
}

func (*MockOffersBatchInsertBuilder) Add

func (*MockOffersBatchInsertBuilder) Exec

type MockOperationClaimableBalanceBatchInsertBuilder

type MockOperationClaimableBalanceBatchInsertBuilder struct {
	mock.Mock
}

MockOperationClaimableBalanceBatchInsertBuilder is a mock implementation of the OperationClaimableBalanceBatchInsertBuilder interface

func (*MockOperationClaimableBalanceBatchInsertBuilder) Add

func (*MockOperationClaimableBalanceBatchInsertBuilder) Exec

type MockOperationLiquidityPoolBatchInsertBuilder

type MockOperationLiquidityPoolBatchInsertBuilder struct {
	mock.Mock
}

MockOperationLiquidityPoolBatchInsertBuilder is a mock implementation of the OperationLiquidityPoolBatchInsertBuilder interface

func (*MockOperationLiquidityPoolBatchInsertBuilder) Add

func (*MockOperationLiquidityPoolBatchInsertBuilder) Exec

type MockOperationParticipantBatchInsertBuilder

type MockOperationParticipantBatchInsertBuilder struct {
	mock.Mock
}

MockOperationParticipantBatchInsertBuilder OperationParticipantBatchInsertBuilder mock

func (*MockOperationParticipantBatchInsertBuilder) Add

Add mock

func (*MockOperationParticipantBatchInsertBuilder) Exec

Exec mock

type MockOperationsBatchInsertBuilder

type MockOperationsBatchInsertBuilder struct {
	mock.Mock
}

MockOperationsBatchInsertBuilder OperationsBatchInsertBuilder mock

func (*MockOperationsBatchInsertBuilder) Add

func (m *MockOperationsBatchInsertBuilder) Add(
	id int64,
	transactionID int64,
	applicationOrder uint32,
	operationType xdr.OperationType,
	details []byte,
	sourceAccount string,
	sourceAccountMuxed null.String,
	isPayment bool,
) error

Add mock

func (*MockOperationsBatchInsertBuilder) Exec

Exec mock

type MockQAccounts

type MockQAccounts struct {
	mock.Mock
}

MockQAccounts is a mock implementation of the QAccounts interface

func (*MockQAccounts) GetAccountsByIDs

func (m *MockQAccounts) GetAccountsByIDs(ctx context.Context, ids []string) ([]AccountEntry, error)

func (*MockQAccounts) NewAccountsBatchInsertBuilder

func (m *MockQAccounts) NewAccountsBatchInsertBuilder() AccountsBatchInsertBuilder

func (*MockQAccounts) RemoveAccounts

func (m *MockQAccounts) RemoveAccounts(ctx context.Context, accountIDs []string) (int64, error)

func (*MockQAccounts) UpsertAccounts

func (m *MockQAccounts) UpsertAccounts(ctx context.Context, accounts []AccountEntry) error

type MockQAssetStats

type MockQAssetStats struct {
	mock.Mock
}

MockQAssetStats is a mock implementation of the QAssetStats interface

func (*MockQAssetStats) CountContractIDs

func (m *MockQAssetStats) CountContractIDs(ctx context.Context) (int, error)

func (*MockQAssetStats) CountTrustLines

func (m *MockQAssetStats) CountTrustLines(ctx context.Context) (int, error)

func (*MockQAssetStats) GetAssetStat

func (m *MockQAssetStats) GetAssetStat(ctx context.Context, assetType xdr.AssetType, assetCode, assetIssuer string) (ExpAssetStat, error)

func (*MockQAssetStats) GetAssetStatByContract

func (m *MockQAssetStats) GetAssetStatByContract(ctx context.Context, contractID [32]byte) (ExpAssetStat, error)

func (*MockQAssetStats) GetAssetStatByContracts

func (m *MockQAssetStats) GetAssetStatByContracts(ctx context.Context, contractIDs [][32]byte) ([]ExpAssetStat, error)

func (*MockQAssetStats) GetAssetStats

func (m *MockQAssetStats) GetAssetStats(ctx context.Context, assetCode, assetIssuer string, page db2.PageQuery) ([]ExpAssetStat, error)

func (*MockQAssetStats) InsertAssetStat

func (m *MockQAssetStats) InsertAssetStat(ctx context.Context, assetStat ExpAssetStat) (int64, error)

func (*MockQAssetStats) InsertAssetStats

func (m *MockQAssetStats) InsertAssetStats(ctx context.Context, assetStats []ExpAssetStat, batchSize int) error

func (*MockQAssetStats) RemoveAssetStat

func (m *MockQAssetStats) RemoveAssetStat(ctx context.Context, assetType xdr.AssetType, assetCode, assetIssuer string) (int64, error)

func (*MockQAssetStats) UpdateAssetStat

func (m *MockQAssetStats) UpdateAssetStat(ctx context.Context, assetStat ExpAssetStat) (int64, error)

type MockQClaimableBalances

type MockQClaimableBalances struct {
	mock.Mock
}

MockQClaimableBalances is a mock implementation of the QAccounts interface

func (*MockQClaimableBalances) CountClaimableBalances

func (m *MockQClaimableBalances) CountClaimableBalances(ctx context.Context) (int, error)

func (*MockQClaimableBalances) GetClaimableBalancesByID

func (m *MockQClaimableBalances) GetClaimableBalancesByID(ctx context.Context, ids []string) ([]ClaimableBalance, error)

func (*MockQClaimableBalances) GetClaimantsByClaimableBalances

func (m *MockQClaimableBalances) GetClaimantsByClaimableBalances(ctx context.Context, ids []string) (map[string][]ClaimableBalanceClaimant, error)

func (*MockQClaimableBalances) NewClaimableBalanceBatchInsertBuilder

func (m *MockQClaimableBalances) NewClaimableBalanceBatchInsertBuilder() ClaimableBalanceBatchInsertBuilder

func (*MockQClaimableBalances) NewClaimableBalanceClaimantBatchInsertBuilder

func (m *MockQClaimableBalances) NewClaimableBalanceClaimantBatchInsertBuilder() ClaimableBalanceClaimantBatchInsertBuilder

func (*MockQClaimableBalances) RemoveClaimableBalanceClaimants

func (m *MockQClaimableBalances) RemoveClaimableBalanceClaimants(ctx context.Context, ids []string) (int64, error)

func (*MockQClaimableBalances) RemoveClaimableBalances

func (m *MockQClaimableBalances) RemoveClaimableBalances(ctx context.Context, ids []string) (int64, error)

type MockQData

type MockQData struct {
	mock.Mock
}

MockQData is a mock implementation of the QAccounts interface

func (*MockQData) CountAccountsData

func (m *MockQData) CountAccountsData(ctx context.Context) (int, error)

func (*MockQData) GetAccountDataByKeys

func (m *MockQData) GetAccountDataByKeys(ctx context.Context, keys []AccountDataKey) ([]Data, error)

func (*MockQData) NewAccountDataBatchInsertBuilder

func (m *MockQData) NewAccountDataBatchInsertBuilder() AccountDataBatchInsertBuilder

func (*MockQData) RemoveAccountData

func (m *MockQData) RemoveAccountData(ctx context.Context, keys []AccountDataKey) (int64, error)

func (*MockQData) UpsertAccountData

func (m *MockQData) UpsertAccountData(ctx context.Context, data []Data) error

type MockQEffects

type MockQEffects struct {
	mock.Mock
}

MockQEffects is a mock implementation of the QEffects interface

func (*MockQEffects) CreateAccounts

func (m *MockQEffects) CreateAccounts(ctx context.Context, addresses []string, maxBatchSize int) (map[string]int64, error)

func (*MockQEffects) NewEffectBatchInsertBuilder

func (m *MockQEffects) NewEffectBatchInsertBuilder() EffectBatchInsertBuilder

type MockQFilter

type MockQFilter struct {
	mock.Mock
}

MockQAccountFilterWhitelist is a mock implementation of the QAccountFilterWhitelist interface

func (*MockQFilter) GetAccountFilterConfig

func (m *MockQFilter) GetAccountFilterConfig(ctx context.Context) (AccountFilterConfig, error)

func (*MockQFilter) GetAssetFilterConfig

func (m *MockQFilter) GetAssetFilterConfig(ctx context.Context) (AssetFilterConfig, error)

func (*MockQFilter) UpdateAccountFilterConfig

func (m *MockQFilter) UpdateAccountFilterConfig(ctx context.Context, config AccountFilterConfig) (AccountFilterConfig, error)

func (*MockQFilter) UpdateAssetFilterConfig

func (m *MockQFilter) UpdateAssetFilterConfig(ctx context.Context, config AssetFilterConfig) (AssetFilterConfig, error)

type MockQHistoryClaimableBalances

type MockQHistoryClaimableBalances struct {
	mock.Mock
}

MockQHistoryClaimableBalances is a mock implementation of the QClaimableBalances interface

func (*MockQHistoryClaimableBalances) CreateHistoryClaimableBalances

func (m *MockQHistoryClaimableBalances) CreateHistoryClaimableBalances(ctx context.Context, ids []string, maxBatchSize int) (map[string]int64, error)

func (*MockQHistoryClaimableBalances) NewOperationClaimableBalanceBatchInsertBuilder

func (m *MockQHistoryClaimableBalances) NewOperationClaimableBalanceBatchInsertBuilder() OperationClaimableBalanceBatchInsertBuilder

NewOperationClaimableBalanceBatchInsertBuilder mock

func (*MockQHistoryClaimableBalances) NewTransactionClaimableBalanceBatchInsertBuilder

func (m *MockQHistoryClaimableBalances) NewTransactionClaimableBalanceBatchInsertBuilder() TransactionClaimableBalanceBatchInsertBuilder

type MockQHistoryLiquidityPools

type MockQHistoryLiquidityPools struct {
	mock.Mock
}

MockQHistoryLiquidityPools is a mock implementation of the QLiquidityPools interface

func (*MockQHistoryLiquidityPools) CreateHistoryLiquidityPools

func (m *MockQHistoryLiquidityPools) CreateHistoryLiquidityPools(ctx context.Context, poolIDs []string, maxBatchSize int) (map[string]int64, error)

func (*MockQHistoryLiquidityPools) NewOperationLiquidityPoolBatchInsertBuilder

func (m *MockQHistoryLiquidityPools) NewOperationLiquidityPoolBatchInsertBuilder() OperationLiquidityPoolBatchInsertBuilder

NewOperationLiquidityPoolBatchInsertBuilder mock

func (*MockQHistoryLiquidityPools) NewTransactionLiquidityPoolBatchInsertBuilder

func (m *MockQHistoryLiquidityPools) NewTransactionLiquidityPoolBatchInsertBuilder() TransactionLiquidityPoolBatchInsertBuilder

type MockQLedgers

type MockQLedgers struct {
	mock.Mock
}

func (*MockQLedgers) NewLedgerBatchInsertBuilder

func (m *MockQLedgers) NewLedgerBatchInsertBuilder() LedgerBatchInsertBuilder

type MockQLiquidityPools

type MockQLiquidityPools struct {
	mock.Mock
}

MockQLiquidityPools is a mock implementation of the QAccounts interface

func (*MockQLiquidityPools) CompactLiquidityPools

func (m *MockQLiquidityPools) CompactLiquidityPools(ctx context.Context, cutOffSequence uint32) (int64, error)

func (*MockQLiquidityPools) CountLiquidityPools

func (m *MockQLiquidityPools) CountLiquidityPools(ctx context.Context) (int, error)

func (*MockQLiquidityPools) FindLiquidityPoolByID

func (m *MockQLiquidityPools) FindLiquidityPoolByID(ctx context.Context, liquidityPoolID string) (LiquidityPool, error)

func (*MockQLiquidityPools) GetLiquidityPoolsByID

func (m *MockQLiquidityPools) GetLiquidityPoolsByID(ctx context.Context, poolIDs []string) ([]LiquidityPool, error)

func (*MockQLiquidityPools) GetUpdatedLiquidityPools

func (m *MockQLiquidityPools) GetUpdatedLiquidityPools(ctx context.Context, sequence uint32) ([]LiquidityPool, error)

func (*MockQLiquidityPools) NewLiquidityPoolBatchInsertBuilder

func (m *MockQLiquidityPools) NewLiquidityPoolBatchInsertBuilder() LiquidityPoolBatchInsertBuilder

func (*MockQLiquidityPools) StreamAllLiquidityPools

func (m *MockQLiquidityPools) StreamAllLiquidityPools(ctx context.Context, callback func(LiquidityPool) error) error

func (*MockQLiquidityPools) UpsertLiquidityPools

func (m *MockQLiquidityPools) UpsertLiquidityPools(ctx context.Context, lps []LiquidityPool) error

type MockQOffers

type MockQOffers struct {
	mock.Mock
}

MockQOffers is a mock implementation of the QOffers interface

func (*MockQOffers) CompactOffers

func (m *MockQOffers) CompactOffers(ctx context.Context, cutOffSequence uint32) (int64, error)

func (*MockQOffers) CountOffers

func (m *MockQOffers) CountOffers(ctx context.Context) (int, error)

func (*MockQOffers) GetOffersByIDs

func (m *MockQOffers) GetOffersByIDs(ctx context.Context, ids []int64) ([]Offer, error)

func (*MockQOffers) GetUpdatedOffers

func (m *MockQOffers) GetUpdatedOffers(ctx context.Context, newerThanSequence uint32) ([]Offer, error)

func (*MockQOffers) NewOffersBatchInsertBuilder

func (m *MockQOffers) NewOffersBatchInsertBuilder() OffersBatchInsertBuilder

func (*MockQOffers) StreamAllOffers

func (m *MockQOffers) StreamAllOffers(ctx context.Context, callback func(Offer) error) error

func (*MockQOffers) UpsertOffers

func (m *MockQOffers) UpsertOffers(ctx context.Context, rows []Offer) error

type MockQOperations

type MockQOperations struct {
	mock.Mock
}

MockQOperations is a mock implementation of the QOperations interface

func (*MockQOperations) NewOperationBatchInsertBuilder

func (m *MockQOperations) NewOperationBatchInsertBuilder() OperationBatchInsertBuilder

NewOperationBatchInsertBuilder mock

type MockQParticipants

type MockQParticipants struct {
	mock.Mock
}

MockQParticipants is a mock implementation of the QParticipants interface

func (*MockQParticipants) CreateAccounts

func (m *MockQParticipants) CreateAccounts(ctx context.Context, addresses []string, maxBatchSize int) (map[string]int64, error)

func (*MockQParticipants) NewOperationParticipantBatchInsertBuilder

func (m *MockQParticipants) NewOperationParticipantBatchInsertBuilder() OperationParticipantBatchInsertBuilder

NewOperationParticipantBatchInsertBuilder mock

func (*MockQParticipants) NewTransactionParticipantsBatchInsertBuilder

func (m *MockQParticipants) NewTransactionParticipantsBatchInsertBuilder() TransactionParticipantsBatchInsertBuilder

type MockQSigners

type MockQSigners struct {
	mock.Mock
}

func (*MockQSigners) AccountsForSigner

func (m *MockQSigners) AccountsForSigner(ctx context.Context, signer string, page db2.PageQuery) ([]AccountSigner, error)

func (*MockQSigners) CountAccounts

func (m *MockQSigners) CountAccounts(ctx context.Context) (int, error)

func (*MockQSigners) CreateAccountSigner

func (m *MockQSigners) CreateAccountSigner(ctx context.Context, account, signer string, weight int32, sponsor *string) (int64, error)

func (*MockQSigners) GetLastLedgerIngest

func (m *MockQSigners) GetLastLedgerIngest(ctx context.Context) (uint32, error)

func (*MockQSigners) GetLastLedgerIngestNonBlocking

func (m *MockQSigners) GetLastLedgerIngestNonBlocking(ctx context.Context) (uint32, error)

func (*MockQSigners) NewAccountSignersBatchInsertBuilder

func (m *MockQSigners) NewAccountSignersBatchInsertBuilder() AccountSignersBatchInsertBuilder

func (*MockQSigners) RemoveAccountSigner

func (m *MockQSigners) RemoveAccountSigner(ctx context.Context, account, signer string) (int64, error)

func (*MockQSigners) SignersForAccounts

func (m *MockQSigners) SignersForAccounts(ctx context.Context, accounts []string) ([]AccountSigner, error)

func (*MockQSigners) UpdateLastLedgerIngest

func (m *MockQSigners) UpdateLastLedgerIngest(ctx context.Context, ledgerSequence uint32) error

type MockQTrades

type MockQTrades struct {
	mock.Mock
}

func (*MockQTrades) CreateAccounts

func (m *MockQTrades) CreateAccounts(ctx context.Context, addresses []string, maxBatchSize int) (map[string]int64, error)

func (*MockQTrades) CreateAssets

func (m *MockQTrades) CreateAssets(ctx context.Context, assets []xdr.Asset, maxBatchSize int) (map[string]Asset, error)

func (*MockQTrades) CreateHistoryLiquidityPools

func (m *MockQTrades) CreateHistoryLiquidityPools(ctx context.Context, poolIDs []string, maxBatchSize int) (map[string]int64, error)

func (*MockQTrades) NewTradeBatchInsertBuilder

func (m *MockQTrades) NewTradeBatchInsertBuilder() TradeBatchInsertBuilder

func (*MockQTrades) RebuildTradeAggregationBuckets

func (m *MockQTrades) RebuildTradeAggregationBuckets(ctx context.Context, fromLedger, toLedger uint32, roundingSlippageFilter int) error

type MockQTransactions

type MockQTransactions struct {
	mock.Mock
}

MockQTransactions is a mock implementation of the QTransactions interface

func (*MockQTransactions) NewTransactionBatchInsertBuilder

func (m *MockQTransactions) NewTransactionBatchInsertBuilder() TransactionBatchInsertBuilder

func (*MockQTransactions) NewTransactionFilteredTmpBatchInsertBuilder

func (m *MockQTransactions) NewTransactionFilteredTmpBatchInsertBuilder() TransactionBatchInsertBuilder

type MockQTrustLines

type MockQTrustLines struct {
	mock.Mock
}

MockQTrustLines is a mock implementation of the QOffers interface

func (*MockQTrustLines) GetTrustLinesByKeys

func (m *MockQTrustLines) GetTrustLinesByKeys(ctx context.Context, keys []string) ([]TrustLine, error)

func (*MockQTrustLines) NewTrustLinesBatchInsertBuilder

func (m *MockQTrustLines) NewTrustLinesBatchInsertBuilder() TrustLinesBatchInsertBuilder

func (*MockQTrustLines) RemoveTrustLines

func (m *MockQTrustLines) RemoveTrustLines(ctx context.Context, ledgerKeys []string) (int64, error)

func (*MockQTrustLines) UpsertTrustLines

func (m *MockQTrustLines) UpsertTrustLines(ctx context.Context, trustLines []TrustLine) error

type MockTradeBatchInsertBuilder

type MockTradeBatchInsertBuilder struct {
	mock.Mock
}

func (*MockTradeBatchInsertBuilder) Add

func (m *MockTradeBatchInsertBuilder) Add(entries ...InsertTrade) error

func (*MockTradeBatchInsertBuilder) Exec

type MockTransactionClaimableBalanceBatchInsertBuilder

type MockTransactionClaimableBalanceBatchInsertBuilder struct {
	mock.Mock
}

MockTransactionClaimableBalanceBatchInsertBuilder is a mock implementation of the TransactionClaimableBalanceBatchInsertBuilder interface

func (*MockTransactionClaimableBalanceBatchInsertBuilder) Add

func (*MockTransactionClaimableBalanceBatchInsertBuilder) Exec

type MockTransactionLiquidityPoolBatchInsertBuilder

type MockTransactionLiquidityPoolBatchInsertBuilder struct {
	mock.Mock
}

MockTransactionLiquidityPoolBatchInsertBuilder is a mock implementation of the TransactionLiquidityPoolBatchInsertBuilder interface

func (*MockTransactionLiquidityPoolBatchInsertBuilder) Add

func (*MockTransactionLiquidityPoolBatchInsertBuilder) Exec

type MockTransactionParticipantsBatchInsertBuilder

type MockTransactionParticipantsBatchInsertBuilder struct {
	mock.Mock
}

MockTransactionParticipantsBatchInsertBuilder is a mock implementation of the TransactionParticipantsBatchInsertBuilder interface

func (*MockTransactionParticipantsBatchInsertBuilder) Add

func (*MockTransactionParticipantsBatchInsertBuilder) Exec

type MockTransactionsBatchInsertBuilder

type MockTransactionsBatchInsertBuilder struct {
	mock.Mock
}

func (*MockTransactionsBatchInsertBuilder) Add

func (*MockTransactionsBatchInsertBuilder) Exec

type MockTrustLinesBatchInsertBuilder

type MockTrustLinesBatchInsertBuilder struct {
	mock.Mock
}

func (*MockTrustLinesBatchInsertBuilder) Add

func (*MockTrustLinesBatchInsertBuilder) Exec

type Offer

type Offer struct {
	SellerID string `db:"seller_id"`
	OfferID  int64  `db:"offer_id"`

	SellingAsset xdr.Asset `db:"selling_asset"`
	BuyingAsset  xdr.Asset `db:"buying_asset"`

	Amount             int64       `db:"amount"`
	Pricen             int32       `db:"pricen"`
	Priced             int32       `db:"priced"`
	Price              float64     `db:"price"`
	Flags              int32       `db:"flags"`
	Deleted            bool        `db:"deleted"`
	LastModifiedLedger uint32      `db:"last_modified_ledger"`
	Sponsor            null.String `db:"sponsor"`
}

Offer is row of data from the `offers` table from horizon DB

type OffersBatchInsertBuilder

type OffersBatchInsertBuilder interface {
	Add(offer Offer) error
	Exec(ctx context.Context) error
}

OffersBatchInsertBuilder is used to insert offers into the offers table

type OffersQuery

type OffersQuery struct {
	PageQuery db2.PageQuery
	SellerID  string
	Sponsor   string
	Selling   *xdr.Asset
	Buying    *xdr.Asset
}

OffersQuery is a helper struct to configure queries to offers

type Operation

type Operation struct {
	TotalOrderID
	TransactionID         int64             `db:"transaction_id"`
	TransactionHash       string            `db:"transaction_hash"`
	TxResult              string            `db:"tx_result"`
	ApplicationOrder      int32             `db:"application_order"`
	Type                  xdr.OperationType `db:"type"`
	DetailsString         null.String       `db:"details"`
	SourceAccount         string            `db:"source_account"`
	SourceAccountMuxed    null.String       `db:"source_account_muxed"`
	TransactionSuccessful bool              `db:"transaction_successful"`
	IsPayment             bool              `db:"is_payment"`
}

Operation is a row of data from the `history_operations` table

func (*Operation) LedgerSequence

func (r *Operation) LedgerSequence() int32

LedgerSequence return the ledger in which the effect occurred.

func (*Operation) UnmarshalDetails

func (r *Operation) UnmarshalDetails(dest interface{}) error

UnmarshalDetails unmarshals the details of this operation into `dest`

type OperationBatchInsertBuilder

type OperationBatchInsertBuilder interface {
	Add(
		id int64,
		transactionID int64,
		applicationOrder uint32,
		operationType xdr.OperationType,
		details []byte,
		sourceAccount string,
		sourceAcccountMuxed null.String,
		isPayment bool,
	) error
	Exec(ctx context.Context, session db.SessionInterface) error
}

OperationBatchInsertBuilder is used to insert a transaction's operations into the history_operations table

type OperationClaimableBalanceBatchInsertBuilder

type OperationClaimableBalanceBatchInsertBuilder interface {
	Add(operationID int64, claimableBalance FutureClaimableBalanceID) error
	Exec(ctx context.Context, session db.SessionInterface) error
}

type OperationLiquidityPoolBatchInsertBuilder

type OperationLiquidityPoolBatchInsertBuilder interface {
	Add(operationID int64, lp FutureLiquidityPoolID) error
	Exec(ctx context.Context, session db.SessionInterface) error
}

type OperationParticipantBatchInsertBuilder

type OperationParticipantBatchInsertBuilder interface {
	Add(
		operationID int64,
		accountID FutureAccountID,
	) error
	Exec(ctx context.Context, session db.SessionInterface) error
}

OperationParticipantBatchInsertBuilder is used to insert a transaction's operations into the history_operations table

type OperationsQ

type OperationsQ struct {
	Err error
	// contains filtered or unexported fields
}

OperationsQ is a helper struct to aid in configuring queries that loads slices of Operation structs.

func (*OperationsQ) Fetch

func (q *OperationsQ) Fetch(ctx context.Context) ([]Operation, []Transaction, error)

Fetch returns results specified by a filtered operations query

func (*OperationsQ) ForAccount

func (q *OperationsQ) ForAccount(ctx context.Context, aid string) *OperationsQ

ForAccount filters the operations collection to a specific account

func (*OperationsQ) ForClaimableBalance

func (q *OperationsQ) ForClaimableBalance(ctx context.Context, cbID string) *OperationsQ

ForClaimableBalance filters the query to only operations pertaining to a claimable balance, specified by the claimable balance's hex-encoded id.

func (*OperationsQ) ForLedger

func (q *OperationsQ) ForLedger(ctx context.Context, seq int32) *OperationsQ

ForLedger filters the query to a only operations in a specific ledger, specified by its sequence.

func (*OperationsQ) ForLiquidityPool

func (q *OperationsQ) ForLiquidityPool(ctx context.Context, lpID string) *OperationsQ

ForLiquidityPools filters the query to only operations pertaining to a liquidity pool, specified by the liquidity pool id as an hex-encoded string.

func (*OperationsQ) ForTransaction

func (q *OperationsQ) ForTransaction(ctx context.Context, hash string) *OperationsQ

ForTransaction filters the query to only operations in a specific transaction, specified by the transactions's hex-encoded hash.

func (*OperationsQ) IncludeFailed

func (q *OperationsQ) IncludeFailed() *OperationsQ

IncludeFailed changes the query to include failed transactions.

func (*OperationsQ) IncludeTransactions

func (q *OperationsQ) IncludeTransactions() *OperationsQ

IncludeTransactions changes the query to fetch transaction data in addition to operation records.

func (*OperationsQ) OnlyPayments

func (q *OperationsQ) OnlyPayments() *OperationsQ

OnlyPayments filters the query being built to only include operations that are in the "payment" class of classic operations: CreateAccountOps, Payments, and PathPayments. OR also includes contract asset balance changes as expressed in 'is_payment' flag on the history operations table.

func (*OperationsQ) Page

func (q *OperationsQ) Page(page db2.PageQuery) *OperationsQ

Page specifies the paging constraints for the query being built by `q`.

type OrderBookSummary

type OrderBookSummary struct {
	Asks []PriceLevel
	Bids []PriceLevel
}

OrderBookSummary is a summary of a set of offers for a given base and counter currency

type PriceLevel

type PriceLevel struct {
	Pricen int32
	Priced int32
	Pricef string
	Amount string
}

PriceLevel represents an aggregation of offers to trade at a certain price.

type Q

type Q struct {
	db.SessionInterface
}

Q is a helper struct on which to hang common_trades queries against a history portion of the horizon database.

func (*Q) AccountByAddress

func (q *Q) AccountByAddress(ctx context.Context, dest interface{}, addy string) error

AccountByAddress loads a row from `history_accounts`, by address

func (*Q) AccountEntriesForSigner

func (q *Q) AccountEntriesForSigner(ctx context.Context, signer string, page db2.PageQuery) ([]AccountEntry, error)

AccountEntriesForSigner returns a list of `AccountEntry` rows for a given signer

func (*Q) AccountsByAddresses

func (q *Q) AccountsByAddresses(ctx context.Context, dest interface{}, addresses []string) error

AccountsByAddresses loads a rows from `history_accounts`, by addresses

func (*Q) AccountsForAsset

func (q *Q) AccountsForAsset(ctx context.Context, asset xdr.Asset, page db2.PageQuery) ([]AccountEntry, error)

AccountsForAsset returns a list of `AccountEntry` rows who are trustee to an asset

func (*Q) AccountsForLiquidityPool

func (q *Q) AccountsForLiquidityPool(ctx context.Context, poolID string, page db2.PageQuery) ([]AccountEntry, error)

AccountsForLiquidityPool returns a list of `AccountEntry` rows who are trustee to a liquidity pool share asset

func (*Q) AccountsForSigner

func (q *Q) AccountsForSigner(ctx context.Context, signer string, page db2.PageQuery) ([]AccountSigner, error)

AccountsForSigner returns a list of `AccountSigner` rows for a given signer

func (*Q) AccountsForSponsor

func (q *Q) AccountsForSponsor(ctx context.Context, sponsor string, page db2.PageQuery) ([]AccountEntry, error)

AccountsForSponsor return all the accounts where `sponsor“ is sponsoring the account entry or any of its subentries (trust lines, signers, data, or account entry)

func (*Q) AllTransactionsByHashesSinceLedger

func (q *Q) AllTransactionsByHashesSinceLedger(ctx context.Context, hashes []string, sinceLedgerSeq uint32) ([]Transaction, error)

TransactionsByHashesSinceLedger fetches transactions from `history_transactions_filtered_tmp` table which match the given hash since the given ledger sequence (for perf reasons).

func (*Q) ClaimableBalanceByID

func (q *Q) ClaimableBalanceByID(ctx context.Context, id string) (dest HistoryClaimableBalance, err error)

ClaimableBalanceByID loads a row from `history_claimable_balances`, by claimable_balance_id

func (*Q) ClaimableBalancesByIDs

func (q *Q) ClaimableBalancesByIDs(ctx context.Context, ids []string) (dest []HistoryClaimableBalance, err error)

ClaimableBalancesByIDs loads rows from `history_claimable_balances`, by claimable_balance_id

func (*Q) CloneIngestionQ

func (q *Q) CloneIngestionQ() IngestionQ

CloneIngestionQ clones underlying db.Session and returns IngestionQ

func (*Q) CompactLiquidityPools

func (q *Q) CompactLiquidityPools(ctx context.Context, cutOffSequence uint32) (int64, error)

CompactLiquidityPools removes rows from the liquidity pools table which are marked for deletion.

func (*Q) CompactOffers

func (q *Q) CompactOffers(ctx context.Context, cutOffSequence uint32) (int64, error)

CompactOffers removes rows from the offers table which are marked for deletion.

func (*Q) CountAccounts

func (q *Q) CountAccounts(ctx context.Context) (int, error)

func (*Q) CountAccountsData

func (q *Q) CountAccountsData(ctx context.Context) (int, error)

func (*Q) CountClaimableBalances

func (q *Q) CountClaimableBalances(ctx context.Context) (int, error)

CountClaimableBalances returns the total number of claimable balances in the DB

func (*Q) CountLiquidityPools

func (q *Q) CountLiquidityPools(ctx context.Context) (int, error)

CountLiquidityPools returns the total number of liquidity pools in the DB

func (*Q) CountOffers

func (q *Q) CountOffers(ctx context.Context) (int, error)

func (*Q) CountTrustLines

func (q *Q) CountTrustLines(ctx context.Context) (int, error)

func (*Q) CreateAccountSigner

func (q *Q) CreateAccountSigner(ctx context.Context, account, signer string, weight int32, sponsor *string) (int64, error)

CreateAccountSigner creates a row in the accounts_signers table. Returns number of rows affected and error.

func (*Q) CreateAccounts

func (q *Q) CreateAccounts(ctx context.Context, addresses []string, batchSize int) (map[string]int64, error)

CreateAccounts creates rows in the history_accounts table for a given list of addresses. CreateAccounts returns a mapping of account address to its corresponding id in the history_accounts table

func (*Q) CreateAssets

func (q *Q) CreateAssets(ctx context.Context, assets []xdr.Asset, batchSize int) (map[string]Asset, error)

CreateAssets creates rows in the history_assets table for a given list of assets.

func (*Q) CreateHistoryClaimableBalances

func (q *Q) CreateHistoryClaimableBalances(ctx context.Context, ids []string, batchSize int) (map[string]int64, error)

CreateHistoryClaimableBalances creates rows in the history_claimable_balances table for a given list of ids. CreateHistoryClaimableBalances returns a mapping of id to its corresponding internal id in the history_claimable_balances table

func (*Q) CreateHistoryLiquidityPools

func (q *Q) CreateHistoryLiquidityPools(ctx context.Context, poolIDs []string, batchSize int) (map[string]int64, error)

CreateHistoryLiquidityPools creates rows in the history_liquidity_pools table for a given list of ids. CreateHistoryLiquidityPools returns a mapping of id to its corresponding internal id in the history_liquidity_pools table

func (*Q) DeleteRangeAll

func (q *Q) DeleteRangeAll(ctx context.Context, start, end int64) error

DeleteRangeAll deletes a range of rows from all history tables between `start` and `end` (exclusive).

func (*Q) DeleteTransactionsFilteredTmpOlderThan

func (q *Q) DeleteTransactionsFilteredTmpOlderThan(ctx context.Context, howOldInSeconds uint64) (int64, error)

DeleteTransactionsFilteredTmpOlderThan deletes entries older than certain duration

func (*Q) Effects

func (q *Q) Effects() *EffectsQ

Effects provides a helper to filter rows from the `history_effects` table with pre-defined filters. See `TransactionsQ` methods for the available filters.

func (*Q) ElderLedger

func (q *Q) ElderLedger(ctx context.Context, dest interface{}) error

ElderLedger loads the oldest ledger known to the history database

func (*Q) FeeStats

func (q *Q) FeeStats(ctx context.Context, currentSeq int32, dest *FeeStats) error

FeeStats returns operation fee stats for the last 5 ledgers. Currently, we hard code the query to return the last 5 ledgers worth of transactions. TODO: make the number of ledgers configurable.

func (*Q) FindClaimableBalanceByID

func (q *Q) FindClaimableBalanceByID(ctx context.Context, balanceID string) (ClaimableBalance, error)

FindClaimableBalanceByID returns a claimable balance.

func (*Q) FindLiquidityPoolByID

func (q *Q) FindLiquidityPoolByID(ctx context.Context, liquidityPoolID string) (LiquidityPool, error)

FindLiquidityPoolByID returns a liquidity pool.

func (*Q) GetAccountByID

func (q *Q) GetAccountByID(ctx context.Context, id string) (AccountEntry, error)

func (*Q) GetAccountDataByAccountID

func (q *Q) GetAccountDataByAccountID(ctx context.Context, id string) ([]Data, error)

GetAccountDataByAccountID loads account data for a given account ID

func (*Q) GetAccountDataByAccountsID

func (q *Q) GetAccountDataByAccountsID(ctx context.Context, id []string) ([]Data, error)

GetAccountDataByAccountsID loads account data for a list of account ID

func (*Q) GetAccountDataByKeys

func (q *Q) GetAccountDataByKeys(ctx context.Context, keys []AccountDataKey) ([]Data, error)

GetAccountDataByKeys loads a row from the `accounts_data` table, selected by multiple keys.

func (*Q) GetAccountDataByName

func (q *Q) GetAccountDataByName(ctx context.Context, id, name string) (Data, error)

GetAccountDataByName loads account data for a given account ID and data name

func (*Q) GetAccountFilterConfig

func (q *Q) GetAccountFilterConfig(ctx context.Context) (AccountFilterConfig, error)

func (*Q) GetAccountSignersByAccountID

func (q *Q) GetAccountSignersByAccountID(ctx context.Context, id string) ([]AccountSigner, error)

func (*Q) GetAccountsByIDs

func (q *Q) GetAccountsByIDs(ctx context.Context, ids []string) ([]AccountEntry, error)

func (*Q) GetAssetFilterConfig

func (q *Q) GetAssetFilterConfig(ctx context.Context) (AssetFilterConfig, error)

func (*Q) GetAssetID

func (q *Q) GetAssetID(ctx context.Context, asset xdr.Asset) (id int64, err error)

GetAssetID fetches the id for an Asset

func (*Q) GetAssetStat

func (q *Q) GetAssetStat(ctx context.Context, assetType xdr.AssetType, assetCode, assetIssuer string) (ExpAssetStat, error)

GetAssetStat returns a row in the exp_asset_stats table.

func (*Q) GetAssetStatByContract

func (q *Q) GetAssetStatByContract(ctx context.Context, contractID [32]byte) (ExpAssetStat, error)

func (*Q) GetAssetStatByContracts

func (q *Q) GetAssetStatByContracts(ctx context.Context, contractIDs [][32]byte) ([]ExpAssetStat, error)

func (*Q) GetAssetStats

func (q *Q) GetAssetStats(ctx context.Context, assetCode, assetIssuer string, page db2.PageQuery) ([]ExpAssetStat, error)

GetAssetStats returns a page of exp_asset_stats rows.

func (*Q) GetClaimableBalances

func (q *Q) GetClaimableBalances(ctx context.Context, query ClaimableBalancesQuery) ([]ClaimableBalance, error)

GetClaimableBalances finds all claimable balances where accountID is one of the claimants

func (*Q) GetClaimableBalancesByID

func (q *Q) GetClaimableBalancesByID(ctx context.Context, ids []string) ([]ClaimableBalance, error)

GetClaimableBalancesByID finds all claimable balances by ClaimableBalanceId

func (*Q) GetClaimantsByClaimableBalances

func (q *Q) GetClaimantsByClaimableBalances(ctx context.Context, ids []string) (map[string][]ClaimableBalanceClaimant, error)

GetClaimantsByClaimableBalances finds all claimants for ClaimableBalanceIds. The returned list is sorted by ids and then destination ids for each balance id.

func (*Q) GetExpStateInvalid

func (q *Q) GetExpStateInvalid(ctx context.Context) (bool, error)

GetExpStateInvalid returns true if the state was found to be invalid. Returns false otherwise.

func (*Q) GetIngestVersion

func (q *Q) GetIngestVersion(ctx context.Context) (int, error)

GetIngestVersion returns the ingestion version. Returns zero if there is no value.

func (*Q) GetLastLedgerIngest

func (q *Q) GetLastLedgerIngest(ctx context.Context) (uint32, error)

GetLastLedgerIngest returns the last ledger ingested by ingest system in Horizon. Returns ErrKeyNotFound error if no value has been previously set. This is using `SELECT ... FOR UPDATE` what means it's blocking the row for all other transactions.This behavior is critical in distributed ingestion so do not change it unless you know what you are doing. The value can be set using UpdateLastLedgerIngest.

func (*Q) GetLastLedgerIngestNonBlocking

func (q *Q) GetLastLedgerIngestNonBlocking(ctx context.Context) (uint32, error)

GetLastLedgerIngestNonBlocking works like GetLastLedgerIngest but it does not block the value and does not return error if the value has not been previously set. This is used in status reporting (ex. in root resource of Horizon).

func (*Q) GetLatestHistoryLedger

func (q *Q) GetLatestHistoryLedger(ctx context.Context) (uint32, error)

GetLatestHistoryLedger loads the latest known ledger. Returns 0 if no ledgers in `history_ledgers` table.

func (*Q) GetLedgerGaps

func (q *Q) GetLedgerGaps(ctx context.Context) ([]LedgerRange, error)

GetLedgerGaps obtains ingestion gaps in the history_ledgers table. Returns the gaps and error.

func (*Q) GetLedgerGapsInRange

func (q *Q) GetLedgerGapsInRange(ctx context.Context, start, end uint32) ([]LedgerRange, error)

GetLedgerGapsInRange obtains ingestion gaps in the history_ledgers table within the given range. Returns the gaps and error.

func (*Q) GetLiquidityPoolCompactionSequence

func (q *Q) GetLiquidityPoolCompactionSequence(ctx context.Context) (uint32, error)

GetLiquidityPoolCompactionSequence returns the sequence number corresponding to the last time the liquidity pools table was compacted.

func (*Q) GetLiquidityPools

func (q *Q) GetLiquidityPools(ctx context.Context, query LiquidityPoolsQuery) ([]LiquidityPool, error)

GetLiquidityPools finds all liquidity pools where accountID owns assets

func (*Q) GetLiquidityPoolsByID

func (q *Q) GetLiquidityPoolsByID(ctx context.Context, poolIDs []string) ([]LiquidityPool, error)

GetLiquidityPoolsByID finds all liquidity pools by PoolId

func (*Q) GetOfferByID

func (q *Q) GetOfferByID(ctx context.Context, id int64) (Offer, error)

GetOfferByID loads a row from the `offers` table, selected by offerid.

func (*Q) GetOfferCompactionSequence

func (q *Q) GetOfferCompactionSequence(ctx context.Context) (uint32, error)

GetOfferCompactionSequence returns the sequence number corresponding to the last time the offers table was compacted.

func (*Q) GetOffers

func (q *Q) GetOffers(ctx context.Context, query OffersQuery) ([]Offer, error)

GetOffers loads rows from `offers` by paging query.

func (*Q) GetOffersByIDs

func (q *Q) GetOffersByIDs(ctx context.Context, ids []int64) ([]Offer, error)

GetOffersByIDs loads a row from the `offers` table, selected by multiple offerid.

func (*Q) GetOrderBookSummary

func (q *Q) GetOrderBookSummary(ctx context.Context, sellingAsset, buyingAsset xdr.Asset, maxPriceLevels int) (OrderBookSummary, error)

GetOrderBookSummary returns an OrderBookSummary for a given trading pair. GetOrderBookSummary should only be called in a repeatable read transaction.

func (*Q) GetSequenceNumbers

func (q *Q) GetSequenceNumbers(ctx context.Context, addresses []string) (map[string]uint64, error)

func (*Q) GetSortedTrustLinesByAccountID

func (q *Q) GetSortedTrustLinesByAccountID(ctx context.Context, id string) ([]TrustLine, error)

func (*Q) GetSortedTrustLinesByAccountIDs

func (q *Q) GetSortedTrustLinesByAccountIDs(ctx context.Context, id []string) ([]TrustLine, error)

GetSortedTrustLinesByAccountIDs loads trust lines for a list of accounts ID, ordered by asset and issuer

func (Q) GetTradeAggregationsQ

func (q Q) GetTradeAggregationsQ(baseAssetID int64, counterAssetID int64, resolution int64,
	offset int64, pagingParams db2.PageQuery) (*TradeAggregationsQ, error)

GetTradeAggregationsQ initializes a TradeAggregationsQ query builder based on the required parameters

func (*Q) GetTrades

func (q *Q) GetTrades(
	ctx context.Context, page db2.PageQuery, account string, tradeType string,
) ([]Trade, error)

func (*Q) GetTradesForAssets

func (q *Q) GetTradesForAssets(
	ctx context.Context, page db2.PageQuery, account, tradeType string, baseAsset, counterAsset xdr.Asset,
) ([]Trade, error)

func (*Q) GetTradesForLiquidityPool

func (q *Q) GetTradesForLiquidityPool(
	ctx context.Context, page db2.PageQuery, poolID string,
) ([]Trade, error)

func (*Q) GetTradesForOffer

func (q *Q) GetTradesForOffer(
	ctx context.Context, page db2.PageQuery, offerID int64,
) ([]Trade, error)

func (*Q) GetTrustLinesByKeys

func (q *Q) GetTrustLinesByKeys(ctx context.Context, ledgerKeys []string) ([]TrustLine, error)

GetTrustLinesByKeys loads a row from the `trust_lines` table, selected by multiple keys.

func (*Q) GetUpdatedLiquidityPools

func (q *Q) GetUpdatedLiquidityPools(ctx context.Context, newerThanSequence uint32) ([]LiquidityPool, error)

GetUpdatedLiquidityPools returns all liquidity pools created, updated, or deleted after the given ledger sequence.

func (*Q) GetUpdatedOffers

func (q *Q) GetUpdatedOffers(ctx context.Context, newerThanSequence uint32) ([]Offer, error)

GetUpdatedOffers returns all offers created, updated, or deleted after the given ledger sequence.

func (*Q) InsertAssetStat

func (q *Q) InsertAssetStat(ctx context.Context, assetStat ExpAssetStat) (int64, error)

InsertAssetStat a single asset assetStat row into the exp_asset_stats Returns number of rows affected and error.

func (*Q) InsertAssetStats

func (q *Q) InsertAssetStats(ctx context.Context, assetStats []ExpAssetStat, batchSize int) error

InsertAssetStats a set of asset stats into the exp_asset_stats

func (*Q) LatestLedger

func (q *Q) LatestLedger(ctx context.Context, dest interface{}) error

LatestLedger loads the latest known ledger

func (*Q) LatestLedgerBaseFeeAndSequence

func (q *Q) LatestLedgerBaseFeeAndSequence(ctx context.Context, dest interface{}) error

LatestLedgerBaseFeeAndSequence loads the latest known ledger's base fee and sequence number.

func (*Q) LatestLedgerSequenceClosedAt

func (q *Q) LatestLedgerSequenceClosedAt(ctx context.Context) (int32, time.Time, error)

LatestLedgerSequenceClosedAt loads the latest known ledger sequence and close time, returns empty values if no ledgers in a DB.

func (*Q) LedgerBySequence

func (q *Q) LedgerBySequence(ctx context.Context, dest interface{}, seq int32) error

LedgerBySequence loads the single ledger at `seq` into `dest`

func (*Q) LedgerCapacityUsageStats

func (q *Q) LedgerCapacityUsageStats(ctx context.Context, currentSeq int32, dest *LedgerCapacityUsageStats) error

LedgerCapacityUsageStats returns ledger capacity stats for the last 5 ledgers. Currently, we hard code the query to return the last 5 ledgers. TODO: make the number of ledgers configurable.

func (*Q) Ledgers

func (q *Q) Ledgers() *LedgersQ

Ledgers provides a helper to filter rows from the `history_ledgers` table with pre-defined filters. See `LedgersQ` methods for the available filters.

func (*Q) LedgersBySequence

func (q *Q) LedgersBySequence(ctx context.Context, dest interface{}, seqs ...int32) error

LedgersBySequence loads the a set of ledgers identified by the sequences `seqs` into `dest`.

func (*Q) LiquidityPoolByID

func (q *Q) LiquidityPoolByID(ctx context.Context, poolID string) (dest HistoryLiquidityPool, err error)

LiquidityPoolByID loads a row from `history_liquidity_pools`, by liquidity_pool_id

func (*Q) LiquidityPoolsByIDs

func (q *Q) LiquidityPoolsByIDs(ctx context.Context, poolIDs []string) (dest []HistoryLiquidityPool, err error)

LiquidityPoolsByIDs loads rows from `history_liquidity_pools`, by liquidity_pool_id

func (*Q) NewAccountDataBatchInsertBuilder

func (q *Q) NewAccountDataBatchInsertBuilder() AccountDataBatchInsertBuilder

func (*Q) NewAccountSignersBatchInsertBuilder

func (q *Q) NewAccountSignersBatchInsertBuilder() AccountSignersBatchInsertBuilder

func (*Q) NewAccountsBatchInsertBuilder

func (q *Q) NewAccountsBatchInsertBuilder() AccountsBatchInsertBuilder

NewAccountsBatchInsertBuilder constructs a new AccountsBatchInsertBuilder instance

func (*Q) NewClaimableBalanceBatchInsertBuilder

func (q *Q) NewClaimableBalanceBatchInsertBuilder() ClaimableBalanceBatchInsertBuilder

NewClaimableBalanceBatchInsertBuilder constructs a new ClaimableBalanceBatchInsertBuilder instance

func (*Q) NewClaimableBalanceClaimantBatchInsertBuilder

func (q *Q) NewClaimableBalanceClaimantBatchInsertBuilder() ClaimableBalanceClaimantBatchInsertBuilder

NewClaimableBalanceClaimantBatchInsertBuilder constructs a new ClaimableBalanceClaimantBatchInsertBuilder instance

func (*Q) NewEffectBatchInsertBuilder

func (q *Q) NewEffectBatchInsertBuilder() EffectBatchInsertBuilder

NewEffectBatchInsertBuilder constructs a new EffectBatchInsertBuilder instance

func (*Q) NewLedgerBatchInsertBuilder

func (q *Q) NewLedgerBatchInsertBuilder() LedgerBatchInsertBuilder

NewLedgerBatchInsertBuilder constructs a new EffectBatchInsertBuilder instance

func (*Q) NewLiquidityPoolBatchInsertBuilder

func (q *Q) NewLiquidityPoolBatchInsertBuilder() LiquidityPoolBatchInsertBuilder

func (*Q) NewOffersBatchInsertBuilder

func (q *Q) NewOffersBatchInsertBuilder() OffersBatchInsertBuilder

NewOffersBatchInsertBuilder constructs a new OffersBatchInsertBuilder instance

func (*Q) NewOperationBatchInsertBuilder

func (q *Q) NewOperationBatchInsertBuilder() OperationBatchInsertBuilder

NewOperationBatchInsertBuilder constructs a new TransactionBatchInsertBuilder instance

func (*Q) NewOperationClaimableBalanceBatchInsertBuilder

func (q *Q) NewOperationClaimableBalanceBatchInsertBuilder() OperationClaimableBalanceBatchInsertBuilder

func (*Q) NewOperationLiquidityPoolBatchInsertBuilder

func (q *Q) NewOperationLiquidityPoolBatchInsertBuilder() OperationLiquidityPoolBatchInsertBuilder

func (*Q) NewOperationParticipantBatchInsertBuilder

func (q *Q) NewOperationParticipantBatchInsertBuilder() OperationParticipantBatchInsertBuilder

NewOperationParticipantBatchInsertBuilder constructs a new OperationParticipantBatchInsertBuilder instance

func (*Q) NewTradeBatchInsertBuilder

func (q *Q) NewTradeBatchInsertBuilder() TradeBatchInsertBuilder

NewTradeBatchInsertBuilder constructs a new TradeBatchInsertBuilder instance

func (*Q) NewTransactionBatchInsertBuilder

func (q *Q) NewTransactionBatchInsertBuilder() TransactionBatchInsertBuilder

NewTransactionBatchInsertBuilder constructs a new TransactionBatchInsertBuilder instance

func (*Q) NewTransactionClaimableBalanceBatchInsertBuilder

func (q *Q) NewTransactionClaimableBalanceBatchInsertBuilder() TransactionClaimableBalanceBatchInsertBuilder

func (*Q) NewTransactionFilteredTmpBatchInsertBuilder

func (q *Q) NewTransactionFilteredTmpBatchInsertBuilder() TransactionBatchInsertBuilder

NewTransactionFilteredTmpBatchInsertBuilder constructs a new TransactionBatchInsertBuilder instance

func (*Q) NewTransactionLiquidityPoolBatchInsertBuilder

func (q *Q) NewTransactionLiquidityPoolBatchInsertBuilder() TransactionLiquidityPoolBatchInsertBuilder

func (*Q) NewTransactionParticipantsBatchInsertBuilder

func (q *Q) NewTransactionParticipantsBatchInsertBuilder() TransactionParticipantsBatchInsertBuilder

NewTransactionParticipantsBatchInsertBuilder constructs a new TransactionParticipantsBatchInsertBuilder instance

func (*Q) NewTrustLinesBatchInsertBuilder

func (q *Q) NewTrustLinesBatchInsertBuilder() TrustLinesBatchInsertBuilder

NewTrustLinesBatchInsertBuilder constructs a new TrustLinesBatchInsertBuilder instance

func (*Q) OperationByID

func (q *Q) OperationByID(ctx context.Context, includeTransactions bool, id int64) (Operation, *Transaction, error)

OperationByID returns an Operation and optionally a Transaction given an operation id

func (*Q) Operations

func (q *Q) Operations() *OperationsQ

Operations provides a helper to filter the operations table with pre-defined filters. See `OperationsQ` for the available filters.

func (*Q) PreFilteredTransactionByHash

func (q *Q) PreFilteredTransactionByHash(ctx context.Context, dest interface{}, hash string) error

func (Q) ReapLookupTables

func (q Q) ReapLookupTables(ctx context.Context, offsets map[string]int64) (
	map[string]int64,
	map[string]int64,
	error,
)

ReapLookupTables removes rows from lookup tables like history_claimable_balances which aren't used (orphaned), i.e. history entries for them were reaped. This method must be executed inside ingestion transaction. Otherwise it may create invalid state in lookup and history tables.

func (Q) RebuildTradeAggregationBuckets

func (q Q) RebuildTradeAggregationBuckets(ctx context.Context, fromSeq, toSeq uint32, roundingSlippageFilter int) error

RebuildTradeAggregationBuckets rebuilds a specific set of trade aggregation buckets, (specified by start and end ledger seq) to ensure complete data in case of partial reingestion.

func (Q) RebuildTradeAggregationTimes

func (q Q) RebuildTradeAggregationTimes(ctx context.Context, from, to strtime.Millis, roundingSlippageFilter int) error

RebuildTradeAggregationTimes rebuilds a specific set of trade aggregation buckets, (specified by start and end times) to ensure complete data in case of partial reingestion.

func (*Q) RemoveAccountData

func (q *Q) RemoveAccountData(ctx context.Context, keys []AccountDataKey) (int64, error)

RemoveAccountData deletes a row in the accounts_data table. Returns number of rows affected and error.

func (*Q) RemoveAccountSigner

func (q *Q) RemoveAccountSigner(ctx context.Context, account, signer string) (int64, error)

RemoveAccountSigner deletes a row in the accounts_signers table. Returns number of rows affected and error.

func (*Q) RemoveAccounts

func (q *Q) RemoveAccounts(ctx context.Context, accountIDs []string) (int64, error)

RemoveAccounts deletes a row in the accounts table. Returns number of rows affected and error.

func (*Q) RemoveAssetStat

func (q *Q) RemoveAssetStat(ctx context.Context, assetType xdr.AssetType, assetCode, assetIssuer string) (int64, error)

RemoveAssetStat removes a row in the exp_asset_stats table.

func (*Q) RemoveClaimableBalanceClaimants

func (q *Q) RemoveClaimableBalanceClaimants(ctx context.Context, ids []string) (int64, error)

RemoveClaimableBalanceClaimants deletes claimable balance claimants. Returns number of rows affected and error.

func (*Q) RemoveClaimableBalances

func (q *Q) RemoveClaimableBalances(ctx context.Context, ids []string) (int64, error)

RemoveClaimableBalances deletes claimable balances table. Returns number of rows affected and error.

func (*Q) RemoveTrustLines

func (q *Q) RemoveTrustLines(ctx context.Context, ledgerKeys []string) (int64, error)

RemoveTrustLine deletes a row in the trust lines table. Returns number of rows affected and error.

func (*Q) SignersForAccounts

func (q *Q) SignersForAccounts(ctx context.Context, accounts []string) ([]AccountSigner, error)

func (*Q) StreamAllLiquidityPools

func (q *Q) StreamAllLiquidityPools(ctx context.Context, callback func(LiquidityPool) error) error

func (*Q) StreamAllOffers

func (q *Q) StreamAllOffers(ctx context.Context, callback func(Offer) error) error

StreamAllOffers loads all non deleted offers

func (*Q) TransactionByHash

func (q *Q) TransactionByHash(ctx context.Context, dest interface{}, hash string) error

TransactionByHash is a query that loads a single row from the `history_transactions` table based upon the provided hash.

func (*Q) Transactions

func (q *Q) Transactions() *TransactionsQ

Transactions provides a helper to filter rows from the `history_transactions` table with pre-defined filters. See `TransactionsQ` methods for the available filters.

func (*Q) TransactionsByIDs

func (q *Q) TransactionsByIDs(ctx context.Context, ids ...int64) (map[int64]Transaction, error)

TransactionsByIDs fetches transactions from the `history_transactions` table which match the given ids

func (*Q) TruncateIngestStateTables

func (q *Q) TruncateIngestStateTables(ctx context.Context) error

TruncateIngestStateTables clears out ingestion state tables. Ingestion state tables are horizon database tables populated by the ingestion system using history archive snapshots. Any horizon database tables which cannot be populated using history archive snapshots will not be truncated.

func (*Q) TryStateVerificationLock

func (q *Q) TryStateVerificationLock(ctx context.Context) (bool, error)

TryStateVerificationLock attempts to acquire the state verification lock which gives the ingesting node exclusive access to perform state verification. TryStateVerificationLock returns true if the lock was acquired or false if the lock could not be acquired because it is held by another node.

func (*Q) UpdateAccountFilterConfig

func (q *Q) UpdateAccountFilterConfig(ctx context.Context, config AccountFilterConfig) (AccountFilterConfig, error)

func (*Q) UpdateAssetFilterConfig

func (q *Q) UpdateAssetFilterConfig(ctx context.Context, config AssetFilterConfig) (AssetFilterConfig, error)

func (*Q) UpdateAssetStat

func (q *Q) UpdateAssetStat(ctx context.Context, assetStat ExpAssetStat) (int64, error)

UpdateAssetStat updates a row in the exp_asset_stats table. Returns number of rows affected and error.

func (*Q) UpdateExpStateInvalid

func (q *Q) UpdateExpStateInvalid(ctx context.Context, val bool) error

UpdateExpStateInvalid updates the state invalid value.

func (*Q) UpdateIngestVersion

func (q *Q) UpdateIngestVersion(ctx context.Context, version int) error

UpdateIngestVersion updates the ingestion version.

func (*Q) UpdateLastLedgerIngest

func (q *Q) UpdateLastLedgerIngest(ctx context.Context, ledgerSequence uint32) error

UpdateLastLedgerIngest updates the last ledger ingested by ingest system. Can be read using GetLastLedgerExpIngest.

func (*Q) UpdateLiquidityPoolCompactionSequence

func (q *Q) UpdateLiquidityPoolCompactionSequence(ctx context.Context, sequence uint32) error

func (*Q) UpdateOfferCompactionSequence

func (q *Q) UpdateOfferCompactionSequence(ctx context.Context, sequence uint32) error

UpdateOfferCompactionSequence sets the sequence number corresponding to the last time the offers table was compacted.

func (*Q) UpsertAccountData

func (q *Q) UpsertAccountData(ctx context.Context, data []Data) error

UpsertAccountData upserts a batch of data in the account_Data table.

func (*Q) UpsertAccounts

func (q *Q) UpsertAccounts(ctx context.Context, accounts []AccountEntry) error

UpsertAccounts upserts a batch of accounts in the accounts table. There's currently no limit of the number of accounts this method can accept other than 2GB limit of the query string length what should be enough for each ledger with the current limits.

func (*Q) UpsertLiquidityPools

func (q *Q) UpsertLiquidityPools(ctx context.Context, lps []LiquidityPool) error

UpsertLiquidityPools upserts a batch of liquidity pools in the liquidity_pools table. There's currently no limit of the number of liquidity pools this method can accept other than 2GB limit of the query string length what should be enough for each ledger with the current limits.

func (*Q) UpsertOffers

func (q *Q) UpsertOffers(ctx context.Context, offers []Offer) error

UpsertOffers upserts a batch of offers in the offers table. There's currently no limit of the number of offers this method can accept other than 2GB limit of the query string length what should be enough for each ledger with the current limits.

func (*Q) UpsertTrustLines

func (q *Q) UpsertTrustLines(ctx context.Context, trustLines []TrustLine) error

UpsertTrustLines upserts a batch of trust lines in the trust lines table. There's currently no limit of the number of trust lines this method can accept other than 2GB limit of the query string length what should be enough for each ledger with the current limits.

type QAccounts

type QAccounts interface {
	GetAccountsByIDs(ctx context.Context, ids []string) ([]AccountEntry, error)
	UpsertAccounts(ctx context.Context, accounts []AccountEntry) error
	RemoveAccounts(ctx context.Context, accountIDs []string) (int64, error)
	NewAccountsBatchInsertBuilder() AccountsBatchInsertBuilder
}

QAccounts defines account related queries.

type QAssetStats

type QAssetStats interface {
	InsertAssetStats(ctx context.Context, stats []ExpAssetStat, batchSize int) error
	InsertAssetStat(ctx context.Context, stat ExpAssetStat) (int64, error)
	UpdateAssetStat(ctx context.Context, stat ExpAssetStat) (int64, error)
	GetAssetStat(ctx context.Context, assetType xdr.AssetType, assetCode, assetIssuer string) (ExpAssetStat, error)
	GetAssetStatByContract(ctx context.Context, contractID [32]byte) (ExpAssetStat, error)
	GetAssetStatByContracts(ctx context.Context, contractIDs [][32]byte) ([]ExpAssetStat, error)
	RemoveAssetStat(ctx context.Context, assetType xdr.AssetType, assetCode, assetIssuer string) (int64, error)
	GetAssetStats(ctx context.Context, assetCode, assetIssuer string, page db2.PageQuery) ([]ExpAssetStat, error)
	CountTrustLines(ctx context.Context) (int, error)
}

QAssetStats defines exp_asset_stats related queries.

type QClaimableBalances

type QClaimableBalances interface {
	RemoveClaimableBalances(ctx context.Context, ids []string) (int64, error)
	RemoveClaimableBalanceClaimants(ctx context.Context, ids []string) (int64, error)
	GetClaimableBalancesByID(ctx context.Context, ids []string) ([]ClaimableBalance, error)
	CountClaimableBalances(ctx context.Context) (int, error)
	NewClaimableBalanceClaimantBatchInsertBuilder() ClaimableBalanceClaimantBatchInsertBuilder
	NewClaimableBalanceBatchInsertBuilder() ClaimableBalanceBatchInsertBuilder
	GetClaimantsByClaimableBalances(ctx context.Context, ids []string) (map[string][]ClaimableBalanceClaimant, error)
}

QClaimableBalances defines claimable-balance-related related queries.

type QCreateAccountsHistory

type QCreateAccountsHistory interface {
	CreateAccounts(ctx context.Context, addresses []string, maxBatchSize int) (map[string]int64, error)
}

type QData

type QData interface {
	CountAccountsData(ctx context.Context) (int, error)
	GetAccountDataByKeys(ctx context.Context, keys []AccountDataKey) ([]Data, error)
	UpsertAccountData(ctx context.Context, data []Data) error
	RemoveAccountData(ctx context.Context, keys []AccountDataKey) (int64, error)
	NewAccountDataBatchInsertBuilder() AccountDataBatchInsertBuilder
}

QData defines account data related queries.

type QEffects

type QEffects interface {
	QCreateAccountsHistory
	NewEffectBatchInsertBuilder() EffectBatchInsertBuilder
}

QEffects defines history_effects related queries.

type QFilter

type QFilter interface {
	GetAccountFilterConfig(ctx context.Context) (AccountFilterConfig, error)
	GetAssetFilterConfig(ctx context.Context) (AssetFilterConfig, error)
	UpdateAssetFilterConfig(ctx context.Context, config AssetFilterConfig) (AssetFilterConfig, error)
	UpdateAccountFilterConfig(ctx context.Context, config AccountFilterConfig) (AccountFilterConfig, error)
}

type QHistoryClaimableBalances

type QHistoryClaimableBalances interface {
	CreateHistoryClaimableBalances(ctx context.Context, ids []string, batchSize int) (map[string]int64, error)
	NewOperationClaimableBalanceBatchInsertBuilder() OperationClaimableBalanceBatchInsertBuilder
	NewTransactionClaimableBalanceBatchInsertBuilder() TransactionClaimableBalanceBatchInsertBuilder
}

QHistoryClaimableBalances defines account related queries.

type QHistoryLiquidityPools

type QHistoryLiquidityPools interface {
	CreateHistoryLiquidityPools(ctx context.Context, poolIDs []string, batchSize int) (map[string]int64, error)
	NewOperationLiquidityPoolBatchInsertBuilder() OperationLiquidityPoolBatchInsertBuilder
	NewTransactionLiquidityPoolBatchInsertBuilder() TransactionLiquidityPoolBatchInsertBuilder
}

QHistoryLiquidityPools defines account related queries.

type QLedgers

type QLedgers interface {
	NewLedgerBatchInsertBuilder() LedgerBatchInsertBuilder
}

QLedgers defines ingestion ledger related queries.

type QLiquidityPools

type QLiquidityPools interface {
	UpsertLiquidityPools(ctx context.Context, lps []LiquidityPool) error
	GetLiquidityPoolsByID(ctx context.Context, poolIDs []string) ([]LiquidityPool, error)
	StreamAllLiquidityPools(ctx context.Context, callback func(LiquidityPool) error) error
	CountLiquidityPools(ctx context.Context) (int, error)
	FindLiquidityPoolByID(ctx context.Context, liquidityPoolID string) (LiquidityPool, error)
	GetUpdatedLiquidityPools(ctx context.Context, newerThanSequence uint32) ([]LiquidityPool, error)
	CompactLiquidityPools(ctx context.Context, cutOffSequence uint32) (int64, error)
	NewLiquidityPoolBatchInsertBuilder() LiquidityPoolBatchInsertBuilder
}

QLiquidityPools defines liquidity-pool-related queries.

type QOffers

type QOffers interface {
	StreamAllOffers(ctx context.Context, callback func(Offer) error) error
	GetOffersByIDs(ctx context.Context, ids []int64) ([]Offer, error)
	CountOffers(ctx context.Context) (int, error)
	GetUpdatedOffers(ctx context.Context, newerThanSequence uint32) ([]Offer, error)
	UpsertOffers(ctx context.Context, offers []Offer) error
	CompactOffers(ctx context.Context, cutOffSequence uint32) (int64, error)
	NewOffersBatchInsertBuilder() OffersBatchInsertBuilder
}

QOffers defines offer related queries.

type QOperations

type QOperations interface {
	NewOperationBatchInsertBuilder() OperationBatchInsertBuilder
}

QOperations defines history_operation related queries.

type QParticipants

type QParticipants interface {
	QCreateAccountsHistory
	NewTransactionParticipantsBatchInsertBuilder() TransactionParticipantsBatchInsertBuilder
	NewOperationParticipantBatchInsertBuilder() OperationParticipantBatchInsertBuilder
}

QParticipants defines ingestion participant related queries.

type QSigners

type QSigners interface {
	GetLastLedgerIngestNonBlocking(ctx context.Context) (uint32, error)
	GetLastLedgerIngest(ctx context.Context) (uint32, error)
	UpdateLastLedgerIngest(ctx context.Context, ledgerSequence uint32) error
	AccountsForSigner(ctx context.Context, signer string, page db2.PageQuery) ([]AccountSigner, error)
	NewAccountSignersBatchInsertBuilder() AccountSignersBatchInsertBuilder
	CreateAccountSigner(ctx context.Context, account, signer string, weight int32, sponsor *string) (int64, error)
	RemoveAccountSigner(ctx context.Context, account, signer string) (int64, error)
	SignersForAccounts(ctx context.Context, accounts []string) ([]AccountSigner, error)
	CountAccounts(ctx context.Context) (int, error)
}

QSigners defines signer related queries.

type QTrades

type QTrades interface {
	QCreateAccountsHistory
	NewTradeBatchInsertBuilder() TradeBatchInsertBuilder
	RebuildTradeAggregationBuckets(ctx context.Context, fromledger, toLedger uint32, roundingSlippageFilter int) error
	CreateAssets(ctx context.Context, assets []xdr.Asset, maxBatchSize int) (map[string]Asset, error)
	CreateHistoryLiquidityPools(ctx context.Context, poolIDs []string, batchSize int) (map[string]int64, error)
}

type QTransactions

type QTransactions interface {
	NewTransactionBatchInsertBuilder() TransactionBatchInsertBuilder
	NewTransactionFilteredTmpBatchInsertBuilder() TransactionBatchInsertBuilder
}

QTransactions defines transaction related queries.

type QTrustLines

type QTrustLines interface {
	GetTrustLinesByKeys(ctx context.Context, ledgerKeys []string) ([]TrustLine, error)
	UpsertTrustLines(ctx context.Context, trustlines []TrustLine) error
	RemoveTrustLines(ctx context.Context, ledgerKeys []string) (int64, error)
	NewTrustLinesBatchInsertBuilder() TrustLinesBatchInsertBuilder
}

QTrustLines defines trust lines related queries.

type SequenceBumped

type SequenceBumped struct {
	NewSeq int64 `json:"new_seq"`
}

SequenceBumped is a struct of data from `effects.DetailsString` when the effect type is sequence bumped.

type TimeBounds

type TimeBounds struct {
	Null  bool
	Upper null.Int
	Lower null.Int
}

TimeBounds represents the time bounds of a Stellar transaction

func (*TimeBounds) Scan

func (t *TimeBounds) Scan(src interface{}) error

Scan implements the database/sql Scanner interface.

func (TimeBounds) Value

func (t TimeBounds) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type TotalOrderID

type TotalOrderID struct {
	ID int64 `db:"id"`
}

TotalOrderID represents the ID portion of rows that are identified by the "TotalOrderID". See total_order_id.go in the `db` package for details.

func (*TotalOrderID) PagingToken

func (r *TotalOrderID) PagingToken() string

PagingToken returns a cursor for this record

type Trade

type Trade struct {
	HistoryOperationID     int64       `db:"history_operation_id"`
	Order                  int32       `db:"order"`
	LedgerCloseTime        time.Time   `db:"ledger_closed_at"`
	BaseOfferID            null.Int    `db:"base_offer_id"`
	BaseAccount            null.String `db:"base_account"`
	BaseAssetType          string      `db:"base_asset_type"`
	BaseAssetCode          string      `db:"base_asset_code"`
	BaseAssetIssuer        string      `db:"base_asset_issuer"`
	BaseAmount             int64       `db:"base_amount"`
	BaseLiquidityPoolID    null.String `db:"base_liquidity_pool_id"`
	CounterOfferID         null.Int    `db:"counter_offer_id"`
	CounterAccount         null.String `db:"counter_account"`
	CounterAssetType       string      `db:"counter_asset_type"`
	CounterAssetCode       string      `db:"counter_asset_code"`
	CounterAssetIssuer     string      `db:"counter_asset_issuer"`
	CounterAmount          int64       `db:"counter_amount"`
	CounterLiquidityPoolID null.String `db:"counter_liquidity_pool_id"`
	LiquidityPoolFee       null.Int    `db:"liquidity_pool_fee"`
	BaseIsSeller           bool        `db:"base_is_seller"`
	PriceN                 null.Int    `db:"price_n"`
	PriceD                 null.Int    `db:"price_d"`
	Type                   TradeType   `db:"trade_type"`
}

Trade represents a trade from the trades table, joined with asset information from the assets table and account addresses from the accounts table

func FilterTradesByType

func FilterTradesByType(trades []Trade, tradeType string) []Trade

FilterTradesByType filters the given trades by type

func (*Trade) HasPrice

func (r *Trade) HasPrice() bool

HasPrice returns true if the trade has non-null price data

func (*Trade) PagingToken

func (r *Trade) PagingToken() string

PagingToken returns a cursor for this trade

type TradeAggregation

type TradeAggregation struct {
	Timestamp     int64   `db:"timestamp"`
	TradeCount    int64   `db:"count"`
	BaseVolume    string  `db:"base_volume"`
	CounterVolume string  `db:"counter_volume"`
	Average       float64 `db:"avg"`
	HighN         int64   `db:"high_n"`
	HighD         int64   `db:"high_d"`
	LowN          int64   `db:"low_n"`
	LowD          int64   `db:"low_d"`
	OpenN         int64   `db:"open_n"`
	OpenD         int64   `db:"open_d"`
	CloseN        int64   `db:"close_n"`
	CloseD        int64   `db:"close_d"`
}

TradeAggregation represents an aggregation of trades from the trades table

type TradeAggregationsQ

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

TradeAggregationsQ is a helper struct to aid in configuring queries to bucket and aggregate trades

func (*TradeAggregationsQ) GetSql

func (q *TradeAggregationsQ) GetSql() sq.SelectBuilder

GetSql generates a sql statement to aggregate Trades based on given parameters

func (*TradeAggregationsQ) WithEndTime

func (q *TradeAggregationsQ) WithEndTime(endTime strtime.Millis) (*TradeAggregationsQ, error)

WithEndTime adds an upper optional time boundary filter to the trades being aggregated.

func (*TradeAggregationsQ) WithStartTime

func (q *TradeAggregationsQ) WithStartTime(startTime strtime.Millis) (*TradeAggregationsQ, error)

WithStartTime adds an optional lower time boundary filter to the trades being aggregated.

type TradeBatchInsertBuilder

type TradeBatchInsertBuilder interface {
	Add(entries ...InsertTrade) error
	Exec(ctx context.Context, session db.SessionInterface) error
}

TradeBatchInsertBuilder is used to insert trades into the history_trades table

type TradeEffectDetails

type TradeEffectDetails struct {
	Seller            string `json:"seller"`
	SellerMuxed       string `json:"seller_muxed,omitempty"`
	SellerMuxedID     uint64 `json:"seller_muxed_id,omitempty"`
	OfferID           int64  `json:"offer_id"`
	SoldAmount        string `json:"sold_amount"`
	SoldAssetType     string `json:"sold_asset_type"`
	SoldAssetCode     string `json:"sold_asset_code,omitempty"`
	SoldAssetIssuer   string `json:"sold_asset_issuer,omitempty"`
	BoughtAmount      string `json:"bought_amount"`
	BoughtAssetType   string `json:"bought_asset_type"`
	BoughtAssetCode   string `json:"bought_asset_code,omitempty"`
	BoughtAssetIssuer string `json:"bought_asset_issuer,omitempty"`
}

TradeEffectDetails is a struct of data from `effects.DetailsString` when the effect type is trade

type TradeFixtures

type TradeFixtures struct {
	Addresses       []string
	Assets          []xdr.Asset
	Trades          []Trade
	LiquidityPools  []string
	TradesByAccount map[string][]Trade
	TradesByAsset   map[string][]Trade
	TradesByPool    map[string][]Trade
	TradesByOffer   map[int64][]Trade
}

TradeFixtures contains the data inserted into the database when running TradeScenario

func TradeScenario

func TradeScenario(tt *test.T, q *Q) TradeFixtures

TradeScenario inserts trade rows into the Horizon DB

func (TradeFixtures) TradesByAssetPair

func (f TradeFixtures) TradesByAssetPair(a, b xdr.Asset) []Trade

TradesByAssetPair returns the trades which match a given trading pair

type TradeType

type TradeType int16

TradeType is an enum which indicates the type of trade

type Transaction

type Transaction struct {
	LedgerCloseTime time.Time `db:"ledger_close_time"`
	TransactionWithoutLedger
}

Transaction is a row of data from the `history_transactions` table

func (*Transaction) HasPreconditions

func (t *Transaction) HasPreconditions() bool

type TransactionBatchInsertBuilder

type TransactionBatchInsertBuilder interface {
	Add(transaction ingest.LedgerTransaction, sequence uint32) error
	Exec(ctx context.Context, session db.SessionInterface) error
}

TransactionBatchInsertBuilder is used to insert transactions into the history_transactions table

type TransactionClaimableBalanceBatchInsertBuilder

type TransactionClaimableBalanceBatchInsertBuilder interface {
	Add(transactionID int64, claimableBalance FutureClaimableBalanceID) error
	Exec(ctx context.Context, session db.SessionInterface) error
}

type TransactionFilteredTmp

type TransactionFilteredTmp struct {
	CreatedAt time.Time `db:"created_at"`
	TransactionWithoutLedger
}

Transaction is a row of data from the `history_transactions_filtered_tmp` table

type TransactionLiquidityPoolBatchInsertBuilder

type TransactionLiquidityPoolBatchInsertBuilder interface {
	Add(transactionID int64, lp FutureLiquidityPoolID) error
	Exec(ctx context.Context, session db.SessionInterface) error
}

type TransactionParticipantsBatchInsertBuilder

type TransactionParticipantsBatchInsertBuilder interface {
	Add(transactionID int64, accountID FutureAccountID) error
	Exec(ctx context.Context, session db.SessionInterface) error
}

TransactionParticipantsBatchInsertBuilder is used to insert transaction participants into the history_transaction_participants table

type TransactionWithoutLedger

type TransactionWithoutLedger struct {
	TotalOrderID
	TransactionHash             string         `db:"transaction_hash"`
	LedgerSequence              int32          `db:"ledger_sequence"`
	ApplicationOrder            int32          `db:"application_order"`
	Account                     string         `db:"account"`
	AccountMuxed                null.String    `db:"account_muxed"`
	AccountSequence             int64          `db:"account_sequence"`
	MaxFee                      int64          `db:"max_fee"`
	FeeCharged                  int64          `db:"fee_charged"`
	OperationCount              int32          `db:"operation_count"`
	TxEnvelope                  string         `db:"tx_envelope"`
	TxResult                    string         `db:"tx_result"`
	TxMeta                      string         `db:"tx_meta"`
	TxFeeMeta                   string         `db:"tx_fee_meta"`
	Signatures                  pq.StringArray `db:"signatures"`
	MemoType                    string         `db:"memo_type"`
	Memo                        null.String    `db:"memo"`
	TimeBounds                  TimeBounds     `db:"time_bounds"`
	LedgerBounds                LedgerBounds   `db:"ledger_bounds"`
	MinAccountSequence          null.Int       `db:"min_account_sequence"`
	MinAccountSequenceAge       null.String    `db:"min_account_sequence_age"`
	MinAccountSequenceLedgerGap null.Int       `db:"min_account_sequence_ledger_gap"`
	ExtraSigners                pq.StringArray `db:"extra_signers"`
	CreatedAt                   time.Time      `db:"created_at"`
	UpdatedAt                   time.Time      `db:"updated_at"`
	Successful                  bool           `db:"successful"`
	FeeAccount                  null.String    `db:"fee_account"`
	FeeAccountMuxed             null.String    `db:"fee_account_muxed"`
	InnerTransactionHash        null.String    `db:"inner_transaction_hash"`
	NewMaxFee                   null.Int       `db:"new_max_fee"`
	InnerSignatures             pq.StringArray `db:"inner_signatures"`
}

type TransactionsQ

type TransactionsQ struct {
	Err error
	// contains filtered or unexported fields
}

TransactionsQ is a helper struct to aid in configuring queries that loads slices of transaction structs.

func (*TransactionsQ) ForAccount

func (q *TransactionsQ) ForAccount(ctx context.Context, aid string) *TransactionsQ

ForAccount filters the transactions collection to a specific account

func (*TransactionsQ) ForClaimableBalance

func (q *TransactionsQ) ForClaimableBalance(ctx context.Context, cbID string) *TransactionsQ

ForClaimableBalance filters the transactions collection to a specific claimable balance

func (*TransactionsQ) ForLedger

func (q *TransactionsQ) ForLedger(ctx context.Context, seq int32) *TransactionsQ

ForLedger filters the query to a only transactions in a specific ledger, specified by its sequence.

func (*TransactionsQ) ForLiquidityPool

func (q *TransactionsQ) ForLiquidityPool(ctx context.Context, poolID string) *TransactionsQ

ForLiquidityPool filters the transactions collection to a specific liquidity pool

func (*TransactionsQ) IncludeFailed

func (q *TransactionsQ) IncludeFailed() *TransactionsQ

IncludeFailed changes the query to include failed transactions.

func (*TransactionsQ) Page

func (q *TransactionsQ) Page(page db2.PageQuery) *TransactionsQ

Page specifies the paging constraints for the query being built by `q`.

func (*TransactionsQ) Select

func (q *TransactionsQ) Select(ctx context.Context, dest interface{}) error

Select loads the results of the query specified by `q` into `dest`.

type TrustLine

type TrustLine struct {
	AccountID          string        `db:"account_id"`
	AssetType          xdr.AssetType `db:"asset_type"`
	AssetIssuer        string        `db:"asset_issuer"`
	AssetCode          string        `db:"asset_code"`
	Balance            int64         `db:"balance"`
	LedgerKey          string        `db:"ledger_key"`
	Limit              int64         `db:"trust_line_limit"`
	LiquidityPoolID    string        `db:"liquidity_pool_id"`
	BuyingLiabilities  int64         `db:"buying_liabilities"`
	SellingLiabilities int64         `db:"selling_liabilities"`
	Flags              uint32        `db:"flags"`
	LastModifiedLedger uint32        `db:"last_modified_ledger"`
	Sponsor            null.String   `db:"sponsor"`
}

TrustLine is row of data from the `trust_lines` table from horizon DB

func MakeTestTrustline

func MakeTestTrustline(account string, asset xdr.Asset, poolId string) TrustLine

func (TrustLine) IsAuthorized

func (trustLine TrustLine) IsAuthorized() bool

IsAuthorized returns true if issuer has authorized account to perform transactions with its credit

func (TrustLine) IsAuthorizedToMaintainLiabilities

func (trustLine TrustLine) IsAuthorizedToMaintainLiabilities() bool

IsAuthorizedToMaintainLiabilities returns true if issuer has authorized the account to maintain liabilities with its credit

func (TrustLine) IsClawbackEnabled

func (trustLine TrustLine) IsClawbackEnabled() bool

IsClawbackEnabled returns true if issuer has authorized the account to claw assets back

type TrustLinesBatchInsertBuilder

type TrustLinesBatchInsertBuilder interface {
	Add(line TrustLine) error
	Exec(ctx context.Context) error
}

TrustLinesBatchInsertBuilder is used to insert trustlines into the trust_lines table

Source Files

Jump to

Keyboard shortcuts

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