core

package
v0.0.0-...-9f124b0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package core contains database record definitions useable for reading rows from a Stellar Core db

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssetFromDB

func AssetFromDB(typ xdr.AssetType, code string, issuer string) (result xdr.Asset, err error)

AssetFromDB produces an xdr.Asset by combining the constituent type, code and issuer, as often retrieved from the DB in 3 separate columns.

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
	BuyingLiabilities  xdr.Int64 `db:"buyingliabilities"`
	SellingLiabilities xdr.Int64 `db:"sellingliabilities"`
}

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

func (Account) IsAuthRequired

func (ac Account) IsAuthRequired() bool

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

func (Account) IsAuthRevocable

func (ac Account) IsAuthRevocable() bool

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

func (r Offer) PagingToken() string

PagingToken returns a suitable paging token for the Offer

func (Offer) PriceAsString

func (r Offer) PriceAsString() string

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

Asks filters the summary into a slice of PriceLevelRecords where the type is 'ask'

func (*OrderBookSummary) Bids

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

type Q struct {
	*db.Session
}

Q is a helper struct on which to hang common queries against a stellar core database.

func (*Q) AccountByAddress

func (q *Q) AccountByAddress(dest interface{}, addy string, protocolVersion int32) error

AccountByAddress loads a row from `accounts`, by address

func (*Q) AccountDataByKey

func (q *Q) AccountDataByKey(dest interface{}, addy string, key string) error

AccountDataByKey loads a row from `accountdata`, by key

func (*Q) AllDataByAddress

func (q *Q) AllDataByAddress(dest interface{}, addy string) error

AllDataByAddress loads all data for `addy`

func (*Q) AssetsForAddress

func (q *Q) AssetsForAddress(dest interface{}, addy string, protocolVersion int32) error

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, string, error)

BalancesForAsset returns all the balances by asset type, code, issuer

func (*Q) ConnectedAssets

func (q *Q) ConnectedAssets(dest interface{}, selling xdr.Asset) error

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

func (q *Q) ElderLedger(dest *int32) error

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

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

LatestLedger loads the latest known ledger

func (*Q) LedgerHeaderBySequence

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

LedgerHeaderBySequence is a query that loads a single row from the `ledgerheaders` table.

func (*Q) OffersByAddress

func (q *Q) OffersByAddress(dest interface{}, addy string, pq db2.PageQuery) error

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

func (q *Q) SequencesForAddresses(dest interface{}, addys []string) error

SequencesForAddresses loads the current sequence number for every accountid specified in `addys`

func (*Q) SignersByAddress

func (q *Q) SignersByAddress(dest interface{}, addy string) error

SignersByAddress loads all signer rows for `addy`

func (*Q) TransactionByHashAfterLedger

func (q *Q) TransactionByHashAfterLedger(
	dest interface{},
	hash string,
	ledger int32,
) error

TransactionByHashAfterLedger is a query that loads a single row from the `txhistory`.

func (*Q) TransactionFeesByLedger

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

TransactionFeesByLedger is a query that loads all rows from `txfeehistory` where ledgerseq matches `Sequence.`

func (*Q) TransactionsByLedger

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

TransactionsByLedger is a query that loads all rows from `txhistory` where ledgerseq matches `Sequence.`

func (*Q) TrustlinesByAddress

func (q *Q) TrustlinesByAddress(dest interface{}, addy string, protocolVersion int32) error

TrustlinesByAddress loads all trustlines for `addy`

type SequenceProvider

type SequenceProvider struct {
	Q *Q
}

SequenceProvider implements `txsub.SequenceProvider`

func (*SequenceProvider) Get

func (sp *SequenceProvider) Get(addys []string) (map[string]uint64, error)

Get implements `txsub.SequenceProvider`

type Signer

type Signer struct {
	Accountid string
	Publickey string
	Weight    int32
}

Signer is a row of data from the `signers` table from stellar-core

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

type Trustline

type Trustline struct {
	Accountid          string
	Assettype          xdr.AssetType
	Issuer             string
	Assetcode          string
	Tlimit             xdr.Int64
	Balance            xdr.Int64
	Flags              int32
	BuyingLiabilities  xdr.Int64 `db:"buyingliabilities"`
	SellingLiabilities xdr.Int64 `db:"sellingliabilities"`
}

Trustline is a row of data from the `trustlines` table from stellar-core

Jump to

Keyboard shortcuts

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