core

package
v0.3.12 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 44 Imported by: 4

Documentation

Index

Constants

View Source
const (
	NetworkRoom = "cess-network-room"

	AllIpAddress = "0.0.0.0"
	LocalAddress = "127.0.0.1"

	DefaultProtocolPrefix         = "/cess"
	DefaultProtocolOverridePrefix = "/cess/dht/"

	ZeroFileHash_8M = "2daeb1f36095b44b318410b3f4e8b5d989dcc7bb023d1426c492dab0a3053e74"

	DirMode = 0755

	SIZE_1KiB = 1024
	SIZE_1MiB = 1024 * SIZE_1KiB
	SIZE_1GiB = 1024 * SIZE_1MiB

	BufferSize   = 64 * SIZE_1KiB
	SegmentSize  = 32 * SIZE_1MiB
	FragmentSize = 8 * SIZE_1MiB
)
View Source
const (
	FileDataDirectionry = "file"
	TmpDataDirectionry  = "tmp"
)
View Source
const (
	ERR_RespTimeOut     = "peer response timeout"
	ERR_RespFailure     = "peer response failure"
	ERR_RespInvalidData = "peer response invalid data"
)
View Source
const FileProtocolBufSize = 2 * 1024 * 1024
View Source
const MaxCustomDataLength = 255
View Source
const MaxFileNameLength = 255
View Source
const OnlineRequest = "/online/req/v0"

pattern: /protocol-name/request-or-response-message/version

View Source
const OnlineResponse = "/online/resp/v0"
View Source
const P2PReadReqRespTime = time.Duration(time.Second * 30)
View Source
const P2PResponseEmpty uint32 = 404
View Source
const P2PResponseFailed uint32 = 400
View Source
const P2PResponseFinish uint32 = 210
View Source
const P2PResponseOK uint32 = 200
View Source
const P2PResponseRemoteFailed uint32 = 500
View Source
const P2PWriteReqRespTime = time.Duration(time.Second * 30)

Variables

This section is empty.

Functions

func CalcFileSHA256 added in v0.0.24

func CalcFileSHA256(f *os.File) (string, error)

CalcFileSHA256 is used to calculate the sha256 value of the file type.

func CalcPathSHA256 added in v0.0.24

func CalcPathSHA256(fpath string) (string, error)

CalcPathSHA256 is used to calculate the sha256 value of a file with a given path.

func CalcSHA256 added in v0.0.24

func CalcSHA256(data []byte) (string, error)

CalcSHA256 is used to calculate the sha256 value of the data.

func FindFile added in v0.1.7

func FindFile(dir, name string) string

func FreeLocalPort added in v0.1.5

func FreeLocalPort(port uint32) bool

func GetExternalIp added in v0.0.2

func GetExternalIp() (string, error)

Get external ip address

func GetLocalIp added in v0.0.29

func GetLocalIp() ([]string, error)

Get local ip address

func IsIPv4 added in v0.1.0

func IsIPv4(ipAddr string) bool

IsIPv4 is used to determine whether ipAddr is an ipv4 address

func IsIPv6 added in v0.1.0

func IsIPv6(ipAddr string) bool

IsIPv6 is used to determine whether ipAddr is an ipv6 address

func NewDHT added in v0.3.4

func NewDHT(ctx context.Context, h host.Host, bucketsize int, version string, boot_nodes []string, protocolPrefix, dhtProtocol string) (*dht.IpfsDHT, string, string, error)

func NewProtocol added in v0.0.24

func NewProtocol() *protocols

func ParseMultiaddrs added in v0.0.37

func ParseMultiaddrs(domain string) ([]string, error)

ParseMultiaddrs

Types

type DataDirs added in v0.0.24

type DataDirs struct {
	FileDir string
	TmpDir  string
}

type Datastore added in v0.2.1

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

Datastore uses a uses a file per key to store values.

func NewDatastore added in v0.2.1

func NewDatastore(path string) (*Datastore, error)

NewDatastore returns a new fs Datastore at given `path`

func (*Datastore) Batch added in v0.2.1

func (d *Datastore) Batch(ctx context.Context) (ds.Batch, error)

func (*Datastore) Close added in v0.2.1

func (d *Datastore) Close() error

func (*Datastore) Delete added in v0.2.1

func (d *Datastore) Delete(ctx context.Context, key ds.Key) (err error)

Delete removes the value for given key

func (*Datastore) DiskUsage added in v0.2.1

func (d *Datastore) DiskUsage(ctx context.Context) (uint64, error)

DiskUsage returns the disk size used by the datastore in bytes.

func (*Datastore) Get added in v0.2.1

func (d *Datastore) Get(ctx context.Context, key ds.Key) (value []byte, err error)

Get returns the value for given key

func (*Datastore) GetSize added in v0.2.1

func (d *Datastore) GetSize(ctx context.Context, key ds.Key) (size int, err error)

func (*Datastore) Has added in v0.2.1

func (d *Datastore) Has(ctx context.Context, key ds.Key) (exists bool, err error)

Has returns whether the datastore has a value for a given key

func (*Datastore) KeyFilename added in v0.2.1

func (d *Datastore) KeyFilename(key ds.Key) string

KeyFilename returns the filename associated with `key`

func (*Datastore) Put added in v0.2.1

func (d *Datastore) Put(ctx context.Context, key ds.Key, value []byte) (err error)

Put stores the given value.

func (*Datastore) Query added in v0.2.1

func (d *Datastore) Query(ctx context.Context, q query.Query) (query.Results, error)

Query implements Datastore.Query

func (*Datastore) Sync added in v0.2.1

func (d *Datastore) Sync(ctx context.Context, prefix ds.Key) error

Sync would ensure that any previous Puts under the prefix are written to disk. However, they already are.

type OnlineProtocol added in v0.3.10

type OnlineProtocol struct {
	*PeerNode
	*sync.Mutex
	// contains filtered or unexported fields
}

func (OnlineProtocol) OnlineAction added in v0.3.10

func (e OnlineProtocol) OnlineAction(id peer.ID) error

func (OnlineProtocol) ReadDataAction added in v0.3.10

func (e OnlineProtocol) ReadDataAction(id peer.ID, roothash, datahash, path string, size int64) error

func (OnlineProtocol) ReadDataStatAction added in v0.3.10

func (e OnlineProtocol) ReadDataStatAction(id peer.ID, roothash string, datahash string) (uint64, error)

func (OnlineProtocol) ReadFileAction added in v0.3.10

func (e OnlineProtocol) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error

func (OnlineProtocol) SetProtocolPrefix added in v0.3.10

func (p OnlineProtocol) SetProtocolPrefix(protocolPrefix string)

func (OnlineProtocol) WriteFileAction added in v0.3.10

func (e OnlineProtocol) WriteFileAction(id peer.ID, roothash, path string) error

type P2P

type P2P interface {
	// Lib-p2p host
	host.Host

	// Message protocol
	Protocol

	// PrivatekeyPath returns the key file location
	PrivatekeyPath() string

	// Workspace returns to the working directory
	Workspace() string

	// GetPeerPublickey returns the host's public key
	GetPeerPublickey() []byte

	// GetProtocolVersion returns the ProtocolVersion of the host
	GetProtocolVersion() string

	//
	GetProtocolPrefix() string

	// GetDhtProtocolVersion returns the host's DHT ProtocolVersion
	GetDhtProtocolVersion() string

	// GetRendezvousVersion returns the rendezvous protocol
	GetRendezvousVersion() string

	// GetDirs returns the data directory structure of the host
	GetDirs() DataDirs

	// GetBootnode returns bootnode
	GetBootnode() string

	// GetNetEnv returns network env
	GetNetEnv() string

	// SetBootnode updates the host's boot node
	SetBootnode(bootnode string)

	//
	GetHost() host.Host

	//
	GetDHTable() *dht.IpfsDHT

	//
	EnableRecv()

	//
	DisableRecv()

	//
	GetRecvFlag() bool

	// Close p2p
	Close() error

	NewPoisCertifierApiClient(addr string, opts ...grpc.DialOption) (pb.PoisCertifierApiClient, error)

	NewPoisVerifierApiClient(addr string, opts ...grpc.DialOption) (pb.PoisVerifierApiClient, error)

	NewPodr2ApiClient(addr string, opts ...grpc.DialOption) (pb.Podr2ApiClient, error)

	NewPodr2VerifierApiClient(addr string, opts ...grpc.DialOption) (pb.Podr2VerifierApiClient, error)

	NewPubkeyApiClient(addr string, opts ...grpc.DialOption) (pb.CesealPubkeysProviderClient, error)

	RequestMinerGetNewKey(
		addr string,
		accountKey []byte,
		timeout time.Duration,
		dialOpts []grpc.DialOption,
		callOpts []grpc.CallOption,
	) (*pb.ResponseMinerInitParam, error)

	RequestMinerCommitGenChall(
		addr string,
		commitGenChall *pb.RequestMinerCommitGenChall,
		timeout time.Duration,
		dialOpts []grpc.DialOption,
		callOpts []grpc.CallOption,
	) (*pb.Challenge, error)

	RequestVerifyCommitProof(
		addr string,
		verifyCommitAndAccProof *pb.RequestVerifyCommitAndAccProof,
		timeout time.Duration,
		dialOpts []grpc.DialOption,
		callOpts []grpc.CallOption,
	) (*pb.ResponseVerifyCommitOrDeletionProof, error)

	RequestVerifyDeletionProof(
		addr string,
		requestVerifyDeletionProof *pb.RequestVerifyDeletionProof,
		timeout time.Duration,
		dialOpts []grpc.DialOption,
		callOpts []grpc.CallOption,
	) (*pb.ResponseVerifyCommitOrDeletionProof, error)

	RequestSpaceProofVerifySingleBlock(
		addr string,
		requestSpaceProofVerify *pb.RequestSpaceProofVerify,
		timeout time.Duration,
		dialOpts []grpc.DialOption,
		callOpts []grpc.CallOption,
	) (*pb.ResponseSpaceProofVerify, error)

	RequestVerifySpaceTotal(
		addr string,
		requestSpaceProofVerifyTotal *pb.RequestSpaceProofVerifyTotal,
		timeout time.Duration,
		dialOpts []grpc.DialOption,
		callOpts []grpc.CallOption,
	) (*pb.ResponseSpaceProofVerifyTotal, error)

	RequestGenTag(c pb.Podr2ApiClient) (pb.Podr2Api_RequestGenTagClient, error)

	RequestEcho(
		addr string,
		echoMessage *pb.EchoMessage,
		timeout time.Duration,
		dialOpts []grpc.DialOption,
		callOpts []grpc.CallOption,
	) (*pb.EchoMessage, error)

	RequestBatchVerify(
		addr string,
		requestBatchVerify *pb.RequestBatchVerify,
		timeout time.Duration,
		dialOpts []grpc.DialOption,
		callOpts []grpc.CallOption,
	) (*pb.ResponseBatchVerify, error)

	GetIdentityPubkey(
		addr string,
		request *pb.Request,
		timeout time.Duration,
		dialOpts []grpc.DialOption,
		callOpts []grpc.CallOption,
	) (*pb.IdentityPubkeyResponse, error)

	GetMasterPubkey(
		addr string,
		request *pb.Request,
		timeout time.Duration,
		dialOpts []grpc.DialOption,
		callOpts []grpc.CallOption,
	) (*pb.MasterPubkeyResponse, error)

	GetPodr2Pubkey(
		addr string,
		request *pb.Request,
		timeout time.Duration,
		dialOpts []grpc.DialOption,
		callOpts []grpc.CallOption,
	) (*pb.Podr2PubkeyResponse, error)
}

P2P is an object participating in a p2p network, which implements protocols or provides services. It handles requests like a Server, and issues requests like a Client. It is called Host because it is both Server and Client (and Peer may be confusing). It references libp2p: https://github.com/libp2p/go-libp2p

type PeerNode added in v0.3.4

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

Node type - Implementation of a P2P Host

func NewPeerNode added in v0.3.4

func NewPeerNode(ctx context.Context, cfg *config.Config) (*PeerNode, error)

NewPeerNode constructs a new *PeerNode

  workspace: service working directory
  privatekeypath: private key file
	  If it is empty, automatically created in the program working directory
	  If it is a directory, it will be created in the specified directory

func (*PeerNode) Addrs added in v0.3.4

func (n *PeerNode) Addrs() []ma.Multiaddr

Returns the listen addresses of the Host

func (*PeerNode) Close added in v0.3.4

func (n *PeerNode) Close() error

Close shuts down the host, its Network, and services.

func (*PeerNode) ConnManager added in v0.3.4

func (n *PeerNode) ConnManager() connmgr.ConnManager

ConnManager returns this hosts connection manager

func (*PeerNode) Connect added in v0.3.4

func (n *PeerNode) Connect(ctx context.Context, pi peer.AddrInfo) error

Connect ensures there is a connection between this host and the peer with given peer.ID. Connect will absorb the addresses in pi into its internal peerstore. If there is not an active connection, Connect will issue a h.Network.Dial, and block until a connection is open, or an error is returned. // TODO: Relay + NAT.

func (*PeerNode) DisableRecv added in v0.3.4

func (n *PeerNode) DisableRecv()

func (*PeerNode) EnableRecv added in v0.3.4

func (n *PeerNode) EnableRecv()

func (*PeerNode) EventBus added in v0.3.4

func (n *PeerNode) EventBus() event.Bus

EventBus returns the hosts eventbus

func (*PeerNode) GetBootnode added in v0.3.7

func (n *PeerNode) GetBootnode() string

func (*PeerNode) GetDHTable added in v0.3.4

func (n *PeerNode) GetDHTable() *dht.IpfsDHT

func (*PeerNode) GetDhtProtocolVersion added in v0.3.4

func (n *PeerNode) GetDhtProtocolVersion() string

func (*PeerNode) GetDirs added in v0.3.4

func (n *PeerNode) GetDirs() DataDirs

func (*PeerNode) GetHost added in v0.3.4

func (n *PeerNode) GetHost() host.Host

func (*PeerNode) GetIdentityPubkey added in v0.3.4

func (n *PeerNode) GetIdentityPubkey(
	addr string,
	request *pb.Request,
	timeout time.Duration,
	dialOpts []grpc.DialOption,
	callOpts []grpc.CallOption,
) (*pb.IdentityPubkeyResponse, error)

func (*PeerNode) GetIdleFileTee added in v0.3.4

func (n *PeerNode) GetIdleFileTee() string

func (*PeerNode) GetMasterPubkey added in v0.3.4

func (n *PeerNode) GetMasterPubkey(
	addr string,
	request *pb.Request,
	timeout time.Duration,
	dialOpts []grpc.DialOption,
	callOpts []grpc.CallOption,
) (*pb.MasterPubkeyResponse, error)

func (*PeerNode) GetNetEnv added in v0.3.8

func (n *PeerNode) GetNetEnv() string

func (*PeerNode) GetPeerPublickey added in v0.3.4

func (n *PeerNode) GetPeerPublickey() []byte

func (*PeerNode) GetPodr2Pubkey added in v0.3.4

func (n *PeerNode) GetPodr2Pubkey(
	addr string,
	request *pb.Request,
	timeout time.Duration,
	dialOpts []grpc.DialOption,
	callOpts []grpc.CallOption,
) (*pb.Podr2PubkeyResponse, error)

func (*PeerNode) GetProtocolPrefix added in v0.3.10

func (n *PeerNode) GetProtocolPrefix() string

func (*PeerNode) GetProtocolVersion added in v0.3.4

func (n *PeerNode) GetProtocolVersion() string

func (*PeerNode) GetRecvFlag added in v0.3.6

func (n *PeerNode) GetRecvFlag() bool

func (*PeerNode) GetRendezvousVersion added in v0.3.4

func (n *PeerNode) GetRendezvousVersion() string

func (*PeerNode) GetServiceFileTee added in v0.3.4

func (n *PeerNode) GetServiceFileTee() string

func (*PeerNode) ID added in v0.3.4

func (n *PeerNode) ID() peer.ID

ID returns the (local) peer.ID associated with this Host

func (*PeerNode) Mux added in v0.3.4

func (n *PeerNode) Mux() protocol.Switch

Mux returns the Mux multiplexing incoming streams to protocol handlers

func (*PeerNode) Network added in v0.3.4

func (n *PeerNode) Network() network.Network

Networks returns the Network interface of the Host

func (*PeerNode) NewMessageData added in v0.3.4

func (n *PeerNode) NewMessageData(messageId string, gossip bool) *pb.MessageData

helper method - generate message data shared between all node's p2p protocols messageId: unique for requests, copied from request for responses

func (*PeerNode) NewOnlineProtocol added in v0.3.10

func (n *PeerNode) NewOnlineProtocol() *OnlineProtocol

func (*PeerNode) NewPeerStream added in v0.3.4

func (n *PeerNode) NewPeerStream(id peer.ID, p protocol.ID) (network.Stream, error)

NewPeerStream

func (*PeerNode) NewPodr2ApiClient added in v0.3.4

func (n *PeerNode) NewPodr2ApiClient(addr string, opts ...grpc.DialOption) (pb.Podr2ApiClient, error)

func (*PeerNode) NewPodr2VerifierApiClient added in v0.3.4

func (n *PeerNode) NewPodr2VerifierApiClient(addr string, opts ...grpc.DialOption) (pb.Podr2VerifierApiClient, error)

func (*PeerNode) NewPoisCertifierApiClient added in v0.3.4

func (n *PeerNode) NewPoisCertifierApiClient(addr string, opts ...grpc.DialOption) (pb.PoisCertifierApiClient, error)

func (*PeerNode) NewPoisVerifierApiClient added in v0.3.4

func (n *PeerNode) NewPoisVerifierApiClient(addr string, opts ...grpc.DialOption) (pb.PoisVerifierApiClient, error)

func (*PeerNode) NewPubkeyApiClient added in v0.3.4

func (n *PeerNode) NewPubkeyApiClient(addr string, opts ...grpc.DialOption) (pb.CesealPubkeysProviderClient, error)

func (*PeerNode) NewReadDataProtocol added in v0.3.4

func (n *PeerNode) NewReadDataProtocol() *ReadDataProtocol

func (*PeerNode) NewReadDataStatProtocol added in v0.3.4

func (n *PeerNode) NewReadDataStatProtocol() *ReadDataStatProtocol

func (*PeerNode) NewReadFileProtocol added in v0.3.4

func (n *PeerNode) NewReadFileProtocol() *ReadFileProtocol

func (*PeerNode) NewStream added in v0.3.4

func (n *PeerNode) NewStream(ctx context.Context, p peer.ID, pids ...protocol.ID) (network.Stream, error)

NewStream opens a new stream to given peer p, and writes a p2p/protocol header with given ProtocolID. If there is no connection to p, attempts to create one. If ProtocolID is "", writes no header. (Threadsafe)

func (*PeerNode) NewWriteFileProtocol added in v0.3.4

func (n *PeerNode) NewWriteFileProtocol() *WriteFileProtocol

func (PeerNode) OnlineAction added in v0.3.10

func (e PeerNode) OnlineAction(id peer.ID) error

func (*PeerNode) Peerstore added in v0.3.4

func (n *PeerNode) Peerstore() peerstore.Peerstore

Peerstore returns the Host's repository of Peer Addresses and Keys.

func (*PeerNode) PrivatekeyPath added in v0.3.4

func (n *PeerNode) PrivatekeyPath() string

func (PeerNode) ReadDataAction added in v0.3.4

func (e PeerNode) ReadDataAction(id peer.ID, roothash, datahash, path string, size int64) error

func (PeerNode) ReadDataStatAction added in v0.3.4

func (e PeerNode) ReadDataStatAction(id peer.ID, roothash string, datahash string) (uint64, error)

func (PeerNode) ReadFileAction added in v0.3.4

func (e PeerNode) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error

func (*PeerNode) RemoveStreamHandler added in v0.3.4

func (n *PeerNode) RemoveStreamHandler(pid protocol.ID)

RemoveStreamHandler removes a handler on the mux that was set by SetStreamHandler

func (*PeerNode) RequestBatchVerify added in v0.3.4

func (n *PeerNode) RequestBatchVerify(
	addr string,
	requestBatchVerify *pb.RequestBatchVerify,
	timeout time.Duration,
	dialOpts []grpc.DialOption,
	callOpts []grpc.CallOption,
) (*pb.ResponseBatchVerify, error)

func (*PeerNode) RequestEcho added in v0.3.4

func (n *PeerNode) RequestEcho(
	addr string,
	echoMessage *pb.EchoMessage,
	timeout time.Duration,
	dialOpts []grpc.DialOption,
	callOpts []grpc.CallOption,
) (*pb.EchoMessage, error)

func (*PeerNode) RequestGenTag added in v0.3.4

func (*PeerNode) RequestMinerCommitGenChall added in v0.3.4

func (n *PeerNode) RequestMinerCommitGenChall(
	addr string,
	commitGenChall *pb.RequestMinerCommitGenChall,
	timeout time.Duration,
	dialOpts []grpc.DialOption,
	callOpts []grpc.CallOption,
) (*pb.Challenge, error)

func (*PeerNode) RequestMinerGetNewKey added in v0.3.4

func (n *PeerNode) RequestMinerGetNewKey(
	addr string,
	accountKey []byte,
	timeout time.Duration,
	dialOpts []grpc.DialOption,
	callOpts []grpc.CallOption,
) (*pb.ResponseMinerInitParam, error)

func (*PeerNode) RequestSpaceProofVerifySingleBlock added in v0.3.4

func (n *PeerNode) RequestSpaceProofVerifySingleBlock(
	addr string,
	requestSpaceProofVerify *pb.RequestSpaceProofVerify,
	timeout time.Duration,
	dialOpts []grpc.DialOption,
	callOpts []grpc.CallOption,
) (*pb.ResponseSpaceProofVerify, error)

func (*PeerNode) RequestVerifyCommitProof added in v0.3.4

func (n *PeerNode) RequestVerifyCommitProof(
	addr string,
	verifyCommitAndAccProof *pb.RequestVerifyCommitAndAccProof,
	timeout time.Duration,
	dialOpts []grpc.DialOption,
	callOpts []grpc.CallOption,
) (*pb.ResponseVerifyCommitOrDeletionProof, error)

func (*PeerNode) RequestVerifyDeletionProof added in v0.3.4

func (n *PeerNode) RequestVerifyDeletionProof(
	addr string,
	requestVerifyDeletionProof *pb.RequestVerifyDeletionProof,
	timeout time.Duration,
	dialOpts []grpc.DialOption,
	callOpts []grpc.CallOption,
) (*pb.ResponseVerifyCommitOrDeletionProof, error)

func (*PeerNode) RequestVerifySpaceTotal added in v0.3.4

func (n *PeerNode) RequestVerifySpaceTotal(
	addr string,
	requestSpaceProofVerifyTotal *pb.RequestSpaceProofVerifyTotal,
	timeout time.Duration,
	dialOpts []grpc.DialOption,
	callOpts []grpc.CallOption,
) (*pb.ResponseSpaceProofVerifyTotal, error)

func (*PeerNode) SendMsgToStream added in v0.3.4

func (n *PeerNode) SendMsgToStream(s network.Stream, msg []byte) error

SendMsgToStream

func (*PeerNode) SendProtoMessage added in v0.3.4

func (n *PeerNode) SendProtoMessage(id peer.ID, p protocol.ID, data proto.Message) error

helper method - writes a protobuf go data object to a network stream data: reference of protobuf go data object to send (not the object itself) s: network stream to write the data to

func (*PeerNode) SetBootnode added in v0.3.7

func (n *PeerNode) SetBootnode(bootnode string)

func (*PeerNode) SetIdleFileTee added in v0.3.4

func (n *PeerNode) SetIdleFileTee(peerid string)

func (PeerNode) SetProtocolPrefix added in v0.3.4

func (p PeerNode) SetProtocolPrefix(protocolPrefix string)

func (*PeerNode) SetServiceFileTee added in v0.3.4

func (n *PeerNode) SetServiceFileTee(peerid string)

func (*PeerNode) SetStreamHandler added in v0.3.4

func (n *PeerNode) SetStreamHandler(pid protocol.ID, handler network.StreamHandler)

SetStreamHandler sets the protocol handler on the Host's Mux. This is equivalent to: host.Mux().SetHandler(proto, handler) (Threadsafe)

func (*PeerNode) SetStreamHandlerMatch added in v0.3.4

func (n *PeerNode) SetStreamHandlerMatch(pid protocol.ID, m func(protocol.ID) bool, handler network.StreamHandler)

SetStreamHandlerMatch sets the protocol handler on the Host's Mux using a matching function for protocol selection.

func (*PeerNode) Workspace added in v0.3.4

func (n *PeerNode) Workspace() string

func (PeerNode) WriteFileAction added in v0.3.4

func (e PeerNode) WriteFileAction(id peer.ID, roothash, path string) error

type Protocol added in v0.0.24

type Protocol interface {
	WriteFileAction(id peer.ID, roothash, path string) error
	ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error
	ReadDataAction(id peer.ID, roothash, datahash, path string, size int64) error
	ReadDataStatAction(id peer.ID, roothash string, datahash string) (uint64, error)
	OnlineAction(id peer.ID) error
}

type ReadDataProtocol added in v0.1.7

type ReadDataProtocol struct {
	*PeerNode // local host
	*sync.Mutex
	// contains filtered or unexported fields
}

func (ReadDataProtocol) OnlineAction added in v0.3.10

func (e ReadDataProtocol) OnlineAction(id peer.ID) error

func (ReadDataProtocol) ReadDataAction added in v0.1.7

func (e ReadDataProtocol) ReadDataAction(id peer.ID, roothash, datahash, path string, size int64) error

func (ReadDataProtocol) ReadDataStatAction added in v0.2.6

func (e ReadDataProtocol) ReadDataStatAction(id peer.ID, roothash string, datahash string) (uint64, error)

func (ReadDataProtocol) ReadFileAction added in v0.1.7

func (e ReadDataProtocol) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error

func (ReadDataProtocol) SetProtocolPrefix added in v0.1.7

func (p ReadDataProtocol) SetProtocolPrefix(protocolPrefix string)

func (ReadDataProtocol) WriteFileAction added in v0.1.7

func (e ReadDataProtocol) WriteFileAction(id peer.ID, roothash, path string) error

type ReadDataStatProtocol added in v0.2.6

type ReadDataStatProtocol struct {
	*PeerNode // local host
	*sync.Mutex
	// contains filtered or unexported fields
}

func (ReadDataStatProtocol) OnlineAction added in v0.3.10

func (e ReadDataStatProtocol) OnlineAction(id peer.ID) error

func (ReadDataStatProtocol) ReadDataAction added in v0.2.6

func (e ReadDataStatProtocol) ReadDataAction(id peer.ID, roothash, datahash, path string, size int64) error

func (ReadDataStatProtocol) ReadDataStatAction added in v0.2.6

func (e ReadDataStatProtocol) ReadDataStatAction(id peer.ID, roothash string, datahash string) (uint64, error)

func (ReadDataStatProtocol) ReadFileAction added in v0.2.6

func (e ReadDataStatProtocol) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error

func (ReadDataStatProtocol) SetProtocolPrefix added in v0.2.6

func (p ReadDataStatProtocol) SetProtocolPrefix(protocolPrefix string)

func (ReadDataStatProtocol) WriteFileAction added in v0.2.6

func (e ReadDataStatProtocol) WriteFileAction(id peer.ID, roothash, path string) error

type ReadFileProtocol added in v0.0.24

type ReadFileProtocol struct {
	*PeerNode // local host
	*sync.Mutex
	// contains filtered or unexported fields
}

func (ReadFileProtocol) OnlineAction added in v0.3.10

func (e ReadFileProtocol) OnlineAction(id peer.ID) error

func (ReadFileProtocol) ReadDataAction added in v0.1.7

func (e ReadFileProtocol) ReadDataAction(id peer.ID, roothash, datahash, path string, size int64) error

func (ReadFileProtocol) ReadDataStatAction added in v0.2.6

func (e ReadFileProtocol) ReadDataStatAction(id peer.ID, roothash string, datahash string) (uint64, error)

func (ReadFileProtocol) ReadFileAction added in v0.0.24

func (e ReadFileProtocol) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error

func (ReadFileProtocol) SetProtocolPrefix added in v0.0.37

func (p ReadFileProtocol) SetProtocolPrefix(protocolPrefix string)

func (ReadFileProtocol) WriteFileAction added in v0.0.24

func (e ReadFileProtocol) WriteFileAction(id peer.ID, roothash, path string) error

type WriteFileProtocol added in v0.0.24

type WriteFileProtocol struct {
	*PeerNode
	*sync.Mutex
	// contains filtered or unexported fields
}

func (WriteFileProtocol) OnlineAction added in v0.3.10

func (e WriteFileProtocol) OnlineAction(id peer.ID) error

func (WriteFileProtocol) ReadDataAction added in v0.1.7

func (e WriteFileProtocol) ReadDataAction(id peer.ID, roothash, datahash, path string, size int64) error

func (WriteFileProtocol) ReadDataStatAction added in v0.2.6

func (e WriteFileProtocol) ReadDataStatAction(id peer.ID, roothash string, datahash string) (uint64, error)

func (WriteFileProtocol) ReadFileAction added in v0.0.24

func (e WriteFileProtocol) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error

func (WriteFileProtocol) SetProtocolPrefix added in v0.0.37

func (p WriteFileProtocol) SetProtocolPrefix(protocolPrefix string)

func (WriteFileProtocol) WriteFileAction added in v0.0.24

func (e WriteFileProtocol) WriteFileAction(id peer.ID, roothash, path string) error

Jump to

Keyboard shortcuts

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