core

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: Apache-2.0 Imports: 14 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
	LastModified       uint32
	BuyingLiabilities  xdr.Int64 `db:"buyingliabilities"`
	SellingLiabilities xdr.Int64 `db:"sellingliabilities"`
}

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

func (Account) IsAuthImmutable

func (ac Account) IsAuthImmutable() bool

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

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

	SellingAsset xdr.Asset `db:"sellingasset"`
	BuyingAsset  xdr.Asset `db:"buyingasset"`

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

AccountByAddress loads a row from `accounts`, by address

func (*Q) AccountDataByKey

func (q *Q) AccountDataByKey(dest *AccountData, addy string, key string) error

AccountDataByKey loads a row from `accountdata`, by key

func (*Q) AllAssets

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

AllAssets loads all (unique) assets from core DB

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(addy string) ([]xdr.Asset, []xdr.Int64, error)

AssetsForAddress returns a list of assets and balances for those assets held by a given address.

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

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

SchemaVersion returns Core DB schema version

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

TrustlinesByAddress loads all trustlines for `addy`

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

func (tx *Transaction) FeeCharged() int32

FeeCharged returns the fee that was actually charged for `tx`

func (*Transaction) IsSuccessful

func (tx *Transaction) IsSuccessful() bool

IsSuccessful returns true when the transaction was successful.

func (*Transaction) MaxFee

func (tx *Transaction) MaxFee() int32

Fee returns the max fee that was set for `tx`

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

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

func (Trustline) IsAuthorized

func (tl Trustline) IsAuthorized() bool

func (Trustline) IsAuthorizedToMaintainLiabilities

func (tl Trustline) IsAuthorizedToMaintainLiabilities() bool

Jump to

Keyboard shortcuts

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