nodedb

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NodeDB

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

NodeDB wraps the Database and provides node storage with async updates.

func NewNodeDB

func NewNodeDB(ctx context.Context, database *db.Database, logger logrus.FieldLogger) *NodeDB

NewNodeDB creates a new node database wrapper.

func (*NodeDB) Close

func (ndb *NodeDB) Close() error

Close waits for pending updates to complete. The context cancellation signals shutdown.

func (*NodeDB) Count

func (ndb *NodeDB) Count() int

Count returns the total number of nodes.

func (*NodeDB) Delete

func (ndb *NodeDB) Delete(id node.ID) error

Delete removes a node from the database.

func (*NodeDB) GetStats

func (ndb *NodeDB) GetStats() NodeDBStats

GetStats returns current database statistics.

func (*NodeDB) List

func (ndb *NodeDB) List() []*node.Node

List returns all nodes in the database.

func (*NodeDB) Load

func (ndb *NodeDB) Load(id node.ID) (*node.Node, error)

Load retrieves a node by ID.

func (*NodeDB) LoadInactiveNodes

func (ndb *NodeDB) LoadInactiveNodes(n int) []*node.Node

LoadInactiveNodes loads up to N inactive nodes from the database. Returns nodes ordered by oldest last_active time (NULL first).

func (*NodeDB) LoadLocalENR

func (ndb *NodeDB) LoadLocalENR() ([]byte, error)

LoadLocalENR retrieves the local node's ENR.

func (*NodeDB) LoadRandomNodes

func (ndb *NodeDB) LoadRandomNodes(n int) []*node.Node

LoadRandomNodes loads up to N random nodes from the database.

func (*NodeDB) NodeExists

func (ndb *NodeDB) NodeExists(id node.ID) (bool, uint64)

NodeExists checks if a node exists in the database.

func (*NodeDB) StoreLocalENR

func (ndb *NodeDB) StoreLocalENR(enrBytes []byte) error

StoreLocalENR stores the local node's ENR.

func (*NodeDB) UpdateLastActive

func (ndb *NodeDB) UpdateLastActive(id node.ID, timestamp time.Time) error

UpdateLastActive queues a last_active timestamp update.

func (*NodeDB) UpdateLastSeen

func (ndb *NodeDB) UpdateLastSeen(id node.ID, timestamp time.Time) error

UpdateLastSeen queues a last_seen timestamp update.

func (*NodeDB) UpdateNodeENR

func (ndb *NodeDB) UpdateNodeENR(n *node.Node) error

UpdateNodeENR queues an ENR update (seq+enr+ip only, preserves stats & timestamps). Use this when receiving nodes from discovery (FINDNODE responses).

func (*NodeDB) UpdateNodeFull

func (ndb *NodeDB) UpdateNodeFull(n *node.Node) error

UpdateNodeFull queues a full node update including stats. Use this after pinging or when stats have changed.

type NodeDBStats

type NodeDBStats struct {
	QueueSize        int   // Current number of pending updates in queue
	ProcessedUpdates int64 // Total updates processed
	MergedUpdates    int64 // Total updates merged with existing pending
	FailedUpdates    int64 // Total updates that failed
	Transactions     int64 // Total database transactions executed
	TotalQueries     int64 // Total database queries executed
	OpenConnections  int   // Current number of open DB connections
}

NodeDBStats contains statistics about database operations.

Jump to

Keyboard shortcuts

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