Skip to content

Commit f26c19c

Browse files
authored
common/mclock: remove dependency on github.com/aristanetworks/goarista (ethereum#22211)
It takes three lines of code to get to runtime.nanotime, no need to pull a dependency for that.
1 parent 9e1bd0f commit f26c19c

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

common/mclock/mclock.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,19 @@ package mclock
2020
import (
2121
"time"
2222

23-
"github.com/aristanetworks/goarista/monotime"
23+
_ "unsafe" // for go:linkname
2424
)
2525

26+
//go:noescape
27+
//go:linkname nanotime runtime.nanotime
28+
func nanotime() int64
29+
2630
// AbsTime represents absolute monotonic time.
27-
type AbsTime time.Duration
31+
type AbsTime int64
2832

2933
// Now returns the current absolute monotonic time.
3034
func Now() AbsTime {
31-
return AbsTime(monotime.Now())
35+
return AbsTime(nanotime())
3236
}
3337

3438
// Add returns t + d as absolute time.
@@ -74,7 +78,7 @@ type System struct{}
7478

7579
// Now returns the current monotonic time.
7680
func (c System) Now() AbsTime {
77-
return AbsTime(monotime.Now())
81+
return Now()
7882
}
7983

8084
// Sleep blocks for the given duration.

common/mclock/mclock.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// This file exists in order to be able to use go:linkname.

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ require (
88
github.com/Azure/go-autorest/autorest/adal v0.8.0 // indirect
99
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
1010
github.com/VictoriaMetrics/fastcache v1.5.7
11-
github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847
1211
github.com/aws/aws-sdk-go v1.25.48
1312
github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6
1413
github.com/cespare/cp v0.1.0

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy
2929
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
3030
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
3131
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
32-
github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847 h1:rtI0fD4oG/8eVokGVPYJEW1F88p1ZNgXiEIs9thEE4A=
33-
github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847/go.mod h1:D/tb0zPVXnP7fmsLZjtdUhSsumbK/ij54UXjjVgMGxQ=
3432
github.com/aws/aws-sdk-go v1.25.48 h1:J82DYDGZHOKHdhx6hD24Tm30c2C3GchYGfN0mf9iKUk=
3533
github.com/aws/aws-sdk-go v1.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
3634
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=

0 commit comments

Comments
 (0)