MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / setupHost

Function setupHost

IceFireDB-SQLProxy/pkg/p2p/p2p.go:168–327  ·  view source on GitHub ↗

A function that generates the p2p configuration options and creates a libp2p host object for the given context. The created host is returned

(ctx context.Context, nodeHostIP string, nodeHostPort int)

Source from the content-addressed store, hash-verified

166// A function that generates the p2p configuration options and creates a
167// libp2p host object for the given context. The created host is returned
168func setupHost(ctx context.Context, nodeHostIP string, nodeHostPort int) (host.Host, *dht.IpfsDHT) {
169 // Set up the host identity options
170 prvkey, pubkey, err := crypto.GenerateKeyPair(
171 crypto.Ed25519, // Select your key type. Ed25519 are nice short
172 -1, // Select key length when possible (i.e. RSA).
173 )
174
175 // Handle any potential error
176 if err != nil {
177 logrus.WithFields(logrus.Fields{
178 "error": err.Error(),
179 }).Fatalln("Failed to Generate P2P Identity Configuration!")
180 }
181
182 _ = pubkey
183
184 // identity := libp2p.Identity(prvkey)
185
186 // // Trace log
187 // logrus.Traceln("Generated P2P Identity Configuration.")
188
189 // // Set up TLS secured TCP transport and options
190 // tlstransport, err := libp2ptls.New(libp2ptls.ID, prvkey, nil)
191 // security := libp2p.Security(libp2ptls.ID, tlstransport)
192 // transport := libp2p.Transport(tcp.NewTCPTransport)
193 // Handle any potential error
194 // if err != nil {
195 // logrus.WithFields(logrus.Fields{
196 // "error": err.Error(),
197 // }).Fatalln("Failed to Generate P2P Security and Transport Configurations!")
198 // }
199
200 // Trace log
201 // logrus.Traceln("Generated P2P Security and Transport Configurations.")
202
203 // multiaddrStr := "/ip4/%s/tcp/%d"
204
205 // //default "/ip4/0.0.0.0/tcp/0"
206 // multiaddrStr = fmt.Sprintf(multiaddrStr, nodeHostIP, nodeHostPort)
207
208 // // Set up host listener address options
209 // muladdr, err := multiaddr.NewMultiaddr(multiaddrStr)
210
211 // logrus.Infoln("Setup Multiaddr", multiaddrStr)
212
213 // listen := libp2p.ListenAddrs(muladdr)
214 // // Handle any potential error
215 // if err != nil {
216 // logrus.WithFields(logrus.Fields{
217 // "error": err.Error(),
218 // }).Fatalln("Failed to Generate P2P Address Listener Configuration!")
219 // }
220
221 // // Trace log
222 // logrus.Traceln("Generated P2P Address Listener Configuration.")
223 // // Set up the stream multiplexer and connection manager options
224 // muxer := libp2p.Muxer("/yamux/1.0.0", yamux.DefaultTransport)
225 // basicConnMgr, err := connmgr.NewConnManager(100, 400, connmgr.WithGracePeriod(time.Minute))

Callers 1

NewP2PFunction · 0.70

Calls 2

setupKadDHTFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected