-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89508e2
commit 3310d48
Showing
2 changed files
with
33 additions
and
1 deletion.
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,28 @@ | ||
package upgrades | ||
|
||
var gracePeriods = []*gracePeriod{ | ||
newGracePeriod(1, 120), | ||
} | ||
|
||
func IsGraceBlock(block uint64) bool { | ||
for _, gp := range gracePeriods { | ||
if gp.isApplicable(block) { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} | ||
|
||
type gracePeriod struct { | ||
from uint64 | ||
to uint64 | ||
} | ||
|
||
func (gp *gracePeriod) isApplicable(block uint64) bool { | ||
return block >= gp.from && block <= gp.to | ||
} | ||
|
||
func newGracePeriod(from uint64, to uint64) *gracePeriod { | ||
return &gracePeriod{from: from, to: to} | ||
} |