mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
fixing import cycle
This commit is contained in:
parent
fe0d2bab52
commit
46e4fe4d82
2 changed files with 2 additions and 16 deletions
|
|
@ -22,8 +22,6 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/params"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// PrettyDuration is a pretty printed version of a time.Duration value that cuts
|
// 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.
|
// ToGWei converts the big.Int wei to its gwei string representation.
|
||||||
func ToGWei(wei *big.Int) string {
|
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.
|
// ToEth converts the big.Int wei to its ether string representation.
|
||||||
func ToEth(wei *big.Int) string {
|
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 {
|
if m.Cmp(new(big.Int)) == 0 {
|
||||||
return z.String()
|
return z.String()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue