diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-01-16 17:49:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-16 17:49:17 +0800 |
commit | 2a1a531ba339516a0a8d0abc0e94a30842bb2fd2 (patch) | |
tree | c66639a59702e70e7a67d08c62b2081395bcefc8 /common/hexutil/json.go | |
parent | b5a100b859213dbb7d4545ce53dabab398b4191e (diff) | |
parent | 51f6b6d33f5b50e16f0b04bcccd03ad370f36636 (diff) | |
download | dexon-2a1a531ba339516a0a8d0abc0e94a30842bb2fd2.tar dexon-2a1a531ba339516a0a8d0abc0e94a30842bb2fd2.tar.gz dexon-2a1a531ba339516a0a8d0abc0e94a30842bb2fd2.tar.bz2 dexon-2a1a531ba339516a0a8d0abc0e94a30842bb2fd2.tar.lz dexon-2a1a531ba339516a0a8d0abc0e94a30842bb2fd2.tar.xz dexon-2a1a531ba339516a0a8d0abc0e94a30842bb2fd2.tar.zst dexon-2a1a531ba339516a0a8d0abc0e94a30842bb2fd2.zip |
Merge pull request #3570 from fjl/hexutil-zero-fix
common/hexutil: fix EncodeBig, Big.MarshalJSON
Diffstat (limited to 'common/hexutil/json.go')
-rw-r--r-- | common/hexutil/json.go | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/common/hexutil/json.go b/common/hexutil/json.go index c36d862b5..7e4736dd6 100644 --- a/common/hexutil/json.go +++ b/common/hexutil/json.go @@ -109,13 +109,8 @@ func (b *Big) MarshalJSON() ([]byte, error) { if nbits == 0 { return jsonZero, nil } - enc := make([]byte, 3, (nbits/8)*2+4) - copy(enc, `"0x`) - for i := len(bigint.Bits()) - 1; i >= 0; i-- { - enc = strconv.AppendUint(enc, uint64(bigint.Bits()[i]), 16) - } - enc = append(enc, '"') - return enc, nil + enc := fmt.Sprintf(`"0x%x"`, bigint) + return []byte(enc), nil } // UnmarshalJSON implements json.Unmarshaler. |