postgresql

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// logrus associated with the postgres db
	PsqlType = "postgres-db"
)

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

Functions

This section is empty.

Types

type Eth2Model

type Eth2Model struct {
	Network string
}

func NewEth2Model

func NewEth2Model(network string) Eth2Model

func (*Eth2Model) CheckPeersSummaryTableStatus

func (p *Eth2Model) CheckPeersSummaryTableStatus(ctx context.Context, pool *pgxpool.Pool) bool

func (*Eth2Model) DeletePeer

func (p *Eth2Model) DeletePeer(ctx context.Context, pool *pgxpool.Pool, peerID string)

func (*Eth2Model) GetConnectedPeers

func (p *Eth2Model) GetConnectedPeers(ctx context.Context, pool *pgxpool.Pool) ([]string, error)

func (*Eth2Model) GetLastActivityTime

func (p *Eth2Model) GetLastActivityTime(ctx context.Context, pool *pgxpool.Pool) (time.Time, error)

func (*Eth2Model) GetNumberOfPeers

func (p *Eth2Model) GetNumberOfPeers(ctx context.Context, pool *pgxpool.Pool) (int, error)

func (*Eth2Model) GetPeers

func (p *Eth2Model) GetPeers(ctx context.Context, pool *pgxpool.Pool) []peer.ID

func (*Eth2Model) LoadClientDiversitySnapshot

func (p *Eth2Model) LoadClientDiversitySnapshot(ctx context.Context, pool *pgxpool.Pool, qTime time.Time) (models.ClientDiversity, error)

So far not used since it's just for exporting Doesn't make much sense to add it to the crawler (no idea why would we need to access the snapshot of a given time)

func (*Eth2Model) LoadPeer

func (p *Eth2Model) LoadPeer(ctx context.Context, pool *pgxpool.Pool, peerID string) (models.Peer, bool)

func (*Eth2Model) StoreClientDiversitySnapshot

func (p *Eth2Model) StoreClientDiversitySnapshot(ctx context.Context, pool *pgxpool.Pool, cliDiver models.ClientDiversity) error

func (*Eth2Model) StorePeer

func (p *Eth2Model) StorePeer(ctx context.Context, pool *pgxpool.Pool, peerID string, peer models.Peer)

type IpfsModel

type IpfsModel struct {
	Network string
}

func NewIpfsPeerModel

func NewIpfsPeerModel(network string) IpfsModel

func (*IpfsModel) CheckPeersSummaryTableStatus

func (p *IpfsModel) CheckPeersSummaryTableStatus(ctx context.Context, pool *pgxpool.Pool) bool

func (*IpfsModel) DeletePeer

func (p *IpfsModel) DeletePeer(ctx context.Context, pool *pgxpool.Pool, peerID string)

func (*IpfsModel) GetConnectedPeers

func (p *IpfsModel) GetConnectedPeers(ctx context.Context, pool *pgxpool.Pool) ([]string, error)

func (*IpfsModel) GetLastActivityTime

func (p *IpfsModel) GetLastActivityTime(ctx context.Context, pool *pgxpool.Pool) (time.Time, error)

func (*IpfsModel) GetNumberOfPeers

func (p *IpfsModel) GetNumberOfPeers(ctx context.Context, pool *pgxpool.Pool) (int, error)

func (*IpfsModel) GetPeers

func (p *IpfsModel) GetPeers(ctx context.Context, pool *pgxpool.Pool) []peer.ID

func (*IpfsModel) LoadClientDiversitySnapshot

func (p *IpfsModel) LoadClientDiversitySnapshot(ctx context.Context, pool *pgxpool.Pool, qTime time.Time) (models.ClientDiversity, error)

So far not used since it's just for exporting Doesn't make much sense to add it to the crawler (no idea why would we need to access the snapshot of a given time)

func (*IpfsModel) LoadPeer

func (p *IpfsModel) LoadPeer(ctx context.Context, pool *pgxpool.Pool, peerID string) (models.Peer, bool)

func (*IpfsModel) StoreClientDiversitySnapshot

func (p *IpfsModel) StoreClientDiversitySnapshot(ctx context.Context, pool *pgxpool.Pool, cliDiver models.ClientDiversity) error

func (*IpfsModel) StorePeer

func (p *IpfsModel) StorePeer(ctx context.Context, pool *pgxpool.Pool, peerID string, peer models.Peer)

type NetworkModel

type NetworkModel interface {

	// Peer model related
	StorePeer(context.Context, *pgxpool.Pool, string, models.Peer)
	LoadPeer(context.Context, *pgxpool.Pool, string) (models.Peer, bool)
	DeletePeer(context.Context, *pgxpool.Pool, string)
	GetPeers(context.Context, *pgxpool.Pool) []peer.ID
	CheckPeersSummaryTableStatus(context.Context, *pgxpool.Pool) bool
	GetConnectedPeers(context.Context, *pgxpool.Pool) ([]string, error)
	GetNumberOfPeers(context.Context, *pgxpool.Pool) (int, error)
	GetLastActivityTime(context.Context, *pgxpool.Pool) (time.Time, error)
	// Client diversity related model
	StoreClientDiversitySnapshot(context.Context, *pgxpool.Pool, models.ClientDiversity) error
	LoadClientDiversitySnapshot(context.Context, *pgxpool.Pool, time.Time) (models.ClientDiversity, error)
	// contains filtered or unexported methods
}

type PostgresDBService

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

func ConnectToDB

func ConnectToDB(ctx context.Context, url string, dbmodel NetworkModel) (*PostgresDBService, error)

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

func (*PostgresDBService) CheckPeersSummaryTableStatus

func (p *PostgresDBService) CheckPeersSummaryTableStatus() bool

Close the connection with the PostgreSQL

func (*PostgresDBService) Close

func (p *PostgresDBService) Close()

Close the connection with the PostgreSQL

func (*PostgresDBService) DeletePeer

func (p *PostgresDBService) DeletePeer(id string)

Close the connection with the PostgreSQL

func (*PostgresDBService) GetConnectedPeers

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

Close the connection with the PostgreSQL

func (*PostgresDBService) GetLastActivityTime

func (p *PostgresDBService) GetLastActivityTime() (time.Time, error)

Close the connection with the PostgreSQL

func (*PostgresDBService) GetNumberOfPeers

func (p *PostgresDBService) GetNumberOfPeers() (int, error)

Close the connection with the PostgreSQL

func (*PostgresDBService) GetPeers

func (p *PostgresDBService) GetPeers() []peer.ID

Close the connection with the PostgreSQL

func (*PostgresDBService) LoadClientDiversitySnapshot

func (p *PostgresDBService) LoadClientDiversitySnapshot(qTime time.Time) (models.ClientDiversity, error)

Close the connection with the PostgreSQL

func (*PostgresDBService) LoadPeer

func (p *PostgresDBService) LoadPeer(id string) (models.Peer, bool)

Close the connection with the PostgreSQL

func (*PostgresDBService) StoreClientDiversitySnapshot

func (p *PostgresDBService) StoreClientDiversitySnapshot(cliDiver models.ClientDiversity) error

Close the connection with the PostgreSQL

func (*PostgresDBService) StorePeer

func (p *PostgresDBService) StorePeer(id string, pm models.Peer)

Close the connection with the PostgreSQL

Jump to

Keyboard shortcuts

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