db

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LastActivityValidRange = 180
)
View Source
const (
	// RoutineFlushTimeout is the time to wait for the routine to flush the queue
	RoutineFlushTimeout = time.Duration(1 * time.Second)
)

Variables

View Source
var (
	QueryTimeout = 5 * time.Minute
	MaxRetries   = 1

	ErrorNoConnFree = "no connection adquirable"
)
View Source
var (
	// wlogrus associated with the postgres db
	PsqlType = "postgres-db"

	MAX_BATCH_QUEUE       = 1000
	MAX_EPOCH_BATCH_QUEUE = 1
)

Static postgres queries, for each modification in the tables, the table needs to be reseted

Functions

This section is empty.

Types

type Persistable

type Persistable struct {
	// contains filtered or unexported fields
}

persistable is the main structure fed to the batcher allows to link batching errors with the query and values that generated it

func NewPersistable

func NewPersistable() Persistable

type PostgresDBService

type PostgresDBService struct {
	// contains filtered or unexported fields
}

func ConnectToDB

func ConnectToDB(
	ctx context.Context, url string, workerNum int, snapshotInterval time.Duration,
) (*PostgresDBService, error)

Connect to the PostgreSQL Database and get the multithread-proof connection from the given url-composed credentials

func (*PostgresDBService) CheckIPRecords

func (p *PostgresDBService) CheckIPRecords(ip string) (exists bool, expired bool, err error)

CheckIPRecords checks if a given IP is already stored in the DB as whether its TTL has expired

func (*PostgresDBService) Finish

func (p *PostgresDBService) Finish()

func (*PostgresDBService) GetArchDistribution

func (db *PostgresDBService) GetArchDistribution() (map[string]interface{}, error)

func (*PostgresDBService) GetClientDistribution

func (db *PostgresDBService) GetClientDistribution() (map[string]interface{}, error)

func (*PostgresDBService) GetDeprecatedNodes

func (db *PostgresDBService) GetDeprecatedNodes() (int, error)

func (*PostgresDBService) GetExpiredIPInfo

func (p *PostgresDBService) GetExpiredIPInfo() ([]string, error)

GetExpiredIpInfo returns all the IP whos' TTL has already expired

func (*PostgresDBService) GetGeoDistribution

func (db *PostgresDBService) GetGeoDistribution() (map[string]interface{}, error)

Basic call over the whole list of non-deprecated peers

func (*PostgresDBService) GetHostingDistribution

func (db *PostgresDBService) GetHostingDistribution() (map[string]interface{}, error)

func (*PostgresDBService) GetIPDistribution

func (db *PostgresDBService) GetIPDistribution() (map[string]interface{}, error)

func (*PostgresDBService) GetIPInfo

func (p *PostgresDBService) GetIPInfo(ip string) (models.IPInfo, error)

GetIPInfo reads all the information available for that specific IP in the DB

func (*PostgresDBService) GetNonDeprecatedNodes

func (d *PostgresDBService) GetNonDeprecatedNodes(networkID uint64) ([]models.HostInfo, error)

func (*PostgresDBService) GetOsDistribution

func (db *PostgresDBService) GetOsDistribution() (map[string]interface{}, error)

func (*PostgresDBService) GetRTTDistribution

func (db *PostgresDBService) GetRTTDistribution() (map[string]interface{}, error)

func (*PostgresDBService) GetVersionDistribution

func (db *PostgresDBService) GetVersionDistribution() (map[string]interface{}, error)

Basic call over the whole list of non-deprecated peers

func (*PostgresDBService) PersistActivePeers

func (DB *PostgresDBService) PersistActivePeers() error

func (*PostgresDBService) PersistENR

func (d *PostgresDBService) PersistENR(enr *models.ENR)

PersistENR queues a new ENR into the databas-e

func (*PostgresDBService) PersistIPInfo

func (p *PostgresDBService) PersistIPInfo(ip models.IPInfo)

func (*PostgresDBService) PersistNodeInfo

func (d *PostgresDBService) PersistNodeInfo(attempt models.ConnectionAttempt, nInfo models.NodeInfo, sameNetwork bool)

PersistNodeInfo is the main method to persist the node info into the DB

func (*PostgresDBService) UpsertIpInfo

func (p *PostgresDBService) UpsertIpInfo(IPInfo models.IPInfo) (query string, args []interface{})

UpsertIP attemtps to insert IP in the DB - or Updates the data info if they where already there

type QueryBatch

type QueryBatch struct {
	// contains filtered or unexported fields
}

func NewQueryBatch

func NewQueryBatch(ctx context.Context, pgxPool *pgxpool.Pool, batchSize int) *QueryBatch

func (*QueryBatch) AddQuery

func (q *QueryBatch) AddQuery(persis Persistable)

func (*QueryBatch) IsReadyToPersist

func (q *QueryBatch) IsReadyToPersist() bool

func (*QueryBatch) Len

func (q *QueryBatch) Len() int

func (*QueryBatch) PersistBatch

func (q *QueryBatch) PersistBatch() error

Jump to

Keyboard shortcuts

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