From 0929f59ec260e2a29863b8764959b271a7f75cc8 Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 8 Jan 2014 23:42:11 +0100 Subject: Updated marshalling --- contract.go | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'contract.go') 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 { -- cgit