-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Chia-Network/dns-intro-time-threshold
- Loading branch information
Showing
3 changed files
with
59 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package healthcheck | ||
|
||
import ( | ||
"encoding/json" | ||
"net/http" | ||
"time" | ||
|
||
log "github.com/sirupsen/logrus" | ||
|
||
"github.com/chia-network/go-chia-libs/pkg/types" | ||
) | ||
|
||
func (h *Healthcheck) fullNodeReceive(resp *types.WebsocketResponse) { | ||
var blockHeight uint32 | ||
|
||
if resp.Command != "get_blockchain_state" { | ||
return | ||
} | ||
|
||
block := &types.WebsocketBlockchainState{} | ||
err := json.Unmarshal(resp.Data, block) | ||
if err != nil { | ||
log.Errorf("Error unmarshalling: %s\n", err.Error()) | ||
return | ||
} | ||
blockHeight = block.BlockchainState.Peak.OrEmpty().Height | ||
|
||
// Edge case, but we should be sure block height is increasing | ||
if blockHeight <= h.lastHeight { | ||
return | ||
} | ||
|
||
h.lastHeight = blockHeight | ||
h.lastHeightTime = time.Now() | ||
} | ||
|
||
// Healthcheck endpoint for the full node service as a whole | ||
func (h *Healthcheck) fullNodeHealthcheck() func(http.ResponseWriter, *http.Request) { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
timeMetricHealthcheckHelper(h.lastHeightTime, w, r) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters