Skip to content

Commit

Permalink
plugin: Update utils lib and add in the screenshot only the last paym…
Browse files Browse the repository at this point in the history
…ents

Fixes #71

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
  • Loading branch information
vincenzopalazzo committed Dec 4, 2021
1 parent cd246e4 commit 31a704d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/LNOpenMetrics/go-lnmetrics.reporter
go 1.17

require (
github.com/LNOpenMetrics/lnmetrics.utils v0.0.0-20211111065808-b086ef397a1d
github.com/LNOpenMetrics/lnmetrics.utils v0.0.3
github.com/elastic/go-sysinfo v1.7.1
github.com/kinbiko/jsonassert v1.0.2
github.com/robfig/cron/v3 v3.0.1
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ github.com/LNOpenMetrics/lnmetrics.utils v0.0.0-20211109065240-8b2308c6c67a h1:7
github.com/LNOpenMetrics/lnmetrics.utils v0.0.0-20211109065240-8b2308c6c67a/go.mod h1:6PC0XEUljl08AHdHdMQtR2tGJ1o9Jzg8yt7nioTnlE4=
github.com/LNOpenMetrics/lnmetrics.utils v0.0.0-20211111065808-b086ef397a1d h1:C/UZkW5fWKce0gyH7RoxYKJkXdLjJ/r5Lk/GrKLQZgg=
github.com/LNOpenMetrics/lnmetrics.utils v0.0.0-20211111065808-b086ef397a1d/go.mod h1:6PC0XEUljl08AHdHdMQtR2tGJ1o9Jzg8yt7nioTnlE4=
github.com/LNOpenMetrics/lnmetrics.utils v0.0.2 h1:USJE6C1dhiNUjiQ29iQ3MHxxZt9Y0atpt1VZ4M9vJbM=
github.com/LNOpenMetrics/lnmetrics.utils v0.0.2/go.mod h1:6PC0XEUljl08AHdHdMQtR2tGJ1o9Jzg8yt7nioTnlE4=
github.com/LNOpenMetrics/lnmetrics.utils v0.0.3 h1:emd43at2elU8FDAeJhTDNkMF1/cbYR0lFS0iyka34Go=
github.com/LNOpenMetrics/lnmetrics.utils v0.0.3/go.mod h1:6PC0XEUljl08AHdHdMQtR2tGJ1o9Jzg8yt7nioTnlE4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
8 changes: 8 additions & 0 deletions internal/plugin/metrics_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/LNOpenMetrics/lnmetrics.utils/hash/sha256"
"github.com/LNOpenMetrics/lnmetrics.utils/log"
"github.com/LNOpenMetrics/lnmetrics.utils/utime"

sysinfo "github.com/elastic/go-sysinfo/types"
"github.com/vincenzopalazzo/glightning/glightning"
Expand Down Expand Up @@ -736,6 +737,13 @@ func (instance *MetricOne) getChannelInfo(lightning *glightning.Lightning,
}

for _, forward := range listForwards {
receivedTime := utime.FromDecimalUnix(forward.ReceivedTime)
// The duration of 30 minutes are relative to the plugin uptime event,
// however, this can change in the future and can be dynamic.
if !utime.InRangeFromUnix(time.Now().Unix(), receivedTime, 30*time.Minute) {
// If is an old payments
continue
}
paymentInfo := &PaymentInfo{
Direction: ChannelDirections[1],
Status: forward.Status,
Expand Down

0 comments on commit 31a704d

Please sign in to comment.