storage

package
v2.0.0-rc.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2016 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrResourceDoesNotExist = bittorrent.ClientError("resource does not exist")

ErrResourceDoesNotExist is the error returned by all delete methods in the store if the requested resource does not exist.

Functions

func AnnounceLeecher

func AnnounceLeecher(b *testing.B, ps PeerStore)

AnnounceLeecher benchmarks the AnnouncePeers method of a PeerStore for announcing a leecher. The swarm announced to has 500 seeders and 500 leechers.

AnnounceLeecher can run in parallel.

func AnnounceLeecher1kInfohash

func AnnounceLeecher1kInfohash(b *testing.B, ps PeerStore)

AnnounceLeecher1kInfohash behaves like AnnounceLeecher with one of 1000 infohashes.

AnnounceLeecher1kInfohash can run in parallel.

func AnnounceSeeder

func AnnounceSeeder(b *testing.B, ps PeerStore)

AnnounceSeeder behaves like AnnounceLeecher with a seeder instead of a leecher.

AnnounceSeeder can run in parallel.

func AnnounceSeeder1kInfohash

func AnnounceSeeder1kInfohash(b *testing.B, ps PeerStore)

AnnounceSeeder1kInfohash behaves like AnnounceSeeder with one of 1000 infohashes.

AnnounceSeeder1kInfohash can run in parallel.

func DeleteNonexist

func DeleteNonexist(b *testing.B, ps PeerStore)

DeleteNonexist benchmarks the DeleteSeeder method of a PeerStore by attempting to delete a Peer that is nonexistent.

DeleteNonexist can run in parallel.

func DeleteNonexist1k

func DeleteNonexist1k(b *testing.B, ps PeerStore)

DeleteNonexist1k benchmarks the DeleteSeeder method of a PeerStore by attempting to delete one of 1000 nonexistent Peers.

DeleteNonexist can run in parallel.

func DeleteNonexist1kInfohash

func DeleteNonexist1kInfohash(b *testing.B, ps PeerStore)

DeleteNonexist1kInfohash benchmarks the DeleteSeeder method of a PeerStore by attempting to delete one Peer from one of 1000 infohashes.

DeleteNonexist1kInfohash can run in parallel.

func DeleteNonexist1kInfohash1k

func DeleteNonexist1kInfohash1k(b *testing.B, ps PeerStore)

DeleteNonexist1kInfohash1k benchmarks the Delete method of a PeerStore by attempting to delete one of 1000 Peers from one of 1000 Infohashes.

DeleteNonexist1kInfohash1k can run in parallel.

func GradNonexist

func GradNonexist(b *testing.B, ps PeerStore)

GradNonexist benchmarks the GraduateLeecher method of a PeerStore by attempting to graduate a nonexistent Peer.

GradNonexist can run in parallel.

func GradNonexist1k

func GradNonexist1k(b *testing.B, ps PeerStore)

GradNonexist1k benchmarks the GraduateLeecher method of a PeerStore by attempting to graduate one of 1000 nonexistent Peers.

GradNonexist1k can run in parallel.

func GradNonexist1kInfohash

func GradNonexist1kInfohash(b *testing.B, ps PeerStore)

GradNonexist1kInfohash benchmarks the GraduateLeecher method of a PeerStore by attempting to graduate a nonexistent Peer for one of 100 Infohashes.

GradNonexist1kInfohash can run in parallel.

func GradNonexist1kInfohash1k

func GradNonexist1kInfohash1k(b *testing.B, ps PeerStore)

GradNonexist1kInfohash1k benchmarks the GraduateLeecher method of a PeerStore by attempting to graduate one of 1000 nonexistent Peers for one of 1000 infohashes.

GradNonexist1kInfohash1k can run in parallel.

func Put

func Put(b *testing.B, ps PeerStore)

Put benchmarks the PutSeeder method of a PeerStore by repeatedly Putting the same Peer for the same InfoHash.

Put can run in parallel.

func Put1k

func Put1k(b *testing.B, ps PeerStore)

Put1k benchmarks the PutSeeder method of a PeerStore by cycling through 1000 Peers and Putting them into the swarm of one infohash.

Put1k can run in parallel.

func Put1kInfohash

func Put1kInfohash(b *testing.B, ps PeerStore)

Put1kInfohash benchmarks the PutSeeder method of a PeerStore by cycling through 1000 infohashes and putting the same peer into their swarms.

Put1kInfohash can run in parallel.

func Put1kInfohash1k

func Put1kInfohash1k(b *testing.B, ps PeerStore)

Put1kInfohash1k benchmarks the PutSeeder method of a PeerStore by cycling through 1000 infohashes and 1000 Peers and calling Put with them.

Put1kInfohash1k can run in parallel.

func PutDelete

func PutDelete(b *testing.B, ps PeerStore)

PutDelete benchmarks the PutSeeder and DeleteSeeder methods of a PeerStore by calling PutSeeder followed by DeleteSeeder for one Peer and one infohash.

PutDelete can not run in parallel.

func PutDelete1k

func PutDelete1k(b *testing.B, ps PeerStore)

PutDelete1k benchmarks the PutSeeder and DeleteSeeder methods in the same way PutDelete does, but with one from 1000 Peers per iteration.

PutDelete1k can not run in parallel.

func PutDelete1kInfohash

func PutDelete1kInfohash(b *testing.B, ps PeerStore)

PutDelete1kInfohash behaves like PutDelete1k with 1000 infohashes instead of 1000 Peers.

PutDelete1kInfohash can not run in parallel.

func PutDelete1kInfohash1k

func PutDelete1kInfohash1k(b *testing.B, ps PeerStore)

PutDelete1kInfohash1k behaves like PutDelete1k with 1000 infohashes in addition to 1000 Peers.

PutDelete1kInfohash1k can not run in parallel.

func PutGradDelete

func PutGradDelete(b *testing.B, ps PeerStore)

PutGradDelete benchmarks the PutLeecher, GraduateLeecher and DeleteSeeder methods of a PeerStore by adding one leecher to a swarm, promoting it to a seeder and deleting the seeder.

PutGradDelete can not run in parallel.

func PutGradDelete1k

func PutGradDelete1k(b *testing.B, ps PeerStore)

PutGradDelete1k behaves like PutGradDelete with one of 1000 Peers.

PutGradDelete1k can not run in parallel.

func PutGradDelete1kInfohash

func PutGradDelete1kInfohash(b *testing.B, ps PeerStore)

PutGradDelete1kInfohash behaves like PutGradDelete with one of 1000 infohashes.

PutGradDelete1kInfohash can not run in parallel.

func PutGradDelete1kInfohash1k

func PutGradDelete1kInfohash1k(b *testing.B, ps PeerStore)

PutGradDelete1kInfohash1k behaves like PutGradDelete with one of 1000 Peers and one of 1000 infohashes.

PutGradDelete1kInfohash can not run in parallel.

Types

type PeerStore

type PeerStore interface {
	// PutSeeder adds a Seeder to the Swarm identified by the provided
	// infoHash.
	PutSeeder(infoHash bittorrent.InfoHash, p bittorrent.Peer) error

	// DeleteSeeder removes a Seeder from the Swarm identified by the
	// provided infoHash.
	//
	// If the Swarm or Peer does not exist, this function should return
	// ErrResourceDoesNotExist.
	DeleteSeeder(infoHash bittorrent.InfoHash, p bittorrent.Peer) error

	// PutLeecher adds a Leecher to the Swarm identified by the provided
	// infoHash.
	PutLeecher(infoHash bittorrent.InfoHash, p bittorrent.Peer) error

	// DeleteLeecher removes a Leecher from the Swarm identified by the
	// provided infoHash.
	//
	// If the Swarm or Peer does not exist, this function should return
	// ErrResourceDoesNotExist.
	DeleteLeecher(infoHash bittorrent.InfoHash, p bittorrent.Peer) error

	// GraduateLeecher promotes a Leecher to a Seeder in the Swarm
	// identified by the provided infoHash.
	//
	// If the given Peer is not present as a Leecher, add the Peer as a
	// Seeder and return no error.
	GraduateLeecher(infoHash bittorrent.InfoHash, p bittorrent.Peer) error

	// AnnouncePeers is a best effort attempt to return Peers from the Swarm
	// identified by the provided infoHash. The returned Peers are required
	// to be either all IPv4 or all IPv6.
	//
	// The returned Peers should strive be:
	// - as close to length equal to numWant as possible without going over
	// - all IPv4 or all IPv6 depending on the provided peer
	// - if seeder is true, should ideally return more leechers than seeders
	// - if seeder is false, should ideally return more seeders than
	//   leechers
	//
	// Returns ErrResourceDoesNotExist if the provided infoHash is not tracked.
	AnnouncePeers(infoHash bittorrent.InfoHash, seeder bool, numWant int, p bittorrent.Peer) (peers []bittorrent.Peer, err error)

	// ScrapeSwarm returns information required to answer a scrape request
	// about a swarm identified by the given infohash.
	// The v6 flag indicates whether or not the IPv6 swarm should be
	// scraped.
	// The Complete and Incomplete fields of the Scrape must be filled,
	// filling the Snatches field is optional.
	// If the infohash is unknown to the PeerStore, an empty Scrape is
	// returned.
	ScrapeSwarm(infoHash bittorrent.InfoHash, v6 bool) bittorrent.Scrape

	// Stopper is an interface that expects a Stop method to stop the
	// PeerStore.
	// For more details see the documentation in the stopper package.
	stopper.Stopper
}

PeerStore is an interface that abstracts the interactions of storing and manipulating Peers such that it can be implemented for various data stores.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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