Documentation ¶
Overview ¶
Package core contains database record definitions useable for reading rows from a Stellar Core db
Index ¶
- func AssetFromDB(typ xdr.AssetType, code string, issuer string) (result xdr.Asset, err error)
- type Account
- type AccountData
- type LedgerHeader
- type Offer
- type OrderBookSummary
- type OrderBookSummaryPriceLevel
- type PriceLevel
- type Q
- func (q *Q) AccountByAddress(dest interface{}, addy string) error
- func (q *Q) AccountDataByKey(dest interface{}, addy string, key string) error
- func (q *Q) AllDataByAddress(dest interface{}, addy string) error
- func (q *Q) AssetsForAddress(dest interface{}, addy string) error
- func (q *Q) BalancesForAsset(assetType int32, assetCode string, assetIssuer string) (int32, int64, error)
- func (q *Q) ConnectedAssets(dest interface{}, selling xdr.Asset) error
- func (q *Q) ElderLedger(dest *int32) error
- func (q *Q) GetOrderBookSummary(dest interface{}, selling xdr.Asset, buying xdr.Asset, limit uint64) error
- func (q *Q) LatestLedger(dest interface{}) error
- func (q *Q) LedgerHeaderBySequence(dest interface{}, seq int32) error
- func (q *Q) OffersByAddress(dest interface{}, addy string, pq db2.PageQuery) error
- func (q *Q) SequenceProvider() *SequenceProvider
- func (q *Q) SequencesForAddresses(dest interface{}, addys []string) error
- func (q *Q) SignersByAddress(dest interface{}, addy string) error
- func (q *Q) TransactionByHashAfterLedger(dest interface{}, hash string, ledger int32) error
- func (q *Q) TransactionFeesByLedger(dest interface{}, seq int32) error
- func (q *Q) TransactionsByLedger(dest interface{}, seq int32) error
- func (q *Q) TrustlinesByAddress(dest interface{}, addy string) error
- type SequenceProvider
- type Signer
- type Transaction
- func (tx *Transaction) Base64Signatures() []string
- func (tx *Transaction) EnvelopeXDR() string
- func (tx *Transaction) Fee() int32
- func (tx *Transaction) IsSuccessful() bool
- func (tx *Transaction) Memo() null.String
- func (tx *Transaction) MemoType() string
- func (tx *Transaction) ResultMetaXDR() string
- func (tx *Transaction) ResultXDR() string
- func (tx *Transaction) Sequence() int64
- func (tx *Transaction) SourceAddress() string
- type TransactionFee
- type Trustline
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Account ¶
type Account struct { Accountid string Balance xdr.Int64 Seqnum string Numsubentries int32 Inflationdest null.String HomeDomain null.String Thresholds xdr.Thresholds Flags xdr.AccountFlags }
Account is a row of data from the `accounts` table
func (Account) IsAuthRequired ¶
IsAuthRequired returns true if the account has the "AUTH_REQUIRED" option turned on.
func (Account) IsAuthRevocable ¶
IsAuthRevocable returns true if the account has the "AUTH_REVOCABLE" option turned on.
type AccountData ¶
type AccountData struct { Accountid string Key string `db:"dataname"` Value string `db:"datavalue"` }
AccountData is a row of data from the `accountdata` table
func (AccountData) Raw ¶
func (ad AccountData) Raw() ([]byte, error)
Raw returns the decoded, raw value of the account data
type LedgerHeader ¶
type LedgerHeader struct { LedgerHash string `db:"ledgerhash"` PrevHash string `db:"prevhash"` BucketListHash string `db:"bucketlisthash"` CloseTime int64 `db:"closetime"` Sequence uint32 `db:"ledgerseq"` Data xdr.LedgerHeader `db:"data"` }
LedgerHeader is row of data from the `ledgerheaders` table
func (*LedgerHeader) DataXDR ¶
func (lh *LedgerHeader) DataXDR() string
DataXDR returns the base64 encoded ledger header
type Offer ¶
type Offer struct { SellerID string `db:"sellerid"` OfferID int64 `db:"offerid"` SellingAssetType xdr.AssetType `db:"sellingassettype"` SellingAssetCode null.String `db:"sellingassetcode"` SellingIssuer null.String `db:"sellingissuer"` BuyingAssetType xdr.AssetType `db:"buyingassettype"` BuyingAssetCode null.String `db:"buyingassetcode"` BuyingIssuer null.String `db:"buyingissuer"` Amount xdr.Int64 `db:"amount"` Pricen int32 `db:"pricen"` Priced int32 `db:"priced"` Price float64 `db:"price"` Flags int32 `db:"flags"` Lastmodified int32 `db:"lastmodified"` }
Offer is row of data from the `offers` table from stellar-core
func (Offer) PagingToken ¶
PagingToken returns a suitable paging token for the Offer
func (Offer) PriceAsString ¶
PriceAsString return the price fraction as a floating point approximate.
type OrderBookSummary ¶
type OrderBookSummary []OrderBookSummaryPriceLevel
OrderBookSummary is a summary of a set of offers for a given base and counter currency
func (*OrderBookSummary) Asks ¶
func (o *OrderBookSummary) Asks() []OrderBookSummaryPriceLevel
Asks filters the summary into a slice of PriceLevelRecords where the type is 'ask'
func (*OrderBookSummary) Bids ¶
func (o *OrderBookSummary) Bids() []OrderBookSummaryPriceLevel
Bids filters the summary into a slice of PriceLevelRecords where the type is 'bid'
type OrderBookSummaryPriceLevel ¶
type OrderBookSummaryPriceLevel struct { Type string `db:"type"` PriceLevel }
OrderBookSummaryPriceLevel is a collapsed view of multiple offers at the same price that contains the summed amount from all the member offers. Used by OrderBookSummary
type PriceLevel ¶
type PriceLevel struct { Pricen int32 `db:"pricen"` Priced int32 `db:"priced"` Pricef float64 `db:"pricef"` Amount int64 `db:"amount"` }
PriceLevel represents an aggregation of offers to trade at a certain price.
func (*PriceLevel) AmountAsString ¶
func (p *PriceLevel) AmountAsString() string
AmountAsString returns the amount as a string, formatted using the amount.String() utility from github.com/stellar/go.
func (*PriceLevel) InvertPricef ¶
func (p *PriceLevel) InvertPricef() float64
InvertPricef returns the inverted price of the price-level, i.e. what the price would be if you were viewing the price level from the other side of the bid/ask dichotomy.
func (*PriceLevel) PriceAsString ¶
func (p *PriceLevel) PriceAsString() string
PriceAsString returns the price as a string
type Q ¶
Q is a helper struct on which to hang common queries against a stellar core database.
func (*Q) AccountByAddress ¶
AccountByAddress loads a row from `accounts`, by address
func (*Q) AccountDataByKey ¶
AccountDataByKey loads a row from `accountdata`, by key
func (*Q) AllDataByAddress ¶
AllDataByAddress loads all data for `addy`
func (*Q) AssetsForAddress ¶
AssetsForAddress loads `dest` as `[]xdr.Asset` with every asset the account at `addy` can hold.
func (*Q) BalancesForAsset ¶
func (q *Q) BalancesForAsset( assetType int32, assetCode string, assetIssuer string, ) (int32, int64, error)
BalancesForAsset returns all the balances by asset type, code, issuer
func (*Q) ConnectedAssets ¶
ConnectedAssets loads xdr.Asset records for the purposes of path finding. Given the input asset type, a list of xdr.Assets is returned that each have some available trades for the input asset.
func (*Q) ElderLedger ¶
ElderLedger represents the oldest "ingestable" ledger known to the stellar-core database this ingestion system is communicating with. Horizon, which wants to operate on a contiguous range of ledger data (i.e. free from gaps) uses the elder ledger to start importing in the case of an empty database. NOTE: This current query used is correct, but slow. Please keep this query out of latency sensitive or frequently trafficked code paths.
func (*Q) GetOrderBookSummary ¶
func (q *Q) GetOrderBookSummary(dest interface{}, selling xdr.Asset, buying xdr.Asset, limit uint64) error
GetOrderBookSummary loads a summary of an order book identified by a selling/buying pair. It is designed to drive an order book summary client interface (bid/ask spread, prices and volume, etc).
func (*Q) LatestLedger ¶
LatestLedger loads the latest known ledger
func (*Q) LedgerHeaderBySequence ¶
LedgerHeaderBySequence is a query that loads a single row from the `ledgerheaders` table.
func (*Q) OffersByAddress ¶
OffersByAddress loads a page of active offers for the given address.
func (*Q) SequenceProvider ¶
func (q *Q) SequenceProvider() *SequenceProvider
SequenceProvider returns a new sequence provider.
func (*Q) SequencesForAddresses ¶
SequencesForAddresses loads the current sequence number for every accountid specified in `addys`
func (*Q) SignersByAddress ¶
SignersByAddress loads all signer rows for `addy`
func (*Q) TransactionByHashAfterLedger ¶
TransactionByHashAfterLedger is a query that loads a single row from the `txhistory`.
func (*Q) TransactionFeesByLedger ¶
TransactionFeesByLedger is a query that loads all rows from `txfeehistory` where ledgerseq matches `Sequence.`
func (*Q) TransactionsByLedger ¶
TransactionsByLedger is a query that loads all rows from `txhistory` where ledgerseq matches `Sequence.`
func (*Q) TrustlinesByAddress ¶
TrustlinesByAddress loads all trustlines for `addy`
type SequenceProvider ¶
type SequenceProvider struct {
Q *Q
}
SequenceProvider implements `txsub.SequenceProvider`
type Transaction ¶
type Transaction struct { TransactionHash string `db:"txid"` LedgerSequence int32 `db:"ledgerseq"` Index int32 `db:"txindex"` Envelope xdr.TransactionEnvelope `db:"txbody"` Result xdr.TransactionResultPair `db:"txresult"` ResultMeta xdr.TransactionMeta `db:"txmeta"` }
Transaction is row of data from the `txhistory` table from stellar-core
func (*Transaction) Base64Signatures ¶
func (tx *Transaction) Base64Signatures() []string
Base64Signatures returns a slice of strings where each element is a base64 encoded representation of a signature attached to this transaction.
func (*Transaction) EnvelopeXDR ¶
func (tx *Transaction) EnvelopeXDR() string
EnvelopeXDR returns the XDR encoded envelope for this transaction
func (*Transaction) Fee ¶
func (tx *Transaction) Fee() int32
Fee returns the fee that was paid for `tx`
func (*Transaction) IsSuccessful ¶
func (tx *Transaction) IsSuccessful() bool
IsSuccessful returns true when the transaction was successful.
func (*Transaction) Memo ¶
func (tx *Transaction) Memo() null.String
Memo returns the memo for this transaction, if there is one.
func (*Transaction) MemoType ¶
func (tx *Transaction) MemoType() string
MemoType returns the memo type for this transaction
func (*Transaction) ResultMetaXDR ¶
func (tx *Transaction) ResultMetaXDR() string
ResultMetaXDR returns the XDR encoded result meta for this transaction
func (*Transaction) ResultXDR ¶
func (tx *Transaction) ResultXDR() string
ResultXDR returns the XDR encoded result for this transaction
func (*Transaction) Sequence ¶
func (tx *Transaction) Sequence() int64
Sequence returns the sequence number for `tx`
func (*Transaction) SourceAddress ¶
func (tx *Transaction) SourceAddress() string
SourceAddress returns the strkey-encoded account id that paid the fee for `tx`.
type TransactionFee ¶
type TransactionFee struct { TransactionHash string `db:"txid"` LedgerSequence int32 `db:"ledgerseq"` Index int32 `db:"txindex"` Changes xdr.LedgerEntryChanges `db:"txchanges"` }
TransactionFee is row of data from the `txfeehistory` table from stellar-core
func (*TransactionFee) ChangesXDR ¶
func (fee *TransactionFee) ChangesXDR() string
ChangesXDR returns the XDR encoded changes for this transaction fee