-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
timer: move Timer inteface to
dbft
package
Store Timer interface along with other dBFT interfaces and provide default timer implementation in `timer` package. Create `dbft.HV` interface and configuration for its customisation. Provide default implementation of `dbft.HV` in `timer` package. A part of #84. Signed-off-by: Anna Shaleva <[email protected]>
- Loading branch information
1 parent
32e1df2
commit f1519e9
Showing
8 changed files
with
147 additions
and
88 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
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,30 @@ | ||
package dbft | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
// Timer is an interface which implements all time-related | ||
// functions. It can be mocked for testing. | ||
type Timer interface { | ||
// Now returns current time. | ||
Now() time.Time | ||
// Reset resets timer to the specified block height and view. | ||
Reset(hv HV, d time.Duration) | ||
// Sleep stops execution for duration d. | ||
Sleep(d time.Duration) | ||
// Extend extends current timer with duration d. | ||
Extend(d time.Duration) | ||
// Stop stops timer. | ||
Stop() | ||
// HV returns current height and view set for the timer. | ||
HV() HV | ||
// C returns channel for timer events. | ||
C() <-chan time.Time | ||
} | ||
|
||
// HV is an abstraction for pair of a Height and a View. | ||
type HV interface { | ||
Height() uint32 | ||
View() byte | ||
} |
Oops, something went wrong.