Documentation ¶
Index ¶
- Constants
- func CreateSchema(db *bun.DB, chainName string) error
- func CreateSchemaForIngester(db *sql.DB) error
- func DoTx(db *bun.DB, action func(dbTx *bun.Tx) error) error
- func DropAllSchemas(db *bun.DB) error
- func DropChainSchema(db *bun.DB, chain uint32) error
- func InitDatabaseForChain(dsn, chain string, migrate bool) (*bun.DB, error)
- func Migrate(db *sql.DB, direction string) (int, error)
- func MigrateSet(db *sql.DB, direction string, set ...Migrations) (int, error)
- func MigrateSetDown(db *sql.DB, set ...Migrations) (int, error)
- func MigrateSetUp(db *sql.DB, set ...Migrations) (int, error)
- func NewAssetSource(fs *embed.FS, rootDirectory string) migrate.MigrationSource
- func NewConn(dsn string, chainName string) (*bun.DB, error)
- func TransformSchemaAfterIngester(db *sql.DB) error
- type Address
- type BalanceRow
- type BlockBits
- type BlockHeaderRow
- type BlockHeaderShortRow
- type BlockRow
- type ChainDB
- func (bt *ChainDB) DeleteBlocks(ctx context.Context, height int64) error
- func (bt *ChainDB) GetAllBlockIDHashesByHeight(ctx context.Context, height int64) ([]IDHashOrphanRow, error)
- func (bt *ChainDB) GetAllPkScriptsByAddress(ctx context.Context, address string) ([]string, error)
- func (bt *ChainDB) GetBalance(ctx context.Context, address string) (BalanceRow, error)
- func (bt *ChainDB) GetBlockByHash(ctx context.Context, hash string) (*BlockRow, error)
- func (bt *ChainDB) GetBlockByID(ctx context.Context, id int64) (*BlockRow, error)
- func (bt *ChainDB) GetBlockHeaderByHash(ctx context.Context, hash string) (*BlockHeaderRow, error)
- func (bt *ChainDB) GetBlockHeaderByHeight(ctx context.Context, height int64) (*BlockHeaderRow, error)
- func (bt *ChainDB) GetBlockIDByHash(ctx context.Context, hash string) (int64, error)
- func (bt *ChainDB) GetBlockIDHashByHeight(ctx context.Context, height int64) (IDHashRow, error)
- func (bt *ChainDB) GetChainsInfoByID(ctx context.Context, shardID uint32) (*ChainInfo, error)
- func (bt *ChainDB) GetLastBlockID(ctx context.Context) (int64, error)
- func (bt *ChainDB) GetLastTxID(ctx context.Context) (int64, error)
- func (bt *ChainDB) GetLastTxOutID(ctx context.Context) (int64, error)
- func (bt *ChainDB) GetNetwork(ctx context.Context) (string, error)
- func (bt *ChainDB) GetScriptByAddress(ctx context.Context, address string) (string, error)
- func (bt *ChainDB) GetSwapTxOutsByTxHash(ctx context.Context, hash string) ([]SwapTxOuts, error)
- func (bt *ChainDB) GetTxByHash(ctx context.Context, hash string) (*TxRow, error)
- func (bt *ChainDB) GetTxIDByHash(ctx context.Context, hash string) (int64, error)
- func (bt *ChainDB) GetTxOutByOutPoint(ctx context.Context, hash string, outN int32) (*TxOutRow, error)
- func (bt *ChainDB) InsertBlock(ctx context.Context, row BlockRow) error
- func (bt *ChainDB) InsertBlockHeader(ctx context.Context, row BlockHeaderRow) error
- func (bt *ChainDB) InsertBlockHeaders(ctx context.Context, row []BlockHeaderRow) error
- func (bt *ChainDB) InsertChainDBMeta(ctx context.Context, meta ChainDBMeta) error
- func (bt *ChainDB) InsertChainsInfo(ctx context.Context, chains []ChainInfo) error
- func (bt *ChainDB) InsertExchangeAgent(ctx context.Context, ead ExchangeAgentRow) error
- func (bt *ChainDB) InsertExchangeAgents(ctx context.Context, rows []ExchangeAgentRow) error
- func (bt *ChainDB) InsertPkScript(ctx context.Context, row PkScriptRow) error
- func (bt *ChainDB) InsertSwapTxOut(ctx context.Context, row SwapTxOuts) error
- func (bt *ChainDB) InsertSwapTxOuts(ctx context.Context, rows []SwapTxOuts) error
- func (bt *ChainDB) InsertTx(ctx context.Context, row TxRow) error
- func (bt *ChainDB) InsertTxIn(ctx context.Context, row TxInRow) error
- func (bt *ChainDB) InsertTxOut(ctx context.Context, row TxOutRow) error
- func (bt *ChainDB) InsertTxStats(ctx context.Context, row TxStatsRow) error
- func (bt *ChainDB) InsertTxStatsRows(ctx context.Context, rows []TxStatsRow) error
- func (bt *ChainDB) ListInTxsForPKScript(ctx context.Context, script string, limit, offset uint32) ([]TxHashRow, error)
- func (bt *ChainDB) ListOutTxsForPKScript(ctx context.Context, script string, limit, offset uint32) ([]TxHashRow, error)
- func (bt *ChainDB) ListTxHashesForAddress(ctx context.Context, address string, since, until int64, limit, offset uint32) ([]TxIDRow, error)
- func (bt *ChainDB) ListTxIDsForPKScript(ctx context.Context, script string, since, until int64, limit, offset uint32, ...) ([]TxIDRow, error)
- func (bt *ChainDB) ListTxOperationsForTxs(ctx context.Context, txHashes []string) ([]TxInOutViewRow, error)
- func (bt *ChainDB) LockTxOuts(ctx context.Context, list []int64, height int32, period int) error
- func (bt *ChainDB) MarkBlockOrphan(ctx context.Context, blockHash string) error
- func (bt *ChainDB) MarkTxOutSpent(ctx context.Context, outID int64) error
- func (bt *ChainDB) PkScriptRow(ctx context.Context, script string) (*PkScriptRow, error)
- func (bt *ChainDB) SelectBlocksBits(ctx context.Context, fromHeight, toHeight int64) ([]BlockBits, error)
- func (bt *ChainDB) SelectChainsInfo(ctx context.Context) ([]ChainInfo, error)
- func (bt *ChainDB) SelectLatestBlocks(ctx context.Context, limit, offset uint32) ([]BlockHeaderShortRow, error)
- func (bt *ChainDB) SelectLatestTxs(ctx context.Context, limit, offset uint32) ([]TxStatsExtRow, error)
- func (bt *ChainDB) SelectTxInsVWForHashes(ctx context.Context, txHashes []string) ([]TxInViewRow, error)
- func (bt *ChainDB) SelectTxOutsVWForHashes(ctx context.Context, txHashes []string) ([]TxOutViewRow, error)
- func (bt *ChainDB) UTXO() *UTXOQ
- func (bt *ChainDB) UnlockTxOuts(ctx context.Context) error
- func (bt *ChainDB) UpdateBalances(ctx context.Context) error
- type ChainDBMeta
- type ChainInfo
- type DBCfg
- type ExchangeAgentRow
- type Executor
- type IDHashOrphanRow
- type IDHashRow
- type IDInOutRow
- type IDScriptRow
- type KV
- type Migrations
- type PkScriptRow
- type RowID
- type SequenceValue
- type SwapTxOuts
- type TxHashRow
- type TxIDRow
- type TxInOutViewRow
- type TxInRow
- type TxInViewRow
- type TxOutRow
- type TxOutViewRow
- type TxRow
- type TxStatsExtRow
- type TxStatsRow
- type UTXO
- type UTXOQ
- func (table *UTXOQ) OrderBy(column, direction string) *UTXOQ
- func (table *UTXOQ) SelectUTXOByAddress(ctx context.Context, address string) ([]UTXO, error)
- func (table *UTXOQ) SelectUTXOByAddressForAmount(ctx context.Context, address string, amountLimit uint64) ([]UTXO, error)
- func (table *UTXOQ) SelectUTXOByTxHashes(ctx context.Context, list []string) ([]UTXO, error)
- func (table *UTXOQ) SelectUTXOByTxHashesWithStatus(ctx context.Context, list []string, locked, spent bool) ([]UTXO, error)
- func (table *UTXOQ) Since(since int64) *UTXOQ
- func (table *UTXOQ) SinceStrict(since int64) *UTXOQ
- func (table *UTXOQ) Until(until int64) *UTXOQ
- func (table *UTXOQ) UntilStrict(until int64) *UTXOQ
- func (table *UTXOQ) WithAddress(address string) *UTXOQ
- func (table *UTXOQ) WithLimit(limit uint32) *UTXOQ
- func (table *UTXOQ) WithLockStatus(isLocked bool) *UTXOQ
- func (table *UTXOQ) WithOffset(offset uint32) *UTXOQ
- func (table *UTXOQ) WithSpentStatus(spent bool) *UTXOQ
Constants ¶
View Source
const ( // MigrateUp causes migrations to be run in the "up" direction. MigrateUp = "up" // MigrateDown causes migrations to be run in the "down" direction. MigrateDown = "down" )
View Source
const (
DBVersion = "v1"
)
Variables ¶
This section is empty.
Functions ¶
func CreateSchemaForIngester ¶
func DropAllSchemas ¶
func InitDatabaseForChain ¶
func MigrateSet ¶
func MigrateSetDown ¶
func MigrateSetDown(db *sql.DB, set ...Migrations) (int, error)
func MigrateSetUp ¶
func MigrateSetUp(db *sql.DB, set ...Migrations) (int, error)
func NewAssetSource ¶
func NewAssetSource(fs *embed.FS, rootDirectory string) migrate.MigrationSource
Types ¶
type BalanceRow ¶
type BlockHeaderRow ¶
type BlockHeaderRow struct { bun.BaseModel `bun:"table:block_headers,alias:bh"` Hash string `bun:"hash"` Orphan bool `bun:"orphan"` Height int64 `bun:"height"` MMRRoot string `bun:"mmr_root"` PrevBlockHash string `bun:"prev_block_hash"` BlockTime int64 `bun:"block_time"` Bits int64 `bun:"bits"` PowHash string `bun:"pow_hash"` BlockSize int64 `bun:"block_size"` HeaderSize int64 `bun:"header_size"` }
type BlockHeaderShortRow ¶
type BlockRow ¶
type ChainDB ¶
type ChainDB struct { ChainName string // contains filtered or unexported fields }
func (*ChainDB) DeleteBlocks ¶
func (*ChainDB) GetAllBlockIDHashesByHeight ¶
func (*ChainDB) GetAllPkScriptsByAddress ¶
func (*ChainDB) GetBalance ¶
func (*ChainDB) GetBlockByHash ¶
func (*ChainDB) GetBlockByID ¶
func (*ChainDB) GetBlockHeaderByHash ¶
func (*ChainDB) GetBlockHeaderByHeight ¶
func (*ChainDB) GetBlockIDByHash ¶
func (*ChainDB) GetBlockIDHashByHeight ¶
func (*ChainDB) GetChainsInfoByID ¶
func (*ChainDB) GetLastBlockID ¶
func (*ChainDB) GetLastTxOutID ¶
func (*ChainDB) GetScriptByAddress ¶
func (*ChainDB) GetSwapTxOutsByTxHash ¶
func (*ChainDB) GetTxByHash ¶
func (*ChainDB) GetTxIDByHash ¶
func (*ChainDB) GetTxOutByOutPoint ¶
func (*ChainDB) InsertBlock ¶
func (*ChainDB) InsertBlockHeader ¶
func (bt *ChainDB) InsertBlockHeader(ctx context.Context, row BlockHeaderRow) error
func (*ChainDB) InsertBlockHeaders ¶
func (bt *ChainDB) InsertBlockHeaders(ctx context.Context, row []BlockHeaderRow) error
func (*ChainDB) InsertChainDBMeta ¶
func (bt *ChainDB) InsertChainDBMeta(ctx context.Context, meta ChainDBMeta) error
func (*ChainDB) InsertChainsInfo ¶
func (*ChainDB) InsertExchangeAgent ¶
func (bt *ChainDB) InsertExchangeAgent(ctx context.Context, ead ExchangeAgentRow) error
func (*ChainDB) InsertExchangeAgents ¶
func (bt *ChainDB) InsertExchangeAgents(ctx context.Context, rows []ExchangeAgentRow) error
func (*ChainDB) InsertPkScript ¶
func (bt *ChainDB) InsertPkScript(ctx context.Context, row PkScriptRow) error
func (*ChainDB) InsertSwapTxOut ¶
func (bt *ChainDB) InsertSwapTxOut(ctx context.Context, row SwapTxOuts) error
func (*ChainDB) InsertSwapTxOuts ¶
func (bt *ChainDB) InsertSwapTxOuts(ctx context.Context, rows []SwapTxOuts) error
func (*ChainDB) InsertTxOut ¶
func (*ChainDB) InsertTxStats ¶
func (bt *ChainDB) InsertTxStats(ctx context.Context, row TxStatsRow) error
func (*ChainDB) InsertTxStatsRows ¶
func (bt *ChainDB) InsertTxStatsRows(ctx context.Context, rows []TxStatsRow) error
func (*ChainDB) ListInTxsForPKScript ¶
func (*ChainDB) ListOutTxsForPKScript ¶
func (*ChainDB) ListTxHashesForAddress ¶ added in v0.4.11
func (*ChainDB) ListTxIDsForPKScript ¶
func (*ChainDB) ListTxOperationsForTxs ¶ added in v0.4.11
func (*ChainDB) LockTxOuts ¶
func (*ChainDB) MarkBlockOrphan ¶
func (*ChainDB) MarkTxOutSpent ¶
func (*ChainDB) PkScriptRow ¶
func (*ChainDB) SelectBlocksBits ¶
func (*ChainDB) SelectChainsInfo ¶
func (*ChainDB) SelectLatestBlocks ¶
func (*ChainDB) SelectLatestTxs ¶
func (*ChainDB) SelectTxInsVWForHashes ¶
func (*ChainDB) SelectTxOutsVWForHashes ¶
type ChainDBMeta ¶
func (ChainDBMeta) ToKV ¶
func (m ChainDBMeta) ToKV() []KV
type ChainInfo ¶
type ChainInfo struct { bun.BaseModel `bun:"table:chains,alias:c"` ChainID int64 `bun:"chain_id"` ChainName string `bun:"chain_name"` ChainGenesis string `bun:"chain_genesis"` ExpansionHeight int32 `bun:"expansion_height"` ExpansionHash string `bun:"expansion_hash"` GenesisBlock []byte `bun:"genesis_block"` }
type ExchangeAgentRow ¶
type Executor ¶
type Executor struct { Migrations // contains filtered or unexported fields }
func (*Executor) SetMigrations ¶
func (executor *Executor) SetMigrations(set Migrations) *Executor
type IDHashOrphanRow ¶
type IDInOutRow ¶
type IDScriptRow ¶
type Migrations ¶
type Migrations struct { Table string Schema string EnablePatchMode bool Assets migrate.MigrationSource }
type PkScriptRow ¶
type SequenceValue ¶
type SequenceValue struct {
LastValue int64 `bun:"last_value"`
}
type SwapTxOuts ¶
type TxInOutViewRow ¶
type TxInOutViewRow struct { ID int64 `bun:"id"` BlockHash string `bun:"block_hash"` TxHash string `bun:"tx_hash"` WitnessHash string `bun:"witness_hash"` Index int32 `bun:"index"` Direction string `bun:"direction"` PkScript string `bun:"pk_script"` Address string `bun:"address"` Value int64 `bun:"value"` Height int64 `bun:"height"` BlockTime int64 `bun:"block_time"` }
type TxInRow ¶
type TxInRow struct { bun.BaseModel `bun:"table:tx_ins,alias:txi"` ID int64 `bun:"id"` TxHash string `bun:"tx_hash"` BlockHash string `bun:"block_hash"` InN int32 `bun:"in_n"` ParentOut int64 `bun:"parent_out"` ParentTxHash string `bun:"parent_tx_hash"` ParentOutN int32 `bun:"parent_out_n"` PkScript string `bun:"pk_script"` Value int64 `bun:"value"` }
type TxInViewRow ¶
type TxInViewRow struct { bun.BaseModel `bun:"table:tx_in_vw,alias:txiv"` TxInOutViewRow }
type TxOutRow ¶
type TxOutRow struct { bun.BaseModel `bun:"table:tx_outs,alias:txo"` ID int64 `bun:"id"` TxHash string `bun:"tx_hash"` BlockHash string `bun:"block_hash"` OutN int32 `bun:"out_n"` PkScript string `bun:"pk_script"` Value int64 `bun:"value"` Orphan bool `bun:"orphan"` Spent bool `bun:"spent"` Locked bool `bun:"locked"` Height int64 `bun:"height"` LockPeriod int64 `bun:"lock_period"` }
type TxOutViewRow ¶
type TxOutViewRow struct { bun.BaseModel `bun:"table:tx_out_vw,alias:txov"` TxInOutViewRow }
type TxRow ¶
type TxRow struct { bun.BaseModel `bun:"table:transactions,alias:tx"` ID int64 `bun:"id"` TxHash string `bun:"tx_hash"` BlockHash string `bun:"block_hash"` TxN int32 `bun:"tx_n"` Version int32 `bun:"version"` LockTime int64 `bun:"lock_time"` Coinbase bool `bun:"coinbase"` WitnessHash string `bun:"witness_hash"` RawTx []byte `bun:"raw_tx"` }
type TxStatsExtRow ¶
type TxStatsRow ¶
type UTXO ¶
type UTXO struct { bun.BaseModel `bun:"table:utxo_vw,alias:utvw"` ID int64 `bun:"id"` BlockHash string `bun:"block_hash"` Height int64 `bun:"height"` TxHash string `bun:"tx_hash"` OutN int64 `bun:"out_n"` Address string `bun:"address"` Value int64 `bun:"value"` Spent bool `bun:"spent"` PKScript string `bun:"pk_script"` ScriptType string `bun:"script_type"` Locked bool `bun:"locked"` LockPeriod int64 `bun:"lock_period"` BlockTime int64 `bun:"block_time"` }
type UTXOQ ¶
type UTXOQ struct {
// contains filtered or unexported fields
}
func (*UTXOQ) SelectUTXOByAddress ¶
func (*UTXOQ) SelectUTXOByAddressForAmount ¶ added in v0.4.11
func (*UTXOQ) SelectUTXOByTxHashes ¶
func (*UTXOQ) SelectUTXOByTxHashesWithStatus ¶ added in v0.4.11
func (*UTXOQ) SinceStrict ¶ added in v0.4.11
func (*UTXOQ) UntilStrict ¶ added in v0.4.11
func (*UTXOQ) WithAddress ¶
func (*UTXOQ) WithLockStatus ¶
func (*UTXOQ) WithOffset ¶
func (*UTXOQ) WithSpentStatus ¶
Click to show internal directories.
Click to hide internal directories.