aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-18 18:39:24 +0800
committerobscuren <geffobscura@gmail.com>2014-12-18 18:39:24 +0800
commitdf3366d910c2b1ddab986264bc186ca79ba65c4e (patch)
tree76a9b96a371c9c159e7fe7e2e7b14e5f0d847b0b
parent4dbdcaecb117d7e1fcaf0869f5d4602312552991 (diff)
downloaddexon-df3366d910c2b1ddab986264bc186ca79ba65c4e.tar
dexon-df3366d910c2b1ddab986264bc186ca79ba65c4e.tar.gz
dexon-df3366d910c2b1ddab986264bc186ca79ba65c4e.tar.bz2
dexon-df3366d910c2b1ddab986264bc186ca79ba65c4e.tar.lz
dexon-df3366d910c2b1ddab986264bc186ca79ba65c4e.tar.xz
dexon-df3366d910c2b1ddab986264bc186ca79ba65c4e.tar.zst
dexon-df3366d910c2b1ddab986264bc186ca79ba65c4e.zip
Rlp shouldn't write null bytes
-rw-r--r--ethutil/rlp.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/ethutil/rlp.go b/ethutil/rlp.go
index 157dd4dd9..1bc1a58a7 100644
--- a/ethutil/rlp.go
+++ b/ethutil/rlp.go
@@ -2,7 +2,6 @@ package ethutil
import (
"bytes"
- "encoding/binary"
"fmt"
"math/big"
"reflect"
@@ -193,8 +192,13 @@ func Encode(object interface{}) []byte {
if blen < 56 {
buff.WriteByte(byte(blen) + 0xc0)
} else {
- buff.WriteByte(byte(intlen(int64(blen))) + 0xf7)
- binary.Write(&buff, binary.BigEndian, int64(blen))
+ ilen := byte(intlen(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)
}