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: 0

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