diff options
author | obscuren <geffobscura@gmail.com> | 2014-01-09 06:42:11 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-01-09 06:42:11 +0800 |
commit | 0929f59ec260e2a29863b8764959b271a7f75cc8 (patch) | |
tree | 42c76016d6f3030594604e6aabc5c4c01eb75519 /contract.go | |
parent | 9f133a92d0853102863b77dd7c884d1462cf73a4 (diff) | |
download | go-tangerine-0929f59ec260e2a29863b8764959b271a7f75cc8.tar.gz go-tangerine-0929f59ec260e2a29863b8764959b271a7f75cc8.tar.zst go-tangerine-0929f59ec260e2a29863b8764959b271a7f75cc8.zip |
Updated marshalling
Diffstat (limited to 'contract.go')
-rw-r--r-- | contract.go | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/contract.go b/contract.go index 778f3578d..a54643f59 100644 --- a/contract.go +++ b/contract.go @@ -22,27 +22,11 @@ func (c *Contract) MarshalRlp() []byte { } func (c *Contract) UnmarshalRlp(data []byte) { - t, _ := Decode(data, 0) - - if slice, ok := t.([]interface{}); ok { - if t, ok := slice[0].(uint8); ok { - c.t = uint32(t) - } + decoder := NewRlpDecoder(data) - if amount, ok := slice[1].(uint8); ok { - c.amount = uint64(amount) - } else if amount, ok := slice[1].(uint16); ok { - c.amount = uint64(amount) - } else if amount, ok := slice[1].(uint32); ok { - c.amount = uint64(amount) - } else if amount, ok := slice[1].(uint64); ok { - c.amount = amount - } - - if root, ok := slice[2].([]uint8); ok { - c.state = NewTrie(Db, string(root)) - } - } + c.t = uint32(decoder.Get(0).AsUint()) + c.amount = decoder.Get(1).AsUint() + c.state = NewTrie(Db, decoder.Get(2).AsString()) } type Ether struct { |