p2p

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2019 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Package p2p provides the parallel file transport in the P2P network.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	p2pHost.Host
}

Node is the framework used for file transport in P2P network.

func NewNode

func NewNode(host p2pHost.Host) *Node

NewNode is the construct for Node.

func (*Node) NewMessageData

func (n *Node) NewMessageData(messageID string, gossip bool) *pb.MessageData

NewMessageData generate message data shared between all node's p2p protocols messageID: unique for requests, copied from request for responses

type SeaDownloadConfirmProtocol

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

SeaDownloadConfirmProtocol provides listener for download confirm protobuf.

func NewSeaDownloadConfirmProtocol

func NewSeaDownloadConfirmProtocol(node *SeaNode) *SeaDownloadConfirmProtocol

NewSeaDownloadConfirmProtocol is the construct for SeaDownloadConfirmProtocol

type SeaDownloadProtocol

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

SeaDownloadProtocol provides listener for download request protobuf and sending download response protobuf.

func NewSeaDownloadProtocol

func NewSeaDownloadProtocol(node *SeaNode) *SeaDownloadProtocol

NewSeaDownloadProtocol is the construct for SeaDownloadProtocol.

type SeaNode

SeaNode is the P2P network node for sea providing storage.

func NewSeaNode

func NewSeaNode(c *lib.ClientFramework, storagePath string, size int64, host p2pHost.Host) (*SeaNode, error)

NewSeaNode is the construct for SeaNode.

func (*SeaNode) SendUserOperations

func (s *SeaNode) SendUserOperations()

SendUserOperations send users' operations for transaction.

type SeaOperationProtocol

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

SeaOperationProtocol provides listener for operation request protobuf.

func NewSeaOperationProtocol

func NewSeaOperationProtocol(node *SeaNode) *SeaOperationProtocol

NewSeaOperationProtocol is the construct for SeaOperationProtocol.

type SeaUploadProtocol

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

SeaUploadProtocol provides listener for upload request protobuf and sending upload response protobuf.

func NewSeaUploadProtocol

func NewSeaUploadProtocol(node *SeaNode) *SeaUploadProtocol

NewSeaUploadProtocol is the construct for SeaUploadProtocol.

type SeaUploadQueryProtocol

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

SeaUploadQueryProtocol provides listener for upload query request protobuf and sending upload query response protobuf.

func NewSeaUploadQueryProtocol

func NewSeaUploadQueryProtocol(node *SeaNode) *SeaUploadQueryProtocol

NewSeaUploadQueryProtocol is the construct for SeaUploadQueryProtocol.

type UserDownloadProtocol

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

UserDownloadProtocol provides sending download request protobuf and listener for download response protobuf.

func NewUserDownloadProtocol

func NewUserDownloadProtocol(node *UserNode) *UserDownloadProtocol

NewUserDownloadProtocol is the construct for UserDownloadProtocol

func (*UserDownloadProtocol) SendDownloadProtocol

func (p *UserDownloadProtocol) SendDownloadProtocol(peerID p2pPeer.ID, dst, owner, hash string, size int64) error

SendDownloadProtocol tag the information of download request then send it.

type UserNode

type UserNode struct {
	*lib.ClientFramework
	*Node
	*UserUploadQueryProtocol
	*UserUploadProtocol
	*UserOperationProtocol
	*UserDownloadProtocol
	// contains filtered or unexported fields
}

UserNode is the P2P network node for user upload and download file.

func NewUserNode

func NewUserNode(host p2pHost.Host, cli *lib.ClientFramework) *UserNode

NewUserNode is the construct for UserNode.

func (*UserNode) Download

func (n *UserNode) Download(dst, owner string, fragment *tpStorage.Fragment) error

Download start download file process. Firstly, generate information for downloaded file. Send download request to start download process. After download finished, the downloaded file will be verify by stored information.

func (*UserNode) Upload

func (n *UserNode) Upload(src *os.File, dst, name, hash string, size int64, seas []string)

Upload start upload file process. Firstly, generate information of source file. After information generated, it will be stored for data transport. Then start upload file process by sending upload query request protobuf.

type UserOperationProtocol

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

UserOperationProtocol provides sending operation request protobuf.

func NewUserOperationProtocol

func NewUserOperationProtocol(n *UserNode) *UserOperationProtocol

NewUserOperationProtocol is the construct for UserOperationProtocol.

type UserUploadProtocol

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

UserUploadProtocol provides sending upload request protobuf and listener for upload response protobuf.

func NewUserUploadProtocol

func NewUserUploadProtocol(node *UserNode) *UserUploadProtocol

NewUserUploadProtocol is the construct for UserUploadProtocol.

type UserUploadQueryProtocol

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

UserUploadQueryProtocol provides sending upload query request protobuf.

func NewUserUploadQueryProtocol

func NewUserUploadQueryProtocol(node *UserNode) *UserUploadQueryProtocol

NewUserUploadQueryProtocol is the construct for UserUploadQueryProtocol.

func (*UserUploadQueryProtocol) SendUploadQuery

func (p *UserUploadQueryProtocol) SendUploadQuery(peerID p2pPeer.ID, tag string, size int64) error

SendUploadQuery send upload query protobuf.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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