diff options
author | johnliu-dexon <42129254+johnliu-dexon@users.noreply.github.com> | 2019-01-17 16:37:15 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 13:50:01 +0800 |
commit | bc54f0f039f2844e9da001a868f25825781a4e9e (patch) | |
tree | 896708de190fbb4efd5b3a4ff5a33ccb94a8eaf1 /common/big.go | |
parent | e8c66fe79346896e9c802d7ba750ffbcf742b444 (diff) | |
download | dexon-bc54f0f039f2844e9da001a868f25825781a4e9e.tar dexon-bc54f0f039f2844e9da001a868f25825781a4e9e.tar.gz dexon-bc54f0f039f2844e9da001a868f25825781a4e9e.tar.bz2 dexon-bc54f0f039f2844e9da001a868f25825781a4e9e.tar.lz dexon-bc54f0f039f2844e9da001a868f25825781a4e9e.tar.xz dexon-bc54f0f039f2844e9da001a868f25825781a4e9e.tar.zst dexon-bc54f0f039f2844e9da001a868f25825781a4e9e.zip |
common: fix big scan from bytes (#157)
We store string of number, not bytes value into database
10 is stored as 0x3130, not 0x0a
Use UnmarshalText instead of SetBytes
Diffstat (limited to 'common/big.go')
-rw-r--r-- | common/big.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/common/big.go b/common/big.go index ea3d4aba6..96a83661e 100644 --- a/common/big.go +++ b/common/big.go @@ -45,7 +45,11 @@ func (b *Big) Scan(src interface{}) error { case uint64: *b = Big(*newB.SetUint64(t)) case []byte: - *b = Big(*newB.SetBytes(t)) + err := newB.UnmarshalText(t) + if err != nil { + return err + } + *b = Big(*newB) case string: v, ok := newB.SetString(t, 10) if !ok { |