database

package
v1.0.1-0...-4c0226b Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SQLiteDB *sql.DB

SQLiteDB holds a connection to a SQLite database

Functions

func SetupMempoolEntriesCache

func SetupMempoolEntriesCache(pool *RedisPool)

SetupMempoolEntriesCache sets up a periodic GetMempoolEntries() fetch job

func SetupSQLite

func SetupSQLite() (db *sql.DB, err error)

SetupSQLite sets up the SQLite Database used for persistently saving mempool entries

Types

type MempoolState

type MempoolState struct {
	Timestamp int64 `json:"timestamp"`

	DataInBuckets []float64 `json:"dataInBuckets"`
	// contains filtered or unexported fields
}

type NeedsUpdate

type NeedsUpdate struct {
	Update2h   bool
	Update12h  bool
	Update48h  bool
	Update7d   bool
	Update30d  bool
	Update180d bool
}

NeedsUpdate holds information about the timeframes that need an update

type RedisPool

type RedisPool struct {
	*redis.Pool
}

RedisPool holds a pool of redis connections

func SetupRedis

func SetupRedis() (pool *RedisPool, err error)

SetupRedis sets up a new Redis Pool

func (*RedisPool) GetBlockEntries

func (p *RedisPool) GetBlockEntries() (blocks []types.BlockEntry, err error)

GetBlockEntries returns the 20 most recent blocks with short TXIDs.

func (*RedisPool) GetHistorical

func (p *RedisPool) GetHistorical(timeframe int, by string) (hmds []types.HistoricalMempoolData, err error)

func (*RedisPool) GetMempool

func (p *RedisPool) GetMempool() (timestamp time.Time, feerateMapJSON string, megabyteMarkersJSON string, mempoolSize int, err error)

GetMempool gets the current mempool from the database

func (*RedisPool) GetMempoolEntries

func (p *RedisPool) GetMempoolEntries() (mes []types.MempoolEntry, err error)

GetMempoolEntries gets the last x mempool Entries from the database

func (*RedisPool) GetMempoolEntriesCache

func (p *RedisPool) GetMempoolEntriesCache() (mesJSON string, err error)

GetMempoolEntriesCache GET the cached response of a recent GetMempoolEntries() call

func (*RedisPool) GetRecentBlocks

func (p *RedisPool) GetRecentBlocks() (blocks []types.RecentBlock, err error)

GetRecentBlocks returns the 10 most recent blocks.

func (*RedisPool) GetRecentFeerateAPIEntries

func (p *RedisPool) GetRecentFeerateAPIEntries() (entries []types.FeeRateAPIEntry, err error)

GetRecentFeerateAPIEntries returns the recent feeRate API entries from Redis

func (*RedisPool) GetTransactionStats

func (p *RedisPool) GetTransactionStats() (tss []types.TransactionStat, err error)

GetTransactionStats gets the Transaction Stats data from the database

func (*RedisPool) ReadHistoricalMempoolNeedUpdate

func (p *RedisPool) ReadHistoricalMempoolNeedUpdate() (nu NeedsUpdate, err error)

ReadHistoricalMempoolNeedUpdate checks which time frame is due (needs an update)

func (*RedisPool) SetMempoolEntriesCache

func (p *RedisPool) SetMempoolEntriesCache(mesJSON string) (err error)

SetMempoolEntriesCache SETs the response of a recent GetMempoolEntries() as a cache

func (*RedisPool) WriteCurrentMempoolData

func (p *RedisPool) WriteCurrentMempoolData(feerateMap map[int]int, mempoolSizeInByte int, megabyteMarkers []int) error

WriteCurrentMempoolData writes the current mempool data into the database

func (*RedisPool) WriteCurrentTransactionStats

func (p *RedisPool) WriteCurrentTransactionStats(segwitCount int, rbfCount int, txCount int) error

WriteCurrentTransactionStats writes the current transaction stats into the database

func (*RedisPool) WriteFeerateAPIEntry

func (p *RedisPool) WriteFeerateAPIEntry(entry types.FeeRateAPIEntry) error

WriteFeerateAPIEntry writes a new feerate API entry into the database

func (*RedisPool) WriteHistoricalMempoolData

func (p *RedisPool) WriteHistoricalMempoolData(countInBuckets []int, feeInBuckets []float64, sizeInBuckets []int, timeframe int) error

WriteHistoricalMempoolData writes the histoical mempool data into the database

func (*RedisPool) WriteMempoolEntries

func (p *RedisPool) WriteMempoolEntries(me types.MempoolEntry) error

WriteMempoolEntries writes a txid and it's feerate to the database

func (*RedisPool) WriteNewBlockData

func (p *RedisPool) WriteNewBlockData(height int, numTx int, sizeWithWitness int, weight int) error

WriteNewBlockData writes data for a new block into the database

func (*RedisPool) WriteNewBlockEntry

func (p *RedisPool) WriteNewBlockEntry(height int, shortTXIDs []string) error

WriteNewBlockEntry writes a BlockEntry into the Redis database.

Jump to

Keyboard shortcuts

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