本文整理汇总了Golang中github.com/ipfs/go-ipfs/p2p/net.Network.LocalPeer方法的典型用法代码示例。如果您正苦于以下问题:Golang Network.LocalPeer方法的具体用法?Golang Network.LocalPeer怎么用?Golang Network.LocalPeer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/ipfs/go-ipfs/p2p/net.Network
的用法示例。
在下文中一共展示了Network.LocalPeer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NetworkConns
func (p *printer) NetworkConns(ni inet.Network) {
fmt.Fprintf(p.w, "%s connected to:\n", ni.LocalPeer())
for _, c := range ni.Conns() {
fmt.Fprintf(p.w, "\t%s (addr: %s)\n", c.RemotePeer(), c.RemoteMultiaddr())
}
fmt.Fprintf(p.w, "\n")
}
示例2: expectConnectedness
func expectConnectedness(t *testing.T, a, b inet.Network, expected inet.Connectedness) {
es := "%s is connected to %s, but Connectedness incorrect. %s %s"
if a.Connectedness(b.LocalPeer()) != expected {
t.Errorf(es, a, b, printConns(a), printConns(b))
}
// test symmetric case
if b.Connectedness(a.LocalPeer()) != expected {
t.Errorf(es, b, a, printConns(b), printConns(a))
}
}
示例3: LinksBetweenNets
func (mn *mocknet) LinksBetweenNets(n1, n2 inet.Network) []Link {
return mn.LinksBetweenPeers(n1.LocalPeer(), n2.LocalPeer())
}
示例4: DisconnectNets
func (mn *mocknet) DisconnectNets(n1, n2 inet.Network) error {
return n1.ClosePeer(n2.LocalPeer())
}
示例5: ConnectNets
func (mn *mocknet) ConnectNets(a, b inet.Network) (inet.Conn, error) {
return a.DialPeer(mn.ctx, b.LocalPeer())
}
示例6: UnlinkNets
func (mn *mocknet) UnlinkNets(n1, n2 inet.Network) error {
return mn.UnlinkPeers(n1.LocalPeer(), n2.LocalPeer())
}
示例7: Disconnected
func (nn *metricsNotifiee) Disconnected(n inet.Network, v inet.Conn) {
peersTotalGauge(n.LocalPeer()).Set(float64(len(n.Conns())))
}
示例8: DivulgeAddresses
func DivulgeAddresses(a, b inet.Network) {
id := a.LocalPeer()
addrs := a.Peerstore().Addrs(id)
b.Peerstore().AddAddrs(id, addrs, peer.PermanentAddrTTL)
}