database

package
v0.0.0-...-ff78b6e Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	io.Closer

	UpsertNodeAddr(ctx context.Context, id NodeID, addr NodeAddr) error
	FindNodeAddr(ctx context.Context, id NodeID) (*NodeAddr, error)

	ResetPingError(ctx context.Context, id NodeID) error
	UpdatePingError(ctx context.Context, id NodeID) error
	CountPingErrors(ctx context.Context, id NodeID) (*uint, error)

	UpdateClientID(ctx context.Context, id NodeID, clientID string) error
	FindClientID(ctx context.Context, id NodeID) (*string, error)
	UpdateNetworkID(ctx context.Context, id NodeID, networkID uint) error
	UpdateEthVersion(ctx context.Context, id NodeID, ethVersion uint) error
	UpdateHandshakeTransientError(ctx context.Context, id NodeID, hasTransientErr bool) error
	InsertHandshakeError(ctx context.Context, id NodeID, handshakeErr string) error
	DeleteHandshakeErrors(ctx context.Context, id NodeID) error
	FindHandshakeLastErrors(ctx context.Context, id NodeID, limit uint) ([]HandshakeError, error)
	UpdateHandshakeRetryTime(ctx context.Context, id NodeID, retryTime time.Time) error
	FindHandshakeRetryTime(ctx context.Context, id NodeID) (*time.Time, error)
	CountHandshakeCandidates(ctx context.Context) (uint, error)
	FindHandshakeCandidates(ctx context.Context, limit uint) ([]NodeID, error)
	MarkTakenHandshakeCandidates(ctx context.Context, nodes []NodeID) error
	// TakeHandshakeCandidates runs FindHandshakeCandidates + MarkTakenHandshakeCandidates in a transaction.
	TakeHandshakeCandidates(ctx context.Context, limit uint) ([]NodeID, error)

	UpdateForkCompatibility(ctx context.Context, id NodeID, isCompatFork bool) error

	UpdateNeighborBucketKeys(ctx context.Context, id NodeID, keys []string) error
	FindNeighborBucketKeys(ctx context.Context, id NodeID) ([]string, error)

	UpdateSentryCandidatesLastEventTime(ctx context.Context, value time.Time) error
	FindSentryCandidatesLastEventTime(ctx context.Context) (*time.Time, error)

	UpdateCrawlRetryTime(ctx context.Context, id NodeID, retryTime time.Time) error
	CountCandidates(ctx context.Context) (uint, error)
	FindCandidates(ctx context.Context, limit uint) ([]NodeID, error)
	MarkTakenNodes(ctx context.Context, nodes []NodeID) error
	// TakeCandidates runs FindCandidates + MarkTakenNodes in a transaction.
	TakeCandidates(ctx context.Context, limit uint) ([]NodeID, error)

	IsConflictError(err error) bool

	CountNodes(ctx context.Context, maxPingTries uint, networkID uint) (uint, error)
	CountIPs(ctx context.Context, maxPingTries uint, networkID uint) (uint, error)
	CountClients(ctx context.Context, clientIDPrefix string, maxPingTries uint, networkID uint) (uint, error)
	CountClientsWithNetworkID(ctx context.Context, clientIDPrefix string, maxPingTries uint) (uint, error)
	CountClientsWithHandshakeTransientError(ctx context.Context, clientIDPrefix string, maxPingTries uint) (uint, error)
	EnumerateClientIDs(ctx context.Context, maxPingTries uint, networkID uint, enumFunc func(clientID *string)) error
}

type DBRetrier

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

func NewDBRetrier

func NewDBRetrier(db DB, logger log.Logger) DBRetrier

func (DBRetrier) CountCandidates

func (db DBRetrier) CountCandidates(ctx context.Context) (uint, error)

func (DBRetrier) CountHandshakeCandidates

func (db DBRetrier) CountHandshakeCandidates(ctx context.Context) (uint, error)

func (DBRetrier) CountPingErrors

func (db DBRetrier) CountPingErrors(ctx context.Context, id NodeID) (*uint, error)

func (DBRetrier) DeleteHandshakeErrors

func (db DBRetrier) DeleteHandshakeErrors(ctx context.Context, id NodeID) error

func (DBRetrier) FindClientID

func (db DBRetrier) FindClientID(ctx context.Context, id NodeID) (*string, error)

func (DBRetrier) FindHandshakeLastErrors

func (db DBRetrier) FindHandshakeLastErrors(ctx context.Context, id NodeID, limit uint) ([]HandshakeError, error)

func (DBRetrier) FindHandshakeRetryTime

func (db DBRetrier) FindHandshakeRetryTime(ctx context.Context, id NodeID) (*time.Time, error)

func (DBRetrier) FindNeighborBucketKeys

func (db DBRetrier) FindNeighborBucketKeys(ctx context.Context, id NodeID) ([]string, error)

func (DBRetrier) FindNodeAddr

func (db DBRetrier) FindNodeAddr(ctx context.Context, id NodeID) (*NodeAddr, error)

func (DBRetrier) FindSentryCandidatesLastEventTime

func (db DBRetrier) FindSentryCandidatesLastEventTime(ctx context.Context) (*time.Time, error)

func (DBRetrier) InsertHandshakeError

func (db DBRetrier) InsertHandshakeError(ctx context.Context, id NodeID, handshakeErr string) error

func (DBRetrier) IsConflictError

func (db DBRetrier) IsConflictError(err error) bool

func (DBRetrier) ResetPingError

func (db DBRetrier) ResetPingError(ctx context.Context, id NodeID) error

func (DBRetrier) TakeCandidates

func (db DBRetrier) TakeCandidates(ctx context.Context, limit uint) ([]NodeID, error)

func (DBRetrier) TakeHandshakeCandidates

func (db DBRetrier) TakeHandshakeCandidates(ctx context.Context, limit uint) ([]NodeID, error)

func (DBRetrier) UpdateClientID

func (db DBRetrier) UpdateClientID(ctx context.Context, id NodeID, clientID string) error

func (DBRetrier) UpdateCrawlRetryTime

func (db DBRetrier) UpdateCrawlRetryTime(ctx context.Context, id NodeID, retryTime time.Time) error

func (DBRetrier) UpdateEthVersion

func (db DBRetrier) UpdateEthVersion(ctx context.Context, id NodeID, ethVersion uint) error

func (DBRetrier) UpdateForkCompatibility

func (db DBRetrier) UpdateForkCompatibility(ctx context.Context, id NodeID, isCompatFork bool) error

func (DBRetrier) UpdateHandshakeRetryTime

func (db DBRetrier) UpdateHandshakeRetryTime(ctx context.Context, id NodeID, retryTime time.Time) error

func (DBRetrier) UpdateHandshakeTransientError

func (db DBRetrier) UpdateHandshakeTransientError(ctx context.Context, id NodeID, hasTransientErr bool) error

func (DBRetrier) UpdateNeighborBucketKeys

func (db DBRetrier) UpdateNeighborBucketKeys(ctx context.Context, id NodeID, keys []string) error

func (DBRetrier) UpdateNetworkID

func (db DBRetrier) UpdateNetworkID(ctx context.Context, id NodeID, networkID uint) error

func (DBRetrier) UpdatePingError

func (db DBRetrier) UpdatePingError(ctx context.Context, id NodeID) error

func (DBRetrier) UpdateSentryCandidatesLastEventTime

func (db DBRetrier) UpdateSentryCandidatesLastEventTime(ctx context.Context, value time.Time) error

func (DBRetrier) UpsertNodeAddr

func (db DBRetrier) UpsertNodeAddr(ctx context.Context, id NodeID, addr NodeAddr) error

type DBSQLite

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

func NewDBSQLite

func NewDBSQLite(filePath string) (*DBSQLite, error)

func (*DBSQLite) Close

func (db *DBSQLite) Close() error

func (*DBSQLite) CountCandidates

func (db *DBSQLite) CountCandidates(ctx context.Context) (uint, error)

func (*DBSQLite) CountClients

func (db *DBSQLite) CountClients(ctx context.Context, clientIDPrefix string, maxPingTries uint, networkID uint) (uint, error)

func (*DBSQLite) CountClientsWithHandshakeTransientError

func (db *DBSQLite) CountClientsWithHandshakeTransientError(ctx context.Context, clientIDPrefix string, maxPingTries uint) (uint, error)

func (*DBSQLite) CountClientsWithNetworkID

func (db *DBSQLite) CountClientsWithNetworkID(ctx context.Context, clientIDPrefix string, maxPingTries uint) (uint, error)

func (*DBSQLite) CountHandshakeCandidates

func (db *DBSQLite) CountHandshakeCandidates(ctx context.Context) (uint, error)

func (*DBSQLite) CountIPs

func (db *DBSQLite) CountIPs(ctx context.Context, maxPingTries uint, networkID uint) (uint, error)

func (*DBSQLite) CountNodes

func (db *DBSQLite) CountNodes(ctx context.Context, maxPingTries uint, networkID uint) (uint, error)

func (*DBSQLite) CountPingErrors

func (db *DBSQLite) CountPingErrors(ctx context.Context, id NodeID) (*uint, error)

func (*DBSQLite) DeleteHandshakeErrors

func (db *DBSQLite) DeleteHandshakeErrors(ctx context.Context, id NodeID) error

func (*DBSQLite) EnumerateClientIDs

func (db *DBSQLite) EnumerateClientIDs(
	ctx context.Context,
	maxPingTries uint,
	networkID uint,
	enumFunc func(clientID *string),
) error

func (*DBSQLite) FindCandidates

func (db *DBSQLite) FindCandidates(
	ctx context.Context,
	limit uint,
) ([]NodeID, error)

func (*DBSQLite) FindClientID

func (db *DBSQLite) FindClientID(ctx context.Context, id NodeID) (*string, error)

func (*DBSQLite) FindHandshakeCandidates

func (db *DBSQLite) FindHandshakeCandidates(
	ctx context.Context,
	limit uint,
) ([]NodeID, error)

func (*DBSQLite) FindHandshakeLastErrors

func (db *DBSQLite) FindHandshakeLastErrors(ctx context.Context, id NodeID, limit uint) ([]HandshakeError, error)

func (*DBSQLite) FindHandshakeRetryTime

func (db *DBSQLite) FindHandshakeRetryTime(ctx context.Context, id NodeID) (*time.Time, error)

func (*DBSQLite) FindNeighborBucketKeys

func (db *DBSQLite) FindNeighborBucketKeys(ctx context.Context, id NodeID) ([]string, error)

func (*DBSQLite) FindNodeAddr

func (db *DBSQLite) FindNodeAddr(ctx context.Context, id NodeID) (*NodeAddr, error)

func (*DBSQLite) FindSentryCandidatesLastEventTime

func (db *DBSQLite) FindSentryCandidatesLastEventTime(ctx context.Context) (*time.Time, error)

func (*DBSQLite) InsertHandshakeError

func (db *DBSQLite) InsertHandshakeError(ctx context.Context, id NodeID, handshakeErr string) error

func (*DBSQLite) IsConflictError

func (db *DBSQLite) IsConflictError(err error) bool

func (*DBSQLite) MarkTakenHandshakeCandidates

func (db *DBSQLite) MarkTakenHandshakeCandidates(ctx context.Context, ids []NodeID) error

func (*DBSQLite) MarkTakenNodes

func (db *DBSQLite) MarkTakenNodes(ctx context.Context, ids []NodeID) error

func (*DBSQLite) ResetPingError

func (db *DBSQLite) ResetPingError(ctx context.Context, id NodeID) error

func (*DBSQLite) TakeCandidates

func (db *DBSQLite) TakeCandidates(
	ctx context.Context,
	limit uint,
) ([]NodeID, error)

func (*DBSQLite) TakeHandshakeCandidates

func (db *DBSQLite) TakeHandshakeCandidates(
	ctx context.Context,
	limit uint,
) ([]NodeID, error)

func (*DBSQLite) UpdateClientID

func (db *DBSQLite) UpdateClientID(ctx context.Context, id NodeID, clientID string) error

func (*DBSQLite) UpdateCrawlRetryTime

func (db *DBSQLite) UpdateCrawlRetryTime(ctx context.Context, id NodeID, retryTime time.Time) error

func (*DBSQLite) UpdateEthVersion

func (db *DBSQLite) UpdateEthVersion(ctx context.Context, id NodeID, ethVersion uint) error

func (*DBSQLite) UpdateForkCompatibility

func (db *DBSQLite) UpdateForkCompatibility(ctx context.Context, id NodeID, isCompatFork bool) error

func (*DBSQLite) UpdateHandshakeRetryTime

func (db *DBSQLite) UpdateHandshakeRetryTime(ctx context.Context, id NodeID, retryTime time.Time) error

func (*DBSQLite) UpdateHandshakeTransientError

func (db *DBSQLite) UpdateHandshakeTransientError(ctx context.Context, id NodeID, hasTransientErr bool) error

func (*DBSQLite) UpdateNeighborBucketKeys

func (db *DBSQLite) UpdateNeighborBucketKeys(ctx context.Context, id NodeID, keys []string) error

func (*DBSQLite) UpdateNetworkID

func (db *DBSQLite) UpdateNetworkID(ctx context.Context, id NodeID, networkID uint) error

func (*DBSQLite) UpdatePingError

func (db *DBSQLite) UpdatePingError(ctx context.Context, id NodeID) error

func (*DBSQLite) UpdateSentryCandidatesLastEventTime

func (db *DBSQLite) UpdateSentryCandidatesLastEventTime(ctx context.Context, value time.Time) error

func (*DBSQLite) UpsertNodeAddr

func (db *DBSQLite) UpsertNodeAddr(ctx context.Context, id NodeID, addr NodeAddr) error

type HandshakeError

type HandshakeError struct {
	StringCode string
	Time       time.Time
}

type NodeAddr

type NodeAddr struct {
	NodeAddr1
	IPv6 NodeAddr1
}

type NodeAddr1

type NodeAddr1 struct {
	IP       net.IP
	PortDisc uint16
	PortRLPx uint16
}

type NodeID

type NodeID string

Jump to

Keyboard shortcuts

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