database

package
v2.4.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2019 License: GPL-3.0 Imports: 11 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 struct {
	*leveldb.DB
	// contains filtered or unexported fields
}

func New

func New(path string, version int, id vnode.NodeID) (db *DB, err error)

func (*DB) BlockIP

func (db *DB) BlockIP(ip net.IP, expiration int64)

func (*DB) BlockId

func (db *DB) BlockId(id vnode.NodeID, expiration int64)

func (*DB) Clean

func (db *DB) Clean(expiration int64)

Clean nodes if time.Now().Unix() - node.activeAt > expiration

func (*DB) Iterate

func (db *DB) Iterate(prefix []byte, fn func(key, value []byte) bool)

func (*DB) ReadMarkNodes

func (db *DB) ReadMarkNodes(n int) (nodes []*vnode.Node)

func (*DB) ReadNodes

func (db *DB) ReadNodes(expiration int64) (nodes []*vnode.Node)

ReadNodes from database, if time.Now().Unix() - node.activeAt < expiration

func (*DB) Register

func (db *DB) Register(prefix []byte) *prefixDB

func (*DB) RemoveNode

func (db *DB) RemoveNode(ID vnode.NodeID)

RemoveNode data about the specific NodeID

func (*DB) RetrieveActiveAt

func (db *DB) RetrieveActiveAt(id vnode.NodeID) int64

func (*DB) RetrieveCheckAt

func (db *DB) RetrieveCheckAt(id vnode.NodeID) int64

func (*DB) RetrieveInt64

func (db *DB) RetrieveInt64(key []byte) int64

func (*DB) RetrieveMark

func (db *DB) RetrieveMark(id vnode.NodeID) int64

func (*DB) RetrieveNode

func (db *DB) RetrieveNode(id vnode.NodeID) (node *vnode.Node, err error)

RetrieveNode Node according to the special nodeID

func (*DB) StoreActiveAt

func (db *DB) StoreActiveAt(id vnode.NodeID, v int64)

func (*DB) StoreCheckAt

func (db *DB) StoreCheckAt(id vnode.NodeID, v int64)

func (*DB) StoreInt64

func (db *DB) StoreInt64(key []byte, n int64)

func (*DB) StoreMark

func (db *DB) StoreMark(id vnode.NodeID, v int64)

value + time

func (*DB) StoreNode

func (db *DB) StoreNode(node *vnode.Node) (err error)

StoreNode node into database Node.activeAt and Node.checkAt is store separately

Jump to

Keyboard shortcuts

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