NUT-08 dynamic output count log(0)
callebtc opened this issue ยท 5 comments
If the fee reserve is 0 sat
, the log will fail. Therefore
def calculate_number_of_blank_outputs(fee_reserve_sat: int):
assert fee_reserve_sat >= 0, "Fee reserve can't be negative."
if fee_reserve_sat == 0:
return 0
return max(math.ceil(math.log2(fee_reserve_sat)), 1)
The code in cashu-ts runs as per protocol, but it is not so straight forward to follow why. I think it would make sense to implement it in the way @callebtc proposed.
Right now:
0 -> -Infinity
this works because -infinity will be smaller than 0 and we won't enter the loop. So 0 messages get created
1 -> 0
which equates to falsy and thus we return 1 and create one message
changing to the code proposed would make it easier to understand what's happening
A Test with 0 Fee
Line 162 in 126013a
changing to the code proposed would make it easier to understand what's happening
We have a test and its works soo.... ๐๐
changing to the code proposed would make it easier to understand what's happening
We have a test and its works soo.... ๐๐
Never argue with JS! ๐ซจ
changing to the code proposed would make it easier to understand what's happening
We have a test and its works soo.... ๐๐
Never argue with JS! ๐ซจ
Never argue with my tests