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) 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) 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) RemoveStreamHandler(pid protocol.ID)
- func (n *Node) SendProtoMessage(id peer.ID, p protocol.ID, data proto.Message) error
- 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) Workspace() string
- type P2P
Constants ¶
const ( SIZE_1KiB = 1024 SIZE_1MiB = 1024 * SIZE_1KiB SIZE_1GiB = 1024 * SIZE_1MiB SIZE_SLICE = 512 * SIZE_1MiB )
byte size
const AllIpAddress = "0.0.0.0"
const DataShards = 2
const DirMode = 0755
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 {
// contains filtered or unexported fields
}
Node type - Implementation of a P2P Host
func NewBasicNode ¶
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) 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) PrivatekeyPath ¶
func (Node) RemoveStreamHandler ¶
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) SetStreamHandler ¶
func (n Node) SetStreamHandler(pid protocol.ID, handler network.StreamHandler)
func (Node) SetStreamHandlerMatch ¶
func (*Node) SignProtoMessage ¶
sign an outgoing p2p message payload
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