Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options to disable_preferred_hotspot #1015

Merged
merged 3 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env-template
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ ROUTER_CHARGE_JOINS=true

# Charge an org for a packet received late or replayed (default: false).
ROUTER_CHARGE_LATE_PACKETS=false

# Flag to disable preferred hotspot feature (default: false).
ROUTER_DISABLE_PREFERRED_HOTSPOT=true
1 change: 1 addition & 0 deletions config/sys.config.src
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
{router, [
{devaddr_prefix, "${ROUTER_DEVADDR_PREFIX}"},
{is_chain_dead, "${ROUTER_IS_CHAIN_DEAD}"},
{disable_preferred_hotspot, "${ROUTER_DISABLE_PREFERRED_HOTSPOT}"},
{grpc_port, ${GRPC_PORT:-8080}},
{max_v8_context, 1000},
{oui, "${ROUTER_OUI}"},
Expand Down
1 change: 1 addition & 0 deletions config/test.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
%% -*- erlang -*-
[
{router, [
{disable_preferred_hotspot, "false"},
{oui, 1},
{devaddr_prefix, "72"},
{metrics_port, 3001},
Expand Down
21 changes: 13 additions & 8 deletions src/device/router_device_routing.erl
Original file line number Diff line number Diff line change
Expand Up @@ -572,15 +572,20 @@ maybe_multi_buy_offer(Device, PHash) ->
Hotspot :: libp2p_crypto:pubkey_bin()
) -> none_preferred | preferred | not_preferred_hotspot.
check_device_preferred_hotspots(Device, Hotspot) ->
case router_device:preferred_hotspots(Device) of
[] ->
case router_utils:get_env_bool(disable_preferred_hotspot, false) of
true ->
none_preferred;
PreferredHotspots when is_list(PreferredHotspots) ->
case lists:member(Hotspot, PreferredHotspots) of
true ->
preferred;
_ ->
not_preferred_hotspot
false ->
case router_device:preferred_hotspots(Device) of
[] ->
none_preferred;
PreferredHotspots when is_list(PreferredHotspots) ->
case lists:member(Hotspot, PreferredHotspots) of
true ->
preferred;
_ ->
not_preferred_hotspot
end
end
end.

Expand Down
Loading