From 35214d8decc334d86fc9ed7b62a50e85cf5436bc Mon Sep 17 00:00:00 2001 From: Kiel barry Date: Thu, 31 May 2018 15:26:49 -0700 Subject: [PATCH 1/2] common: all golint warnings removed --- common/hexutil/hexutil.go | 1 + common/math/big.go | 2 ++ common/math/integer.go | 2 +- common/mclock/mclock.go | 4 +++- common/number/int.go | 9 +++++---- common/types.go | 1 + 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/common/hexutil/hexutil.go b/common/hexutil/hexutil.go index 02c488a3f178..e80be278b2fb 100644 --- a/common/hexutil/hexutil.go +++ b/common/hexutil/hexutil.go @@ -39,6 +39,7 @@ import ( const uintBits = 32 << (uint64(^uint(0)) >> 63) +// Variables that specify custom error messages. var ( ErrEmptyString = &decError{"empty hex string"} ErrSyntax = &decError{"invalid hex string"} diff --git a/common/math/big.go b/common/math/big.go index dbf2770a94f5..ac61381a9a90 100644 --- a/common/math/big.go +++ b/common/math/big.go @@ -22,6 +22,8 @@ import ( "math/big" ) +// Variables allocated a new Int set used to find complement numbers +// and bound maximum byte lengths. var ( tt255 = BigPow(2, 255) tt256 = BigPow(2, 256) diff --git a/common/math/integer.go b/common/math/integer.go index 7eff4d3b0001..93b1d036ddbb 100644 --- a/common/math/integer.go +++ b/common/math/integer.go @@ -21,8 +21,8 @@ import ( "strconv" ) +// Integer limit values. const ( - // Integer limit values. MaxInt8 = 1<<7 - 1 MinInt8 = -1 << 7 MaxInt16 = 1<<15 - 1 diff --git a/common/mclock/mclock.go b/common/mclock/mclock.go index 92005252eb8a..3425364b6bcb 100644 --- a/common/mclock/mclock.go +++ b/common/mclock/mclock.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see . -// package mclock is a wrapper for a monotonic clock source +// Package mclock is a wrapper for a monotonic clock source package mclock import ( @@ -23,8 +23,10 @@ import ( "github.com/aristanetworks/goarista/monotime" ) +// AbsTime will convert an integer number of units to a Duration in hours. type AbsTime time.Duration // absolute monotonic time +// Now returns the current time, as a Duration, in nanoseconds from a monotonic clock func Now() AbsTime { return AbsTime(monotime.Now()) } diff --git a/common/number/int.go b/common/number/int.go index 5b50669703e2..0cac94254a05 100644 --- a/common/number/int.go +++ b/common/number/int.go @@ -22,9 +22,11 @@ import ( "github.com/ethereum/go-ethereum/common" ) -var tt256 = new(big.Int).Lsh(big.NewInt(1), 256) -var tt256m1 = new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(1)) -var tt255 = new(big.Int).Lsh(big.NewInt(1), 255) +var ( + tt256 = new(big.Int).Lsh(big.NewInt(1), 256) + tt256m1 = new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(1)) + tt255 = new(big.Int).Lsh(big.NewInt(1), 255) +) func limitUnsigned256(x *Number) *Number { x.num.And(x.num, tt256m1) @@ -181,7 +183,6 @@ func (i *Number) FirstBitSet() int { } // Variables - var ( Zero = Uint(0) One = Uint(1) diff --git a/common/types.go b/common/types.go index 12c26d94bcfc..4e94da87608b 100644 --- a/common/types.go +++ b/common/types.go @@ -29,6 +29,7 @@ import ( "github.com/ethereum/go-ethereum/crypto/sha3" ) +// Const expresses the required byte length for hashes and addresses. const ( HashLength = 32 AddressLength = 20 From f1ec95b87bcae91ecd3c5acc9fb4a44d57c6a7ab Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 14 Jun 2018 11:13:37 +0200 Subject: [PATCH 2/2] common: fixups --- common/hexutil/hexutil.go | 2 +- common/math/big.go | 5 ++--- common/mclock/mclock.go | 6 +++--- common/types.go | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/common/hexutil/hexutil.go b/common/hexutil/hexutil.go index e80be278b2fb..46223a2815a2 100644 --- a/common/hexutil/hexutil.go +++ b/common/hexutil/hexutil.go @@ -39,7 +39,7 @@ import ( const uintBits = 32 << (uint64(^uint(0)) >> 63) -// Variables that specify custom error messages. +// Errors var ( ErrEmptyString = &decError{"empty hex string"} ErrSyntax = &decError{"invalid hex string"} diff --git a/common/math/big.go b/common/math/big.go index ac61381a9a90..9d2e7946d155 100644 --- a/common/math/big.go +++ b/common/math/big.go @@ -22,14 +22,13 @@ import ( "math/big" ) -// Variables allocated a new Int set used to find complement numbers -// and bound maximum byte lengths. +// Various big integer limit values. var ( tt255 = BigPow(2, 255) tt256 = BigPow(2, 256) tt256m1 = new(big.Int).Sub(tt256, big.NewInt(1)) - MaxBig256 = new(big.Int).Set(tt256m1) tt63 = BigPow(2, 63) + MaxBig256 = new(big.Int).Set(tt256m1) MaxBig63 = new(big.Int).Sub(tt63, big.NewInt(1)) ) diff --git a/common/mclock/mclock.go b/common/mclock/mclock.go index 3425364b6bcb..02608d17b0be 100644 --- a/common/mclock/mclock.go +++ b/common/mclock/mclock.go @@ -23,10 +23,10 @@ import ( "github.com/aristanetworks/goarista/monotime" ) -// AbsTime will convert an integer number of units to a Duration in hours. -type AbsTime time.Duration // absolute monotonic time +// AbsTime represents absolute monotonic time. +type AbsTime time.Duration -// Now returns the current time, as a Duration, in nanoseconds from a monotonic clock +// Now returns the current absolute monotonic time. func Now() AbsTime { return AbsTime(monotime.Now()) } diff --git a/common/types.go b/common/types.go index 4e94da87608b..4d374ad246b4 100644 --- a/common/types.go +++ b/common/types.go @@ -29,7 +29,7 @@ import ( "github.com/ethereum/go-ethereum/crypto/sha3" ) -// Const expresses the required byte length for hashes and addresses. +// Lengths of hashes and addresses in bytes. const ( HashLength = 32 AddressLength = 20