Documentation ¶
Index ¶
- func CreateMultiAddrWithPid(pid peer.ID) ma.Multiaddr
- func CreateMultiAddrWithPidAndNetAddr(pid peer.ID, netAddr ma.Multiaddr) ma.Multiaddr
- func GetLocalAddrs() ([]net.Addr, error)
- func GetNetAddrAndPidFromNormalMultiAddr(addr ma.Multiaddr) (ma.Multiaddr, peer.ID)
- func IsConnClosedError(err error) bool
- func IsNetError(err error) (net.Error, bool)
- func IsNetErrorTemporary(err error) bool
- func IsNetErrorTimeout(err error) bool
- func ParseErrsToStr(errs []error) string
- func ReadPackageData(stream network.ReceiveStream, length uint64) ([]byte, error)
- func ReadPackageLength(stream network.ReceiveStream) (uint64, []byte, error)
- func ResolvePIDFromCertDER(der []byte) (peer.ID, error)
- func ResolvePIDFromPubKey(pubKey crypto.PublicKey) (peer.ID, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMultiAddrWithPid ¶
CreateMultiAddrWithPid parse a peer.ID to p2p multiaddr. For example, "QmcQHCuAXaFkbcsPUj7e37hXXfZ9DdN7bozseo5oX4qiC4" -->> "/p2p/QmcQHCuAXaFkbcsPUj7e37hXXfZ9DdN7bozseo5oX4qiC4"
func CreateMultiAddrWithPidAndNetAddr ¶
CreateMultiAddrWithPidAndNetAddr will parse the peer.ID to p2p multiaddr then join the net addr with it. For example, "QmcQHCuAXaFkbcsPUj7e37hXXfZ9DdN7bozseo5oX4qiC4" & "/ip4/127.0.0.1/tcp/8080" -->> "/ip4/127.0.0.1/tcp/8080/p2p/QmcQHCuAXaFkbcsPUj7e37hXXfZ9DdN7bozseo5oX4qiC4"
func GetLocalAddrs ¶
GetLocalAddrs return a list of net.Addr can be used that bound in each net interfaces.
func GetNetAddrAndPidFromNormalMultiAddr ¶
GetNetAddrAndPidFromNormalMultiAddr resolves a NetAddr and a peer.ID from addr given. For example, if addr is "/ip4/127.0.0.1/tcp/8080/p2p/QmcQHCuAXaFkbcsPUj7e37hXXfZ9DdN7bozseo5oX4qiC4", will return "/ip4/127.0.0.1/tcp/8080" as net addr and "QmcQHCuAXaFkbcsPUj7e37hXXfZ9DdN7bozseo5oX4qiC4" as peer.ID. If addr is "/ip4/127.0.0.1/tcp/8080", will return "/ip4/127.0.0.1/tcp/8080" as net addr and "" as peer.ID.
func IsConnClosedError ¶
IsConnClosedError return true if the info of err contains closed strings.
func IsNetError ¶
IsNetError parse an error to a net.Error if it is an implementation of net.Error interface.
func IsNetErrorTemporary ¶
IsNetErrorTemporary return the value of err.Temporary() if err is a net.Error. If err is not a net.Error, return false.
func IsNetErrorTimeout ¶
IsNetErrorTimeout return the value of err.Timeout() if err is a net.Error. If err is not a net.Error, return false.
func ParseErrsToStr ¶
func ReadPackageData ¶
func ReadPackageData(stream network.ReceiveStream, length uint64) ([]byte, error)
ReadPackageData will read some bytes from network.ReceiveStream. The length is the size of bytes will be read.
func ReadPackageLength ¶
func ReadPackageLength(stream network.ReceiveStream) (uint64, []byte, error)
ReadPackageLength will read 8 bytes from network.ReceiveStream, then parse these bytes to an uint64 value.
func ResolvePIDFromCertDER ¶
ResolvePIDFromCertDER load the peer.ID from cert der bytes.
Types ¶
This section is empty.