protocol

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: AGPL-3.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package protocol defines types for the storage protocol.

Index

Constants

View Source
const ChunkSize = 1024

ChunkSize size of a chunk of data

Variables

View Source
var (
	// ErrUnauthorized is returned when a peer tries to access a file he
	// is not allowed to get.
	ErrUnauthorized = errors.New("peer not authorized for requested file")
)

Functions

This section is empty.

Types

type Host

type Host = ihost.Host

Host represents a Stratumn Node host.

type Storage

type Storage struct {
	FileHandler file.Handler
	// contains filtered or unexported fields
}

Storage implements the storage protocol.

func NewStorage

func NewStorage(host Host, db db.DB, storagePath string) *Storage

NewStorage creates a new storage server.

func (*Storage) Authorize

func (s *Storage) Authorize(ctx context.Context, pids [][]byte, fileHash []byte) error

Authorize adds a list of peers to the authorized peers for a file hash.

func (*Storage) PullFile

func (s *Storage) PullFile(ctx context.Context, fileHash []byte, pid []byte) (err error)

PullFile pulls a file from a peer given the file hash if it has not already be downloaded.

func (*Storage) StreamHandler

func (s *Storage) StreamHandler(ctx context.Context, stream inet.Stream)

StreamHandler handles incoming messages from peers.

Directories

Path Synopsis
mockhandler
Package mockhandler is a generated GoMock package.
Package mockhandler is a generated GoMock package.
p2p
mockencoder
Package mockencoder is a generated GoMock package.
Package mockencoder is a generated GoMock package.

Jump to

Keyboard shortcuts

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