plugeth/common/common.go

35 lines
734 B
Go
Raw Normal View History

2015-03-16 10:27:38 +00:00
package common
2014-02-25 10:20:24 +00:00
import (
"fmt"
"math/big"
2014-07-14 13:24:38 +00:00
"runtime"
"time"
2014-02-25 10:20:24 +00:00
)
2015-03-11 19:29:07 +00:00
// MakeName creates a node name that follows the ethereum convention
// for such names. It adds the operation system name and Go runtime version
// the name.
func MakeName(name, version string) string {
return fmt.Sprintf("%s/v%s/%s/%s", name, version, runtime.GOOS, runtime.Version())
}
// Common big integers often used
var (
Big1 = big.NewInt(1)
Big2 = big.NewInt(2)
2014-10-27 10:44:16 +00:00
Big3 = big.NewInt(3)
Big0 = big.NewInt(0)
BigTrue = Big1
BigFalse = Big0
Big32 = big.NewInt(32)
Big256 = big.NewInt(0xff)
2015-01-12 23:25:45 +00:00
Big257 = big.NewInt(257)
)
func Bench(pre string, cb func()) {
start := time.Now()
cb()
fmt.Println(pre, ": took:", time.Since(start))
}