Documentation ¶
Index ¶
Constants ¶
const DefaultEpochDuration = builtin.EpochDurationSeconds * time.Second
DefaultEpochDuration is the default duration of epochs
const DefaultPropagationDelay = 6 * time.Second
DefaultPropagationDelay is the default time to await for blocks to arrive before mining
Variables ¶
This section is empty.
Functions ¶
func NewFakeChain ¶
Creates a new fake clock and chain clock wrapping it.
Types ¶
type ChainEpochClock ¶
type ChainEpochClock interface { EpochDuration() time.Duration EpochAtTime(t time.Time) abi.ChainEpoch EpochRangeAtTimestamp(t uint64) (abi.ChainEpoch, abi.ChainEpoch) StartTimeOfEpoch(e abi.ChainEpoch) time.Time WaitForEpoch(ctx context.Context, e abi.ChainEpoch) WaitNextEpoch(ctx context.Context) abi.ChainEpoch Clock }
ChainEpochClock is an interface for a clock that represents epochs of the protocol.
func NewChainClock ¶
func NewChainClock(genesisTime uint64, blockTime time.Duration) ChainEpochClock
NewChainClock returns a ChainEpochClock wrapping a default clock.Clock
func NewChainClockFromClock ¶
func NewChainClockFromClock(genesisSeconds uint64, blockTime time.Duration, c Clock) ChainEpochClock
NewChainClockFromClock returns a ChainEpochClock wrapping the provided clock.Clock
type Clock ¶
type Clock interface { After(d time.Duration) <-chan time.Time Sleep(d time.Duration) Now() time.Time Since(t time.Time) time.Duration NewTicker(d time.Duration) Ticker NewTimer(d time.Duration) Timer AfterFunc(d time.Duration, f func()) Timer }
Clock provides an interface that packages can use instead of directly using the time module, so that chronology-related behavior can be tested Adapted from: https://github.com/jonboulle/clockwork
func NewSystemClock ¶
func NewSystemClock() Clock
NewSystemClock returns a Clock that delegates calls to the actual time package; it should be used by packages in production.
type Fake ¶
type Fake interface { Clock // Advance advances the Fake to a new point in time, ensuring any existing // sleepers are notified appropriately before returning Advance(d time.Duration) // BlockUntil will block until the Fake has the given number of // sleepers (callers of Sleep or After) BlockUntil(n int) }
Fake provides an interface for a clock which can be manually advanced. Adapted from: https://github.com/jonboulle/clockwork
type Ticker ¶
Ticker provides an interface which can be used instead of directly using the ticker within the time module. The real-time ticker t provides ticks through t.C which becomes now t.Chan() to make this channel requirement definable in this interface. Adapted from: https://github.com/jonboulle/clockwork