peertracker

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 10, 2019 License: Apache-2.0, MIT Imports: 4 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PeerCompare

func PeerCompare(a, b pq.Elem) bool

PeerCompare implements pq.ElemComparator returns true if peer 'a' has higher priority than peer 'b'

Types

type PeerTracker

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

PeerTracker tracks task blocks for a single peer, as well as active tasks for that peer

func New

func New(target peer.ID) *PeerTracker

New creates a new PeerTracker

func (*PeerTracker) Freeze

func (p *PeerTracker) Freeze()

Freeze increments the freeze value for this peer. While a peer is frozen (freeze value > 0) it will not execute tasks.

func (*PeerTracker) FullThaw

func (p *PeerTracker) FullThaw()

FullThaw completely unfreezes this peer so it can execute tasks.

func (*PeerTracker) Index

func (p *PeerTracker) Index() int

Index implements pq.Elem.

func (*PeerTracker) IsFrozen

func (p *PeerTracker) IsFrozen() bool

IsFrozen returns whether this peer is frozen and unable to execute tasks.

func (*PeerTracker) IsIdle

func (p *PeerTracker) IsIdle() bool

IsIdle returns true if the peer has no active tasks or queued tasks

func (*PeerTracker) PopBlock

func (p *PeerTracker) PopBlock() *peertask.TaskBlock

PopBlock removes a block of tasks from this peers queue

func (*PeerTracker) PushBlock

func (p *PeerTracker) PushBlock(target peer.ID, tasks []peertask.Task, done func(e []peertask.Task))

PushBlock adds a new block of tasks on to a peers queue from the given peer ID, list of tasks, and task block completion function

func (*PeerTracker) Remove

func (p *PeerTracker) Remove(identifier peertask.Identifier)

Remove removes the task with the given identifier from this peers queue

func (*PeerTracker) SetIndex

func (p *PeerTracker) SetIndex(i int)

SetIndex implements pq.Elem.

func (*PeerTracker) StartTask

func (p *PeerTracker) StartTask(identifier peertask.Identifier)

StartTask signals that a task was started for this peer.

func (*PeerTracker) Target

func (p *PeerTracker) Target() peer.ID

Target returns the peer that this peer tracker tracks tasks for

func (*PeerTracker) TaskDone

func (p *PeerTracker) TaskDone(identifier peertask.Identifier)

TaskDone signals that a task was completed for this peer.

func (*PeerTracker) Thaw

func (p *PeerTracker) Thaw() bool

Thaw decrements the freeze value for this peer. While a peer is frozen (freeze value > 0) it will not execute tasks.

Jump to

Keyboard shortcuts

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