Documentation
¶
Index ¶
- Constants
- Variables
- 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 NewDatastore(path string) (ds.Datastore, error)
- func NewProtocol() *protocols
- func ParseMultiaddrs(domain string) ([]string, error)
- type AggrProofProtocol
- func (e AggrProofProtocol) AggrProofReq(peerId peer.ID, ihash, shash []byte, qslice []*pb.Qslice, puk, sign []byte) (uint32, error)
- func (e AggrProofProtocol) FileReq(peerId peer.ID, filehash string, filetype pb.FileType, fpath string) (uint32, error)
- func (e AggrProofProtocol) ReadDataAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (e AggrProofProtocol) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (p AggrProofProtocol) SetProtocolPrefix(protocolPrefix string)
- func (e AggrProofProtocol) TagPushReq(peerid peer.ID) (uint32, error)
- func (e AggrProofProtocol) TagReq(peerId peer.ID, filename, customdata string, blocknum uint64) (uint32, error)
- func (e AggrProofProtocol) WriteFileAction(id peer.ID, roothash, path string) error
- type CustomDataTagProtocol
- func (e CustomDataTagProtocol) AggrProofReq(peerId peer.ID, ihash, shash []byte, qslice []*pb.Qslice, puk, sign []byte) (uint32, error)
- func (e CustomDataTagProtocol) FileReq(peerId peer.ID, filehash string, filetype pb.FileType, fpath string) (uint32, error)
- func (e CustomDataTagProtocol) ReadDataAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (e CustomDataTagProtocol) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (p CustomDataTagProtocol) SetProtocolPrefix(protocolPrefix string)
- func (e CustomDataTagProtocol) TagPushReq(peerid peer.ID) (uint32, error)
- func (e CustomDataTagProtocol) TagReq(peerId peer.ID, filename, customdata string, blocknum uint64) (uint32, error)
- func (e CustomDataTagProtocol) WriteFileAction(id peer.ID, roothash, path 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 DiscoveredPeer
- type FileProtocol
- func (e FileProtocol) AggrProofReq(peerId peer.ID, ihash, shash []byte, qslice []*pb.Qslice, puk, sign []byte) (uint32, error)
- func (e FileProtocol) FileReq(peerId peer.ID, filehash string, filetype pb.FileType, fpath string) (uint32, error)
- func (e FileProtocol) ReadDataAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (e FileProtocol) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (p FileProtocol) SetProtocolPrefix(protocolPrefix string)
- func (e FileProtocol) TagPushReq(peerid peer.ID) (uint32, error)
- func (e FileProtocol) TagReq(peerId peer.ID, filename, customdata string, blocknum uint64) (uint32, error)
- func (e FileProtocol) WriteFileAction(id peer.ID, roothash, path string) error
- type Node
- func (n *Node) AddMultiaddrToPeerstore(multiaddr string, t time.Duration) (peer.ID, error)
- func (n *Node) Addrs() []ma.Multiaddr
- func (e Node) AggrProofReq(peerId peer.ID, ihash, shash []byte, qslice []*pb.Qslice, puk, sign []byte) (uint32, error)
- func (n *Node) Close() error
- func (n *Node) ConnManager() connmgr.ConnManager
- func (n *Node) Connect(ctx context.Context, pi peer.AddrInfo) error
- func (n *Node) DHTFindPeer(peerid string) (peer.AddrInfo, error)
- func (n *Node) EventBus() event.Bus
- func (n *Node) FidToCid(fid string) (string, error)
- func (e Node) FileReq(peerId peer.ID, filehash string, filetype pb.FileType, fpath string) (uint32, error)
- func (n *Node) GetBitSwap() *bitswap.Bitswap
- func (n *Node) GetBlockstore() blockstore.Blockstore
- func (n *Node) GetBootstraps() []string
- func (n *Node) GetCtxCancelFromRoot() context.Context
- func (n *Node) GetCtxQueryFromCtxCancel() context.Context
- func (n *Node) GetCtxRoot() context.Context
- func (n *Node) GetDataFromBlock(ctx context.Context, wantCid string) ([]byte, error)
- func (n *Node) GetDht() *dht.IpfsDHT
- func (n *Node) GetDhtProtocolVersion() string
- func (n *Node) GetDirs() DataDirs
- func (n *Node) GetDiscoveredPeers() <-chan *routing.QueryEvent
- func (n *Node) GetGrpcProtocolVersion() string
- func (n *Node) GetIdleFileTee() string
- func (n *Node) GetLocalDataFromBlock(wantCid string) ([]byte, error)
- func (n *Node) GetPeerPublickey() []byte
- func (n *Node) GetProtocolPrefix() string
- func (n *Node) GetProtocolVersion() string
- func (n *Node) GetRendezvousVersion() string
- func (n *Node) GetRoutingTable() *drouting.RoutingDiscovery
- func (n *Node) GetServiceFileTee() string
- func (n *Node) GetServiceTagCh() <-chan string
- func (n *Node) ID() peer.ID
- func (n *Node) Mux() protocol.Switch
- func (n *Node) Network() network.Network
- func (n *Node) NewAggrProofProtocol() *AggrProofProtocol
- func (n *Node) NewCustomDataTagProtocol() *CustomDataTagProtocol
- func (n *Node) NewFileProtocol() *FileProtocol
- func (n *Node) NewMessageData(messageId string, gossip bool) *pb.MessageData
- func (n *Node) NewPeerStream(id peer.ID, p protocol.ID) (network.Stream, error)
- func (n *Node) NewPushTagProtocol() *PushTagProtocol
- func (n *Node) NewReadDataProtocol() *ReadDataProtocol
- func (n *Node) NewReadFileProtocol() *ReadFileProtocol
- func (n *Node) NewStream(ctx context.Context, p peer.ID, pids ...protocol.ID) (network.Stream, error)
- func (n *Node) NewWriteFileProtocol() *WriteFileProtocol
- func (n *Node) NotifyData(buf []byte) error
- func (n *Node) PeerID() peer.ID
- func (n *Node) Peerstore() peerstore.Peerstore
- func (n *Node) PoisGetMinerInitParam(addr string, accountKey []byte, timeout time.Duration) (*pb.ResponseMinerInitParam, error)
- func (n *Node) PoisGetMinerInitParamP2P(peerid peer.ID, accountKey []byte, timeout time.Duration) (*pb.ResponseMinerInitParam, error)
- func (n *Node) PoisMinerCommitGenChall(addr string, commitGenChall *pb.RequestMinerCommitGenChall, ...) (*pb.Challenge, error)
- func (n *Node) PoisMinerCommitGenChallP2P(peerid peer.ID, commitGenChall *pb.RequestMinerCommitGenChall, ...) (*pb.Challenge, error)
- func (n *Node) PoisNewClient(addr string, opts ...grpc.DialOption) (pb.PoisApiClient, error)
- func (n *Node) PoisRequestVerifyDeletionProof(addr string, RequestVerifyDeletionProof *pb.RequestVerifyDeletionProof, ...) (*pb.ResponseVerifyCommitOrDeletionProof, error)
- func (n *Node) PoisRequestVerifyDeletionProofP2P(peerid peer.ID, requestVerifyDeletionProof *pb.RequestVerifyDeletionProof, ...) (*pb.ResponseVerifyCommitOrDeletionProof, error)
- func (n *Node) PoisRequestVerifySpaceTotal(addr string, accountKey []byte, proofList []*pb.BlocksProof, front int64, ...) (*pb.ResponseSpaceProofVerifyTotal, error)
- func (n *Node) PoisRequestVerifySpaceTotalP2P(peerid peer.ID, accountKey []byte, proofList []*pb.BlocksProof, front int64, ...) (*pb.ResponseSpaceProofVerifyTotal, error)
- func (n *Node) PoisServiceNewClient(addr string, opts ...grpc.DialOption) (pb.Podr2ApiClient, error)
- func (n *Node) PoisServiceRequestBatchVerify(addr string, names []string, us []string, mus []string, sigma string, ...) (*pb.ResponseBatchVerify, error)
- func (n *Node) PoisServiceRequestBatchVerifyP2P(peerid peer.ID, names []string, us []string, mus []string, sigma string, ...) (*pb.ResponseBatchVerify, error)
- func (n *Node) PoisServiceRequestGenTag(addr string, fileData []byte, filehash string, customData string, ...) (*pb.ResponseGenTag, error)
- func (n *Node) PoisServiceRequestGenTagP2P(peerid peer.ID, fileData []byte, filehash string, customData string, ...) (*pb.ResponseGenTag, error)
- func (n *Node) PoisSpaceProofVerifySingleBlock(addr string, accountKey []byte, spaceChals []int64, ...) (*pb.ResponseSpaceProofVerify, error)
- func (n *Node) PoisSpaceProofVerifySingleBlockP2P(peerid peer.ID, accountKey []byte, spaceChals []int64, ...) (*pb.ResponseSpaceProofVerify, error)
- func (n *Node) PoisVerifyCommitProof(addr string, verifyCommitAndAccProof *pb.RequestVerifyCommitAndAccProof, ...) (*pb.ResponseVerifyCommitOrDeletionProof, error)
- func (n *Node) PoisVerifyCommitProofP2P(peerid peer.ID, verifyCommitAndAccProof *pb.RequestVerifyCommitAndAccProof, ...) (*pb.ResponseVerifyCommitOrDeletionProof, error)
- func (n *Node) PrivatekeyPath() string
- func (e Node) ReadDataAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (e Node) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (n *Node) RemoveStreamHandler(pid protocol.ID)
- func (n *Node) RouteTableFindPeers(limit int) (<-chan peer.AddrInfo, error)
- func (n *Node) SaveAndNotifyDataBlock(buf []byte) (cid.Cid, error)
- func (n *Node) SendMsgToStream(s network.Stream, msg []byte) error
- func (n *Node) SendProtoMessage(id peer.ID, p protocol.ID, data proto.Message) error
- func (n *Node) SetBootstraps(bootstrap []string)
- func (n *Node) SetIdleFileTee(peerid string)
- func (p Node) SetProtocolPrefix(protocolPrefix string)
- func (n *Node) SetServiceFileTee(peerid string)
- func (n *Node) SetStreamHandler(pid protocol.ID, handler network.StreamHandler)
- func (n *Node) SetStreamHandlerMatch(pid protocol.ID, m func(protocol.ID) bool, handler network.StreamHandler)
- func (e Node) TagPushReq(peerid peer.ID) (uint32, error)
- func (e Node) TagReq(peerId peer.ID, filename, customdata string, blocknum uint64) (uint32, error)
- func (n *Node) Workspace() string
- func (e Node) WriteFileAction(id peer.ID, roothash, path string) error
- type P2P
- type ProofFileType
- type Protocol
- type PushTagProtocol
- func (e PushTagProtocol) AggrProofReq(peerId peer.ID, ihash, shash []byte, qslice []*pb.Qslice, puk, sign []byte) (uint32, error)
- func (e PushTagProtocol) FileReq(peerId peer.ID, filehash string, filetype pb.FileType, fpath string) (uint32, error)
- func (e PushTagProtocol) ReadDataAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (e PushTagProtocol) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (p PushTagProtocol) SetProtocolPrefix(protocolPrefix string)
- func (e PushTagProtocol) TagPushReq(peerid peer.ID) (uint32, error)
- func (e PushTagProtocol) TagReq(peerId peer.ID, filename, customdata string, blocknum uint64) (uint32, error)
- func (e PushTagProtocol) WriteFileAction(id peer.ID, roothash, path string) error
- type ReadDataProtocol
- func (e ReadDataProtocol) AggrProofReq(peerId peer.ID, ihash, shash []byte, qslice []*pb.Qslice, puk, sign []byte) (uint32, error)
- func (e ReadDataProtocol) FileReq(peerId peer.ID, filehash string, filetype pb.FileType, fpath string) (uint32, error)
- func (e ReadDataProtocol) ReadDataAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (e ReadDataProtocol) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (p ReadDataProtocol) SetProtocolPrefix(protocolPrefix string)
- func (e ReadDataProtocol) TagPushReq(peerid peer.ID) (uint32, error)
- func (e ReadDataProtocol) TagReq(peerId peer.ID, filename, customdata string, blocknum uint64) (uint32, error)
- func (e ReadDataProtocol) WriteFileAction(id peer.ID, roothash, path string) error
- type ReadFileProtocol
- func (e ReadFileProtocol) AggrProofReq(peerId peer.ID, ihash, shash []byte, qslice []*pb.Qslice, puk, sign []byte) (uint32, error)
- func (e ReadFileProtocol) FileReq(peerId peer.ID, filehash string, filetype pb.FileType, fpath string) (uint32, error)
- func (e ReadFileProtocol) ReadDataAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (e ReadFileProtocol) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (p ReadFileProtocol) SetProtocolPrefix(protocolPrefix string)
- func (e ReadFileProtocol) TagPushReq(peerid peer.ID) (uint32, error)
- func (e ReadFileProtocol) TagReq(peerId peer.ID, filename, customdata string, blocknum uint64) (uint32, error)
- func (e ReadFileProtocol) WriteFileAction(id peer.ID, roothash, path string) error
- type WriteFileProtocol
- func (e WriteFileProtocol) AggrProofReq(peerId peer.ID, ihash, shash []byte, qslice []*pb.Qslice, puk, sign []byte) (uint32, error)
- func (e WriteFileProtocol) FileReq(peerId peer.ID, filehash string, filetype pb.FileType, fpath string) (uint32, error)
- func (e WriteFileProtocol) ReadDataAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (e WriteFileProtocol) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error
- func (p WriteFileProtocol) SetProtocolPrefix(protocolPrefix string)
- func (e WriteFileProtocol) TagPushReq(peerid peer.ID) (uint32, error)
- func (e WriteFileProtocol) TagReq(peerId peer.ID, filename, customdata string, blocknum uint64) (uint32, error)
- func (e WriteFileProtocol) WriteFileAction(id peer.ID, roothash, path string) error
Constants ¶
const ( SIZE_1KiB = 1024 SIZE_1MiB = 1024 * SIZE_1KiB SIZE_1GiB = 1024 * SIZE_1MiB )
byte size
const ( FileType_ServiceFile uint32 = iota FileType_IdleFile FileType_TagFile FileType_MusFile FileType_UsFile FileType_NamesFile )
const ( FileDataDirectionry = "file" TmpDataDirectionry = "tmp" ServiceTagDirectionry = "stag" )
const ( ERR_RespTimeOut = "peer response timeout" ERR_RespFailure = "peer response failure" ERR_RespInvalidData = "peer response invalid data" )
const AggrProof_PROTOCOL = "/apv/1"
const AllIpAddress = "0.0.0.0"
const BufferSize = 64 * SIZE_1KiB
const CustomDataTag_Protocol = "/cdtg/1"
const DefaultFDCount = 65535
const DirMode = 0644
const FILE_PROTOCOL = "/kft/1"
const FileBlockDir = "blocks"
const FileProtocolBufSize = 2 * 1024 * 1024
const FileProtocolMsgBuf = 16 * 1024 * 1024
const FragmentSize = 16 * SIZE_1MiB
const IdleProtocolMsgBuf = 1024
const LocalAddress = "127.0.0.1"
const MaxCustomDataLength = 255
const MaxFileNameLength = 255
const MusProtocolMsgBuf = 32
const P2PReadReqRespTime = time.Duration(time.Second * 30)
const P2PResponseFailed uint32 = 400
const P2PResponseFinish uint32 = 210
const P2PResponseOK uint32 = 200
const P2PWriteReqRespTime = time.Duration(time.Second * 30)
const PushTag_Protocol = "/tagpush/1"
const SegmentSize = 64 * SIZE_1MiB
const TagProtocolMsgBuf = 1024 * 1024
Variables ¶
var ( FileNameLengthErr = fmt.Errorf("filename length exceeds %d", MaxFileNameLength) FileNameEmptyErr = fmt.Errorf("filename is empty") CustomDataLengthErr = fmt.Errorf("custom data length exceeds %d", MaxCustomDataLength) )
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 NewDatastore ¶ added in v0.2.1
NewDatastore returns a new fs Datastore at given `path`
func NewProtocol ¶ added in v0.0.24
func NewProtocol() *protocols
func ParseMultiaddrs ¶ added in v0.0.37
ParseMultiaddrs
Types ¶
type AggrProofProtocol ¶ added in v0.0.24
type AggrProofProtocol struct {
*Node
}
func (AggrProofProtocol) AggrProofReq ¶ added in v0.0.24
func (AggrProofProtocol) ReadDataAction ¶ added in v0.1.7
func (AggrProofProtocol) ReadFileAction ¶ added in v0.0.24
func (AggrProofProtocol) SetProtocolPrefix ¶ added in v0.0.37
func (p AggrProofProtocol) SetProtocolPrefix(protocolPrefix string)
func (AggrProofProtocol) TagPushReq ¶ added in v0.0.24
remote peer requests handler
type CustomDataTagProtocol ¶ added in v0.0.24
type CustomDataTagProtocol struct {
*Node
}
func (CustomDataTagProtocol) AggrProofReq ¶ added in v0.0.25
func (CustomDataTagProtocol) ReadDataAction ¶ added in v0.1.7
func (CustomDataTagProtocol) ReadFileAction ¶ added in v0.0.24
func (CustomDataTagProtocol) SetProtocolPrefix ¶ added in v0.0.37
func (p CustomDataTagProtocol) SetProtocolPrefix(protocolPrefix string)
func (CustomDataTagProtocol) TagPushReq ¶ added in v0.0.24
remote peer requests handler
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 (*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 DiscoveredPeer ¶ added in v0.0.24
type FileProtocol ¶ added in v0.0.24
type FileProtocol struct {
*Node
}
func (FileProtocol) AggrProofReq ¶ added in v0.0.25
func (FileProtocol) ReadDataAction ¶ added in v0.1.7
func (FileProtocol) ReadFileAction ¶ added in v0.0.24
func (FileProtocol) SetProtocolPrefix ¶ added in v0.0.37
func (p FileProtocol) SetProtocolPrefix(protocolPrefix string)
func (FileProtocol) TagPushReq ¶ added in v0.0.24
remote peer requests handler
type Node ¶
type Node struct {
*dht.IpfsDHT
*drouting.RoutingDiscovery
// contains filtered or unexported fields
}
Node type - Implementation of a P2P Host
func (*Node) AddMultiaddrToPeerstore ¶ added in v0.0.32
func (Node) AggrProofReq ¶ added in v0.0.25
func (*Node) ConnManager ¶
func (n *Node) ConnManager() connmgr.ConnManager
ConnManager returns this hosts connection manager
func (*Node) Connect ¶
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 (*Node) DHTFindPeer ¶ added in v0.1.0
DHTFindPeer searches for a peer with given ID.
func (*Node) GetBitSwap ¶ added in v0.2.2
func (*Node) GetBlockstore ¶ added in v0.2.2
func (n *Node) GetBlockstore() blockstore.Blockstore
func (*Node) GetBootstraps ¶ added in v0.0.24
func (*Node) GetCtxCancelFromRoot ¶ added in v0.1.1
func (*Node) GetCtxQueryFromCtxCancel ¶ added in v0.1.1
func (*Node) GetCtxRoot ¶ added in v0.1.1
func (*Node) GetDataFromBlock ¶ added in v0.2.1
GetDataFromBlock get data from block
func (*Node) GetDhtProtocolVersion ¶ added in v0.0.24
func (*Node) GetDiscoveredPeers ¶ added in v0.1.1
func (n *Node) GetDiscoveredPeers() <-chan *routing.QueryEvent
GetDiscoveredPeers
func (*Node) GetGrpcProtocolVersion ¶ added in v0.1.11
func (*Node) GetIdleFileTee ¶ added in v0.0.15
func (*Node) GetLocalDataFromBlock ¶ added in v0.2.2
GetLocalDataFromBlock get local data from block
func (*Node) GetPeerPublickey ¶ added in v0.0.25
func (*Node) GetProtocolPrefix ¶ added in v0.0.37
func (*Node) GetProtocolVersion ¶ added in v0.0.24
func (*Node) GetRendezvousVersion ¶ added in v0.1.0
func (*Node) GetRoutingTable ¶ added in v0.2.0
func (n *Node) GetRoutingTable() *drouting.RoutingDiscovery
func (*Node) GetServiceFileTee ¶ added in v0.0.15
func (*Node) GetServiceTagCh ¶ added in v0.0.24
func (*Node) NewAggrProofProtocol ¶ added in v0.0.24
func (n *Node) NewAggrProofProtocol() *AggrProofProtocol
func (*Node) NewCustomDataTagProtocol ¶ added in v0.0.24
func (n *Node) NewCustomDataTagProtocol() *CustomDataTagProtocol
func (*Node) NewFileProtocol ¶ added in v0.0.24
func (n *Node) NewFileProtocol() *FileProtocol
func (*Node) NewMessageData ¶
func (n *Node) 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 (*Node) NewPeerStream ¶ added in v0.0.9
NewPeerStream
func (*Node) NewPushTagProtocol ¶ added in v0.0.24
func (n *Node) NewPushTagProtocol() *PushTagProtocol
func (*Node) NewReadDataProtocol ¶ added in v0.1.7
func (n *Node) NewReadDataProtocol() *ReadDataProtocol
func (*Node) NewReadFileProtocol ¶ added in v0.0.24
func (n *Node) NewReadFileProtocol() *ReadFileProtocol
func (*Node) NewStream ¶
func (n *Node) 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 (*Node) NewWriteFileProtocol ¶ added in v0.0.24
func (n *Node) NewWriteFileProtocol() *WriteFileProtocol
func (*Node) NotifyData ¶ added in v0.2.1
NotifyData notify data
func (*Node) PoisGetMinerInitParam ¶ added in v0.1.8
func (*Node) PoisGetMinerInitParamP2P ¶ added in v0.1.11
func (*Node) PoisMinerCommitGenChall ¶ added in v0.1.8
func (*Node) PoisMinerCommitGenChallP2P ¶ added in v0.1.11
func (*Node) PoisNewClient ¶ added in v0.1.8
func (n *Node) PoisNewClient(addr string, opts ...grpc.DialOption) (pb.PoisApiClient, error)
func (*Node) PoisRequestVerifyDeletionProof ¶ added in v0.1.10
func (n *Node) PoisRequestVerifyDeletionProof( addr string, RequestVerifyDeletionProof *pb.RequestVerifyDeletionProof, timeout time.Duration, ) (*pb.ResponseVerifyCommitOrDeletionProof, error)
func (*Node) PoisRequestVerifyDeletionProofP2P ¶ added in v0.1.11
func (n *Node) PoisRequestVerifyDeletionProofP2P( peerid peer.ID, requestVerifyDeletionProof *pb.RequestVerifyDeletionProof, timeout time.Duration, ) (*pb.ResponseVerifyCommitOrDeletionProof, error)
func (*Node) PoisRequestVerifySpaceTotal ¶ added in v0.1.10
func (*Node) PoisRequestVerifySpaceTotalP2P ¶ added in v0.1.11
func (*Node) PoisServiceNewClient ¶ added in v0.1.10
func (n *Node) PoisServiceNewClient(addr string, opts ...grpc.DialOption) (pb.Podr2ApiClient, error)
func (*Node) PoisServiceRequestBatchVerify ¶ added in v0.1.10
func (*Node) PoisServiceRequestBatchVerifyP2P ¶ added in v0.1.11
func (*Node) PoisServiceRequestGenTag ¶ added in v0.1.10
func (*Node) PoisServiceRequestGenTagP2P ¶ added in v0.1.11
func (*Node) PoisSpaceProofVerifySingleBlock ¶ added in v0.1.8
func (n *Node) PoisSpaceProofVerifySingleBlock( addr string, accountKey []byte, spaceChals []int64, minerPoisInfo *pb.MinerPoisInfo, proof *pb.SpaceProof, spaceProofHashPolkadotSig []byte, timeout time.Duration, ) (*pb.ResponseSpaceProofVerify, error)
func (*Node) PoisSpaceProofVerifySingleBlockP2P ¶ added in v0.1.11
func (n *Node) PoisSpaceProofVerifySingleBlockP2P( peerid peer.ID, accountKey []byte, spaceChals []int64, minerPoisInfo *pb.MinerPoisInfo, proof *pb.SpaceProof, spaceProofHashPolkadotSig []byte, timeout time.Duration, ) (*pb.ResponseSpaceProofVerify, error)
func (*Node) PoisVerifyCommitProof ¶ added in v0.1.8
func (n *Node) PoisVerifyCommitProof( addr string, verifyCommitAndAccProof *pb.RequestVerifyCommitAndAccProof, timeout time.Duration, ) (*pb.ResponseVerifyCommitOrDeletionProof, error)
func (*Node) PoisVerifyCommitProofP2P ¶ added in v0.1.11
func (n *Node) PoisVerifyCommitProofP2P( peerid peer.ID, verifyCommitAndAccProof *pb.RequestVerifyCommitAndAccProof, timeout time.Duration, ) (*pb.ResponseVerifyCommitOrDeletionProof, error)
func (*Node) PrivatekeyPath ¶
func (Node) ReadDataAction ¶ added in v0.1.7
func (Node) ReadFileAction ¶ added in v0.0.24
func (*Node) RemoveStreamHandler ¶
RemoveStreamHandler removes a handler on the mux that was set by SetStreamHandler
func (*Node) RouteTableFindPeers ¶ added in v0.1.0
RouteTableFindPeers
func (*Node) SaveAndNotifyDataBlock ¶ added in v0.2.1
SaveAndNotifyDataBlock
func (*Node) SendMsgToStream ¶ added in v0.0.9
SendMsgToStream
func (*Node) SendProtoMessage ¶
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 (*Node) SetBootstraps ¶ added in v0.0.24
func (*Node) SetIdleFileTee ¶ added in v0.0.15
func (Node) SetProtocolPrefix ¶ added in v0.0.37
func (p Node) SetProtocolPrefix(protocolPrefix string)
func (*Node) SetServiceFileTee ¶ added in v0.0.15
func (*Node) SetStreamHandler ¶
func (n *Node) 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 (*Node) SetStreamHandlerMatch ¶
func (n *Node) 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 (Node) TagPushReq ¶ added in v0.0.24
remote peer requests handler
type P2P ¶
type P2P interface {
// Lib-p2p host
host.Host
// Message protocol
Protocol
// GetCtxRoot returns the root context of the host
GetCtxRoot() context.Context
// GetCtxCancelFromRoot returns the cancel context from root context
GetCtxCancelFromRoot() context.Context
// GetCtxQueryFromCtxCancel returns tne query context from cancel context
GetCtxQueryFromCtxCancel() context.Context
// PrivatekeyPath returns the key file location
PrivatekeyPath() string
// Workspace returns to the working directory
Workspace() string
// AddMultiaddrToPeerstore adds multiaddr to the host's peerstore
AddMultiaddrToPeerstore(multiaddr string, t time.Duration) (peer.ID, error)
// GetPeerPublickey returns the host's public key
GetPeerPublickey() []byte
// GetProtocolVersion returns the ProtocolVersion of the host
GetProtocolVersion() string
// GetDhtProtocolVersion returns the host's DHT ProtocolVersion
GetDhtProtocolVersion() string
// GetRendezvousVersion returns the rendezvous protocol
GetRendezvousVersion() string
// GetGrpcProtocolVersion returns the grpc protocol
GetGrpcProtocolVersion() string
// GetProtocolPrefix returns protocols prefix
GetProtocolPrefix() string
// GetDirs returns the data directory structure of the host
GetDirs() DataDirs
// GetBootstraps returns a list of host bootstraps
GetBootstraps() []string
// SetBootstraps updates the host's bootstrap list
SetBootstraps(bootstrap []string)
//
GetDht() *dht.IpfsDHT
//
GetRoutingTable() *drouting.RoutingDiscovery
// DHTFindPeer searches for a peer with given ID
DHTFindPeer(peerid string) (peer.AddrInfo, error)
// PeerID returns your own peerid
PeerID() peer.ID
// Close p2p
Close() error
//
GetBlockstore() blockstore.Blockstore
//
GetBitSwap() *bitswap.Bitswap
//
FidToCid(fid string) (string, error)
//
SaveAndNotifyDataBlock(buf []byte) (cid.Cid, error)
//
NotifyData(buf []byte) error
// GetDataFromBlock get data from block
GetDataFromBlock(ctx context.Context, wantCid string) ([]byte, error)
//
GetLocalDataFromBlock(wantCid string) ([]byte, error)
//
GetDiscoveredPeers() <-chan *routing.QueryEvent
// RouteTableFindPeers
RouteTableFindPeers(limit int) (<-chan peer.AddrInfo, error)
// GetServiceTagCh returns the tag channel of the service data received by the host
GetServiceTagCh() <-chan string
// PoisNewClient
PoisNewClient(addr string, opts ...grpc.DialOption) (pb.PoisApiClient, error)
//
PoisServiceNewClient(addr string, opts ...grpc.DialOption) (pb.Podr2ApiClient, error)
// PoisGetMinerInitParam
PoisGetMinerInitParam(addr string, accountKey []byte, timeout time.Duration) (*pb.ResponseMinerInitParam, error)
// PoisMinerCommitGenChall
PoisMinerCommitGenChall(
addr string,
commitGenChall *pb.RequestMinerCommitGenChall,
timeout time.Duration,
) (*pb.Challenge, error)
// PoisVerifyCommitProof
PoisVerifyCommitProof(
addr string,
verifyCommitAndAccProof *pb.RequestVerifyCommitAndAccProof,
timeout time.Duration,
) (*pb.ResponseVerifyCommitOrDeletionProof, error)
// PoisSpaceProofVerifySingleBlock
PoisSpaceProofVerifySingleBlock(
addr string,
accountKey []byte,
spaceChals []int64,
minerPoisInfo *pb.MinerPoisInfo,
proof *pb.SpaceProof,
spaceProofHashPolkadotSig []byte,
timeout time.Duration,
) (*pb.ResponseSpaceProofVerify, error)
//
PoisRequestVerifySpaceTotal(
addr string,
accountKey []byte,
proofList []*pb.BlocksProof,
front int64,
rear int64,
acc []byte,
spaceChals []int64,
timeout time.Duration,
) (*pb.ResponseSpaceProofVerifyTotal, error)
//
PoisRequestVerifyDeletionProof(
addr string,
RequestVerifyDeletionProof *pb.RequestVerifyDeletionProof,
timeout time.Duration,
) (*pb.ResponseVerifyCommitOrDeletionProof, error)
//
PoisServiceRequestGenTag(
addr string,
fileData []byte,
filehash string,
customData string,
timeout time.Duration,
) (*pb.ResponseGenTag, error)
//
PoisServiceRequestBatchVerify(
addr string,
names []string,
us []string,
mus []string,
sigma string,
peerid []byte,
minerPbk []byte,
minerPeerIdSign []byte,
qslices *pb.RequestBatchVerify_Qslice,
timeout time.Duration,
) (*pb.ResponseBatchVerify, error)
PoisGetMinerInitParamP2P(peerid peer.ID, accountKey []byte, timeout time.Duration) (*pb.ResponseMinerInitParam, error)
PoisMinerCommitGenChallP2P(
peerid peer.ID,
commitGenChall *pb.RequestMinerCommitGenChall,
timeout time.Duration,
) (*pb.Challenge, error)
PoisVerifyCommitProofP2P(
peerid peer.ID,
verifyCommitAndAccProof *pb.RequestVerifyCommitAndAccProof,
timeout time.Duration,
) (*pb.ResponseVerifyCommitOrDeletionProof, error)
PoisSpaceProofVerifySingleBlockP2P(
peerid peer.ID,
accountKey []byte,
spaceChals []int64,
minerPoisInfo *pb.MinerPoisInfo,
proof *pb.SpaceProof,
spaceProofHashPolkadotSig []byte,
timeout time.Duration,
) (*pb.ResponseSpaceProofVerify, error)
PoisRequestVerifySpaceTotalP2P(
peerid peer.ID,
accountKey []byte,
proofList []*pb.BlocksProof,
front int64,
rear int64,
acc []byte,
spaceChals []int64,
timeout time.Duration,
) (*pb.ResponseSpaceProofVerifyTotal, error)
PoisRequestVerifyDeletionProofP2P(
peerid peer.ID,
requestVerifyDeletionProof *pb.RequestVerifyDeletionProof,
timeout time.Duration,
) (*pb.ResponseVerifyCommitOrDeletionProof, error)
// service p2p
PoisServiceRequestGenTagP2P(
peerid peer.ID,
fileData []byte,
filehash string,
customData string,
timeout time.Duration,
) (*pb.ResponseGenTag, error)
PoisServiceRequestBatchVerifyP2P(
peerid peer.ID,
names []string,
us []string,
mus []string,
sigma string,
minerPeerid []byte,
minerPbk []byte,
minerPeerIdSign []byte,
qslices *pb.RequestBatchVerify_Qslice,
timeout time.Duration,
) (*pb.ResponseBatchVerify, 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
func NewBasicNode ¶
func NewBasicNode( ctx context.Context, port int, workspace string, privatekeypath string, bootstrap []string, cmgr connmgr.ConnManager, protocolPrefix string, publicip string, ) (P2P, error)
NewBasicNode constructs a new *Node
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
type ProofFileType ¶ added in v0.0.24
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
TagPushReq(peerid peer.ID) (uint32, error)
TagReq(peerId peer.ID, filename, customdata string, blocknum uint64) (uint32, error)
FileReq(peerId peer.ID, filehash string, filetype pb.FileType, fpath string) (uint32, error)
AggrProofReq(peerId peer.ID, ihash, shash []byte, qslice []*pb.Qslice, puk, sign []byte) (uint32, error)
}
type PushTagProtocol ¶ added in v0.0.24
type PushTagProtocol struct {
*Node
}
func (PushTagProtocol) AggrProofReq ¶ added in v0.0.25
func (PushTagProtocol) ReadDataAction ¶ added in v0.1.7
func (PushTagProtocol) ReadFileAction ¶ added in v0.0.24
func (PushTagProtocol) SetProtocolPrefix ¶ added in v0.0.37
func (p PushTagProtocol) SetProtocolPrefix(protocolPrefix string)
func (PushTagProtocol) TagPushReq ¶ added in v0.0.24
remote peer requests handler
type ReadDataProtocol ¶ added in v0.1.7
type ReadDataProtocol struct {
*Node // local host
*sync.Mutex
// contains filtered or unexported fields
}
func (ReadDataProtocol) AggrProofReq ¶ added in v0.1.7
func (ReadDataProtocol) ReadDataAction ¶ added in v0.1.7
func (ReadDataProtocol) ReadFileAction ¶ added in v0.1.7
func (ReadDataProtocol) SetProtocolPrefix ¶ added in v0.1.7
func (p ReadDataProtocol) SetProtocolPrefix(protocolPrefix string)
func (ReadDataProtocol) TagPushReq ¶ added in v0.1.7
remote peer requests handler
type ReadFileProtocol ¶ added in v0.0.24
type ReadFileProtocol struct {
*Node // local host
*sync.Mutex
// contains filtered or unexported fields
}
func (ReadFileProtocol) AggrProofReq ¶ added in v0.0.25
func (ReadFileProtocol) ReadDataAction ¶ added in v0.1.7
func (ReadFileProtocol) ReadFileAction ¶ added in v0.0.24
func (ReadFileProtocol) SetProtocolPrefix ¶ added in v0.0.37
func (p ReadFileProtocol) SetProtocolPrefix(protocolPrefix string)
func (ReadFileProtocol) TagPushReq ¶ added in v0.0.24
remote peer requests handler
type WriteFileProtocol ¶ added in v0.0.24
func (WriteFileProtocol) AggrProofReq ¶ added in v0.0.25
func (WriteFileProtocol) ReadDataAction ¶ added in v0.1.7
func (WriteFileProtocol) ReadFileAction ¶ added in v0.0.24
func (WriteFileProtocol) SetProtocolPrefix ¶ added in v0.0.37
func (p WriteFileProtocol) SetProtocolPrefix(protocolPrefix string)
func (WriteFileProtocol) TagPushReq ¶ added in v0.0.24
remote peer requests handler