-
-
Save whyrusleeping/4fe7dd6caa090881c8c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
metrics "QmR3iK4Du2iXd4kgMZbeq36b7Ci7K2WZiL9US8Mh9WfEPS/go-libp2p/p2p/metrics" | |
swarm "QmR3iK4Du2iXd4kgMZbeq36b7Ci7K2WZiL9US8Mh9WfEPS/go-libp2p/p2p/net/swarm" | |
peer "QmR3iK4Du2iXd4kgMZbeq36b7Ci7K2WZiL9US8Mh9WfEPS/go-libp2p/p2p/peer" | |
tu "QmR3iK4Du2iXd4kgMZbeq36b7Ci7K2WZiL9US8Mh9WfEPS/go-libp2p/testutil" | |
context "QmacZi9WygGK7Me8mH53pypyscHzU386aUZXpr28GZgUct/context" | |
ma "QmbWxL1aXQhBjc1XGjGF1f2KGBMCBYSuT2ThA8YXnXJK83/go-multiaddr" | |
) | |
func main() { | |
ctx, cancel := context.WithCancel(context.Background()) | |
defer cancel() | |
laddr, err := ma.NewMultiaddr("/ip4/0.0.0.0/tcp/0") | |
if err != nil { | |
panic(err) | |
} | |
id, err := tu.RandIdentity() | |
if err != nil { | |
panic(err) | |
} | |
ps := peer.NewPeerstore() | |
bwc := metrics.NewBandwidthCounter() | |
netw, err := swarm.NewNetwork(ctx, []ma.Multiaddr{laddr}, id.ID(), ps, bwc) | |
if err != nil { | |
panic(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment