pcache

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: Apache-2.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 PeerCache

type PeerCache struct {
	NLevels uint
	Levels  [][]RPeerInfo
	// contains filtered or unexported fields
}

PeerCache holds the performance requirements and peer levels based on reliability

func NewPeerCache

func NewPeerCache(node *p2pnode.Node, regCache *rcache.RegistryCache) *PeerCache

Constructor for PeerCache

func (*PeerCache) AddPeer

func (cache *PeerCache) AddPeer(pInfo p2putil.PeerInfo)

func (*PeerCache) GetPeer

func (cache *PeerCache) GetPeer(hash string) (peer.ID, error)

Gets a reliable peer from cache

func (*PeerCache) RemovePeer

func (cache *PeerCache) RemovePeer(id peer.ID)

func (*PeerCache) UpdateCache

func (cache *PeerCache) UpdateCache()

Takes care of adding new peers and updating cache levels UpdateCache ideally is run in a separate goroutine

type RPeerInfo

type RPeerInfo struct {
	RCount uint
	Info   p2putil.PeerInfo
}

New type with PeerInfo and RCount R stands for Reliability and counts how many times a peer has been reliable

func (*RPeerInfo) LessThan

func (l *RPeerInfo) LessThan(r RPeerInfo) bool

Jump to

Keyboard shortcuts

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