From 4b2f5072e801915126bfe7faea9ba5b38e0d097a Mon Sep 17 00:00:00 2001 From: rene <41963722+renaynay@users.noreply.github.com> Date: Wed, 24 Jul 2024 12:41:34 +0200 Subject: [PATCH] fix(nodebuilder/p2p): LNs restricted to acting as DHT clients *only* (#3590) Resolves https://github.com/celestiaorg/celestia-node/issues/3574 Potentially targets https://github.com/celestiaorg/celestia-node/issues/3573 --- nodebuilder/p2p/routing.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nodebuilder/p2p/routing.go b/nodebuilder/p2p/routing.go index e9eccf1d53..4006ec03a8 100644 --- a/nodebuilder/p2p/routing.go +++ b/nodebuilder/p2p/routing.go @@ -23,7 +23,6 @@ func contentRouting(r routing.PeerRouting) routing.ContentRouting { // Basically, this provides a way to discover peer addresses by respecting public keys. func peerRouting(cfg Config, tp node.Type, params routingParams) (routing.PeerRouting, error) { opts := []dht.Option{ - dht.Mode(dht.ModeAuto), dht.BootstrapPeers(params.Peers...), dht.ProtocolPrefix(protocol.ID(fmt.Sprintf("/celestia/%s", params.Net))), dht.Datastore(params.DataStore), @@ -36,10 +35,17 @@ func peerRouting(cfg Config, tp node.Type, params routingParams) (routing.PeerRo ) } - if tp == node.Bridge || tp == node.Full { + switch tp { + case node.Light: + opts = append(opts, + dht.Mode(dht.ModeClient), + ) + case node.Bridge, node.Full: opts = append(opts, dht.Mode(dht.ModeServer), ) + default: + return nil, fmt.Errorf("unsupported node type: %s", tp) } d, err := dht.New(params.Ctx, params.Host, opts...)