mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-26 13:40:05 +00:00
31 lines
698 B
Go
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)
|
||
|
}
|