rpcserver: ForwardingHistory end_time defaults to time.Now()
In this commit we change the default behavior of end_time when calling ForwardingHistory. end_time now defaults to time.Now()
This commit is contained in:
parent
0e28ecd616
commit
d9179bee91
@ -3514,8 +3514,9 @@ var forwardingHistoryCommand = cli.Command{
|
|||||||
Query the HTLC switch's internal forwarding log for all completed
|
Query the HTLC switch's internal forwarding log for all completed
|
||||||
payment circuits (HTLCs) over a particular time range (--start_time and
|
payment circuits (HTLCs) over a particular time range (--start_time and
|
||||||
--end_time). The start and end times are meant to be expressed in
|
--end_time). The start and end times are meant to be expressed in
|
||||||
seconds since the Unix epoch. If a start and end time aren't provided,
|
seconds since the Unix epoch. If --start_time isn't provided,
|
||||||
then events over the past 24 hours are queried for.
|
then 24 hours ago is used. If --end_time isn't provided,
|
||||||
|
then the current time is used.
|
||||||
|
|
||||||
The max number of events returned is 50k. The default number is 100,
|
The max number of events returned is 50k. The default number is 100,
|
||||||
callers can use the --max_events param to modify this value.
|
callers can use the --max_events param to modify this value.
|
||||||
|
15
rpcserver.go
15
rpcserver.go
@ -4600,14 +4600,19 @@ func (r *rpcServer) ForwardingHistory(ctx context.Context,
|
|||||||
numEvents uint32
|
numEvents uint32
|
||||||
)
|
)
|
||||||
|
|
||||||
// If the start and end time were not set, then we'll just return the
|
// If the start time wasn't specified, we'll default to 24 hours ago.
|
||||||
// records over the past 24 hours.
|
if req.StartTime == 0 {
|
||||||
if req.StartTime == 0 && req.EndTime == 0 {
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
startTime = now.Add(-time.Hour * 24)
|
startTime = now.Add(-time.Hour * 24)
|
||||||
endTime = now
|
|
||||||
} else {
|
} else {
|
||||||
startTime = time.Unix(int64(req.StartTime), 0)
|
startTime = time.Unix(int64(req.StartTime), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the end time wasn't specified, assume a default end time of now.
|
||||||
|
if req.EndTime == 0 {
|
||||||
|
now := time.Now()
|
||||||
|
endTime = now
|
||||||
|
} else {
|
||||||
endTime = time.Unix(int64(req.EndTime), 0)
|
endTime = time.Unix(int64(req.EndTime), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4618,7 +4623,7 @@ func (r *rpcServer) ForwardingHistory(ctx context.Context,
|
|||||||
numEvents = 100
|
numEvents = 100
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next, we'll map the proto request into a format the is understood by
|
// Next, we'll map the proto request into a format that is understood by
|
||||||
// the forwarding log.
|
// the forwarding log.
|
||||||
eventQuery := channeldb.ForwardingEventQuery{
|
eventQuery := channeldb.ForwardingEventQuery{
|
||||||
StartTime: startTime,
|
StartTime: startTime,
|
||||||
|
Loading…
Reference in New Issue
Block a user