diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-03-18 04:31:42 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-03-18 04:31:42 +0800 |
commit | 3ea99f989ff98432cbfa864d2e7e26628e16cc6f (patch) | |
tree | 45dfc571907fcfc36e415ac3d0f706ef462f1030 /common | |
parent | 048d4ec5be5352dcb06f5123e3458b99aa151e6b (diff) | |
parent | 7330c97b5b00255db9dc1ffaff942992f80fb7d1 (diff) | |
download | dexon-3ea99f989ff98432cbfa864d2e7e26628e16cc6f.tar dexon-3ea99f989ff98432cbfa864d2e7e26628e16cc6f.tar.gz dexon-3ea99f989ff98432cbfa864d2e7e26628e16cc6f.tar.bz2 dexon-3ea99f989ff98432cbfa864d2e7e26628e16cc6f.tar.lz dexon-3ea99f989ff98432cbfa864d2e7e26628e16cc6f.tar.xz dexon-3ea99f989ff98432cbfa864d2e7e26628e16cc6f.tar.zst dexon-3ea99f989ff98432cbfa864d2e7e26628e16cc6f.zip |
Merge pull request #498 from maran/feature/drytoHex
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" { |