history

package
v0.0.0-...-fb9541f Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2020 License: Apache-2.0 Imports: 22 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

This section is empty.

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 ExperimentalIngestionTables = []string{
	"accounts",
	"accounts_data",
	"accounts_signers",
	"exp_asset_stats",
	"offers",
	"trust_lines",
}

ExperimentalIngestionTables is a list of tables populated by the experimental ingestion system

View Source
var StrictResolutionFiltering = true

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

Functions

func EncodeOfferId

func EncodeOfferId(id uint64, typ OfferIDType) int64

EncodeOfferId creates synthetic offer ids to be used by trade resources

This is required because paydex-core does not allocate offer ids for immediately filled offers, while clients expect them for aggregated views.

The encoded value is of type int64 for sql compatibility. The 2nd bit is used to differentiate between paydex-core offer ids and operation ids, which are toids.

Due to the 2nd bit being used, the largest possible toid is: 0011111111111111111111111111111100000000000000000001000000000001 \ ledger /\ transaction /\ op /

= 1073741823
  with avg. 5 sec close time will reach in ~170 years

Types

type Account

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

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

type AccountDataBatchInsertBuilder

type AccountDataBatchInsertBuilder interface {
	Add(data xdr.DataEntry, lastModifiedLedger xdr.Uint32) error
	Exec() error
}

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"`
	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"`
}

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

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 AccountSigner

type AccountSigner struct {
	Account string `db:"account_id"`
	Signer  string `db:"signer"`
	Weight  int32  `db:"weight"`
}

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

type AccountSignersBatchInsertBuilder

type AccountSignersBatchInsertBuilder interface {
	Add(signer AccountSigner) error
	Exec() error
}

type AccountsBatchInsertBuilder

type AccountsBatchInsertBuilder interface {
	Add(account xdr.AccountEntry, lastModifiedLedger xdr.Uint32) error
	Exec() error
}

type AccountsQ

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

AccountsQ is a helper struct to aid in configuring queries that loads slices of account structs.

func (*AccountsQ) Page

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

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

func (*AccountsQ) Select

func (q *AccountsQ) Select(dest interface{}) error

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

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 AssetStat

type AssetStat struct {
	ID          int64  `db:"id"`
	Amount      string `db:"amount"`
	NumAccounts int32  `db:"num_accounts"`
	Flags       int8   `db:"flags"`
	Toml        string `db:"toml"`
}

AssetStat is a row in the asset_stats table representing the stats per Asset

type Data

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

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"`
	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 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
	EffectAccountCredited EffectType = 2 // from create_account, payment, path_payment, merge_account

	// EffectAccountDebited effects occur when an account sends some currency
	EffectAccountDebited EffectType = 3 // from create_account, payment, path_payment, create_account

	// 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

	// 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

	// EffectTrustlineDeauthorized occurs when an anchor revokes access to a asset
	// it issues.
	EffectTrustlineDeauthorized EffectType = 24 // from allow_trust

	// EffectOfferCreated occurs when an account offers to trade an asset
	EffectOfferCreated EffectType = 30 // from manage_offer, creat_passive_offer

	// EffectOfferRemoved occurs when an account removes an offer
	EffectOfferRemoved EffectType = 31 // from manage_offer, creat_passive_offer, path_payment

	// EffectOfferUpdated occurs when an offer is updated by the offering account.
	EffectOfferUpdated EffectType = 32 // from manage_offer, creat_passive_offer, path_payment

	// 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

)

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(aid string) *EffectsQ

ForAccount filters the operations collection to a specific account

func (*EffectsQ) ForLedger

func (q *EffectsQ) ForLedger(seq int32) *EffectsQ

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

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) ForOrderBook

func (q *EffectsQ) ForOrderBook(selling, buying xdr.Asset) *EffectsQ

ForOrderBook filters the query to only effects whose details indicate that the effect is for a specific asset pair.

func (*EffectsQ) ForTransaction

func (q *EffectsQ) ForTransaction(hash string) *EffectsQ

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

func (*EffectsQ) OfType

func (q *EffectsQ) OfType(typ EffectType) *EffectsQ

OfType filters the query to only effects of the given type.

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(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"`
	Amount      string        `db:"amount"`
	NumAccounts int32         `db:"num_accounts"`
}

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

func (ExpAssetStat) PagingToken

func (e ExpAssetStat) PagingToken() string

PagingToken returns a cursor for this asset stat

type ExpIngestRemovalSummary

type ExpIngestRemovalSummary struct {
	LedgersRemoved int64
}

ExpIngestRemovalSummary describes how many rows in the experimental ingestion history tables have been deleted by RemoveExpIngestHistory()

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 KeyValueStoreRow

type KeyValueStoreRow struct {
	Key   string `db:"key"`
	Value string `db:"value"`
}

KeyValueStoreRow represents a row in key value store.

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"`
	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 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(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 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(dest interface{}) error

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

type MockAccountDataBatchInsertBuilder

type MockAccountDataBatchInsertBuilder struct {
	mock.Mock
}

func (*MockAccountDataBatchInsertBuilder) Add

func (m *MockAccountDataBatchInsertBuilder) Add(data xdr.DataEntry, lastModifiedLedger xdr.Uint32) error

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 (m *MockAccountsBatchInsertBuilder) Add(accounts xdr.AccountEntry, lastModifiedLedger xdr.Uint32) error

func (*MockAccountsBatchInsertBuilder) Exec

type MockOffersBatchInsertBuilder

type MockOffersBatchInsertBuilder struct {
	mock.Mock
}

func (*MockOffersBatchInsertBuilder) Add

func (m *MockOffersBatchInsertBuilder) Add(offer xdr.OfferEntry, lastModifiedLedger xdr.Uint32) error

func (*MockOffersBatchInsertBuilder) Exec

type MockQAccounts

type MockQAccounts struct {
	mock.Mock
}

MockQAccounts is a mock implementation of the QAccounts interface

func (*MockQAccounts) GetAccountsByIDs

func (m *MockQAccounts) GetAccountsByIDs(ids []string) ([]AccountEntry, error)

func (*MockQAccounts) InsertAccount

func (m *MockQAccounts) InsertAccount(account xdr.AccountEntry, lastModifiedLedger xdr.Uint32) (int64, error)

func (*MockQAccounts) NewAccountsBatchInsertBuilder

func (m *MockQAccounts) NewAccountsBatchInsertBuilder(maxBatchSize int) AccountsBatchInsertBuilder

func (*MockQAccounts) RemoveAccount

func (m *MockQAccounts) RemoveAccount(accountID string) (int64, error)

func (*MockQAccounts) UpdateAccount

func (m *MockQAccounts) UpdateAccount(account xdr.AccountEntry, lastModifiedLedger xdr.Uint32) (int64, error)

type MockQAssetStats

type MockQAssetStats struct {
	mock.Mock
}

MockQAssetStats is a mock implementation of the QAssetStats interface

func (*MockQAssetStats) GetAssetStat

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

func (*MockQAssetStats) GetAssetStats

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

func (*MockQAssetStats) InsertAssetStat

func (m *MockQAssetStats) InsertAssetStat(assetStat ExpAssetStat) (int64, error)

func (*MockQAssetStats) InsertAssetStats

func (m *MockQAssetStats) InsertAssetStats(assetStats []ExpAssetStat, batchSize int) error

func (*MockQAssetStats) RemoveAssetStat

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

func (*MockQAssetStats) UpdateAssetStat

func (m *MockQAssetStats) UpdateAssetStat(assetStat ExpAssetStat) (int64, error)

type MockQData

type MockQData struct {
	mock.Mock
}

MockQData is a mock implementation of the QAccounts interface

func (*MockQData) GetAccountDataByKeys

func (m *MockQData) GetAccountDataByKeys(keys []xdr.LedgerKeyData) ([]Data, error)

func (*MockQData) InsertAccountData

func (m *MockQData) InsertAccountData(data xdr.DataEntry, lastModifiedLedger xdr.Uint32) (int64, error)

func (*MockQData) NewAccountDataBatchInsertBuilder

func (m *MockQData) NewAccountDataBatchInsertBuilder(maxBatchSize int) AccountDataBatchInsertBuilder

func (*MockQData) RemoveAccountData

func (m *MockQData) RemoveAccountData(key xdr.LedgerKeyData) (int64, error)

func (*MockQData) UpdateAccountData

func (m *MockQData) UpdateAccountData(data xdr.DataEntry, lastModifiedLedger xdr.Uint32) (int64, error)

type MockQLedgers

type MockQLedgers struct {
	mock.Mock
}

func (*MockQLedgers) CheckExpLedger

func (m *MockQLedgers) CheckExpLedger(seq int32) (bool, error)

func (*MockQLedgers) InsertExpLedger

func (m *MockQLedgers) InsertExpLedger(
	ledger xdr.LedgerHeaderHistoryEntry,
	successTxsCount int,
	failedTxsCount int,
	opCount int,
	ingestVersion int,
) (int64, error)

type MockQOffers

type MockQOffers struct {
	mock.Mock
}

MockQOffers is a mock implementation of the QOffers interface

func (*MockQOffers) GetAllOffers

func (m *MockQOffers) GetAllOffers() ([]Offer, error)

func (*MockQOffers) InsertOffer

func (m *MockQOffers) InsertOffer(offer xdr.OfferEntry, lastModifiedLedger xdr.Uint32) (int64, error)

func (*MockQOffers) NewOffersBatchInsertBuilder

func (m *MockQOffers) NewOffersBatchInsertBuilder(maxBatchSize int) OffersBatchInsertBuilder

func (*MockQOffers) RemoveOffer

func (m *MockQOffers) RemoveOffer(offerID xdr.Int64) (int64, error)

func (*MockQOffers) UpdateOffer

func (m *MockQOffers) UpdateOffer(offer xdr.OfferEntry, lastModifiedLedger xdr.Uint32) (int64, error)

type MockQSigners

type MockQSigners struct {
	mock.Mock
}

func (*MockQSigners) AccountsForSigner

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

func (*MockQSigners) CreateAccountSigner

func (m *MockQSigners) CreateAccountSigner(account, signer string, weight int32) (int64, error)

func (*MockQSigners) GetLastLedgerExpIngest

func (m *MockQSigners) GetLastLedgerExpIngest() (uint32, error)

func (*MockQSigners) GetLastLedgerExpIngestNonBlocking

func (m *MockQSigners) GetLastLedgerExpIngestNonBlocking() (uint32, error)

func (*MockQSigners) NewAccountSignersBatchInsertBuilder

func (m *MockQSigners) NewAccountSignersBatchInsertBuilder(maxBatchSize int) AccountSignersBatchInsertBuilder

func (*MockQSigners) RemoveAccountSigner

func (m *MockQSigners) RemoveAccountSigner(account, signer string) (int64, error)

func (*MockQSigners) UpdateLastLedgerExpIngest

func (m *MockQSigners) UpdateLastLedgerExpIngest(ledgerSequence uint32) error

type MockQTrustLines

type MockQTrustLines struct {
	mock.Mock
}

MockQTrustLines is a mock implementation of the QOffers interface

func (*MockQTrustLines) InsertTrustLine

func (m *MockQTrustLines) InsertTrustLine(trustLine xdr.TrustLineEntry, lastModifiedLedger xdr.Uint32) (int64, error)

func (*MockQTrustLines) NewTrustLinesBatchInsertBuilder

func (m *MockQTrustLines) NewTrustLinesBatchInsertBuilder(maxBatchSize int) TrustLinesBatchInsertBuilder

func (*MockQTrustLines) RemoveTrustLine

func (m *MockQTrustLines) RemoveTrustLine(key xdr.LedgerKeyTrustLine) (int64, error)

func (*MockQTrustLines) UpdateTrustLine

func (m *MockQTrustLines) UpdateTrustLine(trustLine xdr.TrustLineEntry, lastModifiedLedger xdr.Uint32) (int64, error)

type MockTrustLinesBatchInsertBuilder

type MockTrustLinesBatchInsertBuilder struct {
	mock.Mock
}

func (*MockTrustLinesBatchInsertBuilder) Add

func (m *MockTrustLinesBatchInsertBuilder) Add(trustLines xdr.TrustLineEntry, lastModifiedLedger xdr.Uint32) error

func (*MockTrustLinesBatchInsertBuilder) Exec

type Offer

type Offer struct {
	SellerID string    `db:"seller_id"`
	OfferID  xdr.Int64 `db:"offer_id"`

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

	Amount             xdr.Int64 `db:"amount"`
	Pricen             int32     `db:"pricen"`
	Priced             int32     `db:"priced"`
	Price              float64   `db:"price"`
	Flags              uint32    `db:"flags"`
	LastModifiedLedger uint32    `db:"last_modified_ledger"`
}

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

type OfferIDType

type OfferIDType uint64
const (
	CoreOfferIDType OfferIDType = 0
	TOIDType        OfferIDType = 1
)

func DecodeOfferID

func DecodeOfferID(encodedId int64) (uint64, OfferIDType)

DecodeOfferID performs the reverse operation of EncodeOfferID

type OffersBatchInsertBuilder

type OffersBatchInsertBuilder interface {
	Add(offer xdr.OfferEntry, lastModifiedLedger xdr.Uint32) error
	Exec() error
}

type OffersQuery

type OffersQuery struct {
	PageQuery db2.PageQuery
	SellerID  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"`
	// Check db2/history.Transaction.Successful field comment for more information.
	TransactionSuccessful *bool `db:"transaction_successful"`
}

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

func (*Operation) IsTransactionSuccessful

func (t *Operation) IsTransactionSuccessful() bool

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 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() ([]Operation, []Transaction, error)

Fetch returns results specified by a filtered operations query

func (*OperationsQ) ForAccount

func (q *OperationsQ) ForAccount(aid string) *OperationsQ

ForAccount filters the operations collection to a specific account

func (*OperationsQ) ForLedger

func (q *OperationsQ) ForLedger(seq int32) *OperationsQ

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

func (*OperationsQ) ForTransaction

func (q *OperationsQ) ForTransaction(hash string) *OperationsQ

ForTransaction filters the query to a 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 operations: CreateAccountOps, Payments, and PathPayments.

func (*OperationsQ) Page

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

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

type Q

type Q struct {
	*db.Session
}

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(dest interface{}, addy string) error

AccountByAddress loads a row from `history_accounts`, by address

func (*Q) AccountByID

func (q *Q) AccountByID(dest interface{}, id int64) error

AccountByID loads a row from `history_accounts`, by id

func (*Q) AccountEntriesForSigner

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

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

func (*Q) Accounts

func (q *Q) Accounts() *AccountsQ

Accounts provides a helper to filter rows from the `history_accounts` table with pre-defined filters. See `AccountsQ` methods for the available filters.

func (*Q) AccountsByAddresses

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

AccountsByAddresses loads a rows from `history_accounts`, by addresses

func (*Q) AccountsForAsset

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

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

func (*Q) AccountsForSigner

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

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

func (*Q) CheckExpLedger

func (q *Q) CheckExpLedger(seq int32) (bool, error)

CheckExpLedger checks that the ledger in exp_history_ledgers matches the one in history_ledgers for a given sequence number

func (*Q) CountAccounts

func (q *Q) CountAccounts() (int, error)

func (*Q) CountAccountsData

func (q *Q) CountAccountsData() (int, error)

func (*Q) CountOffers

func (q *Q) CountOffers() (int, error)

func (*Q) CountTrustLines

func (q *Q) CountTrustLines() (int, error)

func (*Q) CreateAccountSigner

func (q *Q) CreateAccountSigner(account, signer string, weight int32) (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(dest interface{}, addresses []string) error

CreateAccounts creates rows for addresses in history_accounts table and put. `ON CONFLICT` is required when running a distributed ingestion.

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(dest interface{}) error

ElderLedger loads the oldest ledger known to the history database

func (*Q) FeeStats

func (q *Q) FeeStats(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) GetAccountByID

func (q *Q) GetAccountByID(id string) (AccountEntry, error)

func (*Q) GetAccountDataByAccountID

func (q *Q) GetAccountDataByAccountID(id string) ([]Data, error)

GetAccountDataByAccountID loads account data for a given account ID

func (*Q) GetAccountDataByAccountsID

func (q *Q) GetAccountDataByAccountsID(id []string) ([]Data, error)

GetAccountDataByAccountsID loads account data for a list of account ID

func (*Q) GetAccountDataByKeys

func (q *Q) GetAccountDataByKeys(keys []xdr.LedgerKeyData) ([]Data, error)

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

func (*Q) GetAccountSignersByAccountID

func (q *Q) GetAccountSignersByAccountID(id string) ([]AccountSigner, error)

func (*Q) GetAccountsByIDs

func (q *Q) GetAccountsByIDs(ids []string) ([]AccountEntry, error)

func (*Q) GetAllOffers

func (q *Q) GetAllOffers() ([]Offer, error)

GetAllOffers loads a row from `history_accounts`, by address

func (*Q) GetAssetByID

func (q *Q) GetAssetByID(dest interface{}, id int64) (err error)

func (*Q) GetAssetID

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

GetAssetID fetches the id for an Asset. If fetching multiple values, look at GetAssetIDs

func (*Q) GetAssetIDs

func (q *Q) GetAssetIDs(assets []xdr.Asset) ([]int64, error)

GetAssetIDs fetches the ids for many Assets at once

func (*Q) GetAssetStat

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

GetAssetStat returns a row in the exp_asset_stats table.

func (*Q) GetAssetStats

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

GetAssetStats returns a page of exp_asset_stats rows.

func (*Q) GetCreateAccountID

func (q *Q) GetCreateAccountID(
	aid xdr.AccountId,
) (result int64, err error)

Return id for account. If account doesn't exist, it will be created and the new id returned. `ON CONFLICT` is required when running a distributed ingestion.

func (*Q) GetCreateAssetID

func (q *Q) GetCreateAssetID(
	asset xdr.Asset,
) (result int64, err error)

Get asset row id. If asset is first seen, it will be inserted and the new id returned.

func (*Q) GetExpIngestVersion

func (q *Q) GetExpIngestVersion() (int, error)

GetExpIngestVersion returns the exp ingest version. Returns zero if there is no value.

func (*Q) GetExpStateInvalid

func (q *Q) GetExpStateInvalid() (bool, error)

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

func (*Q) GetLastLedgerExpIngest

func (q *Q) GetLastLedgerExpIngest() (uint32, error)

GetLastLedgerExpIngest returns the last ledger ingested by expingest 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 behaviour is critical in distributed ingestion so do not change it unless you know what you are doing. The value can be set using UpdateLastLedgerExpIngest.

func (*Q) GetLastLedgerExpIngestNonBlocking

func (q *Q) GetLastLedgerExpIngestNonBlocking() (uint32, error)

GetLastLedgerExpIngestNonBlocking works like GetLastLedgerExpIngest 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) GetOfferByID

func (q *Q) GetOfferByID(id int64) (Offer, error)

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

func (*Q) GetOffers

func (q *Q) GetOffers(query OffersQuery) ([]Offer, error)

GetOffers loads rows from `offers` by paging query.

func (*Q) GetOffersByIDs

func (q *Q) GetOffersByIDs(ids []int64) ([]Offer, error)

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

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) GetTrustLinesByAccountID

func (q *Q) GetTrustLinesByAccountID(id string) ([]TrustLine, error)

func (*Q) GetTrustLinesByAccountsID

func (q *Q) GetTrustLinesByAccountsID(id []string) ([]TrustLine, error)

GetTrustLinesByAccountsID loads trust lines for a list of accounts ID

func (*Q) GetTrustLinesByKeys

func (q *Q) GetTrustLinesByKeys(keys []xdr.LedgerKeyTrustLine) ([]TrustLine, error)

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

func (*Q) InsertAccount

func (q *Q) InsertAccount(account xdr.AccountEntry, lastModifiedLedger xdr.Uint32) (int64, error)

InsertAccount creates a row in the accounts table. Returns number of rows affected and error.

func (*Q) InsertAccountData

func (q *Q) InsertAccountData(data xdr.DataEntry, lastModifiedLedger xdr.Uint32) (int64, error)

InsertAccountData creates a row in the accounts_data table. Returns number of rows affected and error.

func (*Q) InsertAssetStat

func (q *Q) InsertAssetStat(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(assetStats []ExpAssetStat, batchSize int) error

InsertAssetStats a set of asset stats into the exp_asset_stats

func (*Q) InsertExpLedger

func (q *Q) InsertExpLedger(
	ledger xdr.LedgerHeaderHistoryEntry,
	successTxsCount int,
	failedTxsCount int,
	opCount int,
	ingestVersion int,
) (int64, error)

InsertExpLedger creates a row in the exp_history_ledgers table. Returns number of rows affected and error.

func (*Q) InsertOffer

func (q *Q) InsertOffer(offer xdr.OfferEntry, lastModifiedLedger xdr.Uint32) (int64, error)

InsertOffer creates a row in the offers table. Returns number of rows affected and error.

func (*Q) InsertTrade

func (q *Q) InsertTrade(
	opid int64,
	order int32,
	buyer xdr.AccountId,
	buyOfferExists bool,
	buyOffer xdr.OfferEntry,
	trade xdr.ClaimOfferAtom,
	sellPrice xdr.Price,
	ledgerClosedAt time.Millis,
) error

Trade records a trade into the history_trades table

func (*Q) InsertTrustLine

func (q *Q) InsertTrustLine(trustLine xdr.TrustLineEntry, lastModifiedLedger xdr.Uint32) (int64, error)

InsertTrustLine creates a row in the trust lines table. Returns number of rows affected and error.

func (*Q) LatestLedger

func (q *Q) LatestLedger(dest interface{}) error

LatestLedger loads the latest known ledger

func (*Q) LatestLedgerBaseFeeAndSequence

func (q *Q) LatestLedgerBaseFeeAndSequence(dest interface{}) error

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

func (*Q) LedgerBySequence

func (q *Q) LedgerBySequence(dest interface{}, seq int32) error

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

func (*Q) LedgerCapacityUsageStats

func (q *Q) LedgerCapacityUsageStats(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(dest interface{}, seqs ...int32) error

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

func (*Q) NewAccountDataBatchInsertBuilder

func (q *Q) NewAccountDataBatchInsertBuilder(maxBatchSize int) AccountDataBatchInsertBuilder

func (*Q) NewAccountSignersBatchInsertBuilder

func (q *Q) NewAccountSignersBatchInsertBuilder(maxBatchSize int) AccountSignersBatchInsertBuilder

func (*Q) NewAccountsBatchInsertBuilder

func (q *Q) NewAccountsBatchInsertBuilder(maxBatchSize int) AccountsBatchInsertBuilder

func (*Q) NewOffersBatchInsertBuilder

func (q *Q) NewOffersBatchInsertBuilder(maxBatchSize int) OffersBatchInsertBuilder

func (*Q) NewTrustLinesBatchInsertBuilder

func (q *Q) NewTrustLinesBatchInsertBuilder(maxBatchSize int) TrustLinesBatchInsertBuilder

func (*Q) OldestOutdatedLedgers

func (q *Q) OldestOutdatedLedgers(dest interface{}, currentVersion int) error

OldestOutdatedLedgers populates a slice of ints with the first million outdated ledgers, based upon the provided `currentVersion` number

func (*Q) OperationByID

func (q *Q) OperationByID(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) RemoveAccount

func (q *Q) RemoveAccount(accountID string) (int64, error)

RemoveAccount deletes a row in the offers table. Returns number of rows affected and error.

func (*Q) RemoveAccountData

func (q *Q) RemoveAccountData(key xdr.LedgerKeyData) (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(account, signer string) (int64, error)

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

func (*Q) RemoveAssetStat

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

RemoveAssetStat removes a row in the exp_asset_stats table.

func (*Q) RemoveExpIngestHistory

func (q *Q) RemoveExpIngestHistory(newerThanSequence uint32) (ExpIngestRemovalSummary, error)

RemoveExpIngestHistory removes all rows in the experimental ingestion history tables which have a ledger sequence higher than `newerThanSequence`

func (*Q) RemoveOffer

func (q *Q) RemoveOffer(offerID xdr.Int64) (int64, error)

RemoveOffer deletes a row in the offers table. Returns number of rows affected and error.

func (*Q) RemoveTrustLine

func (q *Q) RemoveTrustLine(ledgerKey xdr.LedgerKeyTrustLine) (int64, error)

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

func (*Q) ReverseTrades

func (q *Q) ReverseTrades() *TradesQ

ReverseTrades provides a helper to filter rows from the `history_trades` table with pre-defined filters and reversed base/counter. See `TradesQ` methods for the available filters.

func (*Q) SignersForAccounts

func (q *Q) SignersForAccounts(accounts []string) ([]AccountSigner, error)

func (*Q) Trades

func (q *Q) Trades() *TradesQ

Trades provides a helper to filter rows from the `history_trades` table with pre-defined filters. See `TradesQ` methods for the available filters.

func (*Q) TradesForAssetPair

func (q *Q) TradesForAssetPair(baseAssetId int64, counterAssetId int64) *TradesQ

TradesForAssetPair provides a helper to filter rows from the `history_trades` table with the base filter of a specific asset pair. See `TradesQ` methods for further available filters.

func (*Q) TransactionByHash

func (q *Q) TransactionByHash(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(ids ...int64) (map[int64]Transaction, error)

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

func (*Q) UpdateAccount

func (q *Q) UpdateAccount(account xdr.AccountEntry, lastModifiedLedger xdr.Uint32) (int64, error)

UpdateAccount updates a row in the offers table. Returns number of rows affected and error.

func (*Q) UpdateAccountData

func (q *Q) UpdateAccountData(data xdr.DataEntry, lastModifiedLedger xdr.Uint32) (int64, error)

UpdateAccountData updates a row in the accounts_data table. Returns number of rows affected and error.

func (*Q) UpdateAssetStat

func (q *Q) UpdateAssetStat(assetStat ExpAssetStat) (int64, error)

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

func (*Q) UpdateExpIngestVersion

func (q *Q) UpdateExpIngestVersion(ledgerSequence int) error

UpdateExpIngestVersion upsets the exp ingest version.

func (*Q) UpdateExpStateInvalid

func (q *Q) UpdateExpStateInvalid(val bool) error

UpdateExpIngestVersion upsets the state invalid value.

func (*Q) UpdateLastLedgerExpIngest

func (q *Q) UpdateLastLedgerExpIngest(ledgerSequence uint32) error

UpdateLastLedgerExpIngest upsets the last ledger ingested by expingest system. Can be read using GetLastLedgerExpIngest.

func (*Q) UpdateOffer

func (q *Q) UpdateOffer(offer xdr.OfferEntry, lastModifiedLedger xdr.Uint32) (int64, error)

UpdateOffer updates a row in the offers table. Returns number of rows affected and error.

func (*Q) UpdateTrustLine

func (q *Q) UpdateTrustLine(trustLine xdr.TrustLineEntry, lastModifiedLedger xdr.Uint32) (int64, error)

UpdateTrustLine updates a row in the trust lines table. Returns number of rows affected and error.

type QAccounts

type QAccounts interface {
	NewAccountsBatchInsertBuilder(maxBatchSize int) AccountsBatchInsertBuilder
	InsertAccount(account xdr.AccountEntry, lastModifiedLedger xdr.Uint32) (int64, error)
	UpdateAccount(account xdr.AccountEntry, lastModifiedLedger xdr.Uint32) (int64, error)
	RemoveAccount(accountID string) (int64, error)
}

QAccounts defines account related queries.

type QAssetStats

type QAssetStats interface {
	InsertAssetStats(stats []ExpAssetStat, batchSize int) error
	InsertAssetStat(stat ExpAssetStat) (int64, error)
	UpdateAssetStat(stat ExpAssetStat) (int64, error)
	GetAssetStat(assetType xdr.AssetType, assetCode, assetIssuer string) (ExpAssetStat, error)
	RemoveAssetStat(assetType xdr.AssetType, assetCode, assetIssuer string) (int64, error)
	GetAssetStats(assetCode, assetIssuer string, page db2.PageQuery) ([]ExpAssetStat, error)
}

QAssetStats defines exp_asset_stats related queries.

type QData

type QData interface {
	NewAccountDataBatchInsertBuilder(maxBatchSize int) AccountDataBatchInsertBuilder
	InsertAccountData(data xdr.DataEntry, lastModifiedLedger xdr.Uint32) (int64, error)
	UpdateAccountData(data xdr.DataEntry, lastModifiedLedger xdr.Uint32) (int64, error)
	RemoveAccountData(key xdr.LedgerKeyData) (int64, error)
}

QData defines account data related queries.

type QExpLedgers

type QExpLedgers interface {
	CheckExpLedger(seq int32) (bool, error)
	InsertExpLedger(
		ledger xdr.LedgerHeaderHistoryEntry,
		successTxsCount int,
		failedTxsCount int,
		opCount int,
		ingestVersion int,
	) (int64, error)
}

QExpLedgers defines experimental ingestion ledger related queries.

type QOffers

type QOffers interface {
	GetAllOffers() ([]Offer, error)
	NewOffersBatchInsertBuilder(maxBatchSize int) OffersBatchInsertBuilder
	InsertOffer(offer xdr.OfferEntry, lastModifiedLedger xdr.Uint32) (int64, error)
	UpdateOffer(offer xdr.OfferEntry, lastModifiedLedger xdr.Uint32) (int64, error)
	RemoveOffer(offerID xdr.Int64) (int64, error)
}

QOffers defines offer related queries.

type QSigners

type QSigners interface {
	GetLastLedgerExpIngestNonBlocking() (uint32, error)
	GetLastLedgerExpIngest() (uint32, error)
	UpdateLastLedgerExpIngest(ledgerSequence uint32) error
	AccountsForSigner(signer string, page db2.PageQuery) ([]AccountSigner, error)
	NewAccountSignersBatchInsertBuilder(maxBatchSize int) AccountSignersBatchInsertBuilder
	CreateAccountSigner(account, signer string, weight int32) (int64, error)
	RemoveAccountSigner(account, signer string) (int64, error)
}

QSigners defines signer related queries.

type QTrustLines

type QTrustLines interface {
	NewTrustLinesBatchInsertBuilder(maxBatchSize int) TrustLinesBatchInsertBuilder
	InsertTrustLine(trustLine xdr.TrustLineEntry, lastModifiedLedger xdr.Uint32) (int64, error)
	UpdateTrustLine(trustLine xdr.TrustLineEntry, lastModifiedLedger xdr.Uint32) (int64, error)
	RemoveTrustLine(key xdr.LedgerKeyTrustLine) (int64, error)
}

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 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"`
	OfferID            int64     `db:"offer_id"`
	BaseOfferID        *int64    `db:"base_offer_id"`
	BaseAccount        string    `db:"base_account"`
	BaseAssetType      string    `db:"base_asset_type"`
	BaseAssetCode      string    `db:"base_asset_code"`
	BaseAssetIssuer    string    `db:"base_asset_issuer"`
	BaseAmount         xdr.Int64 `db:"base_amount"`
	CounterOfferID     *int64    `db:"counter_offer_id"`
	CounterAccount     string    `db:"counter_account"`
	CounterAssetType   string    `db:"counter_asset_type"`
	CounterAssetCode   string    `db:"counter_asset_code"`
	CounterAssetIssuer string    `db:"counter_asset_issuer"`
	CounterAmount      xdr.Int64 `db:"counter_amount"`
	BaseIsSeller       bool      `db:"base_is_seller"`
	PriceN             null.Int  `db:"price_n"`
	PriceD             null.Int  `db:"price_d"`
}

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

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"`
	High          xdr.Price `db:"high"`
	Low           xdr.Price `db:"low"`
	Open          xdr.Price `db:"open"`
	Close         xdr.Price `db:"close"`
}

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 TradesQ

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

TradesQ is a helper struct to aid in configuring queries that loads slices of trade structs.

func (*TradesQ) ForAccount

func (q *TradesQ) ForAccount(aid string) *TradesQ

filter Trades by account id

func (*TradesQ) ForOffer

func (q *TradesQ) ForOffer(id int64) *TradesQ

ForOffer filters the query results by the offer id.

func (*TradesQ) JoinAccounts

func (q *TradesQ) JoinAccounts() *TradesQ

func (*TradesQ) JoinAssets

func (q *TradesQ) JoinAssets() *TradesQ

func (*TradesQ) Page

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

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

func (*TradesQ) Select

func (q *TradesQ) Select(dest interface{}) error

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

type Transaction

type Transaction struct {
	TotalOrderID
	TransactionHash  string      `db:"transaction_hash"`
	LedgerSequence   int32       `db:"ledger_sequence"`
	LedgerCloseTime  time.Time   `db:"ledger_close_time"`
	ApplicationOrder int32       `db:"application_order"`
	Account          string      `db:"account"`
	AccountSequence  string      `db:"account_sequence"`
	MaxFee           int32       `db:"max_fee"`
	FeeCharged       int32       `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"`
	SignatureString  string      `db:"signatures"`
	MemoType         string      `db:"memo_type"`
	Memo             null.String `db:"memo"`
	ValidAfter       null.Int    `db:"valid_after"`
	ValidBefore      null.Int    `db:"valid_before"`
	CreatedAt        time.Time   `db:"created_at"`
	UpdatedAt        time.Time   `db:"updated_at"`
	// NULL indicates successful transaction. We wanted a migration to be fast
	// however Postgres performs a table rewrite if a new column has a default
	// non-null value. We need `NULL` to indicate successful transaction because
	// otherwise all existing transactions would be interpreted as failed until
	// ledger is reingested.
	Successful *bool `db:"successful"`
}

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

func (*Transaction) IsSuccessful

func (t *Transaction) IsSuccessful() bool

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(aid string) *TransactionsQ

ForAccount filters the transactions collection to a specific account

func (*TransactionsQ) ForLedger

func (q *TransactionsQ) ForLedger(seq int32) *TransactionsQ

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

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(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"`
	Limit              int64         `db:"trust_line_limit"`
	BuyingLiabilities  int64         `db:"buying_liabilities"`
	SellingLiabilities int64         `db:"selling_liabilities"`
	Flags              uint32        `db:"flags"`
	LastModifiedLedger uint32        `db:"last_modified_ledger"`
}

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

func (TrustLine) IsAuthorized

func (trustLine TrustLine) IsAuthorized() bool

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

type TrustLinesBatchInsertBuilder

type TrustLinesBatchInsertBuilder interface {
	Add(trustLine xdr.TrustLineEntry, lastModifiedLedger xdr.Uint32) error
	Exec() error
}

Jump to

Keyboard shortcuts

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