Rlp shouldn't write null bytes

This commit is contained in:
obscuren 2014-12-18 11:39:24 +01:00
parent 4dbdcaecb1
commit df3366d910

View File

@ -2,7 +2,6 @@ package ethutil
import ( import (
"bytes" "bytes"
"encoding/binary"
"fmt" "fmt"
"math/big" "math/big"
"reflect" "reflect"
@ -193,8 +192,13 @@ func Encode(object interface{}) []byte {
if blen < 56 { if blen < 56 {
buff.WriteByte(byte(blen) + 0xc0) buff.WriteByte(byte(blen) + 0xc0)
} else { } else {
buff.WriteByte(byte(intlen(int64(blen))) + 0xf7) ilen := byte(intlen(int64(blen)))
binary.Write(&buff, binary.BigEndian, int64(blen)) buff.WriteByte(ilen + 0xf7)
t := make([]byte, ilen)
for i := byte(0); i < ilen; i++ {
t[ilen-i-1] = byte(blen >> (i * 8))
}
buff.Write(t)
} }
buff.ReadFrom(&b) buff.ReadFrom(&b)
} }