Skip to content

Commit

Permalink
Fix charge_when_no_offer (#717)
Browse files Browse the repository at this point in the history
* Fix charge_when_no_offer

* Fix status badge
  • Loading branch information
macpie authored May 2, 2022
1 parent 711e7a6 commit 3d50ac3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Helium Router [![Tests](https://github.com/helium/router/actions/workflows/main.yml/badge.svg)](https://github.com/helium/router/actions/workflows/main.yml)
# Helium Router [![Tests](https://github.com/helium/router/actions/workflows/tests.yml/badge.svg)](https://github.com/helium/router/actions/workflows/tests.yml)

Helium's LoRa Network Server (LNS) backend.

Expand Down
10 changes: 9 additions & 1 deletion src/device/router_device_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,7 @@ validate_frame_(Packet, PubKeyBin, HotspotRegion, Device0, OfferCache, Blockchai
maybe_charge(Device, PayloadSize, Blockchain, PubKeyBin, PHash, OfferCache) ->
case maps:get({PubKeyBin, PHash}, OfferCache, undefined) of
undefined ->
case application:get_env(router, charge_when_no_offer, true) of
case charge_when_no_offer() of
false ->
Metadata = router_device:metadata(Device),
{Balance, Nonce} =
Expand All @@ -1587,6 +1587,14 @@ maybe_charge(Device, PayloadSize, Blockchain, PubKeyBin, PHash, OfferCache) ->
router_console_dc_tracker:charge(Device, PayloadSize, Blockchain)
end.

-spec charge_when_no_offer() -> boolean().
charge_when_no_offer() ->
case application:get_env(router, charge_when_no_offer, true) of
"true" -> true;
true -> true;
_ -> false
end.

%%%-------------------------------------------------------------------
%% @doc
%% Check device's message queue to potentially wait or send reply
Expand Down

0 comments on commit 3d50ac3

Please sign in to comment.