Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add json responses for health endpoints #862

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions components/restapi/core/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@ func configure() error {

routeGroup.GET(api.CoreEndpointNetworkHealth, func(c echo.Context) error {
if deps.RequestHandler.IsNetworkHealthy() {
return c.NoContent(http.StatusOK)
return httpserver.JSONResponse(c, http.StatusOK, &api.NetworkHealthResponse{
IsNetworkHealthy: true,
})
}

return c.NoContent(http.StatusServiceUnavailable)
return httpserver.JSONResponse(c, http.StatusServiceUnavailable, &api.NetworkHealthResponse{
IsNetworkHealthy: false,
})
})

routeGroup.GET(api.CoreEndpointNetworkMetrics, func(c echo.Context) error {
Expand Down
8 changes: 6 additions & 2 deletions components/restapi/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ type RoutesResponse struct {
func setupRoutes() {
deps.Echo.GET(api.RouteHealth, func(c echo.Context) error {
if deps.Protocol.Engines.Main.Get().SyncManager.IsNodeSynced() {
return c.NoContent(http.StatusOK)
return httpserver.JSONResponse(c, http.StatusOK, &api.HealthResponse{
IsHealthy: true,
})
}

return c.NoContent(http.StatusServiceUnavailable)
return httpserver.JSONResponse(c, http.StatusServiceUnavailable, &api.HealthResponse{
IsHealthy: false,
})
})

deps.Echo.GET(api.RouteRoutes, func(c echo.Context) error {
Expand Down
30 changes: 15 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ require (
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/iotaledger/hive.go/ads v0.0.0-20240315104458-b689cbcfddbd
github.com/iotaledger/hive.go/app v0.0.0-20240315104458-b689cbcfddbd
github.com/iotaledger/hive.go/constraints v0.0.0-20240315104458-b689cbcfddbd
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240315104458-b689cbcfddbd
github.com/iotaledger/hive.go/crypto v0.0.0-20240315104458-b689cbcfddbd
github.com/iotaledger/hive.go/constraints v0.0.0-20240320122938-13a946cf3c7a
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240320122938-13a946cf3c7a
github.com/iotaledger/hive.go/crypto v0.0.0-20240320122938-13a946cf3c7a
github.com/iotaledger/hive.go/db v0.0.0-20240315104458-b689cbcfddbd
github.com/iotaledger/hive.go/ds v0.0.0-20240315104458-b689cbcfddbd
github.com/iotaledger/hive.go/ierrors v0.0.0-20240315104458-b689cbcfddbd
github.com/iotaledger/hive.go/ds v0.0.0-20240320122938-13a946cf3c7a
github.com/iotaledger/hive.go/ierrors v0.0.0-20240320122938-13a946cf3c7a
github.com/iotaledger/hive.go/kvstore v0.0.0-20240315104458-b689cbcfddbd
github.com/iotaledger/hive.go/lo v0.0.0-20240315104458-b689cbcfddbd
github.com/iotaledger/hive.go/lo v0.0.0-20240320122938-13a946cf3c7a
github.com/iotaledger/hive.go/log v0.0.0-20240315104458-b689cbcfddbd
github.com/iotaledger/hive.go/runtime v0.0.0-20240315104458-b689cbcfddbd
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240315104458-b689cbcfddbd
github.com/iotaledger/hive.go/runtime v0.0.0-20240320122938-13a946cf3c7a
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240320122938-13a946cf3c7a
github.com/iotaledger/hive.go/sql v0.0.0-20240315104458-b689cbcfddbd
github.com/iotaledger/hive.go/stringify v0.0.0-20240315104458-b689cbcfddbd
github.com/iotaledger/hive.go/stringify v0.0.0-20240320122938-13a946cf3c7a
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240307101848-db58eb9353ec
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022
github.com/iotaledger/iota.go/v4 v4.0.0-20240319114032-b6fcc3585c99
github.com/iotaledger/iota.go/v4 v4.0.0-20240321164059-d61818989ece
github.com/labstack/echo/v4 v4.11.4
github.com/labstack/gommon v0.4.2
github.com/libp2p/go-libp2p v0.33.0
github.com/libp2p/go-libp2p v0.33.1
github.com/libp2p/go-libp2p-kad-dht v0.25.2
github.com/mr-tron/base58 v1.2.0
github.com/multiformats/go-multiaddr v0.12.2
Expand All @@ -41,7 +41,7 @@ require (
github.com/prometheus/client_golang v1.19.0
github.com/sajari/regression v1.0.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.9.0
github.com/zyedidia/generic v1.2.1
go.uber.org/atomic v1.11.0
go.uber.org/dig v1.17.1
Expand Down Expand Up @@ -93,7 +93,7 @@ require (
github.com/huin/goupnp v1.3.0 // indirect
github.com/iancoleman/orderedmap v0.3.0 // indirect
github.com/iotaledger/grocksdb v1.7.5-0.20230220105546-5162e18885c7 // indirect
github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7 // indirect
github.com/iotaledger/iota-crypto-demo v0.0.0-20240320124000-d02f37a4fdff // indirect
github.com/ipfs/boxo v0.18.0 // indirect
github.com/ipfs/go-cid v0.4.1 // indirect
github.com/ipfs/go-datastore v0.6.0 // indirect
Expand Down Expand Up @@ -150,7 +150,7 @@ require (
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pasztorpisti/qs v0.0.0-20171216220353-8d6c33ee906c // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/pelletier/go-toml/v2 v2.2.0 // indirect
github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand All @@ -160,7 +160,7 @@ require (
github.com/prometheus/common v0.50.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/quic-go v0.41.0 // indirect
github.com/quic-go/quic-go v0.42.0 // indirect
github.com/quic-go/webtransport-go v0.6.0 // indirect
github.com/raulk/go-watchdog v1.3.0 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
Expand Down
60 changes: 31 additions & 29 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -293,40 +293,40 @@ github.com/iotaledger/hive.go/ads v0.0.0-20240315104458-b689cbcfddbd h1:VKd76foX
github.com/iotaledger/hive.go/ads v0.0.0-20240315104458-b689cbcfddbd/go.mod h1:tkWq2sJR/vWkbht1BJNIvNP6hJAaRye99wid0A2oU9I=
github.com/iotaledger/hive.go/app v0.0.0-20240315104458-b689cbcfddbd h1:iPJuddZjwPMdUijkonpYKnP+xfaTJCpQr8O5dFiOABw=
github.com/iotaledger/hive.go/app v0.0.0-20240315104458-b689cbcfddbd/go.mod h1:EMUpj6oDb/QSiVpIe5nYwyDKSpO6ue7mdkzmK/VoBn8=
github.com/iotaledger/hive.go/constraints v0.0.0-20240315104458-b689cbcfddbd h1:O35lbQcbEmgycIDWKYzyvnEeN6GcHlx76YknqGPnVPA=
github.com/iotaledger/hive.go/constraints v0.0.0-20240315104458-b689cbcfddbd/go.mod h1:JF7jjkL6tSUOXm23SWadBzBrl7eJk1DQRLc/fNoVZ+o=
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240315104458-b689cbcfddbd h1:Xi7wg5GkOzrV/ogmumiE5kJm0rh62E3fQDY8yG7uTQU=
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240315104458-b689cbcfddbd/go.mod h1:73ODTHUJxAoGUN0InOtuQ29LVq85pDf7GckM9d0ziqo=
github.com/iotaledger/hive.go/crypto v0.0.0-20240315104458-b689cbcfddbd h1:pQQGxs8hJ8CIYA37QVGoOeAEZDBnA/OiH4iGVpwX1kA=
github.com/iotaledger/hive.go/crypto v0.0.0-20240315104458-b689cbcfddbd/go.mod h1:aREIB19gIhSYdY0Hl/37sg1JRH7+j3ajeJxBIQf6mig=
github.com/iotaledger/hive.go/constraints v0.0.0-20240320122938-13a946cf3c7a h1:utdBWBurkt1DyATIR5ciGbU9DzBsv7lsh5O1lIPQvt0=
github.com/iotaledger/hive.go/constraints v0.0.0-20240320122938-13a946cf3c7a/go.mod h1:JF7jjkL6tSUOXm23SWadBzBrl7eJk1DQRLc/fNoVZ+o=
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240320122938-13a946cf3c7a h1:m9dJP6aScnyVi7dKHqr9/MhWbvhsqDYfoDApPEog2Jo=
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240320122938-13a946cf3c7a/go.mod h1:DCIdeNKBJDtkkIBCyixInwFJs6rUv9PFK1U5MEH5hkY=
github.com/iotaledger/hive.go/crypto v0.0.0-20240320122938-13a946cf3c7a h1:61yy+tno2oFxsDHGtoP95S/gPmZWJMuVXYJAoHdbOF0=
github.com/iotaledger/hive.go/crypto v0.0.0-20240320122938-13a946cf3c7a/go.mod h1:Xq2i06mX6g+NlAPMJVicwKx7FHSmIhWVS67dyxup2VU=
github.com/iotaledger/hive.go/db v0.0.0-20240315104458-b689cbcfddbd h1:JMWsW/QODcvOSxiSl3exdH93XGyPVgpnJdNd5EpQr3U=
github.com/iotaledger/hive.go/db v0.0.0-20240315104458-b689cbcfddbd/go.mod h1:8Y5vqE5NK5zG4Af0JV2UQeW67iLlymPLsT1KkOn4qY8=
github.com/iotaledger/hive.go/ds v0.0.0-20240315104458-b689cbcfddbd h1:q7nvD+1SMBX1GjhnlzldAnyyEeFgdBfaeoq3e+qf0mM=
github.com/iotaledger/hive.go/ds v0.0.0-20240315104458-b689cbcfddbd/go.mod h1:wfjeJj9B+MM/3yeUHfvT8Gj8bRsdl9utyh2dZg+1+B0=
github.com/iotaledger/hive.go/ierrors v0.0.0-20240315104458-b689cbcfddbd h1:nvQc2sjO2G3yMiuVWY/iJkyAAHjxgM/2qEZ4wxmXm0s=
github.com/iotaledger/hive.go/ierrors v0.0.0-20240315104458-b689cbcfddbd/go.mod h1:GQY0/35sjgT9Poi1Vrs9kFVvAkuKzGXfVh4j6CBXsAA=
github.com/iotaledger/hive.go/ds v0.0.0-20240320122938-13a946cf3c7a h1:6WKdn9mf4L0p8+QqSziSW0vOEIHLBADHEzVe0yoEwkY=
github.com/iotaledger/hive.go/ds v0.0.0-20240320122938-13a946cf3c7a/go.mod h1:PU8vmnyWDAM7Nbl/j9pRIemNfMEO/vPQ/tN3wks55lE=
github.com/iotaledger/hive.go/ierrors v0.0.0-20240320122938-13a946cf3c7a h1:LkNT/KWU52l/YLQQO9VC+TfOap514Y6AI0LI1EvsDJA=
github.com/iotaledger/hive.go/ierrors v0.0.0-20240320122938-13a946cf3c7a/go.mod h1:GQY0/35sjgT9Poi1Vrs9kFVvAkuKzGXfVh4j6CBXsAA=
github.com/iotaledger/hive.go/kvstore v0.0.0-20240315104458-b689cbcfddbd h1:HegZpJKGZLq0NAE1Tgxs9Y+EHC0mItpyHeodCSYgdEI=
github.com/iotaledger/hive.go/kvstore v0.0.0-20240315104458-b689cbcfddbd/go.mod h1:dCgv8YMOihhGNxQu37Vh5XqT/7wLbIJst2WePqo1z8Y=
github.com/iotaledger/hive.go/lo v0.0.0-20240315104458-b689cbcfddbd h1:bUWLJquwEJXEo93J29R9JsLBHb/d3r++SCuKVhfsNJc=
github.com/iotaledger/hive.go/lo v0.0.0-20240315104458-b689cbcfddbd/go.mod h1:67oLzWYiBLGt5PN7IBVHdbt9P6oBYCx9UvMEL8ExDAc=
github.com/iotaledger/hive.go/lo v0.0.0-20240320122938-13a946cf3c7a h1:OMGfUIguLzYfLVbrMeCH/1q+k+Ddam5klNTxq7WI/DM=
github.com/iotaledger/hive.go/lo v0.0.0-20240320122938-13a946cf3c7a/go.mod h1:V6O70RMPKU1vVN1JqmLbOFeQbR11MmQha9ZboaD3q0Q=
github.com/iotaledger/hive.go/log v0.0.0-20240315104458-b689cbcfddbd h1:AzcvTlArc0zqrC/jyN7jEmsKMAFetsbXp8/ubbcLtsg=
github.com/iotaledger/hive.go/log v0.0.0-20240315104458-b689cbcfddbd/go.mod h1:H5tmswUbT3o5+QiM6UPtBv7VnPf+lJtlantgpp2lzUI=
github.com/iotaledger/hive.go/runtime v0.0.0-20240315104458-b689cbcfddbd h1:+HDX4N/l7geVOZTIICG/6Znrujek+qO2YClXp/ghTAI=
github.com/iotaledger/hive.go/runtime v0.0.0-20240315104458-b689cbcfddbd/go.mod h1:OKoOmZd+qDjm0WsisIB5FYbKhMm5iPx4/mDJL/8SjsU=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240315104458-b689cbcfddbd h1:do82iHBwx14vjJ9VYNK3ZpKxwhb0YQVZKAd4uiqphQ0=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240315104458-b689cbcfddbd/go.mod h1:NK05G4PxwZF1m4jGANJWLhAQ2hP1Nt0L8mgCTFLsSCw=
github.com/iotaledger/hive.go/runtime v0.0.0-20240320122938-13a946cf3c7a h1:Gi3goUvvdETcAcKfikjYRtDQzqzKduRVtIGJHkffudI=
github.com/iotaledger/hive.go/runtime v0.0.0-20240320122938-13a946cf3c7a/go.mod h1:eyKTWoVdSj6RRaaOrDLVnFuaOWUydk88ofEXHb+/Ryo=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240320122938-13a946cf3c7a h1:cPyDaEIjqN43UQLsdVO9Ma3wBj6uY5VXeuSt4SuNeQ8=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240320122938-13a946cf3c7a/go.mod h1:DVwHG6s3mWf/5NXr+CKmLXsqzLZZrhgDR2HE0ti5g7o=
github.com/iotaledger/hive.go/sql v0.0.0-20240315104458-b689cbcfddbd h1:jLUMNfEYZGx41IsXv2jjlKywzqhv0z2F7hzfDTDpbPU=
github.com/iotaledger/hive.go/sql v0.0.0-20240315104458-b689cbcfddbd/go.mod h1:O9R4vLdoSBhEO+WyEEmBHKChlD80oz9EVi7vjuxE+J8=
github.com/iotaledger/hive.go/stringify v0.0.0-20240315104458-b689cbcfddbd h1:pgBMXWsZ2oEoPOSPv4Ycq2Ygy0qt7UNx0B39HhV7Z1E=
github.com/iotaledger/hive.go/stringify v0.0.0-20240315104458-b689cbcfddbd/go.mod h1:O4p7UmsfoeLqtAUwrKbq0lXMxjY/MLQSpZSavvvvGig=
github.com/iotaledger/hive.go/stringify v0.0.0-20240320122938-13a946cf3c7a h1:5C2yVhObYmXJSQyEaepYCf1fG+FZ73WBCB12UGXWiE8=
github.com/iotaledger/hive.go/stringify v0.0.0-20240320122938-13a946cf3c7a/go.mod h1:O4p7UmsfoeLqtAUwrKbq0lXMxjY/MLQSpZSavvvvGig=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240307101848-db58eb9353ec h1:8pasR6AxVTr1AqTbyAgPmrgmEE+Z5Tn4DOQy/Eu8jN8=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240307101848-db58eb9353ec/go.mod h1:LrPLgC2QeGvsgyhS7SYoqH449z4C4ro4HOByg1PXqHw=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022 h1:I178SaWPhSxTvntKKvUVIdeogXIiLDALTbstKvbCuVc=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022/go.mod h1:jTFxIWiMUdAwO263jlJCSWcNLqEkgYEVOFXfjp5aNJM=
github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7 h1:t6k4MqiUov0FrBb2o2JhKlOVSdlPbIQWM8ivYHL0G0g=
github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7/go.mod h1:do+N3LpeDEi9qselEC4XcjqGoRc7cWGiqBtIeBOKEMs=
github.com/iotaledger/iota.go/v4 v4.0.0-20240319114032-b6fcc3585c99 h1:Fs4LqQ8VavnOkv4fRkEex8hVvnnqt1uVSY6R9hocPSU=
github.com/iotaledger/iota.go/v4 v4.0.0-20240319114032-b6fcc3585c99/go.mod h1:8UQOTI7CC5R/3TurawUFuBZbkb37RzW8m4q8Hp7ct30=
github.com/iotaledger/iota-crypto-demo v0.0.0-20240320124000-d02f37a4fdff h1:Do8fakxvFaj7dLckoo/z+mRyBdZo8QvT8HcgnQlG2Sg=
github.com/iotaledger/iota-crypto-demo v0.0.0-20240320124000-d02f37a4fdff/go.mod h1:aVEutEWFnhDNJBxtVuzy2BeTN+8FAlnR83k7hKV0CFE=
github.com/iotaledger/iota.go/v4 v4.0.0-20240321164059-d61818989ece h1:pQPzLYGd7PDG/FhX8v8ptYiGrKZ1o0fbWV9gYjfg8NY=
github.com/iotaledger/iota.go/v4 v4.0.0-20240321164059-d61818989ece/go.mod h1:qn/63CB0/jE1em6ewqDSiz+ovS+E/os7K5b7g2pmJFg=
github.com/ipfs/boxo v0.18.0 h1:MOL9/AgoV3e7jlVMInicaSdbgralfqSsbkc31dZ9tmw=
github.com/ipfs/boxo v0.18.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80=
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=
Expand Down Expand Up @@ -413,8 +413,8 @@ github.com/libp2p/go-cidranger v1.1.0 h1:ewPN8EZ0dd1LSnrtuwd4709PXVcITVeuwbag38y
github.com/libp2p/go-cidranger v1.1.0/go.mod h1:KWZTfSr+r9qEo9OkI9/SIEeAtw+NNoU0dXIXt15Okic=
github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM=
github.com/libp2p/go-flow-metrics v0.1.0/go.mod h1:4Xi8MX8wj5aWNDAZttg6UPmc0ZrnFNsMtpsYUClFtro=
github.com/libp2p/go-libp2p v0.33.0 h1:yTPSr8sJRbfeEYXyeN8VPVSlTlFjtMUwGDRniwaf/xQ=
github.com/libp2p/go-libp2p v0.33.0/go.mod h1:RIJFRQVUBKy82dnW7J5f1homqqv6NcsDJAl3e7CRGfE=
github.com/libp2p/go-libp2p v0.33.1 h1:tvJl9b9M6nSLBtZSXSguq+/lRhRj2oLRkyhBmQNMFLA=
github.com/libp2p/go-libp2p v0.33.1/go.mod h1:zOUTMjG4I7TXwMndNyOBn/CNtVBLlvBlnxfi+8xzx+E=
github.com/libp2p/go-libp2p-asn-util v0.4.1 h1:xqL7++IKD9TBFMgnLPZR6/6iYhawHKHl950SO9L6n94=
github.com/libp2p/go-libp2p-asn-util v0.4.1/go.mod h1:d/NI6XZ9qxw67b4e+NgpQexCIiFYJjErASrYW4PFDN8=
github.com/libp2p/go-libp2p-kad-dht v0.25.2 h1:FOIk9gHoe4YRWXTu8SY9Z1d0RILol0TrtApsMDPjAVQ=
Expand Down Expand Up @@ -552,8 +552,8 @@ github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2D
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y=
github.com/pelletier/go-toml v1.7.0 h1:7utD74fnzVc/cpcyy8sjrlFr5vYpypUixARcHIMIGuI=
github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE=
github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI=
github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pelletier/go-toml/v2 v2.2.0 h1:QLgLl2yMN7N+ruc31VynXs1vhMZa7CeHHejIeBAsoHo=
github.com/pelletier/go-toml/v2 v2.2.0/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o=
github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 h1:jik8PHtAIsPlCRJjJzl4udgEf7hawInF9texMeO2jrU=
github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4=
Expand Down Expand Up @@ -598,8 +598,8 @@ github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
github.com/quic-go/quic-go v0.41.0 h1:aD8MmHfgqTURWNJy48IYFg2OnxwHT3JL7ahGs73lb4k=
github.com/quic-go/quic-go v0.41.0/go.mod h1:qCkNjqczPEvgsOnxZ0eCD14lv+B2LHlFAB++CNOh9hA=
github.com/quic-go/quic-go v0.42.0 h1:uSfdap0eveIl8KXnipv9K7nlwZ5IqLlYOpJ58u5utpM=
github.com/quic-go/quic-go v0.42.0/go.mod h1:132kz4kL3F9vxhW3CtQJLDVwcFe5wdWeJXXijhsO57M=
github.com/quic-go/webtransport-go v0.6.0 h1:CvNsKqc4W2HljHJnoT+rMmbRJybShZ0YPFDD3NxaZLY=
github.com/quic-go/webtransport-go v0.6.0/go.mod h1:9KjU4AEBqEQidGHNDkZrb8CAa1abRaosM2yGOyiikEc=
github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk=
Expand Down Expand Up @@ -665,6 +665,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
Expand All @@ -674,8 +675,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e h1:IWllFTiDjjLIf2oeKxpIUmtiDV5sn71VgeQgg6vcE7k=
github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e/go.mod h1:d7u6HkTYKSv5m6MCKkOQlHwaShTMl3HjqSGW3XtVhXM=
Expand Down
13 changes: 3 additions & 10 deletions pkg/protocol/engine/syncmanager/trivialsyncmanager/syncmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,23 +260,16 @@ func (s *SyncManager) IsNodeSynced() bool {
return s.isSynced
}

func (s *SyncManager) updateIsFinalizationDelayed(latestFinalizedSlot iotago.SlotIndex, latestCommitmentSlot iotago.SlotIndex) (changed bool) {
func (s *SyncManager) updateIsFinalizationDelayed(latestFinalizedSlot iotago.SlotIndex, latestCommitmentSlot iotago.SlotIndex) {
s.isFinalizationDelayedLock.Lock()
defer s.isFinalizationDelayedLock.Unlock()

if latestCommitmentSlot < latestFinalizedSlot {
// This should never happen, but if it does, we don't want to panic.
return false
return
}

isFinalizationDelayed := latestCommitmentSlot-latestFinalizedSlot > s.engine.CommittedAPI().ProtocolParameters().MaxCommittableAge()
if s.isFinalizationDelayed != isFinalizationDelayed {
s.isFinalizationDelayed = isFinalizationDelayed

return true
}

return false
s.isFinalizationDelayed = latestCommitmentSlot-latestFinalizedSlot > s.engine.CommittedAPI().ProtocolParameters().MaxCommittableAge()
}

func (s *SyncManager) IsFinalizationDelayed() bool {
Expand Down
Loading
Loading