aboutsummaryrefslogtreecommitdiffstats
path: root/common/big.go
diff options
context:
space:
mode:
authorjohnliu-dexon <42129254+johnliu-dexon@users.noreply.github.com>2019-01-17 16:37:15 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:56 +0800
commit20d2c46820b895632f7abda71e57164264582b26 (patch)
tree227516c2722fb4a5ee8517f2f9edc30c76a55069 /common/big.go
parent1dc1093dc48231aca0c1794a5a35c8595a1704c9 (diff)
downloaddexon-20d2c46820b895632f7abda71e57164264582b26.tar
dexon-20d2c46820b895632f7abda71e57164264582b26.tar.gz
dexon-20d2c46820b895632f7abda71e57164264582b26.tar.bz2
dexon-20d2c46820b895632f7abda71e57164264582b26.tar.lz
dexon-20d2c46820b895632f7abda71e57164264582b26.tar.xz
dexon-20d2c46820b895632f7abda71e57164264582b26.tar.zst
dexon-20d2c46820b895632f7abda71e57164264582b26.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.go6
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 {