peer

package
Version: v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultPort is the port the peer server listens on if not passed in.
	DefaultPort = 3333
	// LbrycrdAddress to be used when paying for data. Not implemented yet.
	LbrycrdAddress = "bJxKvpD96kaJLriqVajZ7SaQTsWWyrGQct"
)

Variables

View Source
var ErrBlobExists = errors.Base("blob exists on server")

ErrBlobExists is a default error for when a blob already exists on the reflector server.

Functions

This section is empty.

Types

type Client added in v1.1.1

type Client struct {
	Timeout time.Duration
	// contains filtered or unexported fields
}

Client is an instance of a client connected to a server.

func (*Client) Close added in v1.1.1

func (c *Client) Close() error

Close closes the connection with the client.

func (*Client) Connect added in v1.1.1

func (c *Client) Connect(address string) error

Connect connects to a specific clients and errors if it cannot be contacted.

func (*Client) GetBlob added in v1.1.1

func (c *Client) GetBlob(hash string) (stream.Blob, error)

GetBlob gets a blob

func (*Client) GetStream added in v1.1.1

func (c *Client) GetStream(sdHash string, blobCache store.BlobStore) (stream.Stream, error)

GetStream gets a stream

func (*Client) HasBlob added in v1.1.1

func (c *Client) HasBlob(hash string) (bool, error)

HasBlob checks if the blob is available

type Server

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

Server is an instance of a peer server that houses the listener and store.

func NewServer

func NewServer(store store.BlobStore) *Server

NewServer returns an initialized Server pointer.

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown gracefully shuts down the peer server.

func (*Server) Start

func (s *Server) Start(address string) error

Start starts the server listener to handle connections.

type Store added in v1.1.1

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

Store is a blob store that gets blobs from a peer. It satisfies the store.BlobStore interface but cannot put or delete blobs.

func NewStore added in v1.1.1

func NewStore(opts StoreOpts) *Store

NewStore makes a new peer store.

func (*Store) Delete added in v1.1.1

func (p *Store) Delete(hash string) error

Delete is not supported

func (*Store) Get added in v1.1.1

func (p *Store) Get(hash string) (stream.Blob, error)

Get downloads the blob from the peer

func (*Store) Has added in v1.1.1

func (p *Store) Has(hash string) (bool, error)

Has asks the peer if they have a hash

func (*Store) Put added in v1.1.1

func (p *Store) Put(hash string, blob stream.Blob) error

Put is not supported

func (*Store) PutSD added in v1.1.1

func (p *Store) PutSD(hash string, blob stream.Blob) error

PutSD is not supported

type StoreOpts added in v1.1.1

type StoreOpts struct {
	Address string
	Timeout time.Duration
}

StoreOpts allows to set options for a new Store.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL