erigon-pulse/gointerfaces/version.go
Alex Sharov 14c15cba43
Check version of remote services (#1989)
* save

* save

* Squashed 'interfaces/' content from commit 08c32a09e

git-subtree-dir: interfaces
git-subtree-split: 08c32a09e40b1e6fcb5922e723191c9477545356

* Revert "Squashed 'interfaces/' content from commit 08c32a09e"

This reverts commit 8393d9fd

* save

* seve

* Squashed 'interfaces/' content from commit dd6a42724

git-subtree-dir: interfaces
git-subtree-split: dd6a42724401f34c21662ca1aa1718effb92320d

* ensure versions compatibility of all remote services

* Revert "Squashed 'interfaces/' content from commit dd6a42724"

This reverts commit 2a764bf9

* Squashed 'interfaces/' content from commit dd6a42724

git-subtree-dir: interfaces
git-subtree-split: dd6a42724401f34c21662ca1aa1718effb92320d

* Revert "Squashed 'interfaces/' content from commit dd6a42724"

This reverts commit 52621846

* Squashed 'interfaces/' content from commit dd6a42724

git-subtree-dir: interfaces
git-subtree-split: dd6a42724401f34c21662ca1aa1718effb92320d

* a

* a

* a

* a

* a

Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
2021-05-22 11:00:13 +01:00

31 lines
698 B
Go

package gointerfaces
import (
"fmt"
"github.com/ledgerwatch/erigon/gointerfaces/types"
)
type Version struct {
Major, Minor, Patch uint32 // interface Version of the client - to perform compatibility check when opening
}
func VersionFromProto(r *types.VersionReply) Version {
return Version{Major: r.Major, Minor: r.Minor, Patch: r.Patch}
}
// EnsureVersion - Default policy: allow only patch difference
func EnsureVersion(local Version, remote *types.VersionReply) bool {
if remote.Major != local.Major {
return false
}
if remote.Minor != local.Minor {
return false
}
return true
}
func (v Version) String() string {
return fmt.Sprintf("%d.%d.%d", v.Major, v.Minor, v.Patch)
}