diff --git a/congestion/clock.go b/congestion/clock.go new file mode 100644 index 000000000..405fae70f --- /dev/null +++ b/congestion/clock.go @@ -0,0 +1,18 @@ +package congestion + +import "time" + +// A Clock returns the current time +type Clock interface { + Now() time.Time +} + +// DefaultClock implements the Clock interface using the Go stdlib clock. +type DefaultClock struct{} + +var _ Clock = DefaultClock{} + +// Now gets the current time +func (DefaultClock) Now() time.Time { + return time.Now() +} diff --git a/congestion/cubic.go b/congestion/cubic.go index 80e9aa312..c13b98551 100644 --- a/congestion/cubic.go +++ b/congestion/cubic.go @@ -7,11 +7,6 @@ import ( "github.com/lucas-clemente/quic-go/protocol" ) -// A Clock returns the current time -type Clock interface { - Now() time.Time -} - // This cubic implementation is based on the one found in Chromiums's QUIC // implementation, in the files net/quic/congestion_control/cubic.{hh,cc}.