Updated marshalling

This commit is contained in:
obscuren
2014-01-08 23:42:11 +01:00
parent 9f133a92d0
commit 0929f59ec2
5 changed files with 164 additions and 172 deletions

View File

@ -22,27 +22,11 @@ func (c *Contract) MarshalRlp() []byte {
}
func (c *Contract) UnmarshalRlp(data []byte) {
t, _ := Decode(data, 0)
decoder := NewRlpDecoder(data)
if slice, ok := t.([]interface{}); ok {
if t, ok := slice[0].(uint8); ok {
c.t = uint32(t)
}
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 {