-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bump erigon tag * Correct erigon repository * Install erigon using new installation method * Replace missing x86_64 link for nimbus * Update README with erigon version
- Loading branch information
Showing
7 changed files
with
227 additions
and
25 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
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,64 @@ | ||
package common | ||
|
||
import ( | ||
"regexp" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
// https://regexr.com/89qep | ||
var semverExpr = regexp.MustCompile(`^v?\d+(\.\d+){2}$`) | ||
|
||
type Semver struct { | ||
major int | ||
minor int | ||
patch int | ||
} | ||
|
||
func StringToSemver(str string) (semver Semver) { | ||
semver = Semver{ | ||
major: 0, | ||
minor: 0, | ||
patch: 0, | ||
} | ||
|
||
matches := semverExpr.FindAllString(str, -1) | ||
if len(matches) != 1 { | ||
return | ||
} | ||
|
||
// already validated by the regex, conversions and slice accesses won't error/panic | ||
v := strings.Split(strings.Trim(matches[0], "v"), ".") | ||
major, _ := strconv.Atoi(v[0]) | ||
minor, _ := strconv.Atoi(v[1]) | ||
patch, _ := strconv.Atoi(v[2]) | ||
|
||
semver = Semver{ | ||
major: major, | ||
minor: minor, | ||
patch: patch, | ||
} | ||
|
||
return | ||
} | ||
|
||
// IsNewerThan checks whether v1 is a newer version than v2. | ||
// The check is strict (equal values return false) | ||
func (v Semver) IsNewerThan(v2 Semver) (isNewer bool) { | ||
switch { | ||
case v.major > v2.major: | ||
return true | ||
case v.major < v2.major: | ||
return false | ||
case v.minor > v2.minor: | ||
return true | ||
case v.minor < v2.minor: | ||
return false | ||
case v.patch > v2.patch: | ||
return true | ||
case v.patch < v2.patch: | ||
return false | ||
} | ||
|
||
return false | ||
} |
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
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
Oops, something went wrong.