diff options
author | Maran <maran.hidskes@gmail.com> | 2015-03-16 22:17:19 +0800 |
---|---|---|
committer | Maran <maran.hidskes@gmail.com> | 2015-03-16 23:56:11 +0800 |
commit | 7330c97b5b00255db9dc1ffaff942992f80fb7d1 (patch) | |
tree | ad189e91b7ea84221944349b06b8265dc66fc757 /common | |
parent | 22893b7ac925c49168c119f293ea8befc3aff5cc (diff) | |
download | dexon-7330c97b5b00255db9dc1ffaff942992f80fb7d1.tar.gz dexon-7330c97b5b00255db9dc1ffaff942992f80fb7d1.tar.zst dexon-7330c97b5b00255db9dc1ffaff942992f80fb7d1.zip |
DRY up the use of toHex in the project and move it to common
Diffstat (limited to 'common')
-rw-r--r-- | common/common.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/common/common.go b/common/common.go index 1371d18d4..155bb5c2a 100644 --- a/common/common.go +++ b/common/common.go @@ -65,6 +65,15 @@ func DefaultDataDir() string { } } +func ToHex(b []byte) string { + hex := Bytes2Hex(b) + // Prefer output of "0x0" instead of "0x" + if len(hex) == 0 { + hex = "0" + } + return "0x" + hex +} + func FromHex(s string) []byte { if len(s) > 1 { if s[0:2] == "0x" { |