fixing import cycle

This commit is contained in:
lmittmann 2019-01-06 18:12:23 +01:00
parent fe0d2bab52
commit 46e4fe4d82
2 changed files with 2 additions and 16 deletions

View file

@ -22,8 +22,6 @@ import (
"regexp"
"strings"
"time"
"github.com/ethereum/go-ethereum/params"
)
// PrettyDuration is a pretty printed version of a time.Duration value that cuts
@ -86,12 +84,12 @@ func (t PrettyAge) String() string {
// ToGWei converts the big.Int wei to its gwei string representation.
func ToGWei(wei *big.Int) string {
return ToEth(new(big.Int).Mul(wei, big.NewInt(params.GWei)))
return ToEth(new(big.Int).Mul(wei, big.NewInt(1e9)))
}
// ToEth converts the big.Int wei to its ether string representation.
func ToEth(wei *big.Int) string {
z, m := new(big.Int).DivMod(wei, big.NewInt(params.Ether), new(big.Int))
z, m := new(big.Int).DivMod(wei, big.NewInt(1e18), new(big.Int))
if m.Cmp(new(big.Int)) == 0 {
return z.String()
}

View file

@ -52,15 +52,3 @@ func TestToEth(t *testing.T) {
}
}
}
func BenchmarkToEth(b *testing.B) {
for n := 0; n < b.N; n++ {
ToEth(big.NewInt(1))
}
}
func BenchmarkToEth2(b *testing.B) {
for n := 0; n < b.N; n++ {
ToEth(big.NewInt(1000000000000000000))
}
}