multi_torrent

package
v0.0.0-...-1364d92 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExternId

func ExternId(id string) string

func FullId

func FullId(id string, id2 string) string

func InternId

func InternId(id string) string

Types

type Join

type Join struct {
	Id string
}

type MultiElection

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

A MultiElection component is made out of multiple Election components. When an election takes place, the nodes that were elected get banned for the purpose of them not getting reelected. The banning process is done by eliminating all the banned candidates from all the elections that did not take place yet. For this algorithm to be correct, we require the number of sub-Torrents to be smaller than 100/leaderPercent.

func NewMultiElection

func NewMultiElection(elections int, limit int, transport Transport) *MultiElection

func (*MultiElection) NewJoin

func (e *MultiElection) NewJoin(id string)

func (*MultiElection) Recv

func (e *MultiElection) Recv(m interface{})

func (*MultiElection) RegisterCandidate

func (e *MultiElection) RegisterCandidate(candidate cache_torrent.Candidate)

func (*MultiElection) Run

func (e *MultiElection) Run()

type MultiPeer

type MultiPeer struct {
	*cache_torrent.Peer
	// contains filtered or unexported fields
}

A MultiPeer is wrapper over multiple Peers which follow the CacheTorrent protocol. The Original message IDs are decorated with an internal ID, each MultiPeer having an ID format "<multipeer-id>.<peer-id>". Once a message arrives to a Peer, the id is stripped to "<multipeer-id>".

func (*MultiPeer) Bind

func (p *MultiPeer) Bind(m interface{}) int

The MultiTorrent's Bind method distributes all the initialization messages towards the PeerProxies.

func (*MultiPeer) New

func (p *MultiPeer) New(util TorrentNodeUtil) TorrentNode

func (*MultiPeer) OnJoin

func (p *MultiPeer) OnJoin()

func (*MultiPeer) Process

func (p *MultiPeer) Process(m interface{}, state int)

The MultiPeer's Process method redirects all the messages towards the correct PeerProxy.

type MultiTracker

type MultiTracker struct {
	*torrent.Tracker
	// contains filtered or unexported fields
}

The MultiTracker is a usual CacheTorrent Tracker which uses a StripProxy for sending messages towards the correct Peer and runs a MultiElection instead of a usual Election.

func (*MultiTracker) Neighbours

func (t *MultiTracker) Neighbours(id string) interface{}

func (*MultiTracker) New

func (t *MultiTracker) New(util TorrentNodeUtil) TorrentNode

func (*MultiTracker) OnJoin

func (t *MultiTracker) OnJoin()

func (*MultiTracker) Recv

func (t *MultiTracker) Recv(m interface{})

type PeerProxy

type PeerProxy struct {
	*cache_torrent.Peer
	// contains filtered or unexported fields
}

A PeerProxy is a Peer wrapper over Peer which is used to expose a more useful interface towards MultiPeer. The structure has no specific features besides providing more methods. The PeerProxy uses a TransportProxy to relay messages.

func NewPeerProxy

func NewPeerProxy(util TorrentNodeUtil, id string, piecesFrom, piecesTo int) *PeerProxy

func (*PeerProxy) Init

func (p *PeerProxy) Init(trackerId string)

Method called after MultiPeer initalization.

func (*PeerProxy) Process

func (p *PeerProxy) Process(m interface{}, state int)

Method used to use the BindRun callback only once.

func (*PeerProxy) SetIds

func (p *PeerProxy) SetIds(ids []string)

Method used to decorate piece Ids with the <multipeer-id>.

func (*PeerProxy) SetPieces

func (p *PeerProxy) SetPieces(pieces []torrent.PieceMeta)

Method used to strip the pieces from an incoming message to the pieces that only subnode PeerProxy is responsible for.

type StripProxy

type StripProxy struct {
	Transport
}

func NewStripProxy

func NewStripProxy(t Transport) *StripProxy

Each Peer is assigned an internal ID following the format "<multipeer-id>:<peer-id>". When a message departs a peer towards a peer <A>:<B>, the message will be sent towards the multi-peer <A>, which will deliver the message to its internal peer <B>. To implement this mechanism for sending messages, we implement a StripProxy which strips the peer internal ID when a message is sent.

func (*StripProxy) Connect

func (t *StripProxy) Connect(id string) Link

func (*StripProxy) ControlPing

func (t *StripProxy) ControlPing(id string) bool

func (*StripProxy) ControlSend

func (t *StripProxy) ControlSend(id string, m interface{})

Jump to

Keyboard shortcuts

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