Documentation
¶
Index ¶
- Constants
- func ExtractIp4FromMultiaddr(multiaddr string) (string, uint64, error)
- func GetExternalIp() (string, error)
- type Node
- func (n *Node) AddAddrToPearstore(id peer.ID, addr ma.Multiaddr, t time.Duration)
- func (n *Node) AddMultiaddrToPearstore(multiaddr string, t time.Duration) (peer.ID, error)
- func (n *Node) Addrs() []ma.Multiaddr
- func (n *Node) AuthenticateMessage(message proto.Message, data *pb.MessageData) bool
- 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) EventBus() event.Bus
- func (n *Node) GetIdleDataEvent() chan string
- func (n *Node) GetIdleFileTee() string
- func (n *Node) GetIdleTagEvent() chan string
- func (n *Node) GetServiceFileTee() string
- func (n *Node) GetServiceTagEvent() chan string
- func (n *Node) ID() peer.ID
- func (n *Node) Multiaddr() string
- func (n *Node) Mux() protocol.Switch
- func (n *Node) Network() network.Network
- 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) NewStream(ctx context.Context, p peer.ID, pids ...protocol.ID) (network.Stream, error)
- func (n *Node) Peerstore() peerstore.Peerstore
- func (n *Node) PrivatekeyPath() string
- func (n *Node) PutIdleDataEventCh(path string)
- func (n *Node) PutIdleTagEventCh(path string)
- func (n *Node) PutServiceTagEventCh(path string)
- func (n *Node) RemoveStreamHandler(pid protocol.ID)
- func (n *Node) SendFile(ctx context.Context, id peer.ID, path string) 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) SetIdleFileTee(peerid 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 (n *Node) SignProtoMessage(message proto.Message) ([]byte, error)
- func (n *Node) StarFileTransferProtocol()
- func (n *Node) Workspace() string
- type P2P
Constants ¶
const ( SIZE_1KiB = 1024 SIZE_1MiB = 1024 * SIZE_1KiB SIZE_1GiB = 1024 * SIZE_1MiB )
byte size
const ( // FileDataDirectionry = "file" TmpDataDirectionry = "tmp" IdleDataDirectionry = "space" IdleTagDirectionry = "itag" ServiceTagDirectionry = "stag" ProofDirectionry = "proof" // IdleProofFile = "iproof" IdleMuFile = "imu" ServiceProofFile = "sproof" ServiceMuFile = "smu" )
const AllIpAddress = "0.0.0.0"
const BufferSize = 64 * SIZE_1KiB
const DataShards = 2
const DirMode = 0644
const FragmentSize = 8 * SIZE_1MiB
const LocalAddress = "127.0.0.1"
const ParShards = 1
const SegmentSize = 16 * SIZE_1MiB
Variables ¶
This section is empty.
Functions ¶
func ExtractIp4FromMultiaddr ¶ added in v0.0.2
Types ¶
type Node ¶
type Node struct {
FileDir string
TmpDir string
IdleDataDir string
IdleTagDir string
ServiceTagDir string
ProofDir string
IproofFile string
IproofMuFile string
SproofFile string
SproofMuFile string
// contains filtered or unexported fields
}
Node type - Implementation of a P2P Host
func NewBasicNode ¶
func NewBasicNode(multiaddr ma.Multiaddr, workspace string, privatekeypath string, bootpeers []string, cmgr connmgr.ConnManager) (*Node, error)
NewBasicNode constructs a new *Node
multiaddr: listen addresses of p2p host workspace: service working directory privatekeypath: private key file If it's empty, automatically created in the program working directory If it's a directory, it will be created in the specified directory
func (*Node) AddAddrToPearstore ¶
func (*Node) AddMultiaddrToPearstore ¶
func (*Node) AuthenticateMessage ¶
Authenticate incoming p2p message message: a protobufs go data object data: common p2p message data
func (*Node) ConnManager ¶
func (n *Node) ConnManager() connmgr.ConnManager
func (*Node) GetIdleDataEvent ¶ added in v0.0.12
func (*Node) GetIdleFileTee ¶ added in v0.0.15
func (*Node) GetIdleTagEvent ¶ added in v0.0.17
func (*Node) GetServiceFileTee ¶ added in v0.0.15
func (*Node) GetServiceTagEvent ¶ added in v0.0.17
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) PrivatekeyPath ¶
func (*Node) PutIdleDataEventCh ¶ added in v0.0.12
func (*Node) PutIdleTagEventCh ¶ added in v0.0.17
func (*Node) PutServiceTagEventCh ¶ added in v0.0.17
func (*Node) RemoveStreamHandler ¶
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) SetIdleFileTee ¶ added in v0.0.15
func (*Node) SetServiceFileTee ¶ added in v0.0.15
func (*Node) SetStreamHandler ¶
func (n *Node) SetStreamHandler(pid protocol.ID, handler network.StreamHandler)
func (*Node) SetStreamHandlerMatch ¶
func (*Node) SignProtoMessage ¶
sign an outgoing p2p message payload
func (*Node) StarFileTransferProtocol ¶ added in v0.0.9
func (n *Node) StarFileTransferProtocol()
type P2P ¶
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