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 /rpc/util.go | |
parent | 048d4ec5be5352dcb06f5123e3458b99aa151e6b (diff) | |
parent | 7330c97b5b00255db9dc1ffaff942992f80fb7d1 (diff) | |
download | dexon-3ea99f989ff98432cbfa864d2e7e26628e16cc6f.tar.gz 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 'rpc/util.go')
-rw-r--r-- | rpc/util.go | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/rpc/util.go b/rpc/util.go index e5610dc2c..9de8311d6 100644 --- a/rpc/util.go +++ b/rpc/util.go @@ -124,17 +124,8 @@ func (self JsonWrapper) ParseRequestBody(req *http.Request) (RpcRequest, error) return reqParsed, nil } -func toHex(b []byte) string { - hex := common.Bytes2Hex(b) - // Prefer output of "0x0" instead of "0x" - if len(hex) == 0 { - hex = "0" - } - return "0x" + hex -} - func i2hex(n int) string { - return toHex(big.NewInt(int64(n)).Bytes()) + return common.ToHex(big.NewInt(int64(n)).Bytes()) } type RpcServer interface { @@ -155,11 +146,11 @@ func toLogs(logs state.Logs) (ls []Log) { for i, log := range logs { var l Log l.Topic = make([]string, len(log.Topics())) - l.Address = toHex(log.Address()) - l.Data = toHex(log.Data()) + l.Address = common.ToHex(log.Address()) + l.Data = common.ToHex(log.Data()) l.Number = log.Number() for j, topic := range log.Topics() { - l.Topic[j] = toHex(topic) + l.Topic[j] = common.ToHex(topic) } ls[i] = l } |