You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having a type error while following the examples:
package main
// package hostimport (
"crypto/rand"
crypto "github.com/libp2p/go-libp2p-crypto"
peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore""context"
host "github.com/libp2p/go-libp2p-host"
ma "github.com/multiformats/go-multiaddr"
swarm "github.com/libp2p/go-libp2p-swarm"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
)
funcgenHost() host.Host {
// Generate an identity keypair using go's cryptographic randomness sourcepriv, pub, err:=crypto.GenerateEd25519Key(rand.Reader)
iferr!=nil {
panic(err)
}
// A peers ID is the hash of its public keypid, err:=peer.IDFromPublicKey(pub)
iferr!=nil {
panic(err)
}
// We've created the identity, now we need to store it.// A peerstore holds information about peers, including your ownps:=pstore.NewPeerstore()
ps.AddPrivKey(pid, priv)
ps.AddPubKey(pid, pub)
// Make addressmaddr, err:=ma.NewMultiaddr("/ip4/0.0.0.0/tcp/9000")
iferr!=nil {
panic(err)
}
// Make a context to govern the lifespan of the swarmctx:=context.Background()
// Put all this togethernetw, err:=swarm.NewNetwork(ctx, []ma.Multiaddr{maddr}, pid, ps, nil)
iferr!=nil {
panic(err)
}
returnbhost.New(netw)
// //host := libp2p.// fmt.Printf("my address: %s\n", netw.ListenAddresses()[0].String())// hostID := netw.LocalPeer().Loggable()["peerID"]// fmt.Printf("my host ID: %s\n", hostID)// fmt.Println("is equal? ", pid.Loggable()["peerID"] == hostID)
}
How do I fix this?
The text was updated successfully, but these errors were encountered:
I am having a type error while following the examples:
How do I fix this?
The text was updated successfully, but these errors were encountered: