Documentation
¶
Index ¶
- Constants
- func CalcFileSHA256(f *os.File) (string, error)
- func CalcPathSHA256(fpath string) (string, error)
- func CalcSHA256(data []byte) (string, error)
- func FindFile(dir, name string) string
- func FreeLocalPort(port uint32) bool
- func GetExternalIp() (string, error)
- func GetLocalIp() ([]string, error)
- func IsIPv4(ipAddr string) bool
- func IsIPv6(ipAddr string) bool
- func NewDHT(ctx context.Context, h host.Host, bucketsize int, version string, ...) (*dht.IpfsDHT, string, string, error)
- func NewProtocol() *protocols
- func ParseMultiaddrs(domain string) ([]string, error)
- type DataDirs
- type Datastore
- func (d *Datastore) Batch(ctx context.Context) (ds.Batch, error)
- func (d *Datastore) Close() error
- func (d *Datastore) Delete(ctx context.Context, key ds.Key) (err error)
- func (d *Datastore) DiskUsage(ctx context.Context) (uint64, error)
- func (d *Datastore) Get(ctx context.Context, key ds.Key) (value []byte, err error)
- func (d *Datastore) GetSize(ctx context.Context, key ds.Key) (size int, err error)
- func (d *Datastore) Has(ctx context.Context, key ds.Key) (exists bool, err error)
- func (d *Datastore) KeyFilename(key ds.Key) string
- func (d *Datastore) Put(ctx context.Context, key ds.Key, value []byte) (err error)
- func (d *Datastore) Query(ctx context.Context, q query.Query) (query.Results, error)
- func (d *Datastore) Sync(ctx context.Context, prefix ds.Key) error
- type OnlineProtocol
- func (e OnlineProtocol) OnlineAction(id peer.ID) error
- func (e OnlineProtocol) ReadDataAction(id peer.ID, name, savepath string, size int64) error
- func (e OnlineProtocol) ReadDataStatAction(id peer.ID, roothash string, datahash string) (uint64, error)
- func (e OnlineProtocol) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (e OnlineProtocol) ReadFileActionWithExtension(id peer.ID, roothash, datahash string, writer io.Writer, extData []byte) error
- func (p OnlineProtocol) SetProtocolPrefix(protocolPrefix string)
- func (e OnlineProtocol) WriteFileAction(id peer.ID, roothash, path string) error
- type P2P
- type PeerNode
- func (n *PeerNode) Addrs() []ma.Multiaddr
- func (n *PeerNode) Close() error
- func (n *PeerNode) ConnManager() connmgr.ConnManager
- func (n *PeerNode) Connect(ctx context.Context, pi peer.AddrInfo) error
- func (n *PeerNode) DisableRecv()
- func (n *PeerNode) EnableRecv()
- func (n *PeerNode) EventBus() event.Bus
- func (n *PeerNode) GetBootnode() string
- func (n *PeerNode) GetDHTable() *dht.IpfsDHT
- func (n *PeerNode) GetDhtProtocolVersion() string
- func (n *PeerNode) GetDirs() DataDirs
- func (n *PeerNode) GetHost() host.Host
- func (n *PeerNode) GetIdentityPubkey(addr string, request *pb.Request, timeout time.Duration, ...) (*pb.IdentityPubkeyResponse, error)
- func (n *PeerNode) GetIdleFileTee() string
- func (n *PeerNode) GetMasterPubkey(addr string, request *pb.Request, timeout time.Duration, ...) (*pb.MasterPubkeyResponse, error)
- func (n *PeerNode) GetNetEnv() string
- func (n *PeerNode) GetPeerPublickey() []byte
- func (n *PeerNode) GetPodr2Pubkey(addr string, request *pb.Request, timeout time.Duration, ...) (*pb.Podr2PubkeyResponse, error)
- func (n *PeerNode) GetProtocolPrefix() string
- func (n *PeerNode) GetProtocolVersion() string
- func (n *PeerNode) GetRecvFlag() bool
- func (n *PeerNode) GetRendezvousVersion() string
- func (n *PeerNode) GetServiceFileTee() string
- func (n *PeerNode) ID() peer.ID
- func (n *PeerNode) Mux() protocol.Switch
- func (n *PeerNode) Network() network.Network
- func (n *PeerNode) NewMessageData(messageId string, gossip bool) *pb.MessageData
- func (n *PeerNode) NewOnlineProtocol() *OnlineProtocol
- func (n *PeerNode) NewPeerStream(id peer.ID, p protocol.ID) (network.Stream, error)
- func (n *PeerNode) NewPodr2ApiClient(addr string, opts ...grpc.DialOption) (pb.Podr2ApiClient, error)
- func (n *PeerNode) NewPodr2VerifierApiClient(addr string, opts ...grpc.DialOption) (pb.Podr2VerifierApiClient, error)
- func (n *PeerNode) NewPoisCertifierApiClient(addr string, opts ...grpc.DialOption) (pb.PoisCertifierApiClient, error)
- func (n *PeerNode) NewPoisVerifierApiClient(addr string, opts ...grpc.DialOption) (pb.PoisVerifierApiClient, error)
- func (n *PeerNode) NewPubkeyApiClient(addr string, opts ...grpc.DialOption) (pb.CesealPubkeysProviderClient, error)
- func (n *PeerNode) NewReadDataProtocol() *ReadDataProtocol
- func (n *PeerNode) NewReadDataStatProtocol() *ReadDataStatProtocol
- func (n *PeerNode) NewReadFileProtocol() *ReadFileProtocol
- func (n *PeerNode) NewStream(ctx context.Context, p peer.ID, pids ...protocol.ID) (network.Stream, error)
- func (n *PeerNode) NewWriteFileProtocol() *WriteFileProtocol
- func (e PeerNode) OnlineAction(id peer.ID) error
- func (n *PeerNode) Peerstore() peerstore.Peerstore
- func (n *PeerNode) PrivatekeyPath() string
- func (e PeerNode) ReadDataAction(id peer.ID, name, savepath string, size int64) error
- func (e PeerNode) ReadDataStatAction(id peer.ID, roothash string, datahash string) (uint64, error)
- func (e PeerNode) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (e PeerNode) ReadFileActionWithExtension(id peer.ID, roothash, datahash string, writer io.Writer, extData []byte) error
- func (n *PeerNode) RemoveStreamHandler(pid protocol.ID)
- func (n *PeerNode) RequestBatchVerify(addr string, requestBatchVerify *pb.RequestBatchVerify, timeout time.Duration, ...) (*pb.ResponseBatchVerify, error)
- func (n *PeerNode) RequestEcho(addr string, echoMessage *pb.EchoMessage, timeout time.Duration, ...) (*pb.EchoMessage, error)
- func (n *PeerNode) RequestGenTag(c pb.Podr2ApiClient) (pb.Podr2Api_RequestGenTagClient, error)
- func (n *PeerNode) RequestMinerCommitGenChall(addr string, commitGenChall *pb.RequestMinerCommitGenChall, ...) (*pb.Challenge, error)
- func (n *PeerNode) RequestMinerGetNewKey(addr string, accountKey []byte, timeout time.Duration, ...) (*pb.ResponseMinerInitParam, error)
- func (n *PeerNode) RequestSpaceProofVerifySingleBlock(addr string, requestSpaceProofVerify *pb.RequestSpaceProofVerify, ...) (*pb.ResponseSpaceProofVerify, error)
- func (n *PeerNode) RequestVerifyCommitProof(addr string, verifyCommitAndAccProof *pb.RequestVerifyCommitAndAccProof, ...) (*pb.ResponseVerifyCommitOrDeletionProof, error)
- func (n *PeerNode) RequestVerifyDeletionProof(addr string, requestVerifyDeletionProof *pb.RequestVerifyDeletionProof, ...) (*pb.ResponseVerifyCommitOrDeletionProof, error)
- func (n *PeerNode) RequestVerifySpaceTotal(addr string, requestSpaceProofVerifyTotal *pb.RequestSpaceProofVerifyTotal, ...) (*pb.ResponseSpaceProofVerifyTotal, error)
- func (n *PeerNode) SendMsgToStream(s network.Stream, msg []byte) error
- func (n *PeerNode) SendProtoMessage(id peer.ID, p protocol.ID, data proto.Message) error
- func (n *PeerNode) SetBootnode(bootnode string)
- func (n *PeerNode) SetIdleFileTee(peerid string)
- func (p PeerNode) SetProtocolPrefix(protocolPrefix string)
- func (n *PeerNode) SetServiceFileTee(peerid string)
- func (n *PeerNode) SetStreamHandler(pid protocol.ID, handler network.StreamHandler)
- func (n *PeerNode) SetStreamHandlerMatch(pid protocol.ID, m func(protocol.ID) bool, handler network.StreamHandler)
- func (n *PeerNode) Workspace() string
- func (e PeerNode) WriteFileAction(id peer.ID, roothash, path string) error
- type Protocol
- type ReadDataProtocol
- func (e ReadDataProtocol) OnlineAction(id peer.ID) error
- func (e ReadDataProtocol) ReadDataAction(id peer.ID, name, savepath string, size int64) error
- func (e ReadDataProtocol) ReadDataStatAction(id peer.ID, roothash string, datahash string) (uint64, error)
- func (e ReadDataProtocol) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (e ReadDataProtocol) ReadFileActionWithExtension(id peer.ID, roothash, datahash string, writer io.Writer, extData []byte) error
- func (p ReadDataProtocol) SetProtocolPrefix(protocolPrefix string)
- func (e ReadDataProtocol) WriteFileAction(id peer.ID, roothash, path string) error
- type ReadDataStatProtocol
- func (e ReadDataStatProtocol) OnlineAction(id peer.ID) error
- func (e ReadDataStatProtocol) ReadDataAction(id peer.ID, name, savepath string, size int64) error
- func (e ReadDataStatProtocol) ReadDataStatAction(id peer.ID, roothash string, datahash string) (uint64, error)
- func (e ReadDataStatProtocol) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (e ReadDataStatProtocol) ReadFileActionWithExtension(id peer.ID, roothash, datahash string, writer io.Writer, extData []byte) error
- func (p ReadDataStatProtocol) SetProtocolPrefix(protocolPrefix string)
- func (e ReadDataStatProtocol) WriteFileAction(id peer.ID, roothash, path string) error
- type ReadFileProtocol
- func (e *ReadFileProtocol) DefaultReadFileServerHandle(req *pb.ReadfileRequest) (*pb.ReadfileResponse, error)
- func (e ReadFileProtocol) OnlineAction(id peer.ID) error
- func (e ReadFileProtocol) ReadDataAction(id peer.ID, name, savepath string, size int64) error
- func (e ReadFileProtocol) ReadDataStatAction(id peer.ID, roothash string, datahash string) (uint64, error)
- func (e ReadFileProtocol) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (e ReadFileProtocol) ReadFileActionWithExtension(id peer.ID, roothash, datahash string, writer io.Writer, extData []byte) error
- func (p ReadFileProtocol) SetProtocolPrefix(protocolPrefix string)
- func (e *ReadFileProtocol) SetReadFileServiceHandle(handle ReadFileServerHandle)
- func (e ReadFileProtocol) WriteFileAction(id peer.ID, roothash, path string) error
- type ReadFileServerHandle
- type WriteFileProtocol
- func (e WriteFileProtocol) OnlineAction(id peer.ID) error
- func (e WriteFileProtocol) ReadDataAction(id peer.ID, name, savepath string, size int64) error
- func (e WriteFileProtocol) ReadDataStatAction(id peer.ID, roothash string, datahash string) (uint64, error)
- func (e WriteFileProtocol) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (e WriteFileProtocol) ReadFileActionWithExtension(id peer.ID, roothash, datahash string, writer io.Writer, extData []byte) error
- func (p WriteFileProtocol) SetProtocolPrefix(protocolPrefix string)
- func (e WriteFileProtocol) WriteFileAction(id peer.ID, roothash, path string) error
Constants ¶
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 )
const ( FileDataDirectionry = "file" TmpDataDirectionry = "tmp" )
const ( ERR_TimeOut = "receiving data timeout" ERR_RespFailure = "peer response failure" ERR_RespInvalidData = "peer response invalid data" ERR_RespEmptyData = "received empty data" ERR_InvalidData = "received invalid data" )
const FileProtocolBufSize = 32 * 1024
const MaxCustomDataLength = 255
const MaxFileNameLength = 255
const OnlineRequest = "/online/req/v0"
pattern: /protocol-name/request-or-response-message/version
const OnlineResponse = "/online/resp/v0"
const P2PReadReqRespTime = time.Duration(time.Second * 30)
const P2PResponseEmpty uint32 = 404
const P2PResponseFailed uint32 = 400
const P2PResponseFinish uint32 = 210
const P2PResponseOK uint32 = 200
const P2PResponseRemoteFailed uint32 = 500
const P2PWriteReqRespTime = time.Duration(time.Second * 30)
Variables ¶
This section is empty.
Functions ¶
func CalcFileSHA256 ¶ added in v0.0.24
CalcFileSHA256 is used to calculate the sha256 value of the file type.
func CalcPathSHA256 ¶ added in v0.0.24
CalcPathSHA256 is used to calculate the sha256 value of a file with a given path.
func CalcSHA256 ¶ added in v0.0.24
CalcSHA256 is used to calculate the sha256 value of the data.
func FreeLocalPort ¶ added in v0.1.5
func NewProtocol ¶ added in v0.0.24
func NewProtocol() *protocols
func ParseMultiaddrs ¶ added in v0.0.37
ParseMultiaddrs
Types ¶
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
NewDatastore returns a new fs Datastore at given `path`
func (*Datastore) DiskUsage ¶ added in v0.2.1
DiskUsage returns the disk size used by the datastore in bytes.
func (*Datastore) Has ¶ added in v0.2.1
Has returns whether the datastore has a value for a given key
func (*Datastore) KeyFilename ¶ added in v0.2.1
KeyFilename returns the filename associated with `key`
type OnlineProtocol ¶ added in v0.3.10
func (OnlineProtocol) OnlineAction ¶ added in v0.3.10
func (OnlineProtocol) ReadDataAction ¶ added in v0.3.10
func (OnlineProtocol) ReadDataStatAction ¶ added in v0.3.10
func (OnlineProtocol) ReadFileAction ¶ added in v0.3.10
func (OnlineProtocol) ReadFileActionWithExtension ¶ added in v0.3.14
func (OnlineProtocol) SetProtocolPrefix ¶ added in v0.3.10
func (p OnlineProtocol) SetProtocolPrefix(protocolPrefix string)
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
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) 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
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) GetBootnode ¶ added in v0.3.7
func (*PeerNode) GetDHTable ¶ added in v0.3.4
func (*PeerNode) GetDhtProtocolVersion ¶ added in v0.3.4
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 (*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) GetPeerPublickey ¶ added in v0.3.4
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 (*PeerNode) GetProtocolVersion ¶ added in v0.3.4
func (*PeerNode) GetRecvFlag ¶ added in v0.3.6
func (*PeerNode) GetRendezvousVersion ¶ added in v0.3.4
func (*PeerNode) GetServiceFileTee ¶ added in v0.3.4
func (*PeerNode) Mux ¶ added in v0.3.4
Mux returns the Mux multiplexing incoming streams to protocol handlers
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
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 (*PeerNode) Peerstore ¶ added in v0.3.4
Peerstore returns the Host's repository of Peer Addresses and Keys.
func (*PeerNode) PrivatekeyPath ¶ added in v0.3.4
func (PeerNode) ReadDataAction ¶ added in v0.3.4
func (PeerNode) ReadDataStatAction ¶ added in v0.3.4
func (PeerNode) ReadFileAction ¶ added in v0.3.4
func (PeerNode) ReadFileActionWithExtension ¶ added in v0.3.14
func (*PeerNode) RemoveStreamHandler ¶ added in v0.3.4
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 (n *PeerNode) RequestGenTag(c pb.Podr2ApiClient) (pb.Podr2Api_RequestGenTagClient, error)
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
SendMsgToStream
func (*PeerNode) SendProtoMessage ¶ added in v0.3.4
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 (*PeerNode) SetIdleFileTee ¶ added in v0.3.4
func (PeerNode) SetProtocolPrefix ¶ added in v0.3.4
func (p PeerNode) SetProtocolPrefix(protocolPrefix string)
func (*PeerNode) SetServiceFileTee ¶ added in v0.3.4
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.
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, name, savepath 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 (ReadDataProtocol) ReadDataAction ¶ added in v0.1.7
func (ReadDataProtocol) ReadDataStatAction ¶ added in v0.2.6
func (ReadDataProtocol) ReadFileAction ¶ added in v0.1.7
func (ReadDataProtocol) ReadFileActionWithExtension ¶ added in v0.3.14
func (ReadDataProtocol) SetProtocolPrefix ¶ added in v0.1.7
func (p ReadDataProtocol) SetProtocolPrefix(protocolPrefix string)
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 (ReadDataStatProtocol) ReadDataAction ¶ added in v0.2.6
func (ReadDataStatProtocol) ReadDataStatAction ¶ added in v0.2.6
func (ReadDataStatProtocol) ReadFileAction ¶ added in v0.2.6
func (ReadDataStatProtocol) ReadFileActionWithExtension ¶ added in v0.3.14
func (ReadDataStatProtocol) SetProtocolPrefix ¶ added in v0.2.6
func (p ReadDataStatProtocol) SetProtocolPrefix(protocolPrefix string)
type ReadFileProtocol ¶ added in v0.0.24
type ReadFileProtocol struct { *PeerNode // local host *sync.Mutex // contains filtered or unexported fields }
func (*ReadFileProtocol) DefaultReadFileServerHandle ¶ added in v0.3.14
func (e *ReadFileProtocol) DefaultReadFileServerHandle(req *pb.ReadfileRequest) (*pb.ReadfileResponse, error)
func (ReadFileProtocol) OnlineAction ¶ added in v0.3.10
func (ReadFileProtocol) ReadDataAction ¶ added in v0.1.7
func (ReadFileProtocol) ReadDataStatAction ¶ added in v0.2.6
func (ReadFileProtocol) ReadFileAction ¶ added in v0.0.24
func (ReadFileProtocol) ReadFileActionWithExtension ¶ added in v0.3.14
func (ReadFileProtocol) SetProtocolPrefix ¶ added in v0.0.37
func (p ReadFileProtocol) SetProtocolPrefix(protocolPrefix string)
func (*ReadFileProtocol) SetReadFileServiceHandle ¶ added in v0.3.14
func (e *ReadFileProtocol) SetReadFileServiceHandle(handle ReadFileServerHandle)
type ReadFileServerHandle ¶ added in v0.3.14
type ReadFileServerHandle func(req *pb.ReadfileRequest) (*pb.ReadfileResponse, error)
type WriteFileProtocol ¶ added in v0.0.24
func (WriteFileProtocol) OnlineAction ¶ added in v0.3.10
func (WriteFileProtocol) ReadDataAction ¶ added in v0.1.7
func (WriteFileProtocol) ReadDataStatAction ¶ added in v0.2.6
func (WriteFileProtocol) ReadFileAction ¶ added in v0.0.24
func (WriteFileProtocol) ReadFileActionWithExtension ¶ added in v0.3.14
func (WriteFileProtocol) SetProtocolPrefix ¶ added in v0.0.37
func (p WriteFileProtocol) SetProtocolPrefix(protocolPrefix string)