cmd/lncli: extend the fwdinghistory command with series of utility arguments
The recently added lncli fwdinghistory command allows users to query their node to examine the set of HLTCs that have been forwarded through their node in the past 24 hrs (the default arg). The command also lets users specify a custom time range, however, it accepts this time range is expressed in unix epoch time (uint64). As a result, it's a bit difficult to create custom query ranges manually on the cli. In order to make the API easier to use, we can add a set of utility arguments to the command that don't actually exist in the RPC itself. For example, we can add the following utility arguments:
--num_days=N--num_weeks=N--num_months=N
The command should be extended to parse these new utility arguments, and map them to their corresponding values using the already existing --start_time and --end_time arguments.
-
[ ] Map out the set of utility arguments, taking the examples above as a starting point.
-
[ ] Once the set of arguments have been mapped out, extend the command to translate each possible utility command to the equivalent base
ForwardingHistorycommand.
Would --num_years be another utility argument? Would an alternative way to implement this be instead of the 3 or 4 new utility arguments a timestamp format like T20180528:01:01:01 so that if the T is encountered the remaining string would be interpreted as a timestamp instead of epoch time?
The problem with timestamps is that you have to update them in case you want to run periodically with a rolling window. Also you have to do calculations in your head if you just want the last n days/weeks/months/….
As another alternative, a subset of journalctl's --since option could also be used. This would have the advantage that some people are already familiar with it.
E.g. start with supporting day/s, week/s and month/s from man systemd.time.
lncli fwdinghistory --since "-2 days"
I literally just looked into this myself :)
@jrmillerwork any thoughts on that? Not sure that anyone else will pass by anytime soon, so we could just start with a proposal, I guess…
I think your ideas are correct, especially your pointing out that that the feature might well be invoked periodically in a script. I do not know how these tasks get assigned, if it is just a matter of saying, "I'll do this." To be frank, I think you have a much better chance of doing this right based on the thoughts you have already provided. If this is a feature that has work that can be divided up naturally, I would be very happy to work on it with you if you want to drive; alternatively, I would consider tackling it alone but would appreciate any further thoughts you might have on the feature and/or implementation.
I would like to try this one, initially by adding a "since" argument which takes a value like 2D (or 16H or 5W) and the integer can be negative or positive. If no startTime or endTime is specified, only "since" (maybe "interval" would be a better name) then only a negative value is allowed for "since" and endTime is current time with startTime being set to endTime minus the number of days, etc. If end_time is specified and a negative "since" value is present, then start_time is set to end_time minus the since value -- a specified start_time is ignored. If start_time is specified, end_time is set to start_time plus the since value and end_time if specified is ignored. A positive since value without start_time is an error. This may not be the way to go -- maybe it is an error to specify start_time, end_time AND since. But the usefulness of "since" as jraedisch suggests would be only specifying it and having an easy way for a script to run periodically and provide, for example, the past week's worth of events. I guess also specifying a start_time and +1D would also come in handy.
Accomplished with the current set of params.