db

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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MemoryType = "MemoryDB"
)

Functions

This section is empty.

Types

type MemoryDB

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

PeerStoreMemory save the peer's data in RAM. Unless exported, data is lost after execution.

func NewMemoryDB

func NewMemoryDB() MemoryDB

New NewMemoryDB creates an new MemoryDB ready to accept new peers fulfills PeerStoreStorage interface

func (MemoryDB) Close

func (m MemoryDB) Close()

Close and free the space from the memory relative to the DB So far just initialize the

func (MemoryDB) DeletePeer

func (m MemoryDB) DeletePeer(key string)

Delete removes key and value from sync.Map. @param key: the string to locate the value to delete.

func (MemoryDB) ExportToCSV

func (m MemoryDB) ExportToCSV(filePath string) error

ExportToCSV This method will export the whole peerstore into a CSV file. @param filePath file where to dump the CSV lines (create if it does not exist). @return an error if there was.

func (MemoryDB) GetPeerENR

func (m MemoryDB) GetPeerENR(peerID string) (*enode.Node, error)

GetENR returns the Node after parsing the ENR. @param peerID: the peerID of which to get the Node. @return the resulting Node. @return error if applicable, nil in any other case.

func (MemoryDB) GetPeers

func (m MemoryDB) GetPeers() []peer.ID

Peers This method returns a string array with the list of PeerIDs existing in the DB. These would be the keys of each entry in the map @return the string array containisssng the PeerIDs

func (MemoryDB) LoadPeer

func (m MemoryDB) LoadPeer(key string) (value models.Peer, ok bool)

Loads peer value of given key from sync.Map in memory.

func (MemoryDB) Range

func (m MemoryDB) Range(f func(key string, value models.Peer) bool)

Range iterates through the key and values of the sync.Map @param f: the function to apply to each item in the db

func (MemoryDB) StorePeer

func (m MemoryDB) StorePeer(key string, value models.Peer)

Store keeps adds key and Peer values into a sync.Map in memory. @param key: used as key in the map. @param value: the object to store with the given key.

func (MemoryDB) Type

func (m MemoryDB) Type() string

Type

Jump to

Keyboard shortcuts

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