Hardcoded path in project results in an error
mazz opened this issue · comments
server.ex contains a reference to a hard-coded path which results in an error.
https://github.com/RooSoft/nostr/blob/main/lib/examples/nostr_app/server.ex#L26
iex(3)> relays = [
...(3)> "wss://relay.nostr.bg",
...(3)> "wss://relay.nostr.pro"
...(3)> ]
["wss://relay.nostr.bg", "wss://relay.nostr.pro"]
iex(4)> private_key = NostrBasics.Keys.PrivateKey.create
<<72, 161, 72, 23, 141, 32, 17, 65, 229, 20, 181, 81, 173, 185, 106, 166, 37,
55, 144, 35, 102, 130, 5, 9, 193, 150, 68, 195, 35, 7, 187, 136>>
iex(5)> NostrApp.start_link(relays, private_key)
22:39:49.820 [info] Starting a relay socket for wss://relay.nostr.bg, #PID<0.285.0>
22:39:49.823 [info] Starting a relay socket for wss://relay.nostr.pro, #PID<0.286.0>
** (EXIT from #PID<0.271.0>) shell process exited with reason: an exception was raised:
** (MatchError) no match of right hand side value: {:error, :enoent}
(nostr 0.2.0) lib/examples/nostr_app/server.ex:26: NostrApp.Server.init/1
(stdlib 4.2) gen_server.erl:851: :gen_server.init_it/2
(stdlib 4.2) gen_server.erl:814: :gen_server.init_it/6
Error that results:
22:39:49.831 [error] GenServer Nostr.Client terminating
** (MatchError) no match of right hand side value: {:error, :enoent}
(nostr 0.2.0) lib/examples/nostr_app/server.ex:26: NostrApp.Server.init/1
(stdlib 4.2) gen_server.erl:851: :gen_server.init_it/2
(stdlib 4.2) gen_server.erl:814: :gen_server.init_it/6
(stdlib 4.2) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: {:EXIT, #PID<0.281.0>, {{:badmatch, {:error, :enoent}}, [{NostrApp.Server, :init, 1, [file: 'lib/examples/nostr_app/server.ex', line: 26]}, {:gen_server, :init_it, 2, [file: 'gen_server.erl', line: 851]}, {:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 814]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 240]}]}}
State: {:state, {:local, Nostr.Client}, :one_for_one, {[Nostr.Subscriptions, Nostr.Client.Relays.RelayManager], %{Nostr.Client.Relays.RelayManager => {:child, #PID<0.283.0>, Nostr.Client.Relays.RelayManager, {Nostr.Client.Relays.RelayManager, :start_link, [[]]}, :permanent, false, :infinity, :supervisor, [Nostr.Client.Relays.RelayManager]}, Nostr.Subscriptions => {:child, #PID<0.284.0>, Nostr.Subscriptions, {DynamicSupervisor, :start_link, [[name: Nostr.Subscriptions, strategy: :one_for_one]]}, :permanent, false, :infinity, :supervisor, [DynamicSupervisor]}}}, :undefined, 3, 5, [], 0, :never, Nostr.Client, {}}
Hello @mazz
Thanks for pointing that out... turns out that code is useless and will thus be removed.
Just a little bit of context here... the code you are refering to is an example app that's been embedded into the lib so it can be bootstrapped in an easier way. I am considering the option to remove it, as the underlying code is about to be refactored in a big way, making everything simpler.
My question to you... are you using this library? Would be nice to know if people are using this code, before I turn it upside down.
Thank you again!
Marc
hey thanks for the fix. I will pull it.
I haven’t started using it yet(or using it in production for that matter)but I have a great interest in nostr. So it doesn’t affect me personally if you re-architect things.
The great thing about your project compared to the other elixir ones is that you have examples in the documentation to get started with.
Ok, will make sure to keep the examples up to date, then... 🫡