Documentation ¶
Index ¶
- Variables
- func AddNextBlockNumberForProcessing(tx pgx.Tx, blockNumber int64, forward bool, checkPrevBlock bool) (err error)
- func AdditionalDataTableName(dataTablePostfix string) string
- func BeginTransaction() (tx *pgx.Tx, err error)
- func BlockConnectingStateTableName() string
- func BlockIsAlreadyProcessed(tx pgx.Tx, hash string) (processed bool, err error)
- func BlocksForProcessingTableName() string
- func Commit(tx pgx.Tx) (err error)
- func DataTableName() string
- func DeleteOutdatedConnectingStateRecords(tx pgx.Tx, blockNumber int64) (err error)
- func EnsureSchema() (err error)
- func Exec(tx pgx.Tx, sql string) (tag pgconn.CommandTag, err error)
- func ExecTxFree(sql string) (tag pgconn.CommandTag, err error)
- func Free()
- func GetBlockConnectingState(tx pgx.Tx, blockNumber int64) (state uint8, err error)
- func GetNextBlockNumberForProcessing(tx pgx.Tx, impl core.IndexImplementation) (blockNumber int64, forward bool, checkPrevBlock bool, err error)
- func GetPrevBlockNumber(tx pgx.Tx, blockNumber int64) (prevBlockNumber int64, err error)
- func IncrementIndexOffset(tx pgx.Tx) (currentOffset int64, err error)
- func IndexNamePrefix() string
- func Init() (err error)
- func InitIndexBlockOffset() (currentOffset int64, err error)
- func InsertBlockConnectingInfo(tx pgx.Tx, blockNumber, prevBlockNumber int64, state uint8) (err error)
- func MarkBlockProcessed(tx pgx.Tx, hash string) (err error)
- func MinimizeSQLScript(query string) string
- func ProcessedBlocksTableName() string
- func Query(tx pgx.Tx, sql string) (rows pgx.Rows, err error)
- func QueryTxFree(sql string, args ...interface{}) (rows pgx.Rows, err error)
- func RemoveNextBlockNumberForProcessing(tx pgx.Tx, blockNumber int64, forward bool) (err error)
- func Rollback(tx pgx.Tx) (err error)
- func UpdateBlockConnectingState(tx pgx.Tx, blockNumber int64, newState uint8) (err error)
Constants ¶
This section is empty.
Variables ¶
var (
DB *pgxpool.Pool
)
Functions ¶
func AdditionalDataTableName ¶
func BeginTransaction ¶
func BeginTransaction() (tx *pgx.Tx, err error)
func BlockConnectingStateTableName ¶
func BlockConnectingStateTableName() string
func BlockIsAlreadyProcessed ¶
BlockIsAlreadyProcessed returns `true` if block with such hash has been marked as processed earlier. Otherwise (including error cases) returns `false`.
func BlocksForProcessingTableName ¶
func BlocksForProcessingTableName() string
func DataTableName ¶
func DataTableName() string
func EnsureSchema ¶
func EnsureSchema() (err error)
EnsureSchema executes provided schema definition SQL file. By default it ensures all required tables / indexes / constraints / triggers are present. In case if some table (or index, or ...) is absent - it would be recreated. Does not replaces tables in cae if them are present (to not to drop data occasionally).
func ExecTxFree ¶
func ExecTxFree(sql string) (tag pgconn.CommandTag, err error)
func GetBlockConnectingState ¶
func GetNextBlockNumberForProcessing ¶
func GetNextBlockNumberForProcessing(tx pgx.Tx, impl core.IndexImplementation) (blockNumber int64, forward bool, checkPrevBlock bool, err error)
GetNextBlockNumberForProcessing returns block number, that is stored in the database as next to be processed. `tx` defines the postgres's transaction into which the data should be fetched. `impl` is used for the cases when blocks processing should begin in a non-standard manner (e.g. not from zero index).
func GetPrevBlockNumber ¶
func IncrementIndexOffset ¶
IncrementIndexOffset increments block offset of the index in database, using the same TX context, as the rest of index mechanics. Returns current offset of the index, that is fetched in the same query, to save one round trip to the database.
func IndexNamePrefix ¶
func IndexNamePrefix() string
func InitIndexBlockOffset ¶
InitIndexBlockOffset tries to initialize index's block offset number before usage. In case if this index already has the offset number - no error would be emitted (muted on database level). Returns current offset that has been last stored.
func MarkBlockProcessed ¶
MarkBlockProcessed adds latest_blocks hash to the processed latest_blocks table. Returns error if this block is already processed.
func MinimizeSQLScript ¶
func ProcessedBlocksTableName ¶
func ProcessedBlocksTableName() string
func QueryTxFree ¶
Types ¶
This section is empty.