Skip to content

Commit

Permalink
Merge pull request #186 from NodeFactoryIo/dev
Browse files Browse the repository at this point in the history
Release v0.5.1
  • Loading branch information
mpetrunic committed Jan 25, 2021
2 parents 32a95c6 + 208f656 commit 09a85cb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.5.0
version=0.5.1
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
# Changelog

## [unreleased]((https://github.com/NodeFactoryIo/vedran/tree/HEAD))
[Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.5.0...HEAD)
[Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.5.1...HEAD)

### Added

### Fix

### Changed

## [v0.5.1]((https://github.com/NodeFactoryIo/vedran/tree/v0.5.1))
[Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.5.0...v0.5.1)

### Added

### Fix
- Add buffer for target block metric [\#184](https://github.com/NodeFactoryIo/vedran/pull/184) ([MakMuftic](https://github.com/MakMuftic))

### Changed

## [v0.5.0]((https://github.com/NodeFactoryIo/vedran/tree/v0.5.0))
[Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.4.3...v0.5.0)
Expand Down
2 changes: 1 addition & 1 deletion cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var startCmd = &cobra.Command{
PreRunE: func(cmd *cobra.Command, args []string) error {
DisplayBanner()
// create root dir
if _, err := os.Stat(rootDir); os.IsNotExist(err) {
if _, err := os.Stat(rootDir); os.IsNotExist(err) && rootDir != "" {
err = os.Mkdir(rootDir, 0700)
if err != nil {
log.Fatal("Unable to create root dir ", err)
Expand Down
7 changes: 4 additions & 3 deletions internal/active/active.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
const (
IntervalFromLastPing = 10 * time.Second
AllowedBlocksBehind = 10
TargetBlockBuffer = 10
)

// CheckIfNodeActive checks if nodes last recorded ping is in last IntervalFromLastPing and if nodes last recorded
Expand Down Expand Up @@ -52,18 +53,19 @@ func CheckIfMetricsValid(nodeID string, repos *repositories.Repos) (bool, error)
return false, err
}
// check if node synced
if metrics.BestBlockHeight != metrics.TargetBlockHeight {
if (metrics.BestBlockHeight + TargetBlockBuffer) < metrics.TargetBlockHeight {
log.Debugf(
"Node %s not synced. Best block: %d, Target block: %d",
nodeID, metrics.BestBlockHeight, metrics.TargetBlockHeight,
)
return false, nil
}

// get best metrics from pool of nodes
latestBlockMetrics, err := repos.MetricsRepo.GetLatestBlockMetrics()
if err != nil {
return false, err
}
// check if node falling behind
if metrics.BestBlockHeight <= (latestBlockMetrics.BestBlockHeight-AllowedBlocksBehind) ||
metrics.FinalizedBlockHeight <= (latestBlockMetrics.FinalizedBlockHeight-AllowedBlocksBehind) {
log.Debugf(
Expand All @@ -76,7 +78,6 @@ func CheckIfMetricsValid(nodeID string, repos *repositories.Repos) (bool, error)
)
return false, nil
}

return true, nil
}

Expand Down

0 comments on commit 09a85cb

Please sign in to comment.